Detailed Information - Maple Help

fsolve

solve one or more equations using floating-point arithmetic

 Calling Sequence fsolve(equations, variables, complex, fulldigits, useunits, interval, starting_values, options)

Parameters

 equations - equation, set(equation), list(equation), procedure, list(procedure) variables - (optional) name or set(name); unknowns for which to solve complex - (optional) literal name; search for complex solutions fulldigits - (optional) literal name; use Digits setting for all computations useunits - (optional) literal name; deal with units returned by procedures that aren't autodetected interval - (optional) range, equation, set(equation), or list(range); specify a range in which to search for solutions starting_values - (optional) equation, set(equation), or list(value); specify initial value used by solver. You cannot specify the variables option if you specify this option. options - (optional) equation(s) of the form option=value where option is one of avoid or maxsols or useunits; specify solution options

Basic Information

 • This help page contains complete information about the fsolve command. For basic information on the fsolve command, see the fsolve help page.

Description

 • The fsolve command numerically solves one or more equations for their unknowns.

Calling Sequence Shortcuts

 • In the equations parameter, if you specify an expression expr, Maple interprets it as the equation $\mathrm{expr}=0$.
 • If you do not specify the variables parameter, Maple solves for all the variables that appear in equations, that is, indets(equations, name).

Output

 • The solutions to a single equation are returned as an expression sequence.
 • The solutions to a set or list of equations are returned as sets of equation sequences.
 • The solutions to a list of procedures are returned as a sequence of values.
 Note: If you specify a single equation and a set of variables, the solutions are returned as sets of equation sequences.
 • For a single polynomial equation of one variable, the fsolve command computes all real (non-complex) roots. It may not return all roots for exceptionally ill-conditioned polynomials.
 To compute all roots of a polynomial over the field of complex numbers, use the complex option.
 • For a general equation or system of equations or procedures, the fsolve command computes a single real root.
 • If the fsolve command does not find any solutions, it returns the empty sequence (NULL) or returns unevaluated. This means that there are no solutions, or the fsolve command cannot find any solutions.
 It is recommended that you specify an interval option. This may return a solution that was not initially found.
 If the fsolve command returns no solution to a general equation or system of equations, you can search for a complex solution by specifying the complex option In addition, you can also specify a complex interval or complex starting_values option.

Units

 • The fsolve command can deal with expressions and procedures that involve units in most situations. Unit handling is active in the following situations:
 – If equations is an equation or expression or collection of equations or expressions, then one can specify all of the following with units: an interval for one of the variables, an initial value, or a point to be avoided. If more than one of these values is specified for a single variable (as is always the case when specifying an interval: there are two bounds), then fsolve chooses one of the values to provide the unit that all other values for this variable are converted to. If a value cannot be converted to this unit, then the arguments are not specified properly and fsolve aborts with an error message.
 In this case, the value(s) returned by fsolve for such a variable will have the proper unit attached.
 – The same functionality is available if equations is a procedure or collection of procedures.
 – If equations is an equation or expression or collection of equations or expressions, and a unit occurs inside it (as found by the hastype command), then the fsolve command will attempt to strip the unit off of the result before numerical evaluation.
 – If equations is a procedure or collection of procedures, then fsolve cannot detect if any units occur inside it. Instead, if any of the input values have units as described above, then each procedure is wrapped in another procedure that strips the unit off of the result before returning it. In some cases, the input arguments provided for the procedure(s) do not have units, but the output does; this situation cannot be detected automatically. In such a case, use the useunits option to force wrapping of the procedures.

Optional Arguments

avoid

 avoid = set(equation) or set(set(equation)) or set(list(values)) or set(values)
 For example, avoid = {x=0, x=1}, avoid = {{x=0, y=0}, {x=0, y=exp(1)}} or avoid = {[0, 1]}.
 Avoid specified values when searching for roots. The left-hand side of each equation must be a variable name, unless equations is a list of procedures in which case only the right-hand side value must be provided. The right-hand side is the corresponding numeric value to avoid. To avoid values for a single variable, specify a set of equations. To avoid values for multiple variables, specify a set of sets of equations. To avoid values for a list of procedures, specify a set of lists of numeric values. To avoid values for a single procedure, specify a set of numeric values.
 When using the avoid option, it is recommended that you specify a starting_values option to facilitate converging to a different solution.

complex

 complex
 Find one root (or all roots, for polynomials) over the complex floating-point numbers.

fulldigits

 fulldigits
 Prevent fsolve from decreasing Digits for intermediate calculations at high settings of Digits.  With this option, fsolve may escape ill-conditioning problems, but is slower.

useunits option

 useunits
 useunits = list or set of variable/unit pairs
 useunits = list of units
 The fsolve command can automatically deal with equations and expressions that contain unit in most situations, and procedures that contain units if the units are given in initial values or ranges, as explained in the Units section. This option can be used in three ways:
 • When used as just the keyword useunits, this option turns on code for dealing with units if those units had not been detected from the presence in other arguments. This is particularly useful if you specify procedures that return a value with units.
 • When used to specify a list or set of variable/unit pairs, such as x :: Unit(m), which is possible only if expressions or equations, rather than procedures, are submitted to fsolve, then this associates the given unit with the given variable. This is particularly useful if no initial value or range can be specified for the variable, or if the initial point is 0 (with which no unit can be associated in Maple).
 • When used to specify a list of units, such as Unit(m), which is possible only if procedures, rather than expressions or equations, are submitted to fsolve, then this associates the given units with the arguments to the procedure, in the order they are given. The number of units given must equal the number of arguments to the procedure.

interval option

 range, equation, set(equation), or list(range)
 For example, 1..2, x = 1..2, {x = 1..2, y = 10..20}, or [1..2, 10..20].
 Search for roots only in the specified interval. The ranges are closed intervals. That is, the endpoints are included in the range. The left-hand side of each equation must be a variable name, unless equations is a list of procedures in which case only the right-hand side range values must be provided. The right-hand side is the corresponding interval to search. To specify a range for a single variable, specify an equation. To specify a range for multiple variables, specify a set of equations. To specify a range for a list of procedures, specify a list of ranges.
 In conjunction with the complex option, you can specify a complex interval (rectangle in the complex plane) option using the syntax lower_left_point..upper_right_point, for example, x = -1 - I..1 + I.

maxsols

 maxsols = posint
 Find only the specified number of least roots. This option is valid only for a single univariate polynomial equation, in which case the fsolve command computes more than one root.

starting_values option

 equation or set(equation)
 For example, x = 1.2, {x = 1.2, y = 10}, or [1.2, 10].
 Specify starting values for the variables. You cannot specify the variables option if you specify this option.  If the method that fsolve chooses for a particular problem requires more than one starting value, then the additional values are generated by perturbing the given starting values.

Examples

A Polynomial equation in one variable

Finding solutions to univariate polynomials

 By default, the fsolve command finds all real solutions to a univariate polynomial equation.
 > $\mathrm{polynomial}≔23{x}^{5}+105{x}^{4}-10{x}^{2}+17x:$
 > $\mathrm{fsolve}\left(\mathrm{polynomial}\right)$
 ${-4.536168981}{,}{-0.6371813185}{,}{0.}$ (1)

Using the maxsols option

 To find only 2 real solutions, use the maxsols option.
 > $\mathrm{fsolve}\left(\mathrm{polynomial},x,\mathrm{maxsols}=2\right)$
 ${-4.536168981}{,}{-0.6371813185}$ (2)

Finding only real solutions in an interval

 To find only real solutions in an interval, specify the interval.
 > $\mathrm{fsolve}\left(\mathrm{polynomial},x,-1..1\right)$
 ${-0.6371813185}{,}{0.}$ (3)

Finding complex solutions

 To find all the complex solutions, specify the complex option.
 > $\mathrm{fsolve}\left(\mathrm{polynomial},x,\mathrm{complex}\right)$
 ${-4.53616898134311}{,}{-0.637181318531050}{,}{0.}{,}{0.304066454284907}{-}{0.404061905751759}{}{I}{,}{0.304066454284907}{+}{0.404061905751759}{}{I}$ (4)

General Equations and Systems of Equations

Finding solutions to a general solution or system of equations

 By default, the fsolve command finds one real solution to a general equation or system of equations.
 > $\mathrm{fsolve}\left(\mathrm{tan}\left(\mathrm{sin}\left(x\right)\right)=1\right)$
 ${0.9033391108}$ (5)

Specifying the interval for a solution

 You can specify the interval in which to search for a solution.
 > $f≔\mathrm{sin}\left(x+y\right)-\mathrm{exp}\left(x\right)y=0:$
 > $g≔{x}^{2}-y=2:$
 > $\mathrm{fsolve}\left(\left\{f,g\right\},\left\{x=-1..1,y=-2..0\right\}\right)$
 $\left\{{x}{=}{-0.6687012050}{,}{y}{=}{-1.552838698}\right\}$ (6)

Specifying a list of procedures as input

 You can also specify a list of procedures as input.
 > f := proc(x,y) sin(x + y) - exp(x)*y end proc:
 > g := proc(x,y) x^2 - y - 2 end proc:
 > $\mathrm{fsolve}\left(\left[f,g\right],\left[-1..1,-2..0\right]\right)$
 $\left[{-0.66870120500236006}{,}{-1.5528386984284155}\right]$ (7)

Using the complex option to find complex solutions

 If an equation has no real solutions or you are interested in complex solutions, you can search for a complex solution using the complex option.
 > $f≔\mathrm{ln}\left(v\right)={v}^{2}$
 ${f}{≔}{\mathrm{ln}}{}\left({v}\right){=}{{v}}^{{2}}$ (8)
 > $\mathrm{fsolve}\left(f\right)$
 ${\mathrm{fsolve}}{}\left({\mathrm{ln}}{}\left({v}\right){=}{{v}}^{{2}}{,}{v}\right)$ (9)
 > $\mathrm{fsolve}\left(f,v,\mathrm{complex}\right)$
 ${0.6143632454}{-}{0.6810654878}{}{I}$ (10)

Specifying a complex interval

 To find a complex solution in a rectangle in the complex plane, specify a complex interval.
 > $\mathrm{fsolve}\left(f,v,\left\{v=-1-I..1+0.5I\right\},\mathrm{complex}\right)$
 ${0.6143632454}{-}{0.6810654878}{}{I}$ (11)
 > $\mathrm{fsolve}\left(f,v,\left\{v=-1-0.5I..1+I\right\},\mathrm{complex}\right)$
 ${0.6143632454}{+}{0.6810654878}{}{I}$ (12)

Examples with units

 Consider the following model of a parabolic suspension cable. We specify the length of a cable and the sag, and we want to know what the span covered by that cable is. According to Karnovsky and Lebed (see References), we have
 > $\mathrm{cable_length}=\mathrm{int}\left(\mathrm{sqrt}\left(1+{\left(4\mathrm{ratio}\right)}^{2}{\left(\frac{2x}{\mathrm{span}}-1\right)}^{2}\right),x=0..\mathrm{span}\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{assuming}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}0<\mathrm{span},0<\mathrm{ratio}$
 ${\mathrm{cable_length}}{=}\frac{{\mathrm{span}}{}\left({4}{}\sqrt{{16}{}{{\mathrm{ratio}}}^{{2}}{+}{1}}{}{\mathrm{ratio}}{+}{\mathrm{arcsinh}}{}\left({4}{}{\mathrm{ratio}}\right)\right)}{{8}{}{\mathrm{ratio}}}$ (13)
 where $\mathrm{ratio}=\frac{\mathrm{sag}}{\mathrm{span}}$. Approximating for $\mathrm{ratio}$ near 0:
 > $\mathrm{lhs}\left(\right)=\mathrm{series}\left(\mathrm{rhs}\left(\right),\mathrm{ratio},8\right)$
 ${\mathrm{cable_length}}{=}{\mathrm{span}}{+}\frac{{8}}{{3}}{}{\mathrm{span}}{}{{\mathrm{ratio}}}^{{2}}{-}\frac{{32}}{{5}}{}{\mathrm{span}}{}{{\mathrm{ratio}}}^{{4}}{+}\frac{{256}}{{7}}{}{\mathrm{span}}{}{{\mathrm{ratio}}}^{{6}}{+}{O}{}\left({{\mathrm{ratio}}}^{{8}}\right)$ (14)
 > $\mathrm{eval}\left(\mathrm{convert}\left(,'\mathrm{polynom}'\right),\mathrm{ratio}=\frac{\mathrm{sag}}{\mathrm{span}}\right)$
 ${\mathrm{cable_length}}{=}{\mathrm{span}}{+}\frac{{8}{}{{\mathrm{sag}}}^{{2}}}{{3}{}{\mathrm{span}}}{-}\frac{{32}{}{{\mathrm{sag}}}^{{4}}}{{5}{}{{\mathrm{span}}}^{{3}}}{+}\frac{{256}{}{{\mathrm{sag}}}^{{6}}}{{7}{}{{\mathrm{span}}}^{{5}}}$ (15)
 > $\mathrm{cable_length}≔100\mathrm{Unit}\left(\mathrm{ft}\right)$
 ${\mathrm{cable_length}}{≔}{100}{}⟦{\mathrm{ft}}⟧$ (16)
 > $\mathrm{sag}≔2.738\mathrm{Unit}\left(\mathrm{ft}\right)$
 ${\mathrm{sag}}{≔}{2.738}{}⟦{\mathrm{ft}}⟧$ (17)
 > $\mathrm{fsolve}\left(,\mathrm{span}=10\mathrm{Unit}\left(\mathrm{ft}\right)..1000\mathrm{Unit}\left(\mathrm{ft}\right)\right)$
 ${99.80004926}{}⟦{\mathrm{ft}}⟧$ (18)
 We reformulate the same problem in terms of a procedure.
 > $p≔\mathrm{unapply}\left(\mathrm{rhs}\left(\right)-\mathrm{lhs}\left(\right),\mathrm{span}\right)$
 ${p}{≔}{\mathrm{span}}{↦}{-}{100}{\cdot }⟦{\mathrm{ft}}⟧{+}{\mathrm{span}}{+}\frac{{19.99105067}}{{\mathrm{span}}}{\cdot }{⟦{\mathrm{ft}}⟧}^{{2}}{-}\frac{{359.6778961}}{{{\mathrm{span}}}^{{3}}}{\cdot }{⟦{\mathrm{ft}}⟧}^{{4}}{+}\frac{{15407.86938}}{{{\mathrm{span}}}^{{5}}}{\cdot }{⟦{\mathrm{ft}}⟧}^{{6}}$ (19)
 > $\mathrm{fsolve}\left(p,10\mathrm{Unit}\left(\mathrm{ft}\right)..1000\mathrm{Unit}\left(\mathrm{ft}\right)\right)$
 ${99.80004926}{}⟦{\mathrm{ft}}⟧$ (20)
 A range can be specified with different units, but they have to be consistent - otherwise the fsolve command issues an error message.
 > $\mathrm{fsolve}\left(,\mathrm{span}=10\mathrm{Unit}\left(\mathrm{ft}\right)..100\mathrm{Unit}\left(m\right)\right)$
 ${99.80004926}{}⟦{\mathrm{ft}}⟧$ (21)
 > $\mathrm{fsolve}\left(,\mathrm{span}=10\mathrm{Unit}\left(\mathrm{ft}\right)..1000\mathrm{Unit}\left(s\right)\right)$
 If we want the result in fathoms, we can associate that unit with the variable span, even if we do not supply a range.
 > $\mathrm{fsolve}\left(,\mathrm{span},\mathrm{useunits}=\left\{\mathrm{span}::\mathrm{Unit}\left(\mathrm{fathom}\right)\right\}\right)$
 ${16.63334154}{}⟦{\mathrm{fathom}}⟧$ (22)

Other Options

Using the avoid option to ignore solutions

 To ignore solutions, use the avoid option.
 > $\mathrm{fsolve}\left(\mathrm{sin}\left(x\right),x=-5..8,\mathrm{avoid}=\left\{x=0,x=\mathrm{\pi },x=-\mathrm{\pi }\right\}\right)$
 ${6.283185307}$ (23)
 > $\mathrm{fsolve}\left(\mathrm{cos},-5..3,\mathrm{avoid}=\left\{1.570796327,-1.570796327\right\}\right)$
 ${-4.712388980}$ (24)
 To find a solution near a value, specify a starting value.
 > $\mathrm{fsolve}\left(\mathrm{sin}\left(x\right),x=3.1\right)$
 ${3.141592654}$ (25)

Using the avoid option to find additional solutions

 In the following example, fsolve(f, 1.0), 1.0 is the initial value for the solver. After finding a solution, to find additional solutions, use the avoid option in subsequent fsolve calls.
 > f := proc(x) x - cos(x) end proc:
 > $\mathrm{fsolve}\left(f,1.0\right)$
 ${0.7390851332}$ (26)
 > $f,g≔1-{x}^{2}-{y}^{2},{x}^{2}+{y}^{2}-1$
 ${f}{,}{g}{≔}{-}{{x}}^{{2}}{-}{{y}}^{{2}}{+}{1}{,}{{x}}^{{2}}{+}{{y}}^{{2}}{-}{1}$ (27)
 > $\mathrm{S1}≔\mathrm{fsolve}\left(\left\{f,g\right\},\left\{x=-1.0,y=0.1\right\}\right)$
 ${\mathrm{S1}}{≔}\left\{{x}{=}{-0.9949874371}{,}{y}{=}{0.1}\right\}$ (28)
 > $\mathrm{S2}≔\mathrm{fsolve}\left(\left\{f,g\right\},\left\{x=1.0,y=-0.1\right\},\mathrm{avoid}=\left\{\mathrm{S1}\right\}\right)$
 ${\mathrm{S2}}{≔}\left\{{x}{=}{0.9949874371}{,}{y}{=}{-0.1}\right\}$ (29)
 > $\mathrm{S3}≔\mathrm{fsolve}\left(\left\{f,g\right\},\left\{x=0.1,y=0.5\right\},\mathrm{avoid}=\left\{\mathrm{S1},\mathrm{S2}\right\}\right)$
 ${\mathrm{S3}}{≔}\left\{{x}{=}{0.1}{,}{y}{=}{0.9949874371}\right\}$ (30)
 > $\mathrm{fsolve}\left(\left\{f,g\right\},\left\{x=-0.1,y=-0.5\right\},\mathrm{avoid}=\left\{\mathrm{S1},\mathrm{S2},\mathrm{S3}\right\}\right)$
 $\left\{{x}{=}{-0.1}{,}{y}{=}{-0.9949874371}\right\}$ (31)

References

 I.A. Karnovsky and O. Lebed, Advanced Methods of Structural Analysis, Springer, 2010.

Compatibility

 • The fsolve command was updated in Maple 2018.