Professional Documents
Culture Documents
by EMCS 257
May Pyae Phyo Thu
Evaluate the first derivative of y(x) = sin (x) for x = 1 and h = 0.1, 0.01, and 0.001 by the three difference schemes:
Evaluate the errors by comparison to the exact values.
y(x) = sin(x)
x= 1
h= 0.1 0.01 0.001
y'(x) y'(1)
0.540302
y(1+h)− y (1 ) 1st
y ' (1)≈
h
y(1 )− y (1−h)
y ' (1)≈ 2nd
h h
y( 1+ 2
)− y ( 1− 2
) 3rd
y ' ( 1)≈
h
1st d 2nd 3rd
y(x) h y'(1) y'(1) y'(1)
sin(x) 0.1 0.4973638 0.5814408 0.540077208
0.01 0.536086 0.5445006 0.540300055
0.001 0.5398815 0.540723 0.540302283
y'(x)= cos(x)
0.540302
y'(x)= cos(x)
0.5403023059
f(x)= √x
x= 1
h= 0.1 0.05 0.025
f'(x) f'(1)
1 0.5
√x
2
y(1+h)− y (1 )
y ' (1)≈ 1st
h
y(1 )− y (1−h)
y ' (1)≈ 2nd
h h
y(1+ 2 )− y ( 1− 2 ) 3rd
y ' (1)≈
h
1st 2nd 3rd
f(x) h f'(1) f'(1) f'(1) f(x)
0.1 0.488088 0.513167 0.500156
√x √x
0.05 0.493902 0.506411 0.500039
0.025 0.496913 0.503165 0.50001
0.5
0.5
0.01191 0.01317 0.00016
0.00610 0.00641 0.00004
0.00309 0.00316 0.00001
~
f i+3 ¿ 9 f i +1 −8 f i −6 hf i '
2 3 4
h '' h ' '' h
f i+3
[
=9 f i + h f i +
'
]
f + f + f + .. . . −8 f i −6 hf i
2 i 6 i 24 i''''
2 3
3 h h
− h f ''i − f ''i '− f ''''−.. . .
2 2 8 i
.
1 1 2 1 3 1 4
f '( x0) = (
h
Δf 0 − Δ f 0 + Δ f 0 − Δ f 0
2 3 4 )
to compute f(x) = x4, x0 = 0.4, h = 0.2.
0.256
1 1 1 1
f '( x0) =
h (
Δf 0 − Δ 2 f 0 + Δ3 f 0 − Δ 4 f 0
2 3 4 )
x f(x) ∆f0 ∆2f0 ∆3f0 ∆4f0