.Modelica.Math.Nonlinear.solveOneNonlinearEquation

Information

Syntax

solveOneNonlinearEquation(function f(), u_min, u_max);
solveOneNonlinearEquation(function f(), u_min, u_max, tolerance=100*Modelica.Constants.eps);

Description

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. The function computes a smaller interval in which a sign change is present using the relative tolerance "tolerance" that can be given as 4th input argument.

The interval reduction is performed using 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.
Download: https://maths-people.anu.edu.au/~brent/pd/rpb011i.pdf
Errata and new print: https://maths-people.anu.edu.au/~brent/pub/pub011.html

Example

See the examples in Modelica.Math.Nonlinear.Examples.

Interface

function solveOneNonlinearEquation
  extends Modelica.Icons.Function;
  import Modelica.Utilities.Streams.error;
  input Modelica.Math.Nonlinear.Interfaces.partialScalarFunction f "Function y = f(u); u is computed so that y=0";
  input Real u_min "Lower bound of search interval";
  input Real u_max "Upper bound of search interval";
  input Real tolerance = 100 * Modelica.Constants.eps "Relative tolerance of solution u";
  output Real u "Value of independent variable u so that f(u) = 0";
end solveOneNonlinearEquation;

Generated at 2020-06-05T21:39:08Z by OpenModelica 1.16.0~dev-442-g2e5bc9f