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?

12k 1 1 gold badge 23 23 silver badges 38 38 bronze badges asked Jan 23, 2017 at 10:53 21 1 1 silver badge 2 2 bronze badges $\begingroup$ Have you seen Solve[] ? $\endgroup$ Commented 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$

Commented Jan 23, 2017 at 12:00

2 Answers 2

$\begingroup$

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$:

 -Sqrt[5 - y^3]>, Sqrt[5 - y^3]>> 

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

answered Jan 23, 2017 at 11:10 683 1 1 gold badge 7 7 silver badges 17 17 bronze badges $\begingroup$ @Vijay If it worked, you can accept it as an answer. $\endgroup$ Commented Feb 5, 2017 at 19:46 $\begingroup$

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:

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