Read data points for x and y:
For i = 0 to n-1
Read Xi and Yi,0
Next i
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
If given calculation point (xp) is not in
x-data then terminate the process.
If flag = 0
Print "Invalid Calculation Point"
Exit
End If
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
Calculate finite difference: h = X1 - X0
Set sum = 0 and sign = 1
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
Divide sum by finite difference (h) to get result
first_derivative = sum/h
Declare the variables and read the order of the matrix n
Read the coefficients aim as
Read the coefficients a[i] for i=1 to n
Read the coefficients b[i] for i=1 to n
Initialize x0[i] = 0 for i=1 to n
Set key=0
For i=1 to n
Set sum = b[i]
For j=1 to n
If (j not equal to i)
Set sum = sum – a[i][j] * x0[j]
Repeat j
x[i] = sum/a[i][i]
If absolute value of ((x[i] – x0[i]) / x[i]) > er, then
Set key = 1
Set x0[i] = x[i]
Repeat i
If key = 1, then
Goto step 6
Otherwise print results
Lagrange Interpolation Formula is used for unequal intervals.