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.

Asked By: user765443

||

Answers:

This is an underconstrained problem. There are an infiniteset of solutions to your equations

Answered By: user3684792

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.

Answered By: filmor
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.