ISmNonLinearEquations.CoefficientsOrder

Fore Syntax

CoefficientsOrder: String;

Fore.NET Syntax

CoefficientsOrder: string;

Description

The CoefficientsOrder property determines the coefficients order.

Comments

If there are several coefficients, they are separated with semicolon.

Fore Example

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

Sub UserProc;
Var
    Eqs: ISmNonLinearEquations;
    Funcs: Array[0..2Of String;
    inits: Array[0..2Of Double;
    res, i: Integer;
Begin
    Eqs := New SmNonLinearEquations.Create;
    // Set non-linear equations
    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;
    // Set coefficient order
    Eqs.CoefficientsOrder := "X1;X2;X3";
    // Set initial approximations
    inits[0] := 10//x1
    inits[1] := 0//x2
    inits[2] := -1//x3
    Eqs.InitApproximation := inits;
    // Set system solving method
    Eqs.MethodType := NonLinearEquationsType.HMethod;
    // Execute calculation
    res := Eqs.Execute;
    If res <> 0 Then
        Debug.WriteLine(Eqs.Errors);
    // Display calculation results   
    Else
        Debug.WriteLine("Solution: ");
        Debug.Indent;
        For i := 0 To Eqs.Functions.Length - 1 Do
            Debug.WriteLine(i.ToString + ". " + Eqs.Solution[i].ToString);
        End For;
        Debug.Unindent;
        Debug.WriteLine("Actually used initial approximations:");
        Debug.Indent;
        For i := 0 To Eqs.InitApproximationActual.Length - 1 Do
            Debug.WriteLine(i.ToString + ". " + Eqs.InitApproximationActual[i].ToString);
        End For;
        Debug.Unindent;
    End If;
End Sub UserProc;

After executing the example the console window displays a solution for a system of non-linear equations and actually used initial approximations:

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.Stat;

Public Shared Sub Main(Params: StartParams);
Var
    Eqs: ISmNonLinearEquations;
    Funcs: Array[0..2Of String;
    inits: Array[0..2Of Double;
    res, i: Integer;
    Sol, InitApproxActual: System.Array;
Begin
    Eqs := New SmNonLinearEquations.Create();
    // Set non-linear equations
    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;
    // Set coefficient order
    Eqs.CoefficientsOrder := "X1;X2;X3";
    // Set initial approximations
    inits[0] := 10//x1
    inits[1] := 0//x2
    inits[2] := -1//x3
    Eqs.InitApproximation := inits;
    // Set system solving method
    Eqs.MethodType := NonLinearEquationsType.nletHMethod;
    // Execute calculation
    res := Eqs.Execute();
    If res <> 0 Then
        System.Diagnostics.Debug.WriteLine(Eqs.Errors);
    // Display calculation results   
    Else
        System.Diagnostics.Debug.WriteLine("Solution: ");
        System.Diagnostics.Debug.Indent();
        Sol := Eqs.Solution;
        For i := 0 To Eqs.Functions.Length - 1 Do
            System.Diagnostics.Debug.WriteLine(i.ToString() + ". " + Sol[i].ToString());
        End For;
        System.Diagnostics.Debug.Unindent();
        System.Diagnostics.Debug.WriteLine("Actually used initial approximations:");
        System.Diagnostics.Debug.Indent();
        InitApproxActual := Eqs.InitApproximationActual;
        For i := 0 To InitApproxActual.Length - 1 Do
            System.Diagnostics.Debug.WriteLine(i.ToString() + ". " + InitApproxActual[i].ToString());
        End For;
        System.Diagnostics.Debug.Unindent();
    End If;
End Sub;

See also:

ISmNonLinearEquations