fsolve - solve one or more equations using floating-point arithmetic
|
Calling Sequence
|
|
fsolve(equations, variables, complex, fulldigits, 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
|
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; 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 .
|
•
|
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.
|
|
|
Optional Arguments
|
|
|
avoid = set(equation) or set(set(equation)) or set(list(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.
|
|
When using the avoid option, it is recommended that you specify a starting_values option to facilitate converging to a different solution.
|
|
Find one root (or all roots, for polynomials) over the complex floating-point numbers.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
|
|
By default, the fsolve command finds all real solutions to a univariate polynomial equation.
|
>
|
|
>
|
|
| (1) |
|
To find only 2 real solutions, use the maxsols option.
|
>
|
|
| (2) |
|
To find only real solutions in an interval, specify the interval.
|
>
|
|
| (3) |
|
To find all the complex solutions, specify the complex option.
|
>
|
|
| (4) |
|
|
General Equations and Systems of Equations
|
|
|
By default, the fsolve command finds one real solution to a general equation or system of equations.
|
>
|
|
| (5) |
|
You can specify the interval in which to search for a solution.
|
>
|
|
>
|
|
>
|
|
| (6) |
|
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:
|
>
|
|
| (7) |
|
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.
|
>
|
|
| (8) |
>
|
|
| (9) |
>
|
|
| (10) |
|
To find a complex solution in a rectangle in the complex plane, specify a complex interval.
|
>
|
|
| (11) |
>
|
|
| (12) |
|
|
Other Options
|
|
|
To ignore solutions, use the avoid option.
|
>
|
|
| (13) |
|
To find a solution near a value, specify a starting value.
|
>
|
|
| (14) |
|
In 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:
|
>
|
|
| (15) |
>
|
|
| (16) |
>
|
|
| (17) |
>
|
|
| (18) |
>
|
|
| (19) |
>
|
|
| (20) |
|
|
|