Professional Documents
Culture Documents
CE206 - Numerical Differentiation - Integration
CE206 - Numerical Differentiation - Integration
CE206 - Numerical Differentiation - Integration
Computation
p Sessional
fx = gradient(f, h)
Determines the derivative of the data in f at each of
the points. h is the spacing between points; if omitted
h=1.
Uses forward difference for the first point, backward
difference for the last point, and centered difference
for the interior points.
CE 206: Engg. Computation sessional Dr. Tanvir Ahmed
diff and gradient Example
function y=fx(x)
y=0.2+25*x-200*x.^2+675*x.^3-900*x.^4+400*x.^5;
x =[0 0.12 0.22 0.32 0.36 0.4 0.44 0.54 0.64 0.7 0.8];
y=fx(x);
Time (min) 0 5 10 15 20 25
T ((°C)
C) 80 44.5 30 19.1 21.7 20.7
h⎡ n −1
⎤
I = ⎢ f ( x0 ) + 2∑ f ( xi ) + f ( xn )⎥
2⎣ i =1 ⎦
I=
h
[ f (x0 ) + 4 f (x1 ) + f (x2 )] + h [ f (x2 ) + 4 f (x3 ) + f (x4 )] + L + h [ f (xn−2 ) + 4 f (xn−1 ) + f (xn )]
3 3 3
⎡ n −1 n−2
⎤
h⎢
I= f ( x0 ) + 4 ∑ f ( xi ) + 2 ∑ f ( xi ) + f ( xn )⎥
3⎢ i =1 j =2
⎥
⎢⎣ i , odd j , even ⎥⎦
Built-in
B il i functions
f i to evaluate
l i
integrals
l bbased
d on trapezoidal
id l
rule
z = trapz(y)
p (y)
z = trapz(x, y)
produces
d the
th integral
i t l off y with
ith respectt to
t x. If x is
i omitted,
itt d th
the
program assumes h=1.
0.02 40.0 50
0.05 37.5 40
Rod
ss
Stres
R
0.10 43.0 30
0.15 52.0
20
0.20 60.0
10
0.25 55.0
0
0 0.05 0.1 0.15 0.2 0.25
Strain
x0 xn
g = 9.81 m/sec
/ 2 Ans: P = 2.54×10
2 54×109 N
ρgzw( z )(D − z )dz
D
D = 60 m d=
∫ 0
d = 21.97 m
[Ans: 1001.7 lb, 1222.3 lb, 1372.3 lb 1450.8 lb, 1477.1 lb 1479.7 lb, 1480.3 lb
1480 5 lb 1480.6
1480.5 1480 6 lb]