functionsolveOneNonlinearEquation
Extends from Modelica.Icons.Function (Icon for functions).
Information
This function determines the solution of one non-linear algebraic equation "y=f(u)" in one unknown "u" in a reliable way. It is one of the best numerical algorithms for this purpose. As input, the nonlinear function f(u) has to be given, as well as an interval u_min, u_max that contains the solution, i.e., "f(u_min)" and "f(u_max)" must have a different sign. If possible, a smaller interval is computed by inverse quadratic interpolation (interpolating with a quadratic polynomial through the last 3 points and computing the zero). If this fails, bisection is used, which always reduces the interval by a factor of 2. The inverse quadratic interpolation method has superlinear convergence. This is roughly the same convergence rate as a globally convergent Newton method, but without the need to compute derivatives of the non-linear function. The solver function is a direct mapping of the Algol 60 procedure "zero" to Modelica, from:
- Brent R.P.:
- Algorithms for Minimization without derivatives. Prentice Hall, 1973, pp. 58-59.
Inputs
| Type | Name | Default | Description |
|---|---|---|---|
| Real[:] | c1 | [p] coefficients of denominator polynomials (c1[i]*p + 1) | |
| Real[:,2] | c2 | [p^2, p] coefficients of denominator polynomials (c2[i,1]*p^2 + c2[i,2]*p + 1) | |
| Real | u_min | Lower bound of search interval | |
| Real | u_max | Upper bound of search interval | |
| Real | tolerance | 100*Modelica.Constants.eps | Relative tolerance of solution u |
Outputs
| Type | Name | Default | Description |
|---|---|---|---|
| Real | u | Value of independent variable so that f(u) = 0 |