Computational Physics - Department of Physics
3.1 Numerical Differentiation 49 3.1.1 The second derivative ofexp(x). As an example, let us calculate the second derivatives of ...
50 3 Numerical differentiation and interpolation 21 return; 22 }// end function func There are several features to be noted. Li ...
3.1 Numerical Differentiation 51 i = 10;// n is changed to 10 .... } Note well that the way we have defined the input to the fun ...
52 3 Numerical differentiation and interpolation double x, initial_step; doubleh_step,computed_derivative; // read in input data ...
3.1 Numerical Differentiation 53 // Read in from screen the initial step, the number of steps // and the value of x voidinitiali ...
54 3 Numerical differentiation and interpolation An alternative is represented by the following C++ program.This program reads f ...
3.1 Numerical Differentiation 55 * while the last function prints out data to screen. / using namespacestd; include include incl ...
56 3 Numerical differentiation and interpolation One of the problems with C++ is that formatted output is not aseasy to use as t ...
3.1 Numerical Differentiation 57 computed_derivative(loop) = (EXP(x+h)-2.*EXP(x)+EXP(x-h))/(h*h) h = h*0.5 ENDDO END SUBROUTINEd ...
58 3 Numerical differentiation and interpolation similar treatments of arrays in C++. By default however, these features are not ...
3.1 Numerical Differentiation 59 Relative error log 10 (h) ε -14 -12 -10 -8 -6 -4 -2 0 6 4 2 0 -2 -4 -6 -8 -10 Fig. 3.2Log-log p ...
60 3 Numerical differentiation and interpolation most likely the point where roundoff errors take over. If we had used single pr ...
3.2 Numerical Interpolation and Extrapolation 61 3.2.1 Interpolation Let us assume that we have a set ofN+ 1 pointsy 0 =f(x 0 ), ...
62 3 Numerical differentiation and interpolation f(N+^1 )(ξ) (N+ 1 )! (x−x 1 )(x−x 2 )...(x−xN). The quantity f 0 x= f(x)−f(x 0 ...
3.2 Numerical Interpolation and Extrapolation 63 Therafter we construct the unique polynomial of order one which passes through ...
64 3 Numerical differentiation and interpolation 3.2.2 Richardson’s deferred extrapolation method Here we present an elegant met ...
3.3 Classes in C++ 65 D( 0 k)=D(h/ 2 k). This means thatD( 10 )in the second column and row is the result of the extrapolation b ...
66 3 Numerical differentiation and interpolation In Ansi C and C++ arrays start by default fromi= 0. Moreover, if we wish to add ...
3.3 Classes in C++ 67 3.3.1 The Complex class As remarked in chapter 2, C++ has a class complex in its standard template library ...
68 3 Numerical differentiation and interpolation intmain () { Complex a(0.1,1.3);// we declare a complex variable a Complex b(3. ...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf