2 * Introduction to minpack::
3 * Functions and Variables for minpack::
6 @node Introduction to minpack, Functions and Variables for minpack, Package minpack, Package minpack
7 @section Introduction to minpack
9 @code{Minpack} is a Common Lisp translation (via @code{f2cl}) of the
10 Fortran library @url{https://www.netlib.org/minpack/, MINPACK as obtained from Netlib}.
12 @opencatbox{Categories:}
13 @category{Numerical methods}
14 @category{Optimization}
15 @category{Share packages}
16 @category{Package minpack}
19 @node Functions and Variables for minpack, , Introduction to minpack, Package minpack
20 @section Functions and Variables for minpack
22 @anchor{minpack_lsquares}
23 @deffn {Function} minpack_lsquares (@var{flist}, @var{varlist}, @var{guess}, ['tolerance = @var{tolerance}, 'jacobian = @var{jacobian}])
25 Compute the point that minimizes the sum of the squares of the
26 functions in the list @var{flist}. The variables are in the list
27 @var{varlist}. An initial guess of the optimum point must be provided
30 Let @var{flist} be a list of @math{m} functions,
31 m4_mathdot(<<<f_i(x_1, x_2, ..., x_n)>>>, <<<f_i(x_1, x_2, ..., x_n)>>>)
32 Then this function can be used to find the values of
33 m4_math(<<<x_1, x_2, ..., x_n>>>, <<<x_1, x_2, ..., x_n>>>)
34 that solve the least squares problem
37 <<<\sum_i^m f_i(x_1, x_2,...,x_n)^2>>>,
42 ⟩ f (x_1, x_2,..., x_n)
49 The optional keyword arguments, @var{tolerance} and @var{jacobian}
50 provide some control over the algorithm.
54 the estimated relative error desired in the sum of squares. The
55 default value is approximately
56 m4_mathdot(<<<1.0537\times 10^{-8}>>>, <<<1.0537e-8>>>)
58 specifies the Jacobian. If @var{jacobian}
59 is not given or is @code{true} (the default), the Jacobian is computed
60 from @var{flist}. If @var{jacobian} is @code{false}, a numerical
61 approximation is used. @xref{jacobian, Jacobian}.
64 @code{minpack_lsquares} returns a list of three items as follows:
67 The estimated solution
71 The success of the algorithm. The possible values are
74 improper input parameters.
76 algorithm estimates that the relative error in the sum of squares is
77 at most @code{tolerance}.
79 algorithm estimates that the relative error between x and the solution
80 is at most @code{tolerance}.
82 conditions for info = 1 and info = 2 both hold.
84 fvec is orthogonal to the columns of the jacobian to machine
87 number of calls to fcn with iflag = 1 has reached 100*(n+1).
89 tol is too small. no further reduction in the sum of squares is
92 tol is too small. no further improvement in the approximate solution x
97 Here is an example using Powell's singular function.
100 @c powell(x1,x2,x3,x4) := [x1+10*x2, sqrt(5)*(x3-x4), (x2-2*x3)^2, sqrt(10)*(x1-x4)^2]$
101 @c minpack_lsquares(powell(x1,x2,x3,x4), [x1,x2,x3,x4], [3,-1,0,1]);
104 (%i1) load("minpack")$
105 (%i2) powell(x1,x2,x3,x4) := [x1+10*x2, sqrt(5)*(x3-x4), (x2-2*x3)^2, sqrt(10)*(x1-x4)^2]$
107 (%i3) minpack_lsquares(powell(x1,x2,x3,x4), [x1,x2,x3,x4], [3,-1,0,1]);
108 (%o3) [[1.6521175961683935e-17, - 1.6521175961683934e-18,
109 2.6433881538694683e-18, 2.6433881538694683e-18],
110 6.109327859207777e-34, 4]
114 Same problem but use numerical approximation to Jacobian.
117 @c powell(x1,x2,x3,x4) := [x1+10*x2, sqrt(5)*(x3-x4), (x2-2*x3)^2, sqrt(10)*(x1-x4)^2]$
118 @c minpack_lsquares(powell(x1,x2,x3,x4), [x1,x2,x3,x4], [3,-1,0,1], jacobian = false);
121 (%i1) load("minpack")$
122 (%i2) powell(x1,x2,x3,x4) := [x1+10*x2, sqrt(5)*(x3-x4), (x2-2*x3)^2, sqrt(10)*(x1-x4)^2]$
124 (%i3) minpack_lsquares(powell(x1,x2,x3,x4), [x1,x2,x3,x4], [3,-1,0,1], jacobian = false);
125 (%o3) [[5.060282149485331e-11, - 5.060282149491206e-12,
126 2.1794478435472183e-11, 2.1794478435472183e-11],
127 3.534491794847031e-21, 5]
131 @opencatbox{Categories:}
132 @category{Package minpack}
137 @anchor{minpack_solve}
138 @deffn {Function} minpack_solve (@var{flist}, @var{varlist}, @var{guess}, ['tolerance = @var{tolerance}, 'jacobian = @var{jacobian}])
140 Solve a system of @code{n} equations in @code{n} unknowns.
141 The @code{n} equations are given in the list @var{flist}, and the
142 unknowns are in @var{varlist}. An initial guess of the solution must
143 be provided in @var{guess}.
145 Let @var{flist} be a list of @math{m} functions,
146 m4_mathdot(<<<f_i(x_1, x_2, ..., x_n)>>>, <<<f_i(x_1, x_2, ..., x_n)>>>)
147 Then this functions solves the system of @math{m} nonlinear equations
148 in @math{n} variables:
151 <<<f_i(x_1, x_2, ..., x_n) = 0>>>,
152 <<<f_i(x_1, x_2, ..., x_n) = 0>>>)
154 The optional keyword arguments, @var{tolerance} and @var{jacobian}
155 provide some control over the algorithm.
159 the estimated relative error desired in the sum of squares. The
160 default value is approximately
161 m4_mathdot(<<<1.0537\times 10^{-8}>>>, <<<1.0537e-8>>>)
163 specifies the Jacobian. If @var{jacobian}
164 is not given or is @code{true} (the default), the Jacobian is computed
165 from @var{flist}. If @var{jacobian} is @code{false}, a numerical
166 approximation is used. @xref{jacobian, Jacobian}.
169 @code{minpack_solve} returns a list of three items as follows:
172 The estimated solution
176 The success of the algorithm. The possible values are
179 improper input parameters.
181 algorithm estimates that the relative error in the solution is
182 at most @code{tolerance}.
184 number of calls to fcn with iflag = 1 has reached 100*(n+1).
186 tol is too small. no further reduction in the sum of squares is
189 Iteration is not making good progress.
195 @c powell(x1,x2,x3,x4) := [x1+10*x2, sqrt(5)*(x3-x4), (x2-2*x3)^2, sqrt(10)*(x1-x4)^2]$
196 @c minpack_lsquares(powell(x1,x2,x3,x4), [x1,x2,x3,x4], [3,-1,0,1]);
199 (%i1) load("minpack")$
200 (%i2) powell(x1,x2,x3,x4) := [x1+10*x2, sqrt(5)*(x3-x4), (x2-2*x3)^2, sqrt(10)*(x1-x4)^2]$
202 (%i3) minpack_lsquares(powell(x1,x2,x3,x4), [x1,x2,x3,x4], [3,-1,0,1]);
203 (%o3) [[1.6521175961683935e-17, - 1.6521175961683934e-18,
204 2.6433881538694683e-18, 2.6433881538694683e-18],
205 6.109327859207777e-34, 4]
208 In this particular case, we can solve this analytically:
210 @c powell(x1,x2,x3,x4) := [x1+10*x2, sqrt(5)*(x3-x4), (x2-2*x3)^2, sqrt(10)*(x1-x4)^2]$
211 @c solve(powell(x1,x2,x3,x4),[x1,x2,x3,x4]);
214 (%i1) powell(x1,x2,x3,x4) := [x1+10*x2, sqrt(5)*(x3-x4), (x2-2*x3)^2, sqrt(10)*(x1-x4)^2]$
216 (%i2) solve(powell(x1,x2,x3,x4),[x1,x2,x3,x4]);
217 (%o2) [[x1 = 0, x2 = 0, x3 = 0, x4 = 0]]
220 and we see that the numerical solution is quite close the analytical one.
222 @opencatbox{Categories:}
223 @category{Package minpack}
230 @c TeX-master: "include-maxima"