here

advertisement
Anadolu University, Environmental Engineering Department
NUM 202 LINEAR ALGEBRA AND NUMERICAL METHODS
HOMEWORK 2 (2015-2016 Fall Semester) ANSWERS
1).
5
4
3
2
1
0
-1
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2
The stopping criterion is set to Es = 0.05% (with n=3)
For the smaller root we use 0 as a reasonable starting point.
Iteration xi
f (xi)
f’(xi)
xi+1
Eapp
1
0.00000
2.00000
-6.00000
0.33333
100.00000
2
0.33333
0.33622
-3.96585
0.41811
20.27679
3
0.41811
0.02282
-3.42527
0.42478
1.56841
4
0.42478
0.00014
-3.38220
0.42482
0.00998
<0.05%
The root is 0.204
For the larger root we use 2 as the starting point.
Iteration xi
f (xi)
f’(xi)
xi+1
Eapp
1
2.00000
4.81201
11.18799
1.56989
-27.39707
2
1.56989
1.11752
6.14531
1.38805
-13.10108
3
1.38805
0.17168
4.28264
1.34796
-2.97399
4
1.34796
0.00785
3.89235
1.34594
-0.14978
5
1.34594
0.00002
3.87291
1.34594
-0.00038
<0.05%
The root is 1.35
A reasonable starting point will be 1 for the minimum (it lies between 0.8 and 1). Again Es is 0.05%
Iteration
xi
f’ (xi)
f’’(xi)
xi+1
Eapp
1
1.00000
0.79272
8.20728
0.90341
-10.691451
2
0.90341
0.01735
7.85158
0.90120
-0.2452269
3
0.90120
0.00001
7.84370
0.90120
-0.0001232
The minimum is at x = 0.901 and f(0.901)= -0.832
2).
We use z for depth and T(z) for temperature. But x and f(x) will also work.
We use the following four points for the third order polynomial.
z
z0
z1
z2
z3
0.5
1
1.5
2
T(z)
T(z0)
T(z1)
T(z2)
T(z3)
68
55
22
13
Accordingly the coefficients are
a0 = 68
a1 =
55 − 68
= −26
1 − 0.5
1/6
<0.05%
Anadolu University, Environmental Engineering Department
22 − 55
+ 26
π‘Ž2 = 1.5 − 1
= −40
1.5 − 0.5
a 3 = f[z3 , z2 , z1 , z0 ] =
a3 =
48 + 40
176
=
2 − 0.5
3
13 − 22 22 − 55
−
f[z3 , z2 , z1 ] − a 2
1.5 − 1 = −18 + 66 = 48
]
; f[z3 , z2 , z1 = 2 − 1.5
z3 − z0
2− 1
1
The third-order polynomial is
T3 (z) = 68 − 26(z − 0.5) − 40(z − 0.5)(z − 1) +
176
(z − 0.5)(z − 1)(z − 1.5)
3
T3 (1.1) = 68 − 26(1.1 − 0.5) − 40(1.1 − 0.5)(1.1 − 1) +
176
(1.1 − 0.5)(1.1 − 1)(1.1 − 1.5) = 48.6 ℃
3
To estimate the error, we must add a new point to the polynomial. The nearest point to 1.1 is z4 = 0, T(z4) = 70.
Then we find a4.
f[z ,z ,z ,z ]− a
a 4 = f[z4 , z3 , z2 , z1 , z0 ] = 4 3 2 1 3
z4 − z0
f[z4 , z3 , z2 ] − f[z3 , z2 , z1 ]
z4 − z1
f[z4 , z3 , z2 , z1 ] =
70 − 13 13 − 22
57 36
−
−
+
0
−
2
2
−
1.5
2
2 =7
f[z4 , z3 , z2 ] =
=
3
0 − 1.5
−
2
f[z3 , z2 , z1 ] = 48
7 − 48
= 41
0− 1
123 176 −53
−
3 = 3 = 106 = π‘Ž
f[z4 , z3 , z2 , z1 , z0 ] = 3
4
1
0 − 0.5
3
−
2
f[z4 , z3 , z2 , z1 ] =
So, the correction factor is =
106
3
(1.1 − 0.5)(1.1 − 1)(1.1 − 1.5)(1.1 − 2) = 0.76
The estimated error is 0.76 degrees Celsius
The two polynomials look like below. T3 is blue and T4 green. The red dots are the measurements. Note that
extrapolation beyond the range used for interpolation will give very incorrect results.
90
100
80
70
60
50
40
30
20
0
10
0
0.5
1
1.5
2
2.5
3
2/6
Anadolu University, Environmental Engineering Department
3).
n
Sx
Sy
Sx2
Sy2
Sxy
9
35
63
287
667
71
Slope
-1.15
Intercept
11.5
y = -1.15x + 11.5
-0.94
r
4).
Answer:
n
Sx
Sy
Sx2
Sy2
Sxy
12
330
431.6
12650
19250.52
15303
Slope
0.961
Intercept
9.55
y = 0.961x + 9.55
k is equal to the slope and it has the value 0.961 mg/L.min
5).
Answer:
The upper area is 77.4 km2
The lower area is 47.0 km2
The total area is 124.4 km2
6). The function looks like this
450
400
350
300
250
200
150
100
50
0
-50
-2
-1
0
1
2
3
4
a) Analytical solution
4
1
1
𝐼 = [ π‘₯ 6 − π‘₯ 4 − π‘₯ 2 + π‘₯] = 432
6
2
−2
b) Solution with the Trapezoidal Formula
3/6
Anadolu University, Environmental Engineering Department
𝐼𝑇𝐹 = (4 − −2) ∗ [
𝑓(−2) + 𝑓(4)
] = 2304
2
c) Solution with the Multiple Trapezoidal Formula with 6 segments
𝐼𝑀𝑇𝐹 =
(4 − −2)
[𝑓(−2) + 2 ∗ (𝑓(−1) + 𝑓(0) + 𝑓(1) + 𝑓(2) + 𝑓(3)) + 𝑓(4)] = 519
2∗6
d) Solution with the Simpson 1/3 Formula
𝐼𝑆1/3 =
(4 − −2)
[𝑓(−2) + 4 ∗ 𝑓(1) + 𝑓(4)] = 756
6
e) Solution with the Multiple Simpson 1/3 Formula with 6 segments
𝐼𝑀𝑆1/3 =
(4 − −2)
[𝑓(−2) + 4 ∗ (𝑓(−1) + 𝑓(1) + 𝑓(3)) + 2 ∗ (𝑓(0) + 𝑓(2)) + 𝑓(4)] = 436
3∗6
f) Solution with the Simpson 3/8 Formula
𝐼𝑆3/8 =
(4 − −2)
[𝑓(−2) + 3 ∗ 𝑓(0) + 3 ∗ 𝑓(2) + 𝑓(4)] = 576
8
g) The true errors
𝐸𝑇𝐹 = 432 − 2304 = −1872
𝐸𝑀𝑇𝐹 = 432 − 519 = −87
𝐸𝑆1/3 = 432 − 756 = −324
𝐸𝑀𝑆1/3 = 432 − 436 = −4
𝐸𝑆3/8 = 432 − 576 = −144
7).
𝐼𝑆1/3 =
(πœ‹2 − 0)
πœ‹
πœ‹
[𝑓(0) + 4 ∗ 𝑓 ( 4 ) + 𝑓 ( 2 )] = 16.5755
6
The analytical solution is
πœ‹
𝐼 = [8 ∗ π‘₯ − 4π‘π‘œπ‘ π‘₯]02 = 16.5664
Then the true error is 16.5664 – 16.5755 = - 0.0091
The true percentage error is (- 0.0091/16.5664)*100 = -0.0549%
The estimated error formula is
𝐸𝑆1/3 = −
1
𝑓 𝑖𝑣 (πœ‰)(𝑏 − π‘Ž)5
2880
We find the third derivative
𝑓 ′ = 4π‘π‘œπ‘ π‘₯ ; 𝑓 ′′ = −4𝑠𝑖𝑛π‘₯ ; 𝑓 ′′′ = −4π‘π‘œπ‘ π‘₯
4/6
Anadolu University, Environmental Engineering Department
πœ‹
𝑓 𝑖𝑣 (πœ‰) =
[−4π‘π‘œπ‘ π‘₯]02
πœ‹
2 −0
𝐸𝑆1/3 = −
= 2.5465
5
1
πœ‹
2.5465 ( − 0) = −0.0085
2880
2
The true and estimated errors are fairly close to each other.
8).
f(x) = cos(3x)e-x/4 - 0.5
Analytical solution
𝑓 ′ (π‘₯) = (−3𝑠𝑖𝑛3π‘₯ −
1
4
π‘π‘œπ‘ 3π‘₯) 𝑒 −π‘₯⁄4 = −2.66
Forward differences
𝑓 ′ (π‘₯) =
𝑓(0.6) − 𝑓(0.5)
−0.696 + 0.438
=
= −2.58
0.1
0.1
Et = -2.66 + 2.58 = -0.08
Backward differences
𝑓 ′ (π‘₯) =
𝑓(0.5) − 𝑓(0.4)
−0.438 + 0.172
=
= −2.65
0.1
0.1
Et = -2.66 + 2.65 = -0.01
Centered differences
𝑓 ′ (π‘₯) =
𝑓(0.6) − 𝑓(0.4)
−0.696 + 0.172
=
= −2.62
2 ∗ 0.1
0.2
Et = -2.66 + 2.62 = -0.04
9).
t (sec)
0
i(Amperes)
0
di/dt
0.1
0.15
CD
0.2
0.3
0.3
0.55
FD
CD
BD
FD
𝑑𝑖
𝑑𝑑
𝑑𝑖
𝑑𝑑
𝑑𝑖
𝑑𝑑
𝑑𝑖
𝑑𝑑
𝑑𝑖
𝑑𝑑
(0) =
−0.3+4∗0.15−3∗0
(0.1) =
(0.2) =
(0.3) =
(0.3) =
2∗0.1
0.3−0
= 1.5
6
= 1.5
0.2−0
0.55−0.15
8
=2
0.3−0.1
3∗0.55−4∗0.3+0.15
2∗0.1
−1.9+4∗0.8−3∗0.55
2∗0.2
V (Volts)
6
=3
12
= −0.875
FD gives here unrealistic results
The formula for unequally-spaced derivatives gives
𝑑𝑖
(0.3) = 2.08
𝑑𝑑
8.32
5/6
Anadolu University, Environmental Engineering Department
0.5
0.8
0.7
CD
1.9
BD
𝑑𝑖
𝑑𝑑
𝑑𝑖
𝑑𝑑
(0.5) =
(0.7) =
1.9−0.55
0.7−0.3
1.9−0.8
0.7−0.5
13.5
= 3.38
22
= 5.5
Numerical differentiation tends to amplify errors in the data. One way to circumvent this is to pass a low-level (say 2nd order)
polynomial through all the data by polynomial regression. Then the polynomial is differentiated analytically and the
derivatives found as shown below.
2
This is the second order polynomial through the data.
1.8
p(x) = 3.1803x2 + 0.2845x + 0.0649
1.6
1.4
The derivative is
1.2
1
p’(x) = 9.5408x + 0.2845
0.8
0.6
0.4
0.2
0
0
x
p’(x)
V
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0
0.1
0.2
0.3
0.5
0.7
0.2845
1.14
0.9206
3.68
1.5566
6.23
2.1927
8.77
3.4648
13.9
4.7369
18.9
10).
𝑑2𝑑
𝑑𝑑 2
(2) =
−𝑓(4)+16𝑓(3)−30𝑓(2)+16𝑓(1)−𝑓(0)
12∗12
=
−32+16∗18−30∗8+16∗2−0
12
Prof. Dr. Erdem Ahmet Albek
6/6
= 4 km/s2
Download