# vpasolve

Solve equations numerically

## Syntax

## Description

numerically solves the equation `S`

= vpasolve(`eqn`

,`var`

,`init_param`

)`eqn`

for the variable
`var`

using the initial guess or search range
`init_param`

.

numerically solves the system of equations `Y`

= vpasolve(`eqns`

,`vars`

)`eqns`

for the variables
`vars`

. This syntax returns a structure array `Y`

that contains the solutions. The fields in the structure array correspond to the variables
specified by `vars`

. If you do not specify `vars`

,
`vpasolve`

solves for the default variables determined by `symvar`

.

numerically solves the system of equations `Y`

= vpasolve(`eqns`

,`vars`

,`init_param`

)`eqns`

for the variables
`vars`

using the initial guess or search range
`init_param`

.

`[`

numerically solves the system of equations `y1,...,yN`

] = vpasolve(`eqns`

,`vars`

,`init_param`

)`eqns`

for the variables
`vars`

using the initial guess or search range
`init_param`

.

`___ = vpasolve(___,`

uses a random initial guess for finding solutions. Use this input to avoid returning the
same solution repeatedly for nonpolynomial equations. If you specify initial guesses for
all variables, setting `'Random'`

,true)`'Random'`

to `true`

has no
effect.

## Examples

## Input Arguments

## Output Arguments

## Tips

If

`vpasolve`

cannot find a solution, it returns an empty object. Provide initial guess to help the solver finding a solution. For an example, see Provide Initial Guess to Find Solutions.For polynomial equations,

`vpasolve`

returns all solutions. For nonpolynomial equations, there is no general method of finding all solutions and`vpasolve`

returns only one solution by default. To find several different solutions for nonpolynomial, you can set`'Random'`

to true and use`vpasolve`

repeatedly.When you solve a system of equations with nonunique solutions, the behavior of

`vpasolve`

depends on whether the system is polynomial or nonpolynomial. If polynomial,`vpasolve`

returns all solutions by introducing an arbitrary parameter. If nonpolynomial, a single numerical solution is returned, if it exists.When you solve a system of rational equations,

`vpasolve`

transforms the rational equations to polynomials by multiplying out the denominators.`vpasolve`

returns all solutions of the resulting polynomial system, which also include the roots of the denominators.`vpasolve`

ignores assumptions set on variables. You can restrict the returned results to particular ranges by specifying appropriate search ranges using the argument`init_param`

.The output variables

`y1,...,yN`

do not specify the variables for which`vpasolve`

solves equations or systems. If`y1,...,yN`

are the variables that appear in`eqns`

, that does not guarantee that`vpasolve(eqns)`

will assign the solutions to`y1,...,yN`

using the correct order. Thus, for the call`[a,b] = vpasolve(eqns)`

, you might get the solutions for`a`

assigned to`b`

and vice versa.To ensure the order of the returned solutions, specify the variables

`vars`

. For example, the call`[b,a] = vpasolve(eqns,[b,a])`

assigns the solutions for`a`

assigned to`a`

and the solutions for`b`

assigned to`b`

.You can solve equations symbolically using

`solve`

, and then numerically approximate the results using`vpa`

. Using this approach, you get numeric approximations of all solutions found by the symbolic solver. However, this can reduce computational speed since solving symbolically and postprocessing the results take more time than directly using the numeric solver`vpasolve`

.

## Algorithms

When you set

`'Random'`

to`true`

and specify a search range for a variable, random initial guesses within the search range are chosen using the internal random number generator (with uniform distribution).When you set

`'Random'`

to`true`

and do not specify a search range for a variable, random initial guesses are generated using a Cauchy distribution with a half-width of`100`

. This means the initial guesses are real valued and have a large spread of values on repeated calls.

## Version History

**Introduced in R2012b**