0% found this document useful (0 votes)
224 views8 pages

Quiz No. 3 - Functional Approximation - Binalon

The document outlines Quiz No. 03 for MEP 502a, focusing on functional approximation and curve fitting, with problems involving the computation of derivatives using finite difference methods. It includes detailed calculations for forward, backward, and central difference approximations, as well as error estimation and MATLAB solutions. The quiz is due on November 28, 2024, and consists of three problems, each with specific requirements and solutions.

Uploaded by

Jenny Binalon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
224 views8 pages

Quiz No. 3 - Functional Approximation - Binalon

The document outlines Quiz No. 03 for MEP 502a, focusing on functional approximation and curve fitting, with problems involving the computation of derivatives using finite difference methods. It includes detailed calculations for forward, backward, and central difference approximations, as well as error estimation and MATLAB solutions. The quiz is due on November 28, 2024, and consists of three problems, each with specific requirements and solutions.

Uploaded by

Jenny Binalon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Subject: MEP 502a: Computational Methods in Engineering Submission: Quiz No.

03
Topic: Functional Approximation / Curve Fitting Due Date Nov. 28, 2024, 9:00 PM

Problem No 1 (25 points):

Given the system of equations


𝑓(𝑥) = 75𝑥 2 + 12𝑥 + 7

At x=2, with step size of 0.25, determine the following:


(a) Compute forward and backward difference approximations of O(h) and O(h2), and
(b) central difference approximations of O(h2) and O(h4) for the first derivative
(c) Estimate the true percent relative error εt for each approximation
Also, generate a computer-aided solution generated from MATLAB.

Solution:

𝑓(𝑥) = 75𝑥 2 + 12𝑥 + 7


𝑑
𝑓 ′ (𝑥) = (75𝑥 2 + 12𝑥 + 7) = 150𝑥 + 12
𝑑𝑥
At x = 2
𝑓 ′ (𝑥) = 150(2) + 12 = 𝟑𝟏𝟐
ℎ = 0.25

a. Forward and Backward difference

Forward Difference (O(h))


𝑓(𝑥 + ℎ) − 𝑓(𝑥)
𝑓 ′ (𝑥) =

𝑓(2 + 0.25) − 𝑓(2)
𝑓 ′ (2) =
0.25

𝑓(2.25) = 75(2.25)2 + 12(2.25) + 7 = 413.6875

𝑓(2) = 75(2)2 + 12(2) + 7 = 331

413.6875 − 331
𝑓 ′ (2) = = 𝟑𝟑𝟎. 𝟕𝟓
0.25
Forward Difference (O(h2))

−𝑓(𝑥 + 2ℎ) + 4𝑓(𝑥 + ℎ) − 3𝑓(2)


𝑓 ′ (𝑥) =
2ℎ

At x = 2

−𝑓(2 + 2(0.25)) + 4𝑓(2 + 0.25) − 3𝑓(2)


𝑓 ′ (2) =
2(0.25)

−𝑓(2.5) + 4𝑓(2.25) − 3𝑓(2)


𝑓 ′ (2) =
0.5

𝑓(2.5) = 75(2.5)2 + 12(2.5) + 7 = 505.75

−505.75 + 4(413.6875) − 3(331)


𝑓 ′ (2) = = 𝟑𝟏𝟐
0.5

Name: JENNY BABE M. BINALON Page 1 of 8


Page No.
Course & Year: M.Eng CE - 1st Year
Subject: MEP 502a: Computational Methods in Engineering Submission: Quiz No. 03
Topic: Functional Approximation / Curve Fitting Due Date Nov. 28, 2024, 9:00 PM

Backward Difference (O(h))

𝑓(𝑥) − 𝑓(𝑥 − ℎ) 𝑓(2) − 𝑓(2 − 0.25)


𝑓 ′ (𝑥) = =
ℎ 0.25
2
𝑓(1.75) = 75(1.75) + 12(1.75) + 7 = 257.6875

331 − 257.6875
𝑓 ′ (2) = = 𝟐𝟗𝟑. 𝟐𝟓
0.25
Backward Difference (O(h2))

3𝑓(2) − 4𝑓(𝑥 − ℎ) + 𝑓(𝑥 − 2ℎ) 3𝑓(2) − 4𝑓(1.75) + 𝑓(1.5)


𝑓 ′ (𝑥) = =
2ℎ 0.5

𝑓(1.5) = 75(1.5)2 + 12(1.5) + 7 = 193.75

3(331) − 4(257.6875) + 193.75


𝑓 ′ (2) = = 𝟑𝟏𝟐
0.5

b. Central Difference
Central Difference (O(h2))
𝑓(𝑥 + ℎ) − 𝑓(𝑥 − ℎ)
𝑓 ′ (𝑥) =
2ℎ

at x = 2
𝑓(2.25) − 𝑓(1.75)
𝑓 ′ (𝑥) =
0.5
413.6875 − 257.6875
𝑓 ′ (𝑥) = = 𝟑𝟏𝟐
0.5

Central Difference (O(h4))

−𝑓(𝑥 + 2ℎ) + 8𝑓(𝑥 + ℎ) − 8𝑓(𝑥 − ℎ) + 𝑓(𝑥 − 2ℎ)


𝑓 ′ (𝑥) =
12ℎ

At x = 2

−𝑓(2.5) + 8𝑓(2.25) − 8𝑓(1.75) + 𝑓(1.5)


𝑓 ′ (2) =
3
−505.75 + 8(413.6875) − 8(257.6875) + 193.75
𝑓 ′ (2) = = 𝟑𝟏𝟐
3

Name: JENNY BABE M. BINALON Page 2 of 8


Page No.
Course & Year: M.Eng CE - 1st Year
Subject: MEP 502a: Computational Methods in Engineering Submission: Quiz No. 03
Topic: Functional Approximation / Curve Fitting Due Date Nov. 28, 2024, 9:00 PM

c. True percent relative error

Approximation Absolute Error


312 − 330.75
(O(h)) 330.75 εt = | | = 6.0096%
Forward Difference 312
312 − 312
(O(h2)) 312 εt = | |=0
312
312 − 293.25
(O(h)) 293.25 εt = | | | = 6.0096%
Backward Difference 312
312 − 312
(O(h2)) 312 εt = | |=0
312
312 − 312
(O(h)) 312 εt = | |=0
Central Difference 312
312 312 − 312
(O(h2)) εt = | |=0
312

Computer-Aided Solution using Matlab:

Name: JENNY BABE M. BINALON Page 3 of 8


Page No.
Course & Year: M.Eng CE - 1st Year
Subject: MEP 502a: Computational Methods in Engineering Submission: Quiz No. 03
Topic: Functional Approximation / Curve Fitting Due Date Nov. 28, 2024, 9:00 PM

Problem No 2 (25 points):

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)) = 𝟏𝟎𝝅

a. First Order Forward Difference

𝑓(𝑥 + ℎ) − 𝑓(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

b. Second-Order Forward Difference

−3(𝑓(0) + 4(𝑓(ℎ)) − 𝑓(2ℎ)


𝑓 ′ (0) =
2ℎ

𝑓(0) = 0
10π2
𝑓(ℎ) = sin⁡( )
12
5π2
𝑓(2ℎ) = sin⁡( )
3
10π2 5π2
−3(0) + 4sin⁡( 12 ) − sin⁡( 3 )
𝑓 ′ (0) = π
2 (12)

Name: JENNY BABE M. BINALON Page 4 of 8


Page No.
Course & Year: M.Eng CE - 1st Year
Subject: MEP 502a: Computational Methods in Engineering Submission: Quiz No. 03
Topic: Functional Approximation / Curve Fitting Due Date Nov. 28, 2024, 9:00 PM

10π2 5π2
−3(0) + 4sin⁡( 12 ) − sin⁡( 3 )
𝐴𝑏𝑠𝑜𝑙𝑢𝑡𝑒⁡𝐸𝑟𝑟𝑜𝑟 = ⁡ |10𝜋 − π | = 𝟑𝟎. 𝟖𝟕
2 (12)

c. Possible Causes of Errors

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.

Computer-aided Solution Using Matlab

Name: JENNY BABE M. BINALON Page 5 of 8


Page No.
Course & Year: M.Eng CE - 1st Year
Subject: MEP 502a: Computational Methods in Engineering Submission: Quiz No. 03
Topic: Functional Approximation / Curve Fitting Due Date Nov. 28, 2024, 9:00 PM

Problem No 3 (50 points):

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𝑥 − 𝑥

a) Use calculus to determine the correct value of the derivative at x = 2.


b) Develop an M-file function to evaluate the centered finite-difference approximations, starting with x
= 0.5. Thus, for the first evaluation, the x values for the centered difference approximation will be x
= 2 ± 0.5 or x = 1.5 and 2.5. Then, decrease in increments of 0.1 down to a minimum value of Δx =
0.01.
c) Repeat part (b) for the second-order forward and backward differences. (Note that these can be done
at the same time that the centered difference is computed in the loop.)
d) Plot the results of (b) and (c) versus x. Include the exact result on the plot for comparison
Also, generate a computer-aided solution generated from MATLAB.

Solution:

a. Calculus derivative

𝑓(𝑥) = 𝑒 −2𝑥 − 𝑥
𝑓 ′(𝑥) = −2𝑒 −2𝑥 − 1
At x=2 𝑓 ′(2) = −2𝑒 −2(2) − 1 = −𝟎. 𝟗𝟔𝟑

b. Centered finite difference

Name: JENNY BABE M. BINALON Page 6 of 8


Page No.
Course & Year: M.Eng CE - 1st Year
Subject: MEP 502a: Computational Methods in Engineering Submission: Quiz No. 03
Topic: Functional Approximation / Curve Fitting Due Date Nov. 28, 2024, 9:00 PM

c. Second Order forward and backward difference

Name: JENNY BABE M. BINALON Page 7 of 8


Page No.
Course & Year: M.Eng CE - 1st Year
Subject: MEP 502a: Computational Methods in Engineering Submission: Quiz No. 03
Topic: Functional Approximation / Curve Fitting Due Date Nov. 28, 2024, 9:00 PM

d. Plot

Name: JENNY BABE M. BINALON Page 8 of 8


Page No.
Course & Year: M.Eng CE - 1st Year

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy