Main Content

isolate

Isolate variable or expression in equation

Description

isolate(eqn,expr) rearranges the equation eqn so that the expression expr appears on the left side. The result is similar to solving eqn for expr. If isolate cannot isolate expr, it moves all terms containing expr to the left side. The output of isolate lets you eliminate expr from eqn by using subs.

example

Examples

Isolate Variable in Equation

Isolate x in the equation a*x^2 + b*x + c == 0.

syms x a b c
eqn = a*x^2 + b*x + c == 0;
xSol = isolate(eqn, x)
xSol =
x == -(b + (b^2 - 4*a*c)^(1/2))/(2*a)

You can use the output of isolate to eliminate the variable from the equation using subs.

Eliminate x from eqn by substituting lhs(xSol) for rhs(xSol).

eqn2 = subs(eqn, lhs(xSol), rhs(xSol))
eqn2 =
c + (b + (b^2 - 4*a*c)^(1/2))^2/(4*a) - (b*(b + (b^2 - 4*a*c)^(1/2)))/(2*a) == 0

Isolate Expression in Equation

Isolate y(t) in the following equation.

syms y(t)
eqn = a*y(t)^2 + b*c == 0;
isolate(eqn, y(t))
ans =
y(t) == ((-b)^(1/2)*c^(1/2))/a^(1/2)

Isolate a*y(t) in the same equation.

isolate(eqn, a*y(t))
ans =
a*y(t) == -(b*c)/y(t)

isolate Returns Simplest Solution

For equations with multiple solutions, isolate returns the simplest solution.

Demonstrate this behavior by isolating x in sin(x) == 0, which has multiple solutions at 0, pi, 3*pi/2, and so on.

isolate(sin(x) == 0, x)
ans =
x == 0

isolate does not consider special cases when returning the solution. Instead, isolate returns a general solution that is not guaranteed to hold for all values of the variables in the equation.

Isolate x in the equation a*x^2/(x-a) == 1. The returned value of x does not hold in the special case a = 0.

syms a x
isolate(a*x^2/(x-a) == 1, x)
ans =
x == ((-(2*a - 1)*(2*a + 1))^(1/2) + 1)/(2*a)

isolate Follows Assumptions on Variables

isolate returns only results that are consistent with the assumptions on the variables in the equation.

First, assume x is negative, and then isolate x in the equation x^4 == 1.

syms x
assume(x < 0)
eqn = x^4 == 1;
isolate(x^4 == 1, x)
ans =
x == -1

Remove the assumption. isolate chooses a different solution to return.

assume(x, 'clear')
isolate(x^4 == 1, x)
ans =
x == 1

Tips

  • If eqn has no solution, isolate errors. isolate also ignores special cases. If the only solutions to eqn are special cases, then isolate ignores those special cases and errors.

  • The returned solution is not guaranteed to hold for all values of the variables in the solution.

  • expr cannot be a mathematical constant such as pi.

Input Arguments

collapse all

Input equation, specified as a symbolic equation.

Example: a*x^2 + b*x + c == 0

Variable or expression to isolate, specified as a symbolic variable or expression.

Version History

Introduced in R2017a