Assignment1-Solutions
Assignment1-Solutions
Lakehead University
Solve the following problems. Each problem will require some analysis, as well as some
computations. Show your work for the computations. You may verify your solution using
MATLAB or your choice of other programming languages.
𝑘 𝑇 𝑇)
where T is the temperature of the body (C), t is the time (min), k is the proportionality
constant (per minute), and Ta is the ambient temperature (C). Suppose that a cup of
coffee originally has a temperature of 70C. Use Euler’s method to compute the
temperature from t = 0 to 20 min using a step size of 5 min if Ta = 20C and k =
0.019/min.
Solution:
Approximate the derivative by its finite difference equation:
Then place it in the differential equation and solve the equation for 𝑇 𝑡 .
T 𝑇
𝑘 𝑇 𝑇
∆t
Euler’s formula: T 𝑇 𝑘 𝑇 𝑇 ∆𝑡
Given values:
𝑡 0 min
𝑇 70℃
𝑇 20℃
∆𝑡 5min
k = 0.019/min
Solution:
Solution:
Solution:
∞
𝑥
𝑐𝑜𝑠 𝑥 1
2𝑛 !
∞ 𝜋𝑥
𝜋𝑥 2
𝑐𝑜𝑠 1
2 2𝑛 !
𝜋𝑥 𝜋𝑥 𝜋𝑥 𝜋𝑥
1 2 2 2 ⋯ 1 2 ⋯
2 ! 4 ! 6 ! 2𝑛 !
∞ 𝜋𝑥 𝜋𝜉
𝑅 1 2 1 2 , where 𝜉 is a number close to 𝑥.
2𝑖 ! 2 𝑛 1 !
Hence,
𝜋𝜉 1
|𝑅 |
2 2 𝑛 1 !
/
Note: the true value of 𝑐𝑜𝑠 𝑐𝑜𝑠 𝜋/4 1/√2 0.7071068
When |Rn| is used as a measure of error, the parameter can be set to the
operating point = ½.
|t|: the true fractional relative error; i.e. the true error divided by the true value.
The true error is the difference of the true value and the approximated value.
|a|: the approximate percent relative error; i.e. the approximate error divided by
the new approximation. The approximate error is the difference of the new
approximation and the old approximation.
Results:
*Result of Iteration n is the sum of the n+1 terms of the Taylor series.
Question 5 (Finite difference approximations of derivatives) (15 points)
Use forward, backward, and centered difference approximations to estimate the first
derivative of f(x) = (ex – 1)/x at x = 2 using the step size h = 0.5. Compare the true
percent relative error of each approximation.
Solution:
ex 1
f ( x) Objective: find f’(2) using h = 0.5
x
We can find the true value of f’(2) by differentiating f analytically:
xe x (e x 1) e x ( x 1) 1
f ( x)
'
2
2
f ' (2) 2.097264
x x