You are on page 1of 2

Quiz 3 – Tuesday 31 October 2023

1. Plot the following function in the range of 0 and 4 and find the local and global minimum points
coordinates inside the estimated ranges.
𝜋
𝑦(𝑥) = 2𝑒 −0.5𝑥 cos (3𝑥 + )
4
a) (0.7304, -1.3693), (2.8247, -0.4805) (correct)
b) (0.8405, -3.0032), (2.9348, -8.5580)
c) (0.8405, -8.5580), (2.9348, -3.0032)
d) (0.7304, -0.4805), (2.8247, -1.3693)

Solution:
>> y = @(x)(2*exp(-0.5*x).*cos(3*x+pi/4));
>> fplot(y,[0,4])
>> x1 = fminbnd(y,0.5,1)
x1 =
0.7304
>> y1= y(x1)
y1 =
-1.3693
>> x2 = fminbnd(y, 2.5,3)
x2 =
2.8247
>> y2= y(x2)
y2 =
-0.4805
2. Write anonymous functions to implement the following functions.
𝑓(𝑥) = 3𝑥 2 − 5𝑥 + 10, 𝑔(𝑥) = 1 − cos−1 𝑥 and ℎ(𝑥) = 𝑓(𝑔(𝑥)) + 𝑥 2
Then find the value of h(6.5)?
a) 30.6049 - 2.5590i (correct)
b) 40.6049 -28.1488i
c) 43.2500 - 5.3399i
d) 52.1346

Solution:

>> f=@(x)(3*x^2-5*x+10);

>> g=@(x)(1-acos(x));

>> h=@(x)(f(g(x))+x^2);

>> h(6.5)

ans =

30.6049 - 2.5590i

3. write a for loop to calculate the sum of first 10 terms in the following series:

(−1)𝑛+1 ∗ 0.72𝑛−1
, 𝑛 = 1,2,3, … 10
2𝑛 − 1
a) 0.6107 (correct)
b) 0.3631
c) 24.7415
d) 5.6392

Solution:
out = 0;
for n=1:10
out = out + (-1)^(n+1)*0.7^(2*n-1)/(2*n-1);
end

You might also like