Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Math 3607: Homework 4

2022

TOTAL: 30 points

•  Problems marked with  are to be done by hand; those marked with  are to be solved using a computer.

•  Important note. Do not use Symbolic Math Toolbox. Any work done using sym or syms will receive NO credit.

•  Another important note.  When asked write a MATLAB function, write one at the end of your live script.

1.  (Proper usage of lu; FNC 2.6.1)  Suppose that A P Rnˆn  and b P Rn .  On the left is correct MATLAB code to solve Ax “ b; on the right is similar but incorrect code. Explain using mathematical notation exactly what vector is found by the right-hand version.

[L ,U ]  =  lu (A );

x  =  U  \  L  \  b;

2.  (FLOP counting; FNC 2.5.5)  This problem is about evaluation of a polynomial

ppxq  c1 ` c2x ` c3x2 ` ¨ ¨ ¨ ` cnxn´1 .

(a) Here is a little code to do the evaluation.

y  =  c (1);

xpow  =  1;

for  i  =  2:n

xpow  =  xpow  *  x;

y  =  y  +  c (i)*xpow;

end

Assuming that x is a scalar, how many flops does this code take, as a function of n? Provide both the exact answer and the asymptotic answer as n Ñ 8.

Here is another code to do the same task.

y  =  c (n);          %  This  algorithm  is  called  Horners  rule .

for  j  =  n- 1:- 1:1

y  =  y *x  +  c (j);

end

Assuming that x is a scalar, how many flops does this code take, as a function of n? Provide both the exact answer and the asymptotic answer as n Ñ 8.  Then compare the count to the one from (a).

3.  (Understanding matrix multiplication)  Do LM 12.5–3.

4.  (Periodic fit; FNC 3.1.3)  In this problem you are trying to find an approximation to the periodic function  f ptq  “  esinpt´1q  over one period,  0  ď  t  ď  2π .   In MATLAB, let t=linspace(0,2*pi,200)’ and let b be a column vector of evaluations of f at those points.

(a) Find the coefficients of the least square fit

f ptq « c1 ` c2t ` ¨ ¨ ¨ ` c7t6 .

(b) Find the coefficients of the least squares fit

f ptq « d1 ` d2 cosptq ` d3 sinptq ` d4 cosp2tq ` d5 sinp2tq.

(c) Plot the original function f ptq and the two approximations from (a) and (b) together on a well-labeled graph.