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

CAAM 453: Numerical Analysis I

Problem Set 8

Due:  December 2nd 2022

Note:  All MATLAB functions mentioned in this homework assignment can be found on the  CAAM453 homepage,  or come  with  MATLAB .   You  can use the  MATLAB codes posted on the  CAAM453 web-page.  If you modify these codes, please turn in the modified code.  Otherwise you do not have to turn in printouts of the codes posted on the CAAM453 web-page.  Turn in all MATLAB code that you have written and turn in all output generated by  your  MATLAB functions/scripts.   MATLAB functions/scripts  must  be commented, output must be formatted nicely, and plots must be labeled.

Problem 1 (50 points)

A “double pendulum” consists of a pair of pendula which are connected to each other by a pin joint (see Figure 1). The rst pendulum is attached to a fixed point. The two pendula being respectively of lengths l1  and l2  and of masses m1  and m2 , the position of the two pendula can be represented by two angles θ 1  and θ2 . The kinetic energy T and the potential energy U of the system are written in terms of θ 1 (t) and θ2 (t) as

T = e1(2)θ˙1(2) + e2(2)θ˙2(2) + m2e1e2 θ˙1 θ˙2 cos (θ1 θ2 ) ,

U = (m1 + m2 ) e1g cos (θ1 ) m2e2g cos (θ2 ) .

Lagranges equations of motion are in the form

   = 0,    α = 1, 2.

with the Lagrangian of the system L = T  U .

. Write the two equations of motion in the form

  ┐ ┌ θ¨(θ¨)2(1)   = f(f)2(1)   

with m11 , m12 , m22 , f1  and f2  functions of θ1 , θ˙1 , θ2 , and θ˙2 .

. Matrix M is symmetric and invertible. Write the equations of motion as

 θ¨(θ¨)2(1)   = M|1  f(f)2(1)   

. Write this system of 2 second order ODE’s as a system of 4 first order

ODEs. For that, introduce the 4 variables

 

Figure 1: Double pendulum

y1  = θ 1 ,    y2  = θ2 ,    y3  = θ˙1 ,    y4  = θ˙2

and write

((   )) = A ((   ))

'  y˙4   '          '  y4   '

with A R44 .

. Write a MATLAB code that integrates (in time, from t = 0 to t = 60 )

 

any other method of your choice (explicit, implicit, multistep, onestep). As an output, you should provide two graphs:  (i) one graph that draws

the position (x, y) of mass m2  as a function of time and (ii) a graph that draws θ2 , θ˙2 as a function of time.

. The total energy of the system should be conserved over time: E = T + V should not depend on time. Provide a graph E(t) for t = 0 to t = 600. Is the energy conserved numerically and why ?

Problem 2 (50 points)

You are to write Matlab codes LUfac, Lsolve and Usolve based upon the al-gorithms presented in class. LUfac should implement LU-factorization with partial pivoting for stability. Lsolve should implement the lower triangular solve and Usolve should implement the upper triangular solved needed to obtain the solution to a given linear system using the output of LUfac.

Honor Code:  For this code you are not allowed to search the internet or any  other source for an  implementation.   You  can  consult  other written textbooks and look a printed descriptions if you wish, but you may not copy any computer codes.

i.  (20 points) Your LUfac code should check A on input, set a ag and exit if A is not square. It should satisfy the following specifications:

 

ii.  (10 points) Your Lsolve code should check input  A and b to see that dimensions match up.  If not, set a ag and exit.  It should satisfy the following specifications:

 

iii.  (10 points) Your Usolve code should check input  A and c to see that dimensions match up.  If not, set a ag and exit.  During the backsolve, you must test for an exact zero on the diagonal, set a ag and exit if this occurs. It should satisfy the following specifications:

 

iv.  (10 pts) Run the code testLUfac .m using your LUfac, Lsolve, Usolve. You must use testLUfac .m as given (see assignment page). Do not modify this code. Please turn in the printed output from this run.