Algorithm To Find Derivatives Using Newtons Forward Difference Formula
In this article, you will learn step by step procedure (algorithm) to find derivatives using Newton's forward interpolation formula.
Following steps are required inorder to find derivatives using forward difference formula:
1. Start 2. Read number of data (n) 3. Read data points for x and y: For i = 0 to n-1 Read Xi and Yi,0 Next i 4. Read calculation point where derivative is required (xp) 5. Set variable flag to 0 6. Check whether given point is valid data point or not. If it is valid point then get its position at variable index For i = 0 to n-1 If |xp - Xi| < 0.0001 index = i flag = 1 break from loop End If Next i 7. If given calculation point (xp) is not in x-data then terminate the process. If flag = 0 Print "Invalid Calculation Point" Exit End If 8. Generate forward difference table For i = 1 to n-1 For j = 0 to n-1-i Yj,i = Yj+1,i-1 - Yj,i-1 Next j Next i 9. Calculate finite difference: h = X1 - X0 10. Set sum = 0 and sign = 1 11. Calculate sum of different terms in formula to find derivatives using Newton's forward difference formula: For i = 1 to n-1-index term = (Yindex, i)i / i sum = sum + sign * term sign = -sign Next i 12. Divide sum by finite difference (h) to get result first_derivative = sum/h 13. Display value of first_derivative 14. Stop