Mid 2-1
Mid 2-1
Suppose an engineer is working on a project that involves the design of a new turbine engine.
One of the key parameters that he needs to optimize is the rate of change of the engine's
temperature with respect to time. He hires you to do this job.
You have collected data on the temperature of the engine at different time points, and you want
to estimate the rate of change of the temperature using numerical differentiation with the Three-
Point Midpoint Formula. The temperature data is given by:
Time(hours) 0 1 2 3 4
Temprature(°𝑪) 20 50 80 110 140
You want to estimate the rate of change of the temperature at t = 2 hours using the Three-
Point Midpoint Formula, with a step size of h = 1 hour.
Assuming that you are a computer scientist currently developing a computer graphics
application that requires the computation of the area beneath the curve of the function 𝒚 =
𝒙𝟐 + 𝟐𝒙, within the integration interval of [0, 5], you are asked to estimate the area manually
before implementing any solutions. The estimation should be done by utilizing the Composite
Trapezoidal and Composite Simpson's rule furthermore, actual errors of each method
should also be calculated. Additionally, provide your comments on the comparison of actual
error of both methods. (let n = 4 subintervals)
1
Qno4 – CLO 2 4 Marks
Solve 𝑦 ′ = 1 − 𝑦 & 𝑦(0) = 0 𝑖𝑛 𝑡ℎ𝑒 𝑟𝑎𝑛𝑔𝑒 0 ≤ 𝑥 ≤ 0.5 using Euler’s method. (Let h=0.1)
c) Which interpolating method is implemented in part (b). Just give its name.
d) Briefly write the purpose of the following command (ONE LINE ANSWER)
from scipy.interpolate import lagrange
________________________________________________________
Three-point Midpoint Formula
𝟏 𝒉𝟐
𝒇′ (𝒙𝟎 ) = (𝒇(𝒙𝟎 + 𝒉) − 𝒇(𝒙𝟎 − 𝒉)) + 𝒇′′′ (𝜻𝟏 ) ∶ 𝜻 𝒍𝒊𝒆𝒔 𝒃𝒆𝒕𝒘𝒆𝒆𝒏 𝒙𝟎 + 𝒉 𝒂𝒏𝒅 𝒙𝟎 − 𝒉
𝟐𝒉 𝟔
Simpson’s Rule
Trapezoidal Rule
Stirling’s Formula
𝒔𝒉
𝑷𝒏 (𝒙) = 𝒇(𝒙𝟎 ) + (𝒇[𝒙−𝟏 , 𝒙𝟎 ] + 𝒇[𝒙𝟎 , 𝒙𝟏 ]) + 𝒔𝟐 𝒉𝟐 𝒇[𝒙−𝟏 , 𝒙𝟎 , 𝒙𝟏 ]
𝟐
𝒔(𝒔𝟐 − 𝟏)𝒉𝟑
+ (𝒇[𝒙−𝟐 , 𝒙−𝟏 , 𝒙𝟎 , 𝒙𝟏 ] + 𝒇[𝒙−𝟏 , 𝒙𝟎 , 𝒙𝟏 , 𝒙𝟐 ]) + 𝒔𝟐 (𝒔𝟐 − 𝟏)𝒉𝟒 𝒇[𝒙−𝟐 , 𝒙−𝟏 , 𝒙𝟎 , 𝒙𝟏 , 𝒙𝟐 ]
𝟐
Euler’s Method:
𝒉𝟐
𝒚(𝒕𝒊+𝟏 ) = 𝒚(𝒕𝒊 ) + 𝒉𝒚′(𝒕𝒊 ) + 𝒚′′(𝝃𝒊 )
𝟐