HW2 Sol

HW2 Sol - EE 103 Winter 09 Prof SEJ HW 2 Sol Applied Numerical Computing Instructor Prof S E Jacobsen HW2 Solution Students Distributed HW

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
EE 103, Winter ’09, Prof SEJ: HW 2 Sol. Page 1 / 9 Applied Numerical Computing Instructor: Prof. S. E. Jacobsen HW2 Solution Students: Distributed HW solutions are a component of the course and should be fully understood. SEJ Prob 1: The following are the diary file running secant method on Archimedes problem. In the secant method, the stopping conditions are the absolute function values, the number of iterations, and the relative difference between two adjacent iterations, i.e. 1 /max( ,1 ) kk k k x xx x + −+ . The reason of having 1 k x + in the denominator is to have the program work even when k x is zero or getting too close to zero. ee103_secant what function do you wish? arch What is the value of x_1 ? 0.95 What is the value of x_0 ? 3.0 Choose the domain tolerance parameter, tolx ? 1e-3 Choose the function tolerance parameter, tolf ? 1e-6 Choose a value for the max number of iterations ? 20 Your Name, UID = 000000000, e-mail = [email protected] k x(k-2) x(k-1) x(k) f(x(k)) 1 +9.5000000000e-001 +3.0000000000e+000 -2.7977839335e-001 -2.8308600621e+000 2 +3.0000000000e+000 -2.7977839335e-001 -3.4814935791e+001 +4.7994904823e+004 3 -2.7977839335e-001 -3.4814935791e+001 -2.8181524356e-001 -2.8267619109e+000 4 -3.4814935791e+001 -2.8181524356e-001 -2.8384902529e-001 -2.8226365953e+000 5 -2.8181524356e-001 -2.8384902529e-001 -1.6754096611e+000 +1.0643572844e+001 6 -2.8384902529e-001 -1.6754096611e+000 -5.7553244169e-001 -1.8594555421e+000 7 -1.6754096611e+000 -5.7553244169e-001 -7.3910663572e-001 -9.6070530709e-001 8 -5.7553244169e-001 -7.3910663572e-001 -9.1395676670e-001 +3.2399717589e-001 9 -7.3910663572e-001 -9.1395676670e-001 -8.6986021564e-001 -3.3346930658e-002 10 -9.1395676670e-001 -8.6986021564e-001 -8.7397525379e-001 -9.7478469776e-004 11 -8.6986021564e-001 -8.7397525379e-001 -8.7409916513e-001 +3.0901148484e-006 The root is: -8.7409916513e-001 with f(x) = 3.0901148484e-006 type arch.m function fun = arch(h) r=1;lden=1.0;sden=0.74; fun=pi/3*(3*r*h^2-h^3)*lden-4/3*pi*r^3*sden; diary off; The computed root is -8.7409916513e-001, which is not a solution of the problem since it is negative. Given the radius of the solid sphere is 1.0 ft, and the sphere can not sink completely (because of its density), the reasonable h in this problem should lie in (0,2). Hence, instead of using 3.0 as the starting point, we can change it to the value that lies in the reasonable range. The lesson is that when one is looking for a solution of a practical problem, the solution for which is a root of a function with possibly several roots, one should attempt to find all roots, if possible. The following is the Matlab output when setting the starting two points to 0.95 and 2. What function do you wish? arch What is the value of x_1 ? 0.95 What is the value of x_0 ? 2.0
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
EE 103, Winter ’09, Prof SEJ: HW 2 Sol. Page 2 / 9 Choose the domain tolerance parameter, tolx ? 1e-3 Choose the function tolerance parameter, tolf ? 1e-6 Choose a value for the max number of iterations ? 20 Your Name, UID = 000000000, e-mail = [email protected] k x(k-2) x(k-1) x(k) f(x(k)) 1 +9.5000000000e-001 +2.0000000000e+000 +1.4920634921e+000 +4.1578860941e-001 2 +2.0000000000e+000 +1.4920634921e+000 +1.1783917197e+000 -4.5082054438e-001 3 +1.4920634921e+000 +1.1783917197e+000 +1.3415675627e+000 +2.6025526377e-002 4 +1.1783917197e+000 +1.3415675627e+000 +1.3326616757e+000 +1.2267135312e-003
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/30/2009 for the course EE 103 taught by Professor Vandenberghe,lieven during the Winter '08 term at UCLA.

Page1 / 9

HW2 Sol - EE 103 Winter 09 Prof SEJ HW 2 Sol Applied Numerical Computing Instructor Prof S E Jacobsen HW2 Solution Students Distributed HW

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online