# writing the expression for one variable in terms of another variable

I have a polynomial equation with 2 variables, lets say $x$ and $y$. For example: $x^2 + y^3 = 5$

And I want to write the above equation with $x$ on left side expressed in terms of $y$ on right side, like this: $x = (5 - y^3)^{1/2}$.

Any help?

• Have you seen Solve[]? Jan 23 '17 at 10:53
• Vijay, pardon me but is this question about the software product Mathematica? I ask because your example goal is not valid Mathematica syntax, i.e. square brackets are used for function application not precedence. Jan 23 '17 at 12:00

Motivated from J.M.'s comment(credit goes to him).

Solve[x^2 + y^3 == 5, x]


Output is (what you desired for), precisely the solution for $x$:

{{x -> -Sqrt[5 - y^3]}, {x -> Sqrt[5 - y^3]}}


In Solve you can change x-> y, and you will get the inverse i.e. y in terms of x.

• @Vijay If it worked, you can accept it as an answer.
– L.K.
Feb 5 '17 at 19:46

Using Solve certainly works here, and it gives the correct answer (which is that Abs[x] == Sqrt[5 - y^3]). Another way of doing this is to use pure functions and map to perform the algebra step by step. To understand the internal form that MMA stores the equation:

exp = x^2 + y^3 == 5
FullForm[exp]

(* Equal[Plus[Power[x,2],Power[y,3]],5] *)


This allows us to perform algebraic manipulations by mapping over the internal representation. This provides a very general way to do "step by step" algebraic calculations, which can be useful in situations that Solve can't.

This code shows how this would apply here:

r1 = # - (y^3) & /@ exp;
r2 = Sqrt[#] & /@ r1


But MMA doesn't produce what's requested above, instead producing:

This results from the fact that the square root of x^2 is actually Abs[x]. This can be seen by using Refine on the result, and by specifying that x is an element of the Reals:

Refine[r2, x \[Element] Reals]


Here's a link in Wikipedia that explains the principal square root concept and therefore why Solve and Refine produce this result: Wikipedia on Square Root and principal square roots