vpasolve
Solve symbolic equations numerically
Syntax
Description
numerically solves the equation S = vpasolve(eqn,var)eqn for the variable
var using variable-precision arithmetic and returns the solutions
with 32 significant digits by default. To change the number of significant digits, use the
digits function.
If you do not specify var, vpasolve solves for
the default variable as determined by symvar. For example, vpasolve(x + 1 == 2) numerically
solves the equation x + 1 = 2 for x.
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(___,Random=true) 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 to true has no
effect.
Examples
Input Arguments
Output Arguments
Tips
If
vpasolvecannot 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,
vpasolvereturns all solutions. For nonpolynomial equations, there is no general method of finding all solutions andvpasolvereturns only one solution by default. To find several different solutions for nonpolynomial, you can setRandomto true and usevpasolverepeatedly.When you solve a system of equations with nonunique solutions, the behavior of
vpasolvedepends on whether the system is polynomial or nonpolynomial. If polynomial,vpasolvereturns 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,
vpasolvetransforms the rational equations to polynomials by multiplying out the denominators.vpasolvereturns all solutions of the resulting polynomial system, which also include the roots of the denominators.vpasolveignores assumptions set on variables. You can restrict the returned results to particular ranges by specifying appropriate search ranges using the argumentinit_param. However, if the equations or expressions have other variables besides the variables to solve for as specified byvars, thenvpasolvereturns the solutions forvarsin terms of the other variables that are complex in general.The output variables
y1,...,yNdo not specify the variables for whichvpasolvesolves equations or systems. Ify1,...,yNare the variables that appear ineqns, that does not guarantee thatvpasolve(eqns)will assign the solutions toy1,...,yNusing the correct order. Thus, for the call[a,b] = vpasolve(eqns), you might get the solutions foraassigned toband vice versa. To ensure the order of the returned solutions, specify the variablesvars. For example, the call[b,a] = vpasolve(eqns,[b,a])assigns the solutions foraassigned toaand the solutions forbassigned tob.You can solve equations symbolically using
solve, and then numerically approximate the results usingvpa. 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 solvervpasolve.
Algorithms
When you set
Randomtotrueand 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
Randomtotrueand do not specify a search range for a variable, random initial guesses are generated using a Cauchy distribution with a half-width of100. This means the initial guesses are real valued and have a large spread of values on repeated calls.
