Assignment 2011 With Solutions
Assignment 2011 With Solutions
Instructions (i) This assignment is due on 22nd March 2011 1:00pm. (ii) This assignment counts towards 5% of your nal grade. (iii) Assignments should be typed and submitted on A4 sized writing paper. (Handwritten assignments with the required printouts are also accepted.) (iv) The University takes a serious view of plagiarism. Any student found to have committed or aided and abetted the oence of plagiarism may be subject to disciplinary actions in accordance with Section 3 (l) of Statute 06 (Discipline) of the National University of Singapore at: https://share.nus.edu.sg/registrar/ info/statutes/Statute06.pdf (v) Include the following declaration together with your name, matriculation number, lecture group and signature on the rst page of your assignment. I certify that the work submitted here represents solely my own efforts. I am aware of the Universitys regulations about, and penalties for, plagiarism. (vi) Late assignments or those without the above declaration will not be graded. (vii) Students should use either MATLAB or scilab (but not both) to answer their assignments. (viii) Submission of assignment Assignments are to be submitted to the Mathematics General Oce at S17 level 4 during oce hours from 9am, 21th March to 1pm, 22nd March. Please place your assignments in the baskets/trays labeled according to your ocial lecture group A, B, C or D. Each lecture group has been assigned a grader. Students who wish to submit their assignments before 21th March, should contact their designated grader separately.
Group A B C D
Grader Email Samuel Seah [email protected] Hong Liu [email protected] Chen Weidong [email protected] Wang Haitao [email protected]
(ix) Assignments submitted to the wrong group/person/grader run the risk of being misplaced. (x) Students should contact their graders directly for issues concerning grading. Questions: Total Marks: 40.
Q1) (7 Marks) The motion of a damped oscillator system is governed by x + 4x + kx = 0, x(0) = 5, x(0) = 1.
(a) Find the equation of motion for each of k = 3, 4 and 8. Show all necessary workings. (b) Print or write down the MATLAB or scilab code that will plot all three curves, that you obtained from (a), on the same graph over the interval [0, 8]. Use dierent colours or dierent types of lines for your graphs. (c) Run your code to plot the graph. Include your own name as the title of this graph. In the Figure or graphic window, use File Export, to save the graph as a jpeg or gif. Print out this graph and submit it together with your other answers. Q2) (7 Marks) The motion of a forced undamped oscillator system is governed by 10 + 99x = 50 cos t, x x(0) = 0, x(0) = 0,
where , the forcing frequency of the motor, can be adjusted by the user. (a) Compute the natural frequency of the oscillator and T the period (associated with .)
(b) Find the solutions x1 (t) and x2 (t) to the system, when the motor is adjusted to following forcing frequencies, 1 = and 2 = 2.8 respectively. Plot the solutions x1 (t) and x2 (t) from t = 0 to t = 10T , using dierent colours or dierent types of lines for your graphs. Include your own name as the title of this graph and submit your graph. (c) Which solution corresponds to resonance like behaviour? Remark: You may use the solution for x(t) from your lecture notes. Do not use the numerical solvers in MATLAB or scilab. Q3) (5 Marks) The motion of a forced damped oscillator system is governed by 10 + 5x + 120x = 50 cos t, x x(0) = 0, x(0) = 0,
where , the forcing frequency of the motor, can be adjusted by the user. (a) Plot the amplitude response curve of the system for the forcing frequency over the range 0 30. Include your own name as the title of this graph and submit your graph. (b) Find the maximum amplitude and the value of that gives rise to the maximum amplitude. Briey explain how you arrived at your answer and leave your answer correct to 2 decimal places. Remark: You may use the solution for x(t) from your lecture notes. Do not use the numerical solvers in MATLAB or scilab. Q4) (8 Marks) Let x(t) be the number of neutrons ying around inside a nuclear reactor at time t. It satises the dierential equation dx = (x 1)2 x. dt (a) Plot the direction eld of x(t) (Hint: You can use 0 t, x 4. Adjust the interval values of t and x until the equilibriums can be seen clearly from your direction eld.) (b) Identify the equilibriums (if any) and their stability and plot the equilibrium lines into your direction eld graph. (c) Solve for the solution of x(t) that satises the initial condition x(0) = 2.4. Plot this solution into your direction eld graph. (Hint: Your solution should be a function given in terms of tanh.) 3
For this question, you should submit i) your answer about the equilibriums; ii) your solution for part (c); iii) a graph of the direction eld together with the equilibrium lines and the required solution in dierent colours or types of lines; iv) the code you used. Q5) (5 Marks) The motion of a physical system is governed by the initial-value problem x x+x+ = 0, x(0.01) = 4, x(0.01) = 10. t (a) Use the numerical ode solvers of MATLAB or scilab to approximate the solution of x(t) for t ranging from 0.01 to 15. (Scilab users should specify t in intervals of 0.01.) (b) What is the value of x(15)? (c) Plot the graph of x(t) and submit this graph and the code that you used for all the parts of this question. (Hint: We only want the curve of x(t) and not x(t). See page 5 of lab 3 to nd out how this can be done) Q6) (8 Marks) A small country has four residential districts: A, B, C and D. Initially, 70% of the population stays in A, while the remaining population is evenly distributed to the other three districts. A survey showed that every year, 20%, 10% and 10% of residents from A move to districts B, C and D respectively. For district B, 30%, 10% and 10% of residents move to districts A, C and D respectively. For district C, 10%, 30% and 10% of residents move to districts A, B and D respectively. Lastly, for district D, 30%, 10% and 10% of residents move to districts A, B and C respectively. (a) Assuming the population remains constant, write down the probability matrix M that models the transitions of the population between the towns A, B, C and D. (b) Write down the eigenvalues of the matrix M . (c) What is the distribution of the population among the districts after ve years? (Leave your answer as a percentage correct up to 1 decimal place.)
For k = 3, we have x(t) = a1 et + a2 e3t . x(0) = 5 = 5 = a1 + a2 . x(0) = 1 = 1 = a1 3a2 . Hence, x1 (t) = 8et 3e3t . For k = 4, we have x(t) = (b1 + b2 t)e2t . x(0) = 5 = 5 = b1 . x(0) = 1 = 1 = 2b1 + b2 = b2 = 11. Hence, x2 (t) = (5 + 11t)e2t . For k = 8, we have x(t) = e2t (c1 cos(2t) + c2 sin(2t)). x(0) = 5 = 5 = c1 . x(0) = 1 = 1 = 2c1 + 2c2 = c2 = 11 . Hence, 2 x3 (t) = e2t (5 cos(2t) + 11 sin(2t)). 2
Question 1b) Sample Code: For both MATLAB and scilab t=0:0.01:8; x1 = 5*exp(-2*t) + 11*t.*exp(-2*t); x2 = 8*exp(-t) - 3*exp(-3*t); x3 = exp(-2*t).*(5*cos(2*t) +11/2*sin(2*t)); plot(t,x1,b-); hold on %this line is not required in scilab plot(t,x2,r--); plot(t,x3,k-.); title(TanAhLian); Question 1c)
k/m =
99/10 3.1464
1.9969
Question 2b) Sample Code: For both MATLAB and scilab w =sqrt(99/10) F=50; a1=pi; a2=2.8; % for scilab use %pi instead of pi T = (2*pi)/abs(w) % for scilab use %pi instead of pi t = 0:0.01:10*T; x1 = 2*F/(a1^2-w^2) *sin((a1-w)*t/2).*sin((a1+w)*t/2); hold on %this line is not required in scilab x2 = 2*F/(a2^2-w^2) *sin((a2-w)*t/2).*sin((a2+w)*t/2); plot(t,x1,b-) plot(t,x2,r--) title(TanAhLian)
Question 2c) x1 (t) since forcing frequency = 3.14159 is close to natural frequency .
Question 3a) Sample Code: For both MATLAB and scilab F=50; b=5; m=10; k=120; w =sqrt(120/10); a = 0:0.001:30; A = (F/m)./sqrt( (w^2-a.^2).^2 + b^2/m^2*a.^2 ); plot(a,A,b-) title(TanAhLian)
Question 3b) Either use the formula that the maximum amplitude occurs at = and A() 2.89 maxa= sqrt( w^2 -b^2/(2*m^2)) maxA = (F/m)/sqrt( (w^2-maxa^2)^2 + b^2/m^2*maxa^2 ) Or we can use the plot values. Note that to do this our intervals for should be accurate to at least 3 decimal places, so we should have plotted the at intervals of at least 0.01, i.e. a=0:0.01:30. [value index] = max(A); value a(index) Gives value = 2.8943 and ans = 3.4460 . (Manually correct this to 2 dec. pl.) 8 2
b2 2m2
3.45
Question 4) Equilibriums occur at x = 0.3820 (stable) and x = 2.618 (unstable). Solving the d.e. we get 5 3 1 2 tanh ( (x )) = t+C 2 2 5 2 3 = C = tanh1 ( (2.4 )) 1.112 2 5 3 5 5 = x(t) = + tanh( t + 1.112) 2 2 2 Sample Code: scilab deff([xdot]=f(a,x), xdot=[1 ; (-x(2)+(x(2)-1)^2)]) fchamp(f, 0, 0:0.1:4, 0:0.1:4) mtlb_axis ( [0 4 0 4]); xlabel(t) ylabel(x) title( Direction Field of dx/dt = (x-1)^2 - x) // plotting solution t= 0:0.1:4; X= 3/2 +sqrt(5)/2*tanh(-sqrt(5)/2*t+1.112); plot(t,X,b) // plotting equilibriums function ftmp = f(x) ftmp = (x-1)^2 -x endfunction e1=fsolve(0,f) e2=fsolve(2.5,f) plot(t,e1,r-) plot(t,e2,g--)
Sample Code: MATLAB [T, X] = meshgrid(0:0.1:4,0:0.1:4); S = (X-1).^2 -X ; L = sqrt(1+S.^2); quiver(T, X, 1./L, S./L , 0.5) axis equal tight xlabel(t) ylabel(x) title( Direction Field of dx/dt = (x-1)^2 - x) f = inline((X-1)^2 -X,X) % plotting equilibrums e1=fzero(f,0) e2=fzero(f,2.5) hold on t=0:0.01:4; plot(t,e1,r-) plot(t,e2,g--) X= 3/2 +sqrt(5).*tanh(-sqrt(5)/2*t+1.112)/2; % plotting equilibrums plot(t,X,k) hold off 10
Question 5) Answer: x(15) 0.237. Sample Code: MATLAB function xdot = myfunction(t,x) xdot = zeros (2,1); xdot(1) = x(2); xdot(2) = -x(2) -sqrt(x(1))/t; >> [ta, xa] =ode45(myfunction, [0.01 15], [4 10]); >> plot(ta,xa(:,1)) >> xa(end,1) Sample Code: scilab function xdot = myfunction(t,x) xdot = [x(2) ; -x(2) - sqrt(x(1))/t] endfunction t=0.01:0.01:15; x0 = [4; 10]; sol=ode(x0, 0.01, t, myfunction); plot(t,sol(1,:)) sol(1,$)
graph on the left contains only x(t), the graph on the right contains both x(t) and x(t)
11
Question 6)
0.6 0.3 0.1 0.3 0.2 0.5 0.3 0.1 0.1 0.1 0.5 0.1 0.1 0.1 0.1 0.5 mtlb_eig(M) // or eig(M) if you are using MATLAB ans = 1. 0.4 0.3 0.4 v=[0.7 ; 0.1 ; 0.1 ; 0.1] ; M^5*v ans = 0.382769 0.285263 0.165984 0.165984 Eigenvalues are 1, 0.4, 0.4 and 0.3 After ve years, 38.3% will be in A, 28.5% in B, 16.6% in C and 16.6% in D.
12