Ok so first I want to say, it doesn't have to be done with sympy, if there's an easier way to do it please let me know, but below was my failed attempt:
I'm trying to use sympy to approximate a solution under a loose condition. I have over 10 variables which i call x0, x1, x2...
and I have 2 constraints for them, which I call eq1 and eq2. I have some constants which I name as c0, c1, c2...
so eq1 and eq2 looks approximately like this:
eq1 = c0 + c1 / (c2 * x0 + c3 * x1 + ...)
eq2 = c20 + c21 * x0 / (c21 * x0 + c22 * x1 + ...)
In the above, all the x0, x1... are positive, c0 and c20 are negative, and the other cs are non-negative.
I think its pretty obvious that I have way too many variables and not a lot of constraints so I should have a bunch of solutions, and I only really want the first one that the machine can find. But when I use this:
s = sympy.nsolve((eq1,eq2),(x0,x1,x2,...),(a bunch of guesses on x#))
then error pops out and says I need at least as many equations as variables (NotImplementedError: need at least as many equations as variables), so I added some other eqs:
eq3 = 0
eq4 = 0
...
and I did this:
s = sympy.nsolve((eq1,eq2,eq3...),(x0,x1,x2...),(a bunch of guesses on x#))
and another error pops out saying: ZeroDivisionError: matrix is numerically singular
At this point I'm lost, seems like I can't get it work. Please help on giving any method to solve this system of equations, thanks so much!
P.S. I know there are some other questions like this, but I specifically want my program to be able to just guess for variables with random numbers (ideally as close to 0 as possible) and produce one acceptable set of numbers as solution when the system is under-determined with free variables. I can't seem to find an answer for this.