/* Method computing Global Truncation Errors of Numerical Method.
  * Apply() should be called before utilizing this method.
  * Returns array of GTE's at every point of grid.
  */
 public double[] ComputeGlobalTruncationErrors(DifferentialEquation MyDifferentialEquation)
 {
     // Get exact values of y-coordinates.
     double[] y = GetY();
     // Initialize an array to store Global Truncation errors.
     double[] GTE = new double[GetN()];
     // Iteratively compute Global Truncation error for each grid step.
     for (int i = 0; i < GetN(); i++)
     {
         GTE[i] = Math.Abs(y[i] - MyDifferentialEquation.GetY()[i]);
     }
     return(GTE);
 }
 /* Method computing Local Truncation Errors of Numerical Method.
  * Apply() should be called before utilizing this method.
  * Returns array of LTE's at every point of grid.
  */
 public double[] ComputeLocalTruncationErrors(DifferentialEquation MyDifferentialEquation)
 {
     // Get values of x-coordinates.
     double[] x = GetX();
     // Get exact values of y-coordinates.
     double[] y = MyDifferentialEquation.GetY();
     // Initialize an array to store Local Truncation errors.
     double[] LTE = new double[GetN()];
     // Local Truncation error for a first point is 0 as it given by IVP.
     LTE[0] = 0;
     // Iteratively compute Local Truncation error for each grid step.
     for (int i = 1; i < GetN(); i++)
     {
         LTE[i] = Math.Abs(ComputeForPoint(x, y, i - 1, MyDifferentialEquation) - y[i]);
     }
     return(LTE);
 }
 // Update chart of approximations.
 public void UpdateChartApproximation(DifferentialEquation MyDifferentialEquation, Euler EulerApproximation, ImprovedEuler ImprovedEulerApproximation, RungeKutta RungeKuttaApproximation, double X0, double X)
 {
     // Set minimum and maximum values of Tab1ChartApproximation.
     Tab1ChartApproximation.ChartAreas[0].AxisX.Minimum = X0;
     Tab1ChartApproximation.ChartAreas[0].AxisX.Maximum = X;
     // Plot the graphs of exact and numerical solutions.
     Tab1ChartApproximation.Series[0].Points.DataBindXY(MyDifferentialEquation.GetX(), MyDifferentialEquation.GetY());
     Tab1ChartApproximation.Series[1].Points.DataBindXY(EulerApproximation.GetX(), EulerApproximation.GetY());
     Tab1ChartApproximation.Series[2].Points.DataBindXY(ImprovedEulerApproximation.GetX(), ImprovedEulerApproximation.GetY());
     Tab1ChartApproximation.Series[3].Points.DataBindXY(RungeKuttaApproximation.GetX(), RungeKuttaApproximation.GetY());
 }