ISmNonLinearEquations.JacobianCalcFrequency

Syntax

JacobianCalcFrequency: Integer;

Description

The JacobianCalcFrequency property determines how often the Jacobian is calculated when a non-linear equation system is solved using the Newton method.

Comments

Default value is one: that is, the Jacobian is calculated at each iteration. The greater is the value of this property, the less often the Jacobian is calculated and the higher is the speed of equation system solving.

Method of system solving is determined by the ISmNonLinearEquations.MethodType property: it must be set to NonLinearEquationsType.NewtonMethod. When other calculation methods are selected, JacobianCalcFrequency is ignored.

Example

To execute the example you need to add a link to the system assembly Stat.

Sub Main;

Var

Eqs: ISmNonLinearEquations;

Funcs: Array [0..2] Of String;

inits: Array[0..2] Of Double;

res: Integer;

Sub Print(Data: Array Of Double);

Var

i: Integer;

CI: ICultureInfo;

Begin

CI := CultureInfo.Current;

Debug.WriteLine("---Begin---");

For i := 0 To Data.Length - 1 Do

If Double.IsNan(Data[i]) Then

Debug.WriteLine("---empty---");

Else

Debug.WriteLine(i.ToString + ", " + CI.FormatDoublePrec(Data[i], 4));

End If;

End For;

Debug.WriteLine("---End---");

End Sub Print;

Begin

Eqs := New SmNonLinearEquations.Create As ISmNonLinearEquations;

funcs[0] := "X1-22+0.5*X2-X3";

funcs[1] := "X2-26.5+2*X1+0.5*X3";

funcs[2] := "X3+9-X1+6*X2";

Eqs.Functions := Funcs;

Eqs.CoefficientsOrder := "X1;X2;X3";

inits[0] := 10; //x1

inits[1] := 0; //x2

inits[2] := -1; //x3

Eqs.InitApproximation := inits;

Eqs.JacobianCalcFrequency := 5;

Eqs.LinearEqSolutionMethod := LinearEqSolutionType.InvMatrix;

Eqs.MethodType := NonLinearEquationsType.NewtonMethod;

Eqs.DerivativeShift := 0.6;

res := Eqs.Execute;

If res <> 0 Then

Debug.WriteLine(Eqs.Errors);

Else

Print(Eqs.Solution);

End If;

End Sub Main;

After executing the example a nonlinear equation system is created and parameters for calculating this system using Newton method are adjusted:

Next the system is calculated and the console window displays the solution:

Module execution started

---Begin---

0, 14.0000

1, 2.0000

2, -7.0000

---End---

Module execution finished

See also:

ISmNonLinearEquations