Search code examples
pythonmathsympysubstitutionsymbolic-math

Check equality using conditions sympy


I want to proove that (x/a)^2 + (y/b)^2 + (z/c)^2 == 1, if conditions x/a + y/b + z/c ==1 and a/x + b/y + c/z == 0 are given. I know that, for example, in Maple I can simply write

eq1 := x/a + y/b + z/c = 1;
eq2 := a/x + b/y + c/z = 0;
f := x^2/a^2 + y^2/b^2 + z^2/c^2 = 1;
simplify(lhs(f)-rhs(f), {eq1, eq2});

But I'm struggling to come up with solution using sympy.


Solution

  • Without loss of generality, let x <= x/a, etc...

    >>> e1=Eq(x + y + z , 1)
    >>> e2=Eq(1/x+1/y+1/z , 0)
    >>> e3=Eq(x**2 + y**2 + z**2, 1)
    Eq(x**2 + y**2 + z**2, 1)
    >>> [e3.subs(i).expand() for i in solve((e1,e2))]
    [True, True]
    

    Thus, e3 is true for all values that satisfy e1 and e2