assignment with solutions

Upload: russellmahmood

Post on 06-Apr-2018

232 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/3/2019 Assignment With Solutions

    1/12

    National University of Singapore

    Department of Mathematics

    Semester II, 2008/2009 MA1506 Mathematics II Assignment

    Instructions

    (i) This assignment is due on 27th March 2009 5:00pm.

    (ii) This assignment counts towards 5% of your final grade.

    (iii) Assignments should be typed and submitted on A4 sized writing paper. (Hand-

    written assignments with the required printouts are also accepted.)

    (iv) Include the following declaration together with your name, matriculation num-

    ber, lecture group and signature on the first page of your assignment.

    I certify that the work submitted here represents solely my own ef-

    forts. I am aware of the Universitys regulations about, and penalties

    for, plagiarism.

    (v) Late assignments or those without the above declaration will not be graded.

    (vi) Plagiarism is a serious offence. Any student found guilty of plagiarism will be

    accorded zero marks.

    (vii) Students should use either MATLAB or scilab (but not both) to answer their

    assignments.

    (viii) Submission of assignment

    Each lecture group has been assigned a grader, students must submit their as-

    signments to the designated grader according to their official lecture group:

    Group Grader Email Collection at LT

    A Tang Qinglin [email protected] LT7A (Wed) Mar 25th 9.45 am

    B Shao Dongxu [email protected] LT7A (Fri) Mar 27th 9.45am

    C Cheng Yong [email protected] LT6 (Wed) Mar 25th 1.45pm

    D Zhu Huiling [email protected] LT7A (Tue) Mar 24th 3.45pm

    SL Cheng Yong [email protected] see below

    To facilitate submission for engineering students, the grader will be present at

    the above times to collect the assignments after lecture. For SL lecture group,

    early submissions, and students who missed the above time slot, assignments

    1

  • 8/3/2019 Assignment With Solutions

    2/12

    should be placed in pigeonholes located at the ground floor of S14. The pigeon-

    holes are clearly labelled.

    (ix) Assignments submitted to the wrong person/grader runs the risk of being mis-

    placed.

    (x) Students should contact their graders directly for issues concerning grading.

    Questions: Total Marks: 20.

    Q1) (4 Marks)

    The motion of a damped oscillator system is governed by

    x + 2bx + x = 0, x(0) = 10, x(0) = 0.

    (a) Find the equation of motion for each of b = 2, 1 and 35

    . Show all necessary

    workings.

    (b) Print or write down the MATLAB or scilab code that will plot all three

    curves, you obtained from (a), on the same graph over the interval [0, 20].

    (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 savethe graph as a jpeg or gif. Print out this graph and submit it together with

    your other answers.

    Q2) (4 Marks)

    The motion of a forced undamped oscillator system is governed by

    x + kx = Fcos t, x(0) = 0, x(0) = 0.

    (a) For k = 9, F = 80 and = 5. Plot the solution x(t) from t = 0 to eight

    times the period of the natural frequency. Include your own name as the

    title of this graph and submit your graph.

    (b) For k = 2500, F = 30 and = 45. Plot the solution x(t) from t = 0 to

    four times the period of the beat frequency. Include your own name as the

    title of this graph and submit your graph.

    Remark: You may use the solution for x(t) from your lecture notes. Do not use

    the numerical solvers in MATLAB or scilab.

    2

  • 8/3/2019 Assignment With Solutions

    3/12

    Q3) (4 Marks)

    Let N(t), measured in kilotons be the total mass of a certain species of shrimp

    in the Pacific Ocean. We use the logistic model to model the change in shrimp

    population, with B = 0.71 per year and the carrying capacity N = 71 kilotons.

    Using t = 0 to represent 2009, the initial mass N(0) = 0.3N.

    (a) If harvesting of 12 kilotons per year is allowed. Plot the direction field of

    dN

    dt= sN2 + BN E.

    (Hint: You can try to use 0 t, N 80. Adjust the interval values of t andN until the equilibriums can be seen clearly from your direction field.)

    (b) Identify the equilibriums (if any) and their stability and plot the equilibrium

    lines into your direction field graph.

    For this question, you should submit

    i) your answer about the equilibriums,

    ii) a graph of the direction field together with the equilibrium lines in different

    colours,

    iii) the code you used.

    If you are submitting black and white printouts, you may manually draw the

    equilibrium lines and you will be graded based on the code you submitted.

    Q4) (2 Marks)

    Solve the following IVP with a numerical solver.

    dx

    dt=

    t

    x+ x2, x(1) = 2.

    Find the value ofx(2). Submit your code together with your answer, graphs arenot required for this question.

    3

  • 8/3/2019 Assignment With Solutions

    4/12

    Q5) (4 Marks)

    The motion of a physical system is governed by the initial-value problem

    t2x + tx + 25x = 0, x(0.01) = 1, x(0.01) = 50.

    (a) Use the numerical ode solvers of MATLAB or scilab to approximate the

    solution of x(t) for t ranging from 0.01 to 1. (Scilab users should specify t

    in intervals of 0.01.)

    (b) What is the value ofx(1)?

    (c) Plot the graph ofx(t) and submit this graph and the code that you used for

    all the parts of this question. (Hint: We only want the curve ofx(t) and not

    x(t).)

    Q6) (2 Marks) A study has determined that the occupation of a young hobbit, as an

    adult, depends upon the profession of his father and is given by the following

    stochastic matrix ordered by the professions: 1) chef, 2) gardener, 3) adventurer,

    4) farmer and 5) blacksmith.

    M =

    0.71 0.2 0.5 0.31 0.14

    0.12 0.2 0.1 0.15 0.05

    0.05 0.2 0.07 0 0.41

    0.12 0.2 0.23 0.22 0.250 0.2 0.1 0.32 0.15

    .

    So the probability of the son of a chef also becoming a chef is 0.71 and a gardeners

    son has 0.20 probability of taking on any of the five professions.

    (a) Write down the matrix M5, giving your answer accurate up to at least 4

    decimal places.

    (b) What is the probability that the fifth generation descendent of a gardener

    becomes a farmer? (Your answer should be accurate up to 4 decimal places.)

    4

  • 8/3/2019 Assignment With Solutions

    5/12

    Suggested Answers:

    Question 1a)Aux Eq: 2 + 2b + 1 = 0 = ( + b)2 = b2 1. Hence = bb2 1.

    For b = 2, we have x(t) = c1e(2+

    3)t + c2e

    (23)t.

    x(0) = 10 = 10 = c1 + c2.x(0) = 0 = 0 = c1(2 +

    3) + c2(2

    3). Hence,

    x(t) = (5 +10

    3

    )e(2+3)t + (5 10

    3

    )e(23)t.

    For b = 1, we have x(t) = (c1t + c2)et.

    x(0) = 10 = 10 = c2.x(0) = 0 = 0 = c1 c2 = c1 = 10. Hence,

    x(t) = 10(t + 1)et.

    For b = 35

    , we have x(t) = e3t

    5 (c1 cos45

    t + c2 sin45

    t).

    x(0) = 10 = 10 = c1.x(0) = 0 = 0 = 3c15 + 4c25 = c2 = 152 . Hence,

    x(t) = e3t

    5 (10 cos4

    5t +

    15

    2sin

    4

    5t).

    5

  • 8/3/2019 Assignment With Solutions

    6/12

    Question 1b)

    Sample Code: For both MATLAB and scilab

    t=0:0.1:20;

    x1 = (5+10/sqrt(3))*exp((-2+sqrt(3))*t) + (5-10/sqrt(3))*exp((-2-sqrt(3))*t);

    x2 = 10*(t+1).*exp(-t);

    x3 = exp(-3*t/5).*(10*cos((4/5)*t) +15/2*sin((4/5)*t));

    plot(t,x1,b-);

    hold on %this line is not required in scilab

    plot(t,x2,r--);

    plot(t,x3,k-.);

    >> title(BenjaminButton);

    Question 1c)

    6

  • 8/3/2019 Assignment With Solutions

    7/12

    Question 2a)

    8 times period should be 16/3 16.8

    w =sqrt(9); F=80; a=5;

    p = 8*(2*pi)/w;

    t = 0:0.05:p;

    x = 2*F/(a^2-w^2) *sin((a-w)*t/2).*sin((a+w)*t/2);

    plot(t,x)

    title(HeathLedger)

    7

  • 8/3/2019 Assignment With Solutions

    8/12

    Question 2b)

    4 times period should be (4 2)/(12| |) 10

    w =50; F=30; a=45;

    p = 8*(2*pi)/abs(a-w);

    t = 0:0.01:p;

    x = 2*F/(a^2-w^2) *sin((a-w)*t/2).*sin((a+w)*t/2);

    plot(t,x)

    title(HeathLedger)

    8

  • 8/3/2019 Assignment With Solutions

    9/12

    Question 3)

    Unstable equilibrium at e2 27.74 and stable equilibirum at e1 43.26.Sample Code: MATLAB

    [T, N] = meshgrid(0:2:80,0:2:80);

    B=0.71; s=B/(71);

    S = -s*N.^2 +B*N -12;

    L = sqrt(1+S.^2);

    quiver(T, N, 1./L, S./L , 0.5)

    xlabel(t)

    ylabel(N)

    title(Direction Field of dN/dt = -sN^2+BN-E)

    f = inline(-0.01*N^2 +0.71*N-12,N)

    e1=fzero(f,0)

    e2=fzero(f,71)

    hold on

    t=0:0.1:80;

    plot(t,e1,r)

    plot(t,e2,g)

    hold off

    9

  • 8/3/2019 Assignment With Solutions

    10/12

    Question 3)

    Sample Code: scilab

    x= 0: 2:80;

    B=0.71;

    s=B/(71);

    deff([Ndot]=f(a,N), Ndot=[ 1; -s*N(2)^2+B*N(2)-12 ] )

    fchamp(f,0,x,0:2:80,2)

    function ftmp = f(N)

    ftmp = -0.01*N^2 + 0.71*N -12

    endfunction

    e1=fsolve(0,f)

    e2=fsolve(71,f)

    plot(x,e1,r)

    plot(x,e2,g)

    10

  • 8/3/2019 Assignment With Solutions

    11/12

    Question 4)

    Ans: 5.568897

    Sample Code: MATLAB

    >> f=inline(sqrt(t/x +x^2),t,x);

    >> [t, fa]=ode45(f,[1 2], 2);

    >> fa(end)

    Sample Code: scilab

    function xdot = myfunction(t,x)

    xdot = sqrt(t/x +x^2) //change the function

    endfunction

    sol=ode(2, 1, 2, myfunction);

    Question 6)

    M^5=

    0.5012506 0.4874827 0.4949960 0.4880156 0.4892584

    0.1263204 0.1250699 0.1257537 0.1251114 0.1252149

    0.0984408 0.1032534 0.1006091 0.1031477 0.1025599

    0.1703927 0.1744712 0.1722383 0.1742791 0.1739914

    0.1035954 0.1097227 0.1064029 0.1094462 0.1089754

    Answer = 0.1745.

    11

  • 8/3/2019 Assignment With Solutions

    12/12

    Question 5) Answer: x(1) 0.42.

    Sample Code: MATLAB

    function xdot = myfunction(t,x)

    xdot = zeros (2,1);

    xdot(1) = x(2);

    xdot(2) = -x(2)/t -25*x(1)/(t^2);

    >> [ta, xa] =ode45(myfunction, [0.01 1], [-1 50]);

    >> plot(ta,xa(:,1))

    >> xa(end,1)

    Sample Code: scilab

    function xdot = myfunction(t,x)

    xdot = [x(2) ; -x(2)/t - 25*x(1)/(t^2)]

    endfunction

    t=0.01:0.01:1;

    x0 = [-1; 50];

    sol=ode(x0, 0.01, t, myfunction);

    plot(t,sol(1,:)

    sol(1,$)

    the graph on the left is what we want, the graph on the right contains x(t), as a result

    the oscillations in x(t) are not clearly visible.

    12