Reputation: 175
So I know there have been plenty of questions/answers on this topic, but I haven't been able to locate exactly what is going wrong in my attempts. I have two nonlinear function f(x,y)
and g(x,y)
and I am trying to solve the system
f(x,y) - g(x,y) = 0
f(x,y) + g(x,y) = c
where c
is some positive constant. I have been using the snippet described in the answer to this question: How to solve a pair of nonlinear equations using Python?, but I am facing issues. If I run that snippet for my code, it returns the x
and y
values such that only the second equation in the system is satisfied, i.e. it returns x
and y
such that f(x,y) + g(x,y) = c
, while for the other equation it holds that f(x,y) - g(x,y) != 0
. I get the exact same issues when using the scipy.optimize.root
function. I'm quite lost as to what could be causing this issue. Could it mean that there do not exist x, y
such that both equations are satisfied?
Thanks in advance for any help!
Upvotes: 0
Views: 61
Reputation: 845
It is very possible that there is no solution. x + y = 10, x + y = 20 has no solution, for example. This isn't an issue of non-linearity; this is an issue of math. Also, it might be possible, if this can't be solved algebraically, that the first equation has f(x,y) - g(x,y) is approximately zero. If f(x,y)-g(x,y)=0.0001, would you consider this close enough?
For completeness: Check out the math, as noted by @tstanisl. If you add the equations together, you solve f(x,y)=c/2 or g(x,y)=c/2, which is easier.
Upvotes: 1