Nothing Special   »   [go: up one dir, main page]

Sheet 2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 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 2
due 06.11.23 before 8 AM
Solutions must be delivered as specified by the instructions shown in Moodle.

Exercise 2.1:

Consider the integrals Z e


Pn = [ln(x)]n dx. (1)
1

Derive a forward iteration Pn+1 = f (Pn ) and a backward iteration Pn = g (Pn+1 ).


Determine which one of the two is stable. These previous calculations must be
done by hand. Finally, write a Matlab program which uses the stable iteration to
calculate the first 20 terms P1 , P2 , ..., P20 and prints them to the command line.

(10 points)

Exercise 2.2:
The mean-field equation for the Ising model is

x⋆ = tanh(6βx⋆ ) . (2)

The iterative solution of Eq. (2) builds up a sequence

xn+1 = tanh(6βxn ) , x0 > 0 , (3)

which converges to x⋆ . We analyze the case where β is slightly larger than 1/6:

6β = 1 + ϵ with ϵ ≪ 1

and the non-trivial solution x⋆ ̸= 0 of Eq. (2) becomes very “small”.

a) Expand the solution x⋆ to leading order in ϵ [hint: Taylor expansion of


Eq. (2)]. Then discuss the convergence of Eq. (3): to this end write xn =
x⋆ + δn (and similarly for xn+1 ) and expand Eq. (3) to leading order in the
errors δ. How many iterations N are needed to reduce the error by a factor
of 10? The computations must be done by hand.

1
b) Write a Matlab program which calculates the estimates xn and plots the
error δn as a function of n on a semilogarithmic scale. Set β = 0.17 and
in this case x⋆ = 0.24062696159732. Does the error behave as expected?
How many iterations are needed to obtain the solution to machine accuracy?
Compare this number with the result presented in the lecture. Compare
the number of iterations with the analytic result obtained in part a) of the
exercise. What can cause differences between these two values?

(15 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