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?

  • 4
    $\begingroup$ Have you seen Solve[]? $\endgroup$ Jan 23, 2017 at 10:53
  • $\begingroup$ 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. $\endgroup$
    – Mr.Wizard
    Jan 23, 2017 at 12:00

2 Answers 2


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.

  • $\begingroup$ @Vijay If it worked, you can accept it as an answer. $\endgroup$
    – L.K.
    Feb 5, 2017 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

(* 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:

enter image description here

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]

enter image description here

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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.