Symbolic Math Toolbox | ![]() ![]() |
Syntax
g = solve(eq) g = solve(eq,var) g =solve(eq1,eq2,...,eqn)
g =solve(eq1,eq2,...,eqn,var1,var2,...,varn)
Description
Single Equation/Expression.
The input to solve
can be either symbolic expressions or strings. If eq
is a symbolic expression (x^2-2*x+1
) or a string that does not contain an equal sign ('x^2-2*x+1'
), then solve(eq)
solves the equation eq=0
for its default variable (as determined by findsym
).
solve(eq,var)
solves the equation eq
(or eq=0
in the two cases cited above) for the variable var
.
System of Equations.
The inputs are either symbolic expressions or strings specifying equations. solve(eq1,eq2,...,eqn)
solves the system of equations implied by eq1,eq2,...,eqn
in the n
variables determined by applying findsym
to the system.
Examples
solve('a*x^2 + b*x + c')
returns
[ 1/2/a*(-b+(b^2-4*a*c)^(1/2)), 1/2/a*(-b-(b^2-4*a*c)^(1/2))]
solve('a*x^2 + b*x + c','b')
returns
-(a*x^2+c)/x
solve('x + y = 1','x - 11*y = 5')
returns
y = -1/3, x = 4/3
A = solve('a*u^2 + v^2', 'u - v = 1', 'a^2 - 5*a + 6')
returns
A = a: [1x4 sym] u: [1x4 sym] v: [1x4 sym]where
A.a = [ 2, 2, 3, 3] A.u = [ 1/3+1/3*i*2^(1/2), 1/3-1/3*i*2^(1/2), 1/4+1/4*i*3^(1/2), 1/4-1/4*i*3^(1/2)] A.v = [ -2/3+1/3*i*2^(1/2), -2/3-1/3*i*2^(1/2), -3/4+1/4*i*3^(1/2), -3/4-1/4*i*3^(1/2)]
See Also
arithmetic operators
, dsolve
, findsym
![]() | size | subexpr | ![]() |