XLPack 7.0
XLPack Numerical Library (C API) Reference Manual
Loading...
Searching...
No Matches

◆ hybrj1()

void hybrj1 ( void(*)(int, double *, double *, int, double *, int *)  fcn,
int  n,
double  x[],
double  fvec[],
double  xtol,
double  work[],
int  lwork,
int *  info 
)

Solution of a system of nonlinear equations by Powell hybrid method (simple driver)

Purpose
hybrj1 finds a zero of a system of n nonlinear functions in n variables
fi(x1, x2, ..., xn) = 0 (i = 1 to n)
by a modification of the Powell hybrid method.

The user must provide a subroutine which calculates the functions and the Jacobian.

hybrj1 is the simple driver for standard use, which calls the hybrj with default parameters.
Parameters
[in]fcnUser supplied subroutine which calculates the functions fi(x) and the Jacobian defined as follows.
void fcn(int n, double x[], double fvec[], int ldfjac, double fjac[][ldfjac], int *iflag)
{
If iflag = 1:
Calculate the function values fi(x) at x[] and return in fvec[i] (i = 0 to n-1). Other variables should not be changed.
If iflag = 2:
Calculate the Jacobian matrix (dfi/dxj) and return in fjac[j][i] (i = 0 to n-1, j = 0 to n-1). Other variables should not be changed. ldfjac is the leading dimension of the two dimensional array.
}
The value of iflag should not be changed unless the user wants to terminate the execution. In this case, set iflag to a negative integer.
[in]nNumber of functions and variables. (n > 0)
[in,out]x[]Array x[lx] (lx >= n)
[in] An initial estimate of the solution vector.
[out] The obtained solution vector.
[out]fvec[]Array fvec[lfvec] (lfvec >= n)
The function values evaluated at the solution vector x[].
[in]xtolTarget relative tolerance. Termination occurs when the relative error between two consecutive iterations is at most xtol. (xtol >= 0)
[out]work[]Array work[lwork]
Work array.
[in]lworkThe length of work[]. (lwork >= n*(3*n + 17)/2)
[out]info= 0: Successful exit (relative error between two consecutive iterates is at most xtol)
= -2: The argument n had an illegal value (n < 1)
= -5: The argument xtol had an illegal value (xtol < 0)
= -7: The argument lwork had an illegal value (lwork too small)
= 1: Number of calls to fcn with iflag = 1 has reached the limit (100*(n + 1))
= 2: xtol is too small. No further improvement in the approximate solution x is possible
= 3: Iteration is not making good progress, as measured by the improvement from the last five Jacobian evaluations
= 4: Iteration is not making good progress, as measured by the improvement from the last ten iterations
= 5: User imposed termination (returned from fcn with iflag < 0)
Reference
netlib/minpack