summaryrefslogtreecommitdiff
path: root/260/CH12/EX12.3/12_3.sce
blob: 600e8ebbab04855e2b5c552b40952c5c8778a182 (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
//Eg-12.3
//pg-511

clear
clc

x = 1;
h1 = 0.1;
h2 = h1/2;

deff('out = func(in)','out = exp(in)')

//Using central difference formula

Dh1 = (func(x+h1)-func(x-h1))/(2*h1);

Dh2 = (func(x+h2)-func(x-h2))/(2*h2);

//Using equation [16],

Dnew = 4/3*Dh2 - 1/3*Dh1;

printf('The value of the derivative using Richardson extrapolation is %f\n',Dnew)

printf(' This value is very close to the exact value of 2.718\n')