Consider the Laguerre polynomial, which has the general form L_n (x) = e^x/n! d^
ID: 3815876 • Letter: C
Question
Consider the Laguerre polynomial, which has the general form L_n (x) = e^x/n! d^n/dx^n (e^-x x^n) For n = 5, the Laguerre polynomial of order 5 is L_5 (x) = 1/120 (-x^5 + 25x^4 - 200 x^3 + 600x^2 - 600x + 120) Write a MATLAB program that plots the Laguerre polynomial of order 5 on the interval [-2, 13] with appropriate axes labels. Do not use a for loop to generate the vector containing the data for the Laguerre polynomial of order 5 Visually find good intervals to start bisection to find for each of the five roots. Next, the program should ask the user for the starting interval and tolerance for each root and then find the root using the bisection method. Write the bisection method as a separate function that can work for any nonlinear equation f(x). The interval, tolerance, and corresponding root should be output to the command window. For this problem, you must choose the tolerance in order to get an accurate result.Explanation / Answer
Matlab code for plot:
clear all;
clc;
close all;
syms x
f = @(x) ((1/120)*(-(x.^5) + 25*(x.^4) -200*(x.^3) + 600*(x.^2) - 600.*x + 120));
fplot(f, [-2,13])
xlabel('x');
ylabel('f');
findroot.m
function root = findroot(v)
a = v(1);
b = v(2);
c = a;
EPSILON = v(3);
iter = 1;
while ((b-a) >= EPSILON)
c = (a+b)/2;
if ((myfunction(c)) == 0.0)
break;
elseif ((myfunction(c))*(myfunction(a)) < 0)
b = (a+b)/2;
else
a = (a+b)/2;
end
iter = iter + 1;
end
root=c;
end
myfunction.m
function val = myfunction(x)
val = (1/120)*(-(x^5) + 25*(x^4) -200*(x^3) + 600*(x^2) - 600*x + 120);
end
Sample Output:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.