程序代写代做代考 matlab AM 147: Computational Methods and Applications: Winter 2021 Homework #3
AM 147: Computational Methods and Applications: Winter 2021 Homework #3
Instructor: Abhishek Halder Due: January 26, 2021
NOTE: Please submit your Homework as a single zip file named YourlastnameYourfirstnameHW3.zip via CANVAS. For example, HalderAbhishekHW3.zip. Please strictly follow the capital and small letters in the filename of the zip file you submit. You may not receive full credit if you do not follow the file-naming conventions. Your zip file should contain all .m files (MATLAB scripts) for the questions below.
Your zip file must be uploaded to CANVAS by 11:59 PM Pacific Time on the due date. The uploads in CANVAS are time-stamped, so please don’t wait till last moment. Late homework will not be accepted.
Problem 1
Bisection method (15 + 15 = 30 points) (a) Write a MATLAB .m function named bisection.m that computes a real root for any non-
linear equation of the form f(x) = 0 within numerical tolerance ε, where f is continuous in the interval [a, b] . Your MATLAB function should take the inputs: a, b, f, ε and return an approx- imation for the root xapprox. It is a good practice (but not mandatory) to pass an additional input for maximum number of iterations.
(b) For any positive integer n, the degree n Laguerre polynomial Ln(x) has the general form exp(x) dn n
Ln(x) = n! dxn (exp(−x)x ) . For example, when n = 5, we get the degree 5 (quintic) polynomial
L5(x)= 1 !−x5 +25×4 −200×3 +600×2 −600x+120″. 120
It is well-known that all n r√oots of Ln(x) are positive real, and that all of them are located within the interval (0,n+(n−1) n].
Write a MATLAB code YourlastnameYourfirstnameHW3p1.m that plots a graph of the func- tion L5(x). By visually inspecting this plot, call the function bisection.m from part (a) in your code YourlastnameYourfirstnameHW3p1.m to numerically compute all 5 roots of L5(x) within
1
tolerance ε = 10−4. In other words, executing your code YourlastnameYourfirstnameHW3p1.m
should generate a plot of L5(x), AND print its all 5 roots approximated via bisection method in MATLAB command window.
Problem 2
Newton’s method (20 points) Write a MATLAB script YourlastnameYourfirstnameHW3p2.m that performs 6 Newton itera-
tions to compute 51/7 starting with x0 = 2, that is, the script should compute x1, x2, x3, x4, x5, x6. In your MATLAB script, declare power(5,1/7) as xtrue, and in the same code, also compute the relative error |x6 − xtrue|/|xtrue|.
2