Docsity

Computational Project 4: Comparing Convergence Rates of Integration Methods - Prof. Oleg V, Study Guides, Projects, Research of Mechanical Engineering

Toggle sidebar
bg1
Computational Project # 4
Due March 18
The function
(
)
(
)
( ) 1.2 1 exp ( 1)
f x x x x
α
β
= − − −
is convex for all
α
,
β
, and x in [0, 1].
The parameters
α
and
β
allow one to make it very easy or very difficult to integrate. For
(a)
α
= 2,
β
= 0.2,
(b)
α
= 0.2,
β
= 2
integrate the equation using the trapezoidal rule, Simpson’s rule, and adaptive quadrature
algorithm based on the trapezoidal rule.
a) Compare the number of function evaluations (sub-intervals) required to achieve
various tolerances (error).
b) Also compare the rates of convergence of the three integration methods, i.e. plot
the error vs. number of function evaluations (sub-intervals) in log-log scale.
Assume that the exact integral in the first case is 0.0095499658265276 and in the second
case is 0.3457273592825.
In order to evaluate the number of sub-intervals used by adaptive quadrature, the easiest
way is to introduce a global variable that is get updated every time the subroutine is
called. i.e.
global isub
isub=isub+1
You can use for the trapezoidal integration and the adaptive quadrature codes that we
developed during the class. However, put the comment in the very first line that this is
not your code.
P.S. Bring your solution to class. Email your code to [email protected]. The
program that you send should be a working program. All the codes will be checked
whether they run or not. If they are erroneous, but run, points will be taken for the errors.
If the code does not run (it has some syntax errors), an additional 25% will be taken off.
The goal of this class is for you to be comfortable solving engineering problems. Please
take your time and learn how to trust the computer.

Partial preview of the text

Download Computational Project 4: Comparing Convergence Rates of Integration Methods - Prof. Oleg V and more Study Guides, Projects, Research Mechanical Engineering in PDF only on Docsity!

Computational Project # 4

Due March 18

The function f ( ) x = x^ α( 1.2 − x )  1 − exp ( β( x −1)) is convex for all α, β, and x in [0, 1].

The parameters α and β allow one to make it very easy or very difficult to integrate. For (a) α = 2, β = 0.2, (b) α = 0.2, β = 2 integrate the equation using the trapezoidal rule, Simpson’s rule, and adaptive quadrature algorithm based on the trapezoidal rule.

a) Compare the number of function evaluations (sub-intervals) required to achieve various tolerances (error). b) Also compare the rates of convergence of the three integration methods, i.e. plot the error vs. number of function evaluations (sub-intervals) in log-log scale.

Assume that the exact integral in the first case is 0.0095499658265276 and in the second case is 0.3457273592825.

In order to evaluate the number of sub-intervals used by adaptive quadrature, the easiest way is to introduce a global variable that is get updated every time the subroutine is called. i.e.

global isub isub=isub+

You can use for the trapezoidal integration and the adaptive quadrature codes that we developed during the class. However, put the comment in the very first line that this is not your code.

P.S. Bring your solution to class. Email your code to [email protected]. The program that you send should be a working program. All the codes will be checked whether they run or not. If they are erroneous, but run, points will be taken for the errors. If the code does not run (it has some syntax errors), an additional 25% will be taken off. The goal of this class is for you to be comfortable solving engineering problems. Please take your time and learn how to trust the computer.