-1

I have the following system of equations :

-2yz = a
-2xy = b
-x^2 + y^2 - z^2 = c

How can I simplify the solution for these equations using SymPy? x, y, z are unknowns. I have the following script:

from sympy import *

x, y, z = var('x y z')
a, b, c = var('a b c')

E1 = -2 * y * z - a
E2 = -2 * x * y - b
E3 = -x**2 + y ** 2 - z ** 2 - c


sols = solve([E1, E2, E3], [x, y, z])

The simplifies solution is not really palatable. Any idea?

QuestionMark
  • 412
  • 1
  • 4
  • 16

1 Answers1

0

You might consider running cse over your solutions. I will let you see what the replacments are, but here is the result:

>>> r, e = cse(flatten(sols))
>>> reshape(e, (3,))  # restore tuples of 3 solutions
[
(x1*x9, -x11*x13, x9), 
(-x1*x13, x11*x9, -x13), 
(-x16, x12*x17, -x15), 
(x16, x17*x8, x15)]
smichr
  • 16,948
  • 2
  • 27
  • 34