Solve ax+by+cz = k using numpy
Question:
I have scenario where I need to solve following equation and have some data.
We should have only integer value.
ax+by = c
The value of which we have a,b and c and need to determine x and y.
396x+264y = 1980
Ans :The value of x=5 and y=0
396x+264y = 2508
Ans : The vaule of x=5 and y=2
In future, we may add dz.
396+264y+dz = c(some value)
I understand, it can contain multiple solution but I would like to how can I determine those solution. In my scenario is I should be get x, and y integer positive value
is it possible to solve this equation using numpy? I thought, it’s like gcd
factor.
Answers:
This is an underconstrained problem. There are an infiniteset of solutions to your equations
Have a look at this article describing the algorithm to solve the equation ax + by = c
with all a,b,c,x,y
integers. As I already commented, numpy
has nothing to do with this as long as none of a,b,c
is an array.
I have scenario where I need to solve following equation and have some data.
We should have only integer value.
ax+by = c
The value of which we have a,b and c and need to determine x and y.
396x+264y = 1980
Ans :The value of x=5 and y=0
396x+264y = 2508
Ans : The vaule of x=5 and y=2
In future, we may add dz.
396+264y+dz = c(some value)
I understand, it can contain multiple solution but I would like to how can I determine those solution. In my scenario is I should be get x, and y integer positive value
is it possible to solve this equation using numpy? I thought, it’s like gcd
factor.
This is an underconstrained problem. There are an infiniteset of solutions to your equations
Have a look at this article describing the algorithm to solve the equation ax + by = c
with all a,b,c,x,y
integers. As I already commented, numpy
has nothing to do with this as long as none of a,b,c
is an array.