gaussNewton: Gauss-Newton Function Minimization In pracma: Practical Numerical Math Functions

Description

Gauss-Newton method of minimizing a term f_1(x)^2 + … + f_m(x)^2 or F' F where F = (f_1, …, f_m) is a multivariate function of n variables, not necessarily n = m.

Usage

 1 2 gaussNewton(x0, Ffun, Jfun = NULL, maxiter =100, tol = .Machine\$double.eps^(1/2), ...)

Arguments

 Ffun m functions of n variables. Jfun function returning the Jacobian matrix of Ffun; if NULL, the default, the Jacobian will be computed numerically. The gradient of f will be computed internally from the Jacobian (i.e., cannot be supplied). x0 Numeric vector of length n. maxiter Maximum number of iterations. tol Tolerance, relative accuracy. ... Additional parameters to be passed to f.

Details

Solves the system of equations applying the Gauss-Newton's method. It is especially designed for minimizing a sum-of-squares of functions and can be used to find a common zero of several function.

This algorithm is described in detail in the textbook by Antoniou and Lu, incl. different ways to modify and remedy the Hessian if not being positive definite. Here, the approach by Goldfeld, Quandt and Trotter is used, and the hessian modified by the Matthews and Davies algorithm if still not invertible.

To accelerate the iteration, an inexact linesearch is applied.

Value

List with components:
xs the minimum or root found so far,
fs the square root of sum of squares of the values of f,
iter the number of iterations needed, and
relerr the absoulte distance between the last two solutions.

Note

If n=m then directly applying the newtonsys function might be a better alternative.

References

Antoniou, A., and W.-S. Lu (2007). Practical Optimization: Algorithms and Engineering Applications. Springer Business+Science, New York.

Examples

 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 f1 <- function(x) c(x^2 + x^2 - 1, x + x - 1) gaussNewton(c(4, 4), f1) f2 <- function(x) c( x + 10*x, sqrt(5)*(x[] - x), (x - 2*x)^2, 10*(x - x)^2) gaussNewton(c(-2, -1, 1, 2), f2) f3 <- function(x) c(2*x - x - exp(-x), -x + 2*x - exp(-x)) gaussNewton(c(0, 0), f3) # \$xs 0.5671433 0.5671433 f4 <- function(x) # Dennis Schnabel c(x^2 + x^2 - 2, exp(x - 1) + x^3 - 2) gaussNewton(c(2.0, 0.5), f4) # \$xs 1 1 ## Examples (from Matlab) F1 <- function(x) c(2*x-x-exp(-x), -x+2*x-exp(-x)) gaussNewton(c(-5, -5), F1) # Find a matrix X such that X %*% X %*% X = [1 2; 3 4] F2 <- function(x) { X <- matrix(x, 2, 2) D <- X %*% X %*% X - matrix(c(1,3,2,4), 2, 2) return(c(D)) } sol <- gaussNewton(ones(2,2), F2) (X <- matrix(sol\$xs, 2, 2)) # [,1] [,2] # [1,] -0.1291489 0.8602157 # [2,] 1.2903236 1.1611747 X %*% X %*% X

Example output

\$xs
  1.00000e+00 -4.61371e-18

\$fs
 0

\$niter
 9

\$relerr
 3.273629e-12

\$xs
 -5.217195e-26  3.035548e-27 -6.223335e-26 -4.143244e-26

\$fs
 1.310304e-50

\$niter
 7

\$relerr
 3.376084e-17

\$xs
 0.5671433 0.5671433

\$fs
 0

\$niter
 5

\$relerr
 7.721235e-14

\$xs
 1 1

\$fs
 4.930381e-32

\$niter
 8

\$relerr
 5.104648e-10

\$xs
 0.5671433 0.5671433

\$fs
 0

\$niter
 4

\$relerr
 7.909038e-16

[,1]      [,2]
[1,] -0.1291489 0.8602157
[2,]  1.2903236 1.1611747
[,1] [,2]
[1,]    1    2
[2,]    3    4

pracma documentation built on Dec. 11, 2021, 9:57 a.m.