0% found this document useful (0 votes)
30 views2 pages

Sheet 4

This document contains instructions for Homework 4 in the course "CSIS - Computer Simulation in Science" due on November 20th, 2023 before 8 AM. It outlines 3 exercises: 1) Check with a paper-and-pencil calculation that the leading error of the Simpson rule is O(h^5). 2) Write a MATLAB program to integrate functions using the trapezoidal rule and Simpson's rule, and compare their accuracies on sample integrals. 3) Write a MATLAB function to integrate a function within a tolerance δ using Simpson's rule, and use it to calculate terms in an infinite series expansion.

Uploaded by

amarvenkat30
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)
30 views2 pages

Sheet 4

This document contains instructions for Homework 4 in the course "CSIS - Computer Simulation in Science" due on November 20th, 2023 before 8 AM. It outlines 3 exercises: 1) Check with a paper-and-pencil calculation that the leading error of the Simpson rule is O(h^5). 2) Write a MATLAB program to integrate functions using the trapezoidal rule and Simpson's rule, and compare their accuracies on sample integrals. 3) Write a MATLAB function to integrate a function within a tolerance δ using Simpson's rule, and use it to calculate terms in an infinite series expansion.

Uploaded by

amarvenkat30
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/ 2

CSIS

Computer Simulation in Science

Introduction to Computer Simulation


WS 23/24
Prof. Dr. F. Knechtli
M.Sc. T. Asmussen, Dr. J. A. Urrea-Niño

Homework 4
due 20.11.23 before 8 AM

Solutions must be delivered as specified by the instructions shown in Moodle.

Exercise 4.1:
Check with a paper-and-pencil calculation that the leading error of the Simpson
rule is indeed of O(h5 ). [Hint: use a Taylor expansion around the center of the
interval x = x1 .]
(5 points)

Exercise 4.2:
Write a MATLAB program which integrates a function f (x) over the interval [a, b]
with both the extended trapezoidal rule and the extended Simpson’s rule. The file
trapez.m is available for download in Moodle and can be used in the solution.

• Both procedures are able to integrate powers xk exactly for small enough k.
Check up to which value of k each algorithm can integrate exactly.

• Solve numerically the integrals


Z 1
1
dx = ln(2)
0 1+x
Z 1 √
1
x 1 − x2 dx =
0 3
Do a log-log plot of the relative precision as a function of the number of
sub-intervals N with the data from both algorithms. What do you observe?
Is it what you expected? How many function calls do the algorithms need in
order to obtain a relative precision of 10−8 ? Make all these tests with both
integrals above. Why does the second one behave in such a stubborn way?

(10 points)

1
Exercise 4.3:

• Write a Matlab function which integrates a function f (x) in the interval


[a, b] using the extended Simpson rule with a given precision tolerance δ
(Hint: It should increase the number of sub-intervals used until the relative
difference two successive results is smaller than δ).

• Consider the series


∞ n+1
e−x
X Z
n
(−1) dx
n=1 n x

Do a semi-logarithmic plot of the absolute value of the terms of the sum as


a function of n. Use the integrating function you wrote to solve the integrals
−15
PN tolerance of 10 P.N Calculate the largest number of terms
with a precision
N such that n=1 an + aN +1 ̸= n=1 an for Matlab.

(10 points)

Note: For each exercise we should be able to see, from what you handed in, what
you did and what came out of it. Print out/write down everything we need for
this. If you don’t manage to write a working program, then write down a kind of
pseudo code. That is, explain step by step, what your program should be doing.

You might also like