Derivatives Using Forward Difference Formula Pseudocode

In this article, you will learn pseudocode to find derivatives using Newton's backward interpolation formula.

Pseudocode

Pseudocode for finding derivative using Newton's backward interpolation formula is given below. This can be implemented in computer using programming language like C, C++, Python, Java etc.

1. Start

2. Read number of data: n

3. Read data points:

    For i = 0 to n-1
        Read Xi and Yi,0
    Next i

4. Read calculation point: xp

5. flag = 0

6. Check validity of calculation point:
    
    For i = 0 to n-1
    
        If |xp - Xi| < 0.0001
            index = i
            flag = 1
            break from loop
        End If
        
    Next i 

7. If calculation point is invalid then terminate the process:
   
    If flag = 0
        Print "Invalid Calculation Point"
        Exit
    End If

8. 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. h = X1 - X0

10. sum = 0, sign = -1 

11. Finding sum:
 
     For  i = 1 to n-1-index 
         term = (Yindex, i)i / i
         sum = sum + sign*term
         sign = -sign
     Next i

12. first_derivative = sum/h
     
13. Print first_derivative

14. Stop