How would I solve this question using the MATLab 2015 program? Problem 1 (15 poi
ID: 672969 • Letter: H
Question
How would I solve this question using the MATLab 2015 program? Problem 1 (15 points) A Taylor series is a series expansion of a function f(x) about a given point a For one dimensional real valued functions, the general formula for a Taylor series is given a fx)-f(a)+f(a)x-a) x-a) A special case, known as Maclaunn series, ofthe Taylor series custs which a = 0 The Maclaurin series expansions for 4 commonly used functions in science and engineering are 3) 24 1133 and Create a figure that contains subplots with 2 rows and 2 columns. For Eqtn 2, Eqtn. 3, Eqtn 4 and Eqtn. 5, plot the following 3 different lines I) The first term of the series only 2) The first two terms of the series 3) The first three terms of the series ) The first four terms of the series 5) The exact function (ue. what is listed on what left hand side of the equal sign) Each of the plot lines within a subplot should be a different color. Each plot should contain a legend, a title and x and y-labels. Create the plots within a 2 x2 subplot, described as follows The plots for Eqtn. 2 should be in the top left subplot of the figure The plots for Eqtn. 3 should be in the top right subplot of the figure The plots for Eqtn. 4 should be in bottom left subplot of the figure The plots for Eqtn. 5 should be in the bottom right subplot of the figure Restrict each plot's don anox-values) to be from x·-1 to x . 1. ncremented in steps of 0.1 Note that the domain for Eqtn. 4 does not include the point x--1, so for that plot make your lowest value be x =-09 Only use MATLAB commands in your script to create and edit your plot-do not use the plot editor features to modify your plot You may NOT use built-in Taylor series commands to complete this problem (including, but not limited to, the command taylor or other symbolac commands) Instead, simply type in the terms of the series as listed on the previous page. Do not use loops for this problem, instead, consider how you can vectorize this calculation process Hint Reme ber, just like in algebra, every y-alue should have a corresponding x-value lf this isn't true for your pls), the legend colors should tot work out as anticputed 1-2 OF 2Explanation / Answer
n=5;
x=1:n;
disp(x);
% Manual calculations i.e calculating left hand side terms
exManual = zeros(n,1); % creating vector and initialize to zero
sinxManual=zeros(n,1);
lnManual=zeros(n,1);
tanInverseManual=zeros(n,1);
for i=1:n
exManual(i)=exp(x(i));
sinxManual(i)=sin(x(i));
end
x=linspace(-1,1,n);
disp(x);
for i=1:n
lnManual(i)=log(x(i));
tanInverseManual(i)=atan(x(i));
end
x=1:n;
% calculations as per equation i.e calculating right hand side terms
ex = zeros(n,1); % creating vector and initialize to zero
sinx=zeros(n,1);
lnlog=zeros(n,1);
tanInverse=zeros(n,1);
% first term of the series only
ex(1)=1;
sinx(1)=x;
% first 2 terms of the series only
ex(2)=1+x;
sinx(2)=x+(-1)*x^3/6;
% first 3 terms of the series only
ex(3)=1+x+x^2/2;
sinx(3)=x+(-1)*x^3/6+x^5/120;
% first 4 terms of the series only
ex(4)=1+x+x^2/2+x^3/6;
sinx(4)=x+(-1)*x^3/6+x^5/120-x^6/720;
%proceed
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.