Computational Physics - Department of Physics

(Axel Boer) #1

3.6 Exercises 93


3.6.Write a C++ class which sets up various approximations to thederivatives and repeat
exercise 3.1 using this class.


3.7.Write a C++ class which sets up the position for a given particle in arbitrary dimensions.
Write thereafter a program which uses this class in order to set up the electron coordinates
for the ten electrons in the neutral neon atom. This is a three-dimensional system. Calculate


also the distance|ri|=



x^2 i+y^2 i+z^2 i(modulus of the position from the mass center, where the
mass center is defined as the the atomic nucleus) of a given electronito the atomic nucleus.
Extend the class so that it can be used to calculate the modulus of the relative distance
between two electrons


|ri−rj|=


(xi−xj)^2 + (yi−yj)^2 + (zi−zj)^2.

3.8.Use the class from the previous exercise to write a program which reads in the position
of all planets in the solar system, using the sun as the centerof mass of the system. Let this
program calculate the distance from the sun to all planets, and the relative distance between
all planets.


3.9.Use and extend the vector class discussed in this chapter to compute the 1 and 2 vector
norms given by
||x|| 1 =|x 1 |+|x 2 |+···+|xn|,
||x|| 2 = (|x 1 |^2 +|x 2 |^2 +···+|xn|^2 )


(^12)
= (xTx)
(^12)
.
Add to the vector class the possibility to calculate an arbitrary normp
||x||p= (|x 1 |p+|x 2 |p+···+|xn|p)
(^1) p
,
wherep≥ 1.
Write thereafter a program which checks numerically the theso-called Cauchy-Schwartz.
For anyxandybeing real-valued or complex-valued quantities, the innerproduct space
satisfies
|xTy|≤||x|| 2 ||y|| 2 ,
and the equality is obeyed only ifxandyare linearly dependent. Your program should be able
to read from file two tabulated vectors, or, alternatively let the program set them up.

Free download pdf