Computational Physics - Department of Physics
2.4 Programming Examples on Loss of Precision and Round-offErrors 29 IMPLICITNONE REAL(DP) :: x, term, final_sum INTEGER:: n, lo ...
30 2 Introduction to C++ and Fortran 2.4.3 Further examples 2.4.3.1 Summing 1 /n Let us look at another roundoff example which m ...
2.4 Programming Examples on Loss of Precision and Round-offErrors 31 Using single precision results in a standard deviation ofσ= ...
32 2 Introduction to C++ and Fortran sumsq2=0.; for( i=0; i < 127; i++){ sumsq2 += pow( (double) (x[i]-xbar),2.); } sigma2=sq ...
2.5 Additional Features of C++ and Fortran 33 Table 2.5 lists several relational and arithmetic operators. Logical operators in ...
34 2 Introduction to C++ and Fortran A = expression1? expression2 : expression3; Hereexpression1is computed first. If this is"tr ...
2.5 Additional Features of C++ and Fortran 35 Line Comments 4 • Defines an integer variable var. 5 • Define an integer pointer – ...
36 2 Introduction to C++ and Fortran Address of the matrix element matr[1]: 0xbfffef70 Value of the matrix element matr[1]; 321 ...
2.5 Additional Features of C++ and Fortran 37 define MIN(a,b) ( ((a) < (b))? (a) : (b) ) define MAX(a,b) ( ((a) > (b)) ...
38 2 Introduction to C++ and Fortran of C++, or the correspondingly similarTYPEin Fortran. The latter data type will also be dis ...
2.6 Exercises 39 INTEGER:: total_states INTEGER,DIMENSION(:),POINTER:: n, lorb, jang, spin, m_l CHARACTER(LEN=10),DIMENSION(:),P ...
40 2 Introduction to C++ and Fortran precision problems discussed in the text. Write thereaftera program which implements this a ...
2.6 Exercises 41 Using Eq. (2.4) we obtain the final result F(x) =b 0 −b 1 cos(x), (2.7) andb 0 andb 1 are determined from Eq. ( ...
42 2 Introduction to C++ and Fortran 2.10.Many physics problems have spherical harmonics as solutions, such as the angular part ...
2.6 Exercises 43 ∫∞ −∞ e−xLn(x)^2 dx= 1 , and the recursion relation (n+ 1 )Ln+ 1 (x) = ( 2 n+ 1 −x)Ln(x)−nLn− 1 (x). Similalry, ...
...
Chapter 3 Numerical differentiation and interpolation AbstractNumerical integration and differentiation are some of the most fre ...
46 3 Numerical differentiation and interpolation where the suffix 2 refers to the fact that we are using two points to define th ...
3.1 Numerical Differentiation 47 ✲ f(x) x ✻ x 0 − 2 h x 0 −h x 0 x 0 +h x 0 + 2 h Fig. 3.1Demonstration of the subdivision of th ...
48 3 Numerical differentiation and interpolation To show this for the first and second derivatives starting with the three point ...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf