Home Site Statistics  |   Contact  |   About Us       Monday, July 13, 2020   

j0185201- Back to Home

Skip Navigation Links.

   Skip Navigation LinksHOME ›  AREAS OF EXPERTISE ›   Numerical Difference ›  ~ Backward Difference

"Numerical Differentiation"
Backward Difference Method

       Derivatives for f(x) = sin(x)

Y-Array =

       Derivatives for Y Array values:

Specify New Y Array size:

Specify New delegate x values = { , }

[ Initial delegate function: x = {7) ]
(s/b within y-array size)

[ Initial Y index: {7} ]
(selected delegate function: x values will match Y index values)

[ Initial Y Array: {15} ]

Backward Difference Method

The backward finite difference can be obtained from the equation shown under "Overview - Numerical Differentiation" tab. The first four derivatives of the function f(x) are given by the following formulas:

f'(x) = f(x + h) - f(x)
f''(x) = f(x + 2h) - 2f(x + h) + f(x)
f'''(x) = f(x + 3h) - 3f(x + 2h) + 3(f + h) - f(x)
f(4)(x) = f(x + 4h) - 4f(x + 3h) + 6f(x + 2h) - 4f(x + h) + f(x)

The above equations are usually not used to compute derivatives because they have a large truncation error (order of O(h)). The common practice is to use expressions of O(h2). To obtain backward difference formulas of this order, it is necessary to retain more terms in the Taylor series. Below are listed the results (without derivations):

f'(x) = -3f(x) + 4f(x + h) - f(x + 2h)
f''(x) = 2f(x) - 5f(x + h) + 4f(x + 2h) - f(x +3h)
f'''(x) = -5f(x) + 18f(x + h) - 24f(x + 2h) + 14f(x +3h) - 3f(x +4h)
f(4)(x) = 3f(x) - 14f(x + h) + 26f(x + 2h) - 24f(x +3h) + 11f(x +4h) - 2f(x + 5h)

Each derivative has two overloaded methods: one for the function and another for the array of data values. In order to calculate derivatives for a function, one has to pass a delegate function f(x), the value of x at which the derivative is computed, and the increment h as input parameters.

On the other hand, in order to calculate derivatives for an array of data values, each method has input parameters which pass the yarray values, the index called yindex which specifies the location at which the derivative is computed, and the increment h. Here, the increment parameter is the value used to generate the function values.

The x increment defined as h = 1 and created the Y array of the sine function using this increment. Then calculated the first four derivatives directly for the delegate function at x = 7. Derivatives for Y array also at x = 7, which corresponds to yindex = 7.

Running this example generates the results above. The reader will see that derivatives for the function and for the array values, as expected, are almost identical. Slight differences only because numerical round-off error. Users can manipulate function and array values.

Testing the Backward Difference Method

To test the Backward Difference method, a new static method has been added to show how to calculate the first four derivatives for f(x) = Sin x. The TestBackwardMethod() method has been written, added and executed:

           static void TestBackwardMethod();
                 double h = 0.1;
                 double[] yarray=new double[10];
           // create yarray:
                 for (int i = 0; i < 10; i++)
                    yarray[i] = f(i * h);
           // Calculate derivatives for function:
                     double dy = Differentiation.Backward(f, 7, h);
                     listBox1.Items.Add("f'(x) = " + dy.ToString());
                     dy = Differentiation.Backward2(f, 7, h);
                     listBox1.Items.Add("f''(x) = " + dy.ToString());
                     dy = Differentiation.Backward3(f, 7, h);
                     listBox1.Items.Add("f'''(x) = " + dy.ToString());
                     dy = Differentiation.Backward4(f, 7, h);
                     listBox1.Items.Add("f''''(x) = " + dy.ToString());
           // Calculate derivatives for array values:
                 foreach (double y1 in yarray)
                     listBox2.Items.Add(" " + y1.ToString());
                     dy = Differentiation.Backward1(yarray, 7, h);
                     listBox3.Items.Add("y' = " + dy.ToString());
                     dy = Differentiation.Backward2(yarray, 7, h);
                     listBox3.Items.Add("y'' = " + dy.ToString());
                     dy = Differentiation.Backward3(yarray, 7, h);
                     listBox3.Items.Add("y''' = " + dy.ToString());
                     dy = Differentiation.Backward4(yarray, 7, h);
                     listBox3.Items.Add("y'''' = " + dy.ToString());
           static double f(double x)
              return Math.Sin(x);

Other Implementations...

Object-Oriented Implementation
Graphics and Animation
Sample Applications
Ore Extraction Optimization
Vectors and Matrices
Complex Numbers and Functions
Ordinary Differential Equations - Euler Method
Ordinary Differential Equations 2nd-Order Runge-Kutta
Ordinary Differential Equations 4th-Order Runge-Kutta
Higher Order Differential Equations
Nonlinear Systems
Numerical Integration
Numerical Differentiation
Function Evaluation

Consulting Services - Back to Home

Home Math, Analysis,

Eigen Inverse Iteration
Rayleigh-Quotient Method
Cubic Spline Method


Applied Mathematical Algorithms

Home A complex number z = x + iy, where...

Complex Functions
Home Non-linear system methods...

Non Linear Systems
Home Construction of differentiation...

Home Consider the function where...

About Us

KMP Engineering is an independent multidisciplinary engineering consulting company specializing in mathematical algorithms.

KMP Website >
Site Statistics >
Contact Us

2461 E Orangethorpe Ave Fullerton, CA 92631 USA info@keystoneminingpost.com
Site Map

> Home
> Areas of Expertise
> Reference Items
> Managed Services
> Login

Mining & Software Engineering

Since 2006 All Rights Reserved  © KMP Engineering LINKS | PRIVACY POLICY | LEGAL NOTICE