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

◆ sos_r()

void sos_r ( int  n,
double  x[],
double  rtolx,
double  atolx,
double  tolf,
int  nprint,
int  maxiter,
int *  iter,
double  work[],
int  lwork,
int  iwork[],
int  liwork,
int *  info,
int *  k,
double  xx[],
double *  yy,
int *  irev 
)

Solution of a system of nonlinear equations by Brown's method (reverse communication version)

Purpose
sos_r finds a zero of a system of n nonlinear functions in n variables
fi(x1, x2, ..., xn) = 0 (i = 1 to n)
by the Brown's method.

The algorithm is based on an iterative method which is a variation of Newton's method using Gaussian elimination in a manner similar to the Gauss-Seidel process. Convergence is roughly quadratic. The convergence behavior of this code is affected by the ordering of the equations, and it is advantageous to place linear and mildly nonlinear equations first in the ordering.

The user must provide the calculated function values according to irev. All partial derivatives required by the algorithm are approximated by first difference quotients.
Parameters
[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.
[in]rtolxRelative error tolerance used in the convergence criteria. Each solution component x[i] is checked by an accuracy test of the form abs(x[i] - xold[i]) <= rtolx*abs(x[i]) + atolx, where xold[i] represents the previous iteration value. (rtolx >= 0)
[in]atolxAbsolute error tolerance used in the convergence criteria. If the user suspects some solution component may be zero, he should set atolx to an appropriate (depends on the scale of the remaining variables) positive value for better efficiency. (atolx >= 0)
[in]tolfResidual error tolerance used in the convergence criteria. Convergence will be indicated if all residuals (values of the functions or equations) are not bigger than tolf in magnitude. Note that extreme care must be given in assigning an appropriate value for tolf because this convergence test is dependent on the scaling of the equations. An inappropriate value can cause premature termination of the iteration process. (tolf >= 0)
[in]nprint= 0: Do not return to print out the intermediate solution.
= 1: Return with irev = 50 to print out the intermediate solution on every iteration.
(For other values, nprint = 0 is assumed.)
[in]maxiterMaximum number of iterations. (maxiter >= 1)
[out]iterNumber of iterations required to converge.
[out]work[]Array work[lwork]
Work array.
On return, work[0] contains a norm of the residual.
[in]lworkThe length of work[]. (lwork >= 1 + 5*n + n*(n + 1)/2)
[out]iwork[]Array iwork[liwork]
Work array.
On return with info = 0, iwork[0] contains the sub-code.
= 1: Each component x(i) satisfies the error tolerance test: abs(x(i)-xold(i)) <= rtolx*abs(x(i)) + atolx.
= 2: All residuals are at most tolf in magnitude: abs(f(x,i)) <= tolf.
= 3: Both of above are satisfied.
= 4: Possibly converged (error tolerance too small or very slow convergence). (residual norms have remained roughly constant over several consecutive iterations)
[in]liworkThe length of iwork[]. (liwork >= n)
[out]info= 0: Successful exit (sub-code is set to iwork[0])
= -1: The argument n had an illegal value (n < 1)
= -3: The argument rtolx had an illegal value (rtolx < 0)
= -4: The argument atolx had an illegal value (atolx < 0)
= -5: The argument tolf had an illegal value (tolf < 0)
= -7: The argument maxiter had an illegal value (maxiter <= 0)
= -10: The argument lwork had an illegal value (lwork < 1+5*n+n*(n+1)/2)
= -12: The argument liwork had an illegal value (liwork < n)
= 1: Number of iterations has reached maxiter (maybe very slow convergence. Check if error tolerances are appropriate)
= 2: Number of iterations has reached maxiter (a local minimum may have been encountered or there may be limiting precision difficulties)
= 3: Iterative scheme appears to be diverging (residual norms have increased over several consecutive iterations)
= 4: A Jacobian-related matrix was singular
[out]kirev = 1 or 2: The k-th function value should be evaluated and given in the next call.
irev = 50: Number of iterations so far.
[out]xx[]Array xx[lxx] (lxx >= n)
irev = 1 or 2: The abscissa where the function value should be evaluated and given in the next call.
irev = 50: The last approximate solution.
[in,out]yy[in] irev = 1 or 2: The function value fi(xx[]) (i = k) should be given in yy in the next call.
[out] irev = 50: Residual norm at the last approximate solution.
[in,out]irevControl variable for reverse communication.
[in] Before first call, irev should be initialized to zero. On succeeding calls, irev should not be altered.
[out] If irev is not zero, complete the following process and call this routine again.
= 0: Computation finished. See return code in info.
= 1 or 2: User should set the k-th function value at xx[] in yy. Do not alter any variables other than yy.
= 50: Display the intermediate result (k: number of iterations, yy: residual norm at xx[], etc.) (only in the case of nprint = 1). Do not alter any variables.
Reference
SLATEC