讲解MATH202-19S2、辅导Java/c++设计、Python编程语言调试 辅导R语言编程|讲解R语言编程

- 首页 >> Algorithm 算法
MATH202-19S2 Assignment A1
Due — 4pm, 23 August
Your completed assignment should be handed in via the MATH202 box in the reception area on
Level 4 of the Erskine building. You may do the assignment on your own, or as a pair with one
other student. If you do the assignment as a pair then you will both get the same mark. Ensure
that your name(s) and student ID number(s) are clearly written on the assignment.
The breakdown of marks is: A1.1: 20%, A1.2: 30%, A1.3: 30%, presentation: 20%.
To get the presentation marks your assignment must be clearly readable, written in complete
sentences, all figures should be clearly labelled and referenced in your text, and the actual questions
must be answered! You should conclude with statements like: “The general solution to
the differential equation given in part (b) is therefore .....”. It is not necessary to type your
assignment. You can use Maple or any other symbolic maths software to evaluate integrals
(just explain that this is what you have done).
Note: there are two parts in the first question, four parts in the second question and three parts
in the third question.
A1.1 Solve the following problems using the techniques required in each question
(i) Given that
show that, by reduction of order, the general solution to this equation is
y(t) = c1 et + c2 (1 + t).
(ii) Find the general solution of
t y00 (1 + t) y
0 + y = t
using variation of parameters.
A1.2 (i) Consider a chemical reaction in which compounds A and B combine to form a
third compound X. The reaction can be written as
If 2g of A and 1g of B are required to produce 3g of compound X, then the
amount of compound x at time t satisfies the differential equation
1where a and b are the amounts of A and B at time 0 (respectively), and initially
none of compound X is present (so x(0) = 0). Time is in units of minutes, and
k is the reaction rate, per minute per gram.
Use separation of variables (and integration by partial fractions) to show that
the solution can be expressed in the form
where the constant c depends on k, a, b. Now suppose that a = 15g, b = 20g
and after 10min, 15g of compound X has been formed. Using (?) or otherwise,
find the amount of X after 20mins. Show you working, and write down your
reasoning in simple sentences.
(ii) With the same values a = 15, b = 20, use the geometric method to identify
the ranges of x for which x = x(t) is an increasing function and a decreasing
function. Sketch the solution, and determine how much of compound X will
form in the limit as t → ∞. Your answer should be illustrated with suitable
diagrams. Clear hand-drawn diagrams are perfectly acceptable.
(iii) Now use the values k = 0.009731, a = 15 and b = 20 and ode45 in MATLAB to
produce a numerical solution to equation (*) over the interval t ∈ [0, 30], with
the initial condition x(0) = 0. Your answer should include a printout of a graph
of this solution, suitably labelled, and an explanation of how you calculated it.
(iv) Repeat your geometric and numerical methods with different initial concentrations
of A and B. Look in particular at (a, b) = (15, 40) and (a, b) = (40, 15).
How much of compound X is formed as t → ∞ in each of these two cases?
Finally, give a general formula for how limt→∞ x(t) depends on a and b and give
a brief physical interpretation.
In presenting your answers to this part it is not necessary to give as much detail of
the calculations as in the earlier questions. But do continue to write in complete
sentences!
A1.3 We will revisit the pendulum problem that you approximated in Lab 2,
N + sin(θN ) = 0, 0 < t ≤ 2π (1)
θN (0) = a, θ0
N (0) = 0.
The subscript N means that we are considering the nonlinear equation. Remember that
θN measures the position of the pendulum (in radians) with respect to the vertical.
(i) We will start with an approximation to problem (1). It is known that if θN is
small we can approximate the nonlinear problem with its linear version,
Where the L subscript means that we consider the linear problem. Find the
solution for (2) in terms of a.
2(ii) Use the code your wrote in Lab 2 to approximate the solution to (1) using Heun’s
method (or modified Euler, or RK-2) for a = 0.1, 0.2, 0.3, · · · , 1. You should
use h = 0.001. Plot in the same figure θL(t) and θN (t) with t ∈ [0, 2π] for
values of a 0.1, 0.4, 0.7 and 1. Explain what you see.
(iii) Calculate the relative error between θN and θL with respect to a and plot your
results. The x-axis should have the ten values of a and the y-axis should have
the relative error between the two variables at each value of a. Remember that
the relative error is defined by
eR =
||θN θL||
||θN || .
Use the function norm in MATLAB to calculate the norms. When do you think
the linear approximation to the full nonlinear problem starts to lose validity?
3