ISmDerivative.CoefficientsOrder

Syntax

CoefficientsOrder: String;

Description

The CoefficientsOrder property determines the variables used in the function.

Comments

The function is determined by the ISmDerivative.Expression property.

Example

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

Sub UserProc;
Var
    AnDeriv: ISmDerivative;
    ArgVals: Array[0..3Of Double;
    i, res, size: Integer;
Begin
    AnDeriv := New SmDerivative.Create;
    // Set expression for differentiation
    AnDeriv.Expression := "A1 + A2 * A2 + A3 * A3 * A2";
    // Specify variables order
    AnDeriv.CoefficientsOrder := "A1;A2;A3;A4";
    // Specify differentiation variables
    AnDeriv.DiffVariables := "A2;A1";
    // Set values for variables
    ArgVals[0] := 1.5;
    ArgVals[1] := 2.0;
    ArgVals[2] := 2.5;
    ArgVals[3] := Double.Nan;
    AnDeriv.VariablesValues := ArgVals;
    // Indicate that analytical derivatives are calculated
    AnDEriv.UseAnalyticCalc := True;
    res := AnDeriv.Execute;
    // Output calculation results
    Debug.WriteLine("Execution status: " + res.ToString);
    Debug.WriteLine(AnDeriv.Errors);
    For i := 0 To AnDeriv.Warnings.Length - 1 Do
        Debug.WriteLine(AnDeriv.Warnings[i]);
    End For;
    If res = 0 Then
        Debug.WriteLine("== Analytical derivatives ==");
        size := AnDeriv.DerivativeExpressions.Length;
        For i := 0 To size - 1 Do
            Debug.Write("  - derivative expression: ");
            Debug.WriteLine(AnDeriv.DerivativeExpressions[i]);
            Debug.Write("  - value of derivative: ");
            Debug.WriteLine(AnDeriv.DerivativeValues[i]);
            Debug.WriteLine("");
        End For;
        Debug.WriteLine("Function value: " + Anderiv.FunctionValue.ToString);
    End If;
    Debug.WriteLine("");
    // Indicate that approximate values of partial derivatives are calculated
    AnDEriv.UseAnalyticCalc := False;
    // Specify increment of the argument
    AnDEriv.Increment := 0.00000003;
    res := AnDeriv.Execute;
    // Output calculation results
    Debug.WriteLine("Execution status: " + res.ToString);
    Debug.WriteLine(AnDeriv.Errors);
    For i := 0 To AnDeriv.Warnings.Length - 1 Do
        Debug.WriteLine(AnDeriv.Warnings[i]);
    End For;
    If res = 0 Then
        Debug.WriteLine("== Approximate values of partial derivatives ==");
        size := AnDeriv.DerivativeValues.Length;
        For i := 0 To size - 1 Do
            Debug.WriteLine(AnDeriv.DerivativeValues[i]);
        End For;
        Debug.WriteLine("Function value: " + Anderiv.FunctionValue.ToString);
    End If;
End Sub UserProc;

After executing the example the console window displays the results of function calculation using analytical derivatives and approximate values of partial derivatives.

See also:

ISmDerivative