blob: f56be633aae9ea59e8f7cb21111b2a5e9085d97d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
//Example 5.1
//Backward Difference Formula
//Page no. 124
clc;close;clear;
printf('\tx\t\ty\t1st Difference 2nd Difference 3rd Difference 4th Difference\n')
printf('-------------------------------------------------------------------------------------------------')
h=0.02;
z=[-1;0;1;2;3;4;5]
deff('y=f(x)','y=x^3-3*x^2+5*x-7')
for i=1:7
z(i,2)=f(z(i,1))
end
for i=3:8
for j=1:9-i
z(j,i)=z(j+1,i-1)-z(j,i-1)
end
end
printf('\n')
for i=1:7
for j=1:6
if z(i,j)==0 then
printf('\t%i\t',z(i,j))
else
printf('\t%i\t',z(i,j))
end
end
printf('\n')
end
|