midterm solutionD

midterm solutionD - Question 1>> f =(x x^2-46>>...

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Question 1 >> f = @(x) x^2-46; >> bisect (f, 4, 10, 0.001, 1) step xl xh 1 4.000000 10.000000 2 4.000000 7.000000 3 5.500000 7.000000 xr 7.000000 5.500000 6.250000 yr 3.000000 -15.750000 -6.937500 Emax 3.000000 1.500000 0.750000 3 marks for hand execution of bisection algorithm: 1 mark for Emax column 2 marks for the rest x 0 initial interval 0.75 N log(x 0 / EMAX ) 16.195 log 2 17 additional iterations 1 marks xr = (4.3578 + 4.3579)/2 = 4.35785 > 4.3578 (5 digits, rounding to even) The important point here is realizing that the correct answer can't be stored. 0.5 marks The search will go on indefinitely, with xL and xU never changing. 0.5 marks Question 2 the derivate is 2 x 5 the required commands are: >> fp [email protected](x) 2*x 5; >> minx = fzero (fp, [0 4]); 1 mark fzero must be used (it must be assumed that the root cannot just be found by algebraic manipulation). >> f = @(x) x^2 - 5*x - 6; >> goldenTemp (f, 0, 4, 0.001, 1) xL xU x2 0.000000 4.000000 1.527864 1.527864 4.000000 2.472136 1.527864 3.055728 2.111456 2.111456 3.055728 x1 2.472136 3.055728 2.472136 -11.304952 -12.249224 -12.099034 -12.249224 -11.941166 -12.249224 2.5 marks for hand execution of algorithm the best guess is the midpoint = 2.583592 max error is half the interval width = 0.472136 0.5 mark required commands: >> f = @(x) x^2 5*x 6; >> xmin = fminbnd(f, 0, 4) 1 mark Question 3 >> x = secant (f, 3, 5, 0.001, 10, 1) Step x(i1) x(i) x(i+1) y(i+1) Eapp 1 3.000000 5.000000 7.000000 8.000000 2.000000 2 5.000000 7.000000 5.857143 0.979592 1.142857 3 7.000000 5.857143 5.981818 0.126942 0.124675 3 marks for hand execution of algorithm A NetwonRaphson search with the given starting point will fail because the denominator is 0 (the tangent line has zero slope and does not intersect the x axis). The solution is to choose a different starting point. Any number of possibilities will work . The function is a parabola and symmetric about x = 2.5. In order to find the correct root the starting point must be greater than 2.5. 2 marks 1 mark for explaining the problem 1 mark for any reasonable solution Question 4 Then the volume of the tank is V X * (0.7 X ) * (0.7 X 0.6) Formulation for solution requires the form f(x) = 0: X * (0.7 X ) * (0.7 X 0.6) 56 0 2 marks 1 mark for correct volume formula 1 mark for putting problem into the form f(x) = 0 If X is zero the volume will be too low. This gives one limit. The other is established by picking values until one gives a volume that is greater than 56. Ten is one possible choice (10 * 7 * 6.4 >> 56.3). Any number of correct answers are possible. 1 mark Matlab commands: f = @(x) x * 0.7 * x * (0.7 * x 0.6) x = fzero (f, [low, high]); fprintf ('The length, width and height are %fm, %f m and %f\n', x, x*0.7, x*0.7 0.6); 2 marks 0.5 for defining function (award mark if function matches earlier answer, even if wrong) 0.5 mark for using fzero 0.5 marks for limits (low and high should be as selected earlier) 0.5 marks for fprintf (don't be picky is student clearly has the basic idea) ...
View Full Document

{[ snackBarMessage ]}

What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern