CS计算机代考程序代写 matlab algorithm Updated on July 14, 2021

Updated on July 14, 2021
Math 3607: Exam 2 Due: 11:59PM, Saturday, July 17, 2021
Please read the statements below and sign your name.
Disclaimers and Instructions
• You may use any of the book functions (quote), any of functions provided in lectures, ac- companying live scripts, and homework or practice problem solutions, and any of your own helper functions. As stated in the syllabus, you must be able to explain how they are sup- posed to work. You may be requested to explain your code to me, in which case a proper and satisfactory explanation must be provided to receive any credits on relevant parts.
• You are not allowed to search online forums or even MathWorks website. All problems can be solved with what has been taught in class. If you need to look something up, then you must be doing it incorrectly.
• Unlike for homework, you are not allowed to collaborate with classmates.
• If any code is found to be plagiarized from the internet or another person, you will receive a
zero on the entire exam (both parts).
Academic Integrity Statements
• All of the work shown on this exam is my own.
• I will not consult with any resources (MATLAB documentation, online searches, etc.) other than the textbooks, lecture notes, and supplementary resources provided on the course Car- men pages.
• I will not discuss any part of this exam with anyone, online or offline.
• I understand that academic misconduct during an exam at The Ohio State University is very serious and can result in my failing this class or worse.
• I understand that any suspicious activity on my part will be automatically reported to the OSU Committee on Academic Misconduct for their review.
Signature
1

Notation. Problems marked with à are to be done by hand; those marked with are to be solved using a computer.
1 PLU Factorization
à Find the PLU factorization of the matrix
 2 −1 3 A =  10 −7 10
−6 4 −5
[15 points]
by Gaussian elimination with partial pivoting. That is, find matrices P (permutation matrix), L (unit lower triangular matrix), and U (upper triangular matrix) such that PA = LU. Justify all your steps.
Hint. You may (and should) use, without proof, the properties of Gaussian transformation matrices presented in Problem 7 of Module 2 practice problem set. Be sure to give a clear reference to the properties used in your solution.
2

2
Let
(a)
(b)
(c) (d)
Catastrophic Cancellation
2 1 − cos x f(x) = x2
[20 points]
if x ̸= 0, if x = 0.
1
à Find the condition number κf (x); simplify it as much as you can. Then compute
lim κf (x). x→0
à For small x, the “obvious” evaluation algorithm f1 = @(x) 2*(1-cos(x))./(x.^2);
suffers from catastrophic cancellation. Explain why.
à Using the first 3 terms of the Taylor series expansion of f(x), establish a second algorithm
f2 to compute f(x) stably for small x. Fully justify the derivation of your algorithm.
Evaluate f (x) for x = 10−k for k ∈ N[1, 10] using the two algorithms f1 and f2. Tabulate the results neatly. The table should have three columns with the first being x, the second being f1, and the third being f2. Use either format long g or an appropriate fprintf statement to display full accuracy.
3

3 Least Squares for Periodic Data [30 points]
The graph below represents arterial blood pressure collected at 8 ms (milliseconds) intervals over one heart beat from an infant patient:
100 95 90 85 80 75 70 65 60
0 0.1
0.2 0.3 0.4 time (sec)
Denote the data points by (ti, yi) for i = 1, . . . , m. The data can be fit using a low-degree polynomial of the form
f(t)=c1+c2t+···+cntn−1, n= 1.’)
end
%% Step 1: Initialization
nr_th = 41; nr_ph = 31;
th = linspace(0, 2*pi, nr_th);
ph = linspace(0, pi, nr_ph);
[T, P] = meshgrid(th, ph);
x1 = cos(T).*sin(P);
x2 = sin(T).*sin(P);
x3 = cos(P);
X = [x1(:), x2(:), x3(:)]’;
%% Step 2: [FILL IN] Normalize columns of X into unit vectors
%% Step 3: [FILL IN] Form Y = A*X; calculate norms of columns of Y
%% Step 4: [FILL IN] Calculate p-norm of A (approximate)
%% Step 5: [FILL IN] Generate surface plots
end
1The function must be written at the very end of your Live Script.
5

(b)
The following steps are carried out by the program. Step 1. Create 3-vectors
cos θi sin φj 
xk =sinθisinφj, for1≤i≤41,1≤j≤31 (4)
cos φj
using 41 evenly distributed θi in [0,2π] and 31 evenly distributed φj in [0,π]. Note the
use of meshgrid, which is useful for surface plots later.
Step 2. Normalize xk into a unit vector in p-norm by xk ← xk/∥xk∥p (that is, replacing xk
with xk/∥xk∥p).
Step 3. For each k, let yk = Axk. Calculate and store ∥yk∥p.
Step 4. Approximate ∥A∥p based on the norms ∥yk∥p calculated in the previous step.
Step 5. Generate surface plots of the unit sphere in the p-norm and its image under A. Use surf function; see pp. 125-128 of Module 1 lecture slides. Use subplot to put two graphs side by side.
Run the program with p = 1, 32 , 2, 4, all with the same matrix
2 0 0 
A = 0 cos(π/12) − sin(π/12) . (5)
0 sin(π/12) cos(π/12)
A = [2 0 0;
0 cos(pi/12) -sin(pi/12);
0 sin(pi/12) cos(pi/12)];
visMatrixNorms3D(A, 1);
visMatrixNorms3D(A, 3/2);
visMatrixNorms3D(A, 2);
visMatrixNorms3D(A, 4);
% Depending on how you write the code,
% you may need to use ’clf’ or ’hold off’
% in between function calls.
Figure 1: Example output. 6