Search code examples
pythonmatlabsympysymbolic-math

How to manipulate equation in Matlab or python?


I have a complicated equation which is function of several variables and I want to manipulate like this example:

y = (x + a) / z 

x = y*z - a 

Is it possible to do this kind of manipulation matlab or python?

If there is possibility then please point out method or function to do this operation.

I tried following code in Sympy Shell:

x,y,z,a = symbols ('x y z a')
solve ( y = (x-a)/z, x)

I am getting following error:

Traceback (most recent call last):
  File "<string>", line 1
SyntaxError: non-keyword arg after keyword arg

Solution

  • In Matlab you'd need the symbolic math toolbox (which I don't have so I can't test) and then you should be able to do use the solve function:

    syms y x a z
    solve(y == (x+a)/z, x)
    

    I have NO experince with sympy but pretty sure based on the docs this is how you do it:

    from sympy import solve, Poly, Eq, Function, exp
    from sympy.abc import x, y, z, a
    solve(y - (x+a)/z, x)