Backward Difference

//Backward Difference
x=input("Enter the value of x as row natrix:")
y=input("Enter the value of y as row matrix:")
xg=input("Enter xg at which we want to Interpolate:")
n=length(x)
h=x(2)-x(1)
u=(xg-x(n))/h
disp("Backward difference table is:")
for i=1:n-1
    disp(diff(y,i))
end
yg=y(n)
p=u
for i=1:n-1
    d=diff(y,i)
    yg=yg+p*d(n-i)
    p=p*((u+i)/(i+1))
end
disp(yg,"Interpolation by Backward difference table is :")

//Output
-->exec('D:\Scilab\Scilab without outputs\Backward difference.sce', -1)
Enter the value of x as row natrix:[10 20 30 40 50]
Enter the value of y as row matrix:[45 65 80 92 100]
Enter xg at which we want to Interpolate:43

 Backward difference table is:  

    20.    15.    12.    8.

  - 5.  - 3.  - 4.

    2.  - 1.

  - 3.

 Interpolation by Backward difference table is  

    94.943988

6 comments:

  1. finding difference between variable y & i is wrong due to their different dimention


    Enter the value of x as row natrix:[10 20 30 40 50]
    Enter the value of y as row matrix:[45 65 80 92 100]
    Enter xg at which we want to Interpolate:17

    Backward difference table is:
    !--error 21
    Invalid index.
    at line 6 of function diff called by :
    disp(diff(y,i))
    at line 11 of exec file called by :
    ollege\QT\BackwardDifference.sce', -1


    -->y
    y =

    45. 65. 80. 92. 100.

    -->i
    i =

    1.

    ReplyDelete
  2. exec('C:\Users\PC PLANET\Documents\back.sce', -1)
    x=input("Enter the value of x as row natrix:")
    !--error 4
    Undefined variable: input
    at line 2 of exec file called by :
    exec('C:\Users\PC PLANET\Documents\back.sce', -1)



    error in both forwrd & backword method

    ReplyDelete
  3. How to creat Sine angle function backward difference table using scilab by loop or using matrix formation.?❓

    ReplyDelete
  4. yaha bhi aao xirtma

    ReplyDelete
  5. Do you mean Matrix? Is this someone's discord name?

    ReplyDelete