Starting from:

$30

ASSIGNMENT #3 solution

This is a really large class and the logistics of grading assignments are challenging. Me and the markers require your help in making this process go smoothly. Please ensure that your assignments conform to the following requirements - any violation will result in getting a zero for the particular assignment.All assignments should be submitted electronically through the ConneX course website and shoud be SINGLE PDF FILES. No other formats will be accepted.. Handwrit-ten answers are ok but they will need to be scanned and merged into a single pdf le together with any code examples and associated plots.The assignment number, student name and student number should be clearly visible on the top of every page of your assignment submission.PLEASE DO NOT COPY THE ASSIGNMENT DESCRIPTION IN YOUR SUBMISSIONThe asnwers to the questions should be in the same order as in the assignment speci-cation.Some of the questions of the assignments are recycled from previous years but typically with small changes in either the description or the numbers. Any submission that contains numbers from previous years in any questions will be immediately graded with zero.Any assignment related email questions should have a subject line of the form CSC349A Assignment X, where X is the number of the corresponding assignment.The total number of points for this assignment is 20.Question #1 - 4 marks.Use the condition numberxf~0 (~x)to determine whethersin xis ill-conditioned or well-f(~x)1 + cos xconditioned when,x~ = 1:0005 radians.x~ = 1:0005 radians.Question #2 - 6 marks.Let(sin x ex) + 1f(x) =where x 6= 0 is in radians.x21Using b = 10, k = 4, idealized, oating-point arithmetic with chopping, compute (f(x)) at x = 0:123.To 4 signi cant digits the exact value of f(0:123) is 0:5416, so the computation in(a) is inaccurate. In order to obtain a better formula for approximating f(x) when x is close to 0, use the Taylor polynomial approximations for ex and sin x (both expanded about a = 0 with n = 4) in order to obtain a quadratic polynomial approxiamtion for f(x).Use the polynomial approximation for f(x) from (b) to show that the computation of (f(0:123)) in (a) is unstable.Question #3 - 10 Marks(a) Write a MATLAB function M- le with headerfunction root = Bisect ( xl , xu , eps , imax, f, enablePlot )corresponding to the pseudocode given in Handout #8 for the Bisection method (in xl it is an \ell" not a \one").The only di erences from that given algorithm are the following:print a caption for your computed approximations by inserting the following statement just before the while statement:fprintf ( ' iteration approximation \n')print each successive computed approximation by inserting the following statement after the computation of xr at the beginning of the while loop:fprintf ( ' %6.0f %18.8f \n', i, xr )print a message to indicate that the algorithm has failed to converge in imax steps by replacing the last statement in the pseudocode by the following:fprintf ( ' failed to converge in %g iterations\n', imax )The extra argument enablePlot is used to select optional plotting of gures showing each iteration of the bisection method when enablePlot is set to 1. When enablePlot is set to 0 no gures will be generated. The command gure with no arguments can be used to create multiple windows for plotting using the plot command. For example try the following to understand how this works:x = [0:0.1:1];figure;plot(x, exp(x));figure;plot(x, log(x));2For each iteration you should plot the function between xl and xu as well as stars indicating on the graph the values of f(xl), f(xu) and f(xr). The following example MATLAB code (continuation of the previous example) can help you understand the syntax to accomplish this.z = [0.2, 0.4, 0.8];fz = exp(z);plot(x, exp(x), z, fz, '*g');Alternatively you can use the hold command to achieve the same e ect with multiple plot commands. The formatting string '*g' tells the plot function to use the star symbol and green color.z = [0.2, 0.4, 0.8];fz = exp(z);plot(x, exp);hold;plot(z, fz, '*g');DO NOT INCLUDE ALL THE PLOTS IN YOUR ANSWER. DO PRO-VIDE PLOTS FOR ITERATIONS 1, 2, 4, 6.DELIVARABLES: A copy of your MATLAB M- le.Water is owing in a trapezoidal channel at a rate of Q = 20m3=s. The critical depth y for such a channel must satisfy the equation:Q20 = 1 BgA3cwhere g = 9:81m=s2, Ac = the cross-sectional area (m2), and B = the width of the channel at the surface (m). For this case, the width and the cross-sectional area can be related to depth y byB = 3 + y and Ac = 3y +y22Express this problem as a root nding problem for an appropriately de ned function of the critical depth y.DELIVARABLES: Show all your work in deriving your formula.Use the function M- le Bisect to solve the above problem (b) with initial guesses of xl = 0:5 and xu = 2:5, and itereate until the approximate error falls below 1% or the number of iterations exceeds 10. You will need to write an additional MATLAB function M- le. Iffunction y = your_function(x)corresponds to the function of which you are computing a zero call this with3Bisect ( xl , xu , eps , imax, @your_function, enable_plot)with the appropriate parameter values.DELIVARABLES:the additional function M- le.a copy of the MATLAB statement(s) you used to call Bisect. your output from Bisect including gures for iterations (1,2,4,6).

More products