equations and systems solver -凯发k8网页登录
equations and systems solver
support for character vector or string inputs has been removed. instead, use to declare variables and replace inputs such as solve('2*x ==
1','x')
with solve(2*x == 1,x)
.
syntax
description
uses additional options specified by one or more s
= solve(eqn
,var
,name,value
)name,value
pair
arguments.
solves the system of equations y
= solve(eqns
,vars
)eqns
for the variables
vars
and returns a structure that contains the solutions. if you do
not specify vars
, solve
uses to find the variables to solve for. in this case, the number of
variables that symvar
finds is equal to the number of equations
eqns
.
uses additional options specified by one or more y
= solve(eqns
,vars
,name,value
)name,value
pair
arguments.
[
solves the system of equations y1,...,yn
] = solve(eqns
,vars
)eqns
for the variables
vars
. the solutions are assigned to the variables
y1,...,yn
. if you do not specify the variables,
solve
uses symvar
to find the variables to
solve for. in this case, the number of variables that symvar
finds is
equal to the number of output arguments n
.
[
uses additional options specified by one or more y1,...,yn
] = solve(eqns
,vars
,name,value
)name,value
pair
arguments.
[
returns the additional arguments y1,...,yn
,parameters
,conditions
]
= solve(eqns
,vars
,'returnconditions
',true)parameters
and
conditions
that specify the parameters in the solution and the
conditions on the solution.
examples
input arguments
output arguments
tips
if
solve
cannot find a solution andreturnconditions
isfalse
, thesolve
function internally calls the numeric solvervpasolve
that tries to find a numeric solution. for polynomial equations and systems without symbolic parameters, the numeric solver returns all solutions. for nonpolynomial equations and systems without symbolic parameters, the numeric solver returns only one solution (if a solution exists).if
solve
cannot find a solution andreturnconditions
istrue
,solve
returns an empty solution with a warning. if no solutions exist,solve
returns an empty solution without a warning.if the solution contains parameters and
returnconditions
istrue
,solve
returns the parameters in the solution and the conditions under which the solutions are true. ifreturnconditions
isfalse
, thesolve
function either chooses values of the parameters and returns the corresponding results, or returns parameterized solutions without choosing particular values. in the latter case,solve
also issues a warning indicating the values of parameters in the returned solutions.if a parameter does not appear in any condition, it means the parameter can take any complex value.
the output of
solve
can contain parameters from the input equations in addition to parameters introduced bysolve
.parameters introduced by
solve
do not appear in the matlab workspace. they must be accessed using the output argument that contains them. alternatively, to use the parameters in the matlab workspace usesyms
to initialize the parameter. for example, if the parameter isk
, usesyms k
.the variable names
parameters
andconditions
are not allowed as inputs tosolve
.to solve differential equations, use the function.
when solving a system of equations, always assign the result to output arguments. output arguments let you access the values of the solutions of a system.
maxdegree
only accepts positive integers smaller than 5 because, in general, there are no explicit expressions for the roots of polynomials of degrees higher than 4.the output variables
y1,...,yn
do not specify the variables for whichsolve
solves equations or systems. ify1,...,yn
are the variables that appear ineqns
, then there is no guarantee thatsolve(eqns)
will assign the solutions toy1,...,yn
using the correct order. thus, when you run[b,a] = solve(eqns)
, you might get the solutions fora
assigned tob
and vice versa.to ensure the order of the returned solutions, specify the variables
vars
. for example, the call[b,a] = solve(eqns,b,a)
assigns the solutions fora
toa
and the solutions forb
tob
.
algorithms
when you use ignoreanalyticconstraints
, the solver applies some of
these rules to the expressions on both sides of an equation.
log(a) log(b) = log(a·b) for all values of a and b. in particular, the following equality is valid for all values of a, b, and c:
(a·b)c = ac·bc.
log(ab) = b·log(a) for all values of a and b. in particular, the following equality is valid for all values of a, b, and c:
(ab)c = ab·c.
if f and g are standard mathematical functions and f(g(x)) = x for all small positive numbers, f(g(x)) = x is assumed to be valid for all complex values x. in particular:
log(ex) = x
asin(sin(x)) = x, acos(cos(x)) = x, atan(tan(x)) = x
asinh(sinh(x)) = x, acosh(cosh(x)) = x, atanh(tanh(x)) = x
wk(x·ex) = x for all branch indices k of the lambert w function.
the solver can multiply both sides of an equation by any expression except
0
.the solutions of polynomial equations must be complete.
version history
introduced before r2006a
see also
functions
- | | | | | |