Quiz No. 3 - Functional Approximation - Binalon
Quiz No. 3 - Functional Approximation - Binalon
03
Topic: Functional Approximation / Curve Fitting Due Date Nov. 28, 2024, 9:00 PM
Solution:
413.6875 − 331
𝑓 ′ (2) = = 𝟑𝟑𝟎. 𝟕𝟓
0.25
Forward Difference (O(h2))
At x = 2
331 − 257.6875
𝑓 ′ (2) = = 𝟐𝟗𝟑. 𝟐𝟓
0.25
Backward Difference (O(h2))
b. Central Difference
Central Difference (O(h2))
𝑓(𝑥 + ℎ) − 𝑓(𝑥 − ℎ)
𝑓 ′ (𝑥) =
2ℎ
at x = 2
𝑓(2.25) − 𝑓(1.75)
𝑓 ′ (𝑥) =
0.5
413.6875 − 257.6875
𝑓 ′ (𝑥) = = 𝟑𝟏𝟐
0.5
At x = 2
Consider the function 𝑓(𝑥) = sin 10𝜋𝑥. Find f’(0) using forward difference representations
𝜋
with ∆𝑥 = 12.
a. To the order of 𝜕(ℎ). What is the corresponding absolute error?
b. To the order of 𝜕(ℎ)2 . What is the corresponding absolute error?
c. Explain the possible cause of errors.
Also, generate a computer-aided solution generated from MATLAB.
Solution:
𝑓(𝑥) = sin 10𝜋𝑥
𝑓′(𝑥) = 10𝜋cos(10𝜋(0)) = 𝟏𝟎𝝅
𝑓(𝑥 + ℎ) − 𝑓(0)
𝑓 ′ (0) =
ℎ
𝑓(0) = sin(π(0)) = 0
π π 10π2
𝑓 ( ) = sin (10π( )) = sin( )
12 12 12
2
π 10π
𝑓 ( ) − 𝑓(0) sin ( 12 ) − 0
𝑓 ′ (0) = 12 =
π π
12 12
𝟏𝟎𝛑𝟐
𝐬𝐢𝐧 ( 𝟏𝟐 )
𝒇′ (𝟎) = 𝛑
𝟏𝟐
10π2
sin ( 12 )
𝐴𝑏𝑠𝑜𝑙𝑢𝑡𝑒𝐸𝑟𝑟𝑜𝑟 = |10𝜋 − π | = 𝟑𝟎. 𝟖𝟕
12
𝑓(0) = 0
10π2
𝑓(ℎ) = sin( )
12
5π2
𝑓(2ℎ) = sin( )
3
10π2 5π2
−3(0) + 4sin( 12 ) − sin( 3 )
𝑓 ′ (0) = π
2 (12)
10π2 5π2
−3(0) + 4sin( 12 ) − sin( 3 )
𝐴𝑏𝑠𝑜𝑙𝑢𝑡𝑒𝐸𝑟𝑟𝑜𝑟 = |10𝜋 − π | = 𝟑𝟎. 𝟖𝟕
2 (12)
The possible causes of errors in numerical differentiation using forward difference methods can arise from
truncation error and round off error. It is because we are using finite difference to approximate the derivatives which
leads to a lower order approximation. On the other hand, when the step size is very small, the round off errors
become significant.
The objective of this problem is to compare second order accurate forward, backward, and centered finite
difference approximations of the first derivative of a function to the actual value of the derivative. This
will be done for
𝑓(𝑥) = 𝑒 −2𝑥 − 𝑥
Solution:
a. Calculus derivative
𝑓(𝑥) = 𝑒 −2𝑥 − 𝑥
𝑓 ′(𝑥) = −2𝑒 −2𝑥 − 1
At x=2 𝑓 ′(2) = −2𝑒 −2(2) − 1 = −𝟎. 𝟗𝟔𝟑
d. Plot