Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

solving a system of equations, depending on only a subset of variables

i have a set of equations like this

x,z, xm, xs, zs, z2, d1, d2, em, es =var('x z xm xs zs z2 d1 d2 em es')

equations = [
    d1 == sqrt(xm*xm + zs*zs),
    d2 == sqrt(z2*z2 + xs*xs),
    xm + xs == x,
    zs + z2 == z,
    (xm/zs)/(xs/z2) == (em/es)
]

from sympy import *
from sympy.solvers import solve

#solve(equations, [xs,xm])
sol = solve(equations, [d1,d2])

and get this solution:

︡{d1: sqrt(xm**2 + zs**2), d2: sqrt(xs**2 + z2**2)}

which is correct, of course.

But i would like to get a solution based only on em, es, zs, x and z, eliminating xm, xs and z2.

How can I get it to do that?