Manual 3
Manual 3
Figure 1: Graph of cos(x^5) produced by ezplot command. It is wrong because cos u should oscillate smoothly between -1
and 1. The problem with the plot is that cos(x^5) oscillates extremely rapidly, and the plot did not consider enough points.
>> solve(polyex)
Another useful property of symbolic functions is that you can substitute numerical vectors for the
variables:
>> X = 2:0.1:4;
>> Y = subs(polyex, X);
>> plot(X, Y)
𝑆𝑁 = ∑ 𝑥 𝑛 (2)
𝑛=0
1 − 𝑥 𝑁+!
𝑆𝑁 = (3)
1−𝑥
Observe what happens when abs(x) > 1.
Write MATLAB code for the calculation of approximated value of equation 1 (series expansion) and
print actual value of the same equation 1, obtained from f(x). Also, plot two graphs in one figure
containing error and Taylor approximation at each iteration. You can create 1x5 array (all zeros) using
following instruction.
>> j = zeros(1, 5);
Following snippet will also work for array with elements of your choice (Currently, 1 to 10).
for i = 1: 10
arr(i) = i;
end
3.Write a MATLAB function which calculates maximum and minimum value of functions at certain
interval, using extreme value theorem. Test it with following functions.
(a) f(x) = sin x + cos x on [0, 2π].
(b) f(x) = x 4−3 x3−1 on [−2,2]
Following function definition will hold for this question.
[min, max] = calculateExtremeValues(f, interval)
% where f is a function and interval is a vector with two values [start end]
4. Write a paragraph on “Numerical analysis in computer science and engineering” in comments. Make
sure you do not copy it as it will result in a 0.