This example solves the following nonlinear equations with function solveOneNonlinearEquation. The user can set the parameters, like "w" or "m", and can experiment with different start intervals. The following nonlinear equations are solved:
function solveNonlinearEquations2 extends Modelica.Icons.Function; import Modelica.Utilities.Streams.print; input Real tolerance = 100*Modelica.Constants.eps "Relative tolerance of solution u" annotation( Dialog(group = "General")); input Real u_min1 = -0.5 "Lower limit" annotation( Dialog(group = "u^2-1")); input Real u_max1 = 10 "Upper limit" annotation( Dialog(group = "u^2-1")); input Real u_min2 = 0 "Lower limit" annotation( Dialog(group = "3*u - sin(w*u) - 1")); input Real u_max2 = 5 "Upper limit" annotation( Dialog(group = "3*u - sin(w*u) - 1")); input Real w = 3 "Angular velocity" annotation( Dialog(group = "3*u - sin(w*u) - 1")); input Real u_min3 = 1 "Lower limit" annotation( Dialog(group = "p[1] + log(p[2]*u) - m*u")); input Real u_max3 = 8 "Upper limit" annotation( Dialog(group = "p[1] + log(p[2]*u) - m*u")); input Real p[2] = {5, 1} "Parameter vector" annotation( Dialog(group = "p[1] + log(p[2]*u) - m*u")); input Real m = 1 "Parameter" annotation( Dialog(group = "p[1] + log(p[2]*u) - m*u")); end solveNonlinearEquations2;