2 * Introduction to mnewton::
3 * Functions and Variables for mnewton::
6 @c -----------------------------------------------------------------------------
7 @node Introduction to mnewton, Functions and Variables for mnewton, Package mnewton, Package mnewton
8 @section Introduction to mnewton
9 @c -----------------------------------------------------------------------------
11 @code{mnewton} is an implementation of Newton's method for solving nonlinear
12 equations in one or more variables.
14 @opencatbox{Categories:}
15 @category{Numerical methods}
16 @category{Share packages}
17 @category{Package mnewton}
20 @c -----------------------------------------------------------------------------
21 @node Functions and Variables for mnewton, , Introduction to mnewton, Package mnewton
22 @section Functions and Variables for mnewton
23 @c -----------------------------------------------------------------------------
25 @c -----------------------------------------------------------------------------
26 @anchor{newtonepsilon}
27 @defvr {Option variable} newtonepsilon
28 Default value: @code{10.0^(-fpprec/2)}
30 Precision to determine when the @code{mnewton} function has converged towards
33 When @code{newtonepsilon} is a bigfloat,
34 @code{mnewton} computations are done with bigfloats;
35 otherwise, ordinary floats are used.
37 See also @mrefdot{mnewton}
39 @opencatbox{Categories:}
40 @category{Package mnewton}
44 @c -----------------------------------------------------------------------------
45 @anchor{newtonmaxiter}
46 @defvr {Option variable} newtonmaxiter
47 Default value: @code{50}
49 Maximum number of iterations to stop the @code{mnewton} function
50 if it does not converge or if it converges too slowly.
52 See also @mrefdot{mnewton}
54 @opencatbox{Categories:}
55 @category{Package mnewton}
59 @c -----------------------------------------------------------------------------
61 @defvr {Option variable} newtondebug
62 Default value: @code{false}
64 When @code{newtondebug} is @code{true},
65 @code{mnewton} prints out debugging information while solving a problem.
67 @opencatbox{Categories:}
68 @category{Package mnewton}
72 @c -----------------------------------------------------------------------------
74 @deffn {Function} mnewton @
75 @fname{mnewton} (@var{FuncList}, @var{VarList}, @var{GuessList}) @
76 @fname{mnewton} (@var{FuncList}, @var{VarList}, @var{GuessList}, @var{DF})
78 Approximate solution of multiple nonlinear equations by Newton's method.
80 @var{FuncList} is a list of functions to solve,
81 @var{VarList} is a list of variable names, and
82 @var{GuessList} is a list of initial approximations.
83 The optional argument @var{DF} is the Jacobian matrix of the list of functions;
84 if not supplied, it is calculated automatically from @var{FuncList}.
86 @var{FuncList} may be specified as a list of equations,
87 in which case the function to be solved is the left-hand side of each equation minus the right-hand side.
89 If there is only a single function, variable, and initial point,
90 they may be specified as a single expression, variable, and initial value;
91 they need not be lists of one element.
93 A variable may be a simple symbol or a subscripted symbol.
95 The solution, if any, is returned as a list of one element,
96 which is a list of equations, one for each variable,
97 specifying an approximate solution;
98 this is the same format as returned by @code{solve}.
99 If the solution is not found, @code{[]} is returned.
101 Functions and initial points may contain complex numbers,
102 and solutions likewise may contain complex numbers.
104 @code{mnewton} is governed by global variables @mref{newtonepsilon} and
105 @mrefcomma{newtonmaxiter} and the global flag @mrefdot{newtondebug}
107 @code{load("mnewton")} loads this function.
109 See also @mrefcomma{realroots} @mrefcomma{allroots} @mref{find_root} and
115 (%i1) load("mnewton")$
117 (%i2) mnewton([x1+3*log(x1)-x2^2, 2*x1^2-x1*x2-5*x1+1],
119 (%o2) [[x1 = 3.756834008012769, x2 = 2.779849592817897]]
120 (%i3) mnewton([2*a^a-5],[a],[1]);
121 (%o3) [[a = 1.70927556786144]]
122 (%i4) mnewton([2*3^u-v/u-5, u+2^v-4], [u, v], [2, 2]);
123 (%o4) [[u = 1.066618389595407, v = 1.552564766841786]]
126 The variable @code{newtonepsilon} controls the precision of the
127 approximations. It also controls if computations are performed with
131 (%i1) load("mnewton")$
133 (%i2) (fpprec : 25, newtonepsilon : bfloat(10^(-fpprec+5)))$
135 (%i3) mnewton([2*3^u-v/u-5, u+2^v-4], [u, v], [2, 2]);
136 (%o3) [[u = 1.066618389595406772591173b0,
137 v = 1.552564766841786450100418b0]]
140 @opencatbox{Categories:}
141 @category{Package mnewton}