Solution1
pdf
keyboard_arrow_up
School
University of the Fraser Valley *
*We aren’t endorsed by this school
Course
135
Subject
Mathematics
Date
Jan 9, 2024
Type
Pages
5
Uploaded by CaptainEagle3867
Unset
MECE 390
Assignment 1
Question 1 – Part I.
Show the Taylor Series Approximation of orders 1, 2, and 3 to
?
=6 - 4/
?
. This is to be done
manually (i.e. do NOT perform the differentiation numerically) and submitted as part of your
report.
NOTE: Don't use the decimal format of numbers, use fractions and whole numbers instead. Your
answers should contain the lowercase terms
?
and
𝑎
.
P
1
(x) = (4*(x-a))/a^2-4/a+6
P
2
(x) = -((4*(x-a)^2)/a^3)+(4*(x-a))/a^2-4/a+6
P
3
(x) = (4*(x-a)^3)/a^4-(4*(x-a)^2)/a^3+(4*(x-a))/a^2-4/a+6
Store each approximation as a separate function in MATLAB. You should have four different
functions that you can recall for the next questions in the lab, one for the primary function and
one for each of the three approximations.
Question 1 – Part II.
Write a MATLAB code (M-file) that calculates each of the above approximations about
𝑎
=1.0 at
the values
?
=0.85 and
?
=1.15. Plot the results along with the exact function
?
(
?
).
Plot the actual function in a solid line, and the approximations asked for below as single
points using a marker (i.e. 'o'). You may plot the lines for the approximations, but they
must appear as dashed or dotted lines, and a legend must be included.
function taylor_Approx() %output=funcname(inputs)
% in this section put some some text describing the matlab function
% Prepared by :NAME ID:## Date:##
% Constants
lb=0.85; %Beg. of interval
ub=1.15; %End of interval
a = 1;
% Exact solution
f_exact=@(x) 6-4./x; % given function (for example only): 5*x^2+2*exp(2*x)
% Taylor Series Approximation
p1= @(x)(4.*(x-a))./a^2-4/a+6; %First order approx.
p2= @(x) -((4.*(x-a).^2)./a^3)+(4.*(x-a))./a^2-4/a+6; %Second order
p3= @(x)(4.*(x-a).^3)./a^4-(4.*(x-a).^2)./a^3+(4.*(x-a))/a^2-4/a+6; %3rd order
% Plotting
hold on
fplot(f_exact,[lb,ub])
fplot(p1,[lb,ub])
fplot(p2,[lb,ub])
fplot(p3,[lb,ub])
grid on
xlabel('x')
ylabel('f(x)')
legend('Exact','First Order','Second Order','Third Order')
title('Taylor Expansion')
% ERROR Calculation and Plot
E1 = @(x)(f_exact(x)-p1(x));% True (absolute) error
E2 = @(x)(f_exact(x)-p2(x));% True (absolute) error
E3 = @(x)(f_exact(x)-p3(x));% True (absolute) error
figure;
hold on
fplot(E1,[lb,ub])
fplot(E2,[lb,ub])
fplot(E3,[lb,ub])
xlabel('x')
ylabel('True Error')
legend('E1','E2','E3')
title('Error Comparison')
grid on
end
Using your code, answer the following questions.
NOTE: Insert at least three digits of numbers, e.g. 0.00123 for 0.0012345.
?
(
?
=0.85)
= 1.29412
𝑃
1
(
?
=0.85) = 1.4
𝑃
2
(
?
=0.85) = 1.31
𝑃
3
(
?
=0.85) = 1.2965
?
(
?
=1.15)
= 2.52174
𝑃
1
(
?
=1.15) = 2.6
𝑃
2
(
?
=1.15) = 2.51
𝑃
3
(
?
=1.15) = 2.5235
The red curve in figure 1 is the plot of …! Explain your reasoning.
a)
f
b) P
1
c) P
2
d) P
3
Figure 1
Question 1 – Part III.
Include in your MATLAB code for the calculation of the True Error for each of these
approximations about
𝑎
=1.0 and between the values of
?
=0.9 and
?
=1.1. Plot the error values in
a separate figure, including a line for the zero axes.
Plot the actual function in a solid line, and the approximations asked for below as single
points using a marker (i.e. 'o'). You may plot the lines for the approximations, but they
must appear as dashed or dotted lines, and a legend must be included.
Using your code, answer the following questions.
NOTE: Please insert at least three digits of numbers, e.g. 0.00102 for 0.0010234.
𝐸
1(
?
=0.9) = -0.0444
𝐸
2(
?
=0.9) =
-0.0044
𝐸
3(
?
=0.9) =
-4.4444e-04
𝐸
1(
?
=1.1) =
-0.0364
𝐸
2(
?
=1.1) =
0.0036
𝐸
3(
?
=1.1) =
-3.6364e-04
The red curve in figure 2 is the plot of …! Explain your reasoning.
a)
E
1
b) E
2
d) E
3
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Figure 2
Question 1 – Part IV.
Comment on the Following
-
How does the error change with the order of the approximation? Is this behavior
expected?
o
By increasing the order of approximation, the error reduces, and that can be
shown by writing the error estimation formula the order of approximation
converges to infinity the error converges to zero
-
For a given order of approximation, how does the error change with respect to the base
point
𝑎
?
o
Error increases as we get farther away from the base point the explanation can be
shown based on the theory of the taylor series
Question 2
The damped vibration response of a shock absorber in a vehicle can be represented by the
following equation:
? = 𝐴(?
−?
1
?
+
?
−?
2
?
) where
?
1
,
?
2
are found to be -1.58
?
−1
and -6.32
?
−1
respectively, and
𝐴
= 4.21 cm.
Discuss
the
approach
to
using
the
Taylor
series
approximation
of
to determine the mass position at
?
= 0.5 seconds. You
?
?
= 1 + ?
1!
+ ?
2
2!
+ ?
3
3!
+ …
must discuss how the method (i.e. Taylor Series Approximation) can be implemented as
well as the sources of error in your estimation.
Note: you do NOT need to provide a numerical response to the question in your report, and even
if you do there is no grade assigned to this value.
points that should be discussed:
-
substitute e^(-r1*t) with 1+(r1*t)/1! + (r1*t)^2/2! + …
-
same goes for e^(-r2*t)
-
a for loop in Matlab could solve for y
-
sources
of
error
are
the
inherent
error
that
comes
with
Taylor
series
approximation(truncation error) and rounding error that happens in Matlab calculations