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