I am trying to solve a system of multivariate equations, which are the result of some Java code. Neither the form, nor the number of variables is known before runtime. An example would be
(I) (e-a*d*e-b*d*e+2*b*d*f+2*b*d*e*g)/(-1+a*d+b*d)+f == 0
(II) e*g+((f+e*g)*a*d)/(-1+a*d+b*d)==0
(III) -e*h+((-f-e*g)*d)/(-1+a*d+b*d)==0
(IV) -e*j+((-f-e*g)*c)/(-1+a*d+b*d)==0
I tried using Symja, which simply returns the input, and SymPy, which throws an Error
ZeroDivisionError: polynomial division
The variables are all from the interval [0,1], and I need all solutions. Mathematica is able to solve this, but as it is commercial software I unfortunately cannot use it in this project.
I would be grateful for any recommendations on which software to use. I really would have liked SymPy to work, and I don't understand why it throws this error, ideas are appreciated. Below a MWE to the SymPy Error:
from sympy.solvers import solve
from sympy.abc import a,b,c,d,e,f,g,h,j
lst = a,b,c,d,e,f,g,h,j
sys = [(e-a*d*e-b*d*e+2*b*d*f+2*b*d*e*g)/(-1+a*d+b*d)+f,e*g+((f+e*g)*a*d)/(-1+a*d+b*d),-e*h+((-f-e*g)*d)/(-1+a*d+b*d),-e*j+((-f-e*g)*c)/(-1+a*d+b*d)]
solution = solve(sys, lst)
print solution
The Mathematica version is:
eqn = {(e - a*d*e - b*d*e + 2*b*d*f + 2*b*d*e*g)/(-1 + a*d + b*d) + f == 0, e*g + ((f + e*g)*a*d)/(-1 + a*d + b*d) == 0, -e*h + ((-f - e*g)*d)/(-1 + a*d + b*d) == 0, -e*j + ((-f - e*g)*c)/(-1 + a*d + b*d) == 0};
Simplify[Solve[eqn, {a, b, c, d, e, f, g, h, j}]]
Output:
{{e -> 0, f -> 0},
{c -> (1 - 2 a d - 3 b d) j, f -> ((-1 + 2 a d + b d) e)/(-1 + 2 a d + 3 b d), g -> (a d)/(1 - 2 a d - 3 b d), h -> d/(1 - 2 a d - 3 b d)},
{a -> 0, c -> j - 3 b d j, f -> ((-1 + b d) e)/(-1 + 3 b d), g -> 0, h -> d/(1 - 3 b d)},
{a -> (1 - b d)/(2 d), c -> -2 b d j, f -> 0, g -> 1/4 - 1/(4 b d), h -> -(1/(2 b))}}
Ok, I was able to solve the problem myself using SAGE, with gives the same output as Mathematica.
Gives the output