APPROXIMATION OF FUNCTIONS BY SERIES

Let us approximate y(x) by a linear combination of functions Φn(x)

y(x) = a1 Φ1(x) + + ai Φi(x) + + an Φn(x) (2.1)

by the least square method (the square error is minimum),

E = a b [ y(x) - a1 Φ1(x) + + ai Φi(x) + + an Φn(x) ] 2 dx = min . (2.2)

For a discrete set of data yj, j=1,2,,r is given by a column matrix Y, the set of coefficients ai by a column matrix A, i=1,2,,n and a rectangular matrix Φ with elements Φij corresponds to values at points jΔx, in i columns. In the discrete case the square error is

E = j=1 r [ yj - i=1 n Φ ij a i ] 2 = [ Y - ΦA ] T [ Y - ΦA ] = min . (2.3)

In the case n=r, Φ is a square matrix and if it is not singular, the error is minimum if the expression in the square brackets is zero. It follows A is the solution of the following linear equation

ΦA = Y . (2.4)

In the case n>r we have more equations than unknowns the differentiation with respect to ai leads to the following expression

j=1 r Φjs i=1 n Φji ai = j=1 r Φjs yj . (2.5)

It corresponds to the following matrix equation

ΦT Φ A = ΦT Y . (2.6)

The relative error is E/ (YTY) .

Let us consider the approximation of measured damped free vibrations by the solution of the linear theory. Thus for the case of one degree of freedom the square error

E(a,b,f,η) = 0 tk f(a,b,f,η,t) dt = 0 tk [ y(t) - a e-ηt cos(2πft) - b e-ηt sin(2πft) ] 2 dt (2.7)

should be minimum. In the integral y(x) is known a and b are displacements of the terms, f is the frequency in Hz and η is the damping coefficient in 1/s. It is convenient to introduce the following notation: x1=a, x2=b, x3=f, x4=η,

The necessary condition that the square error is minimum corresponds to the condition that all partial derivatives are zero

E xi = 0 , i=14 (2.8)

The problem is solved usually by iterations. The choice of estimated initial values is very important to obtain a convergent procedure. A simple and traditional method of approach is to expand the function under the integral in Taylor series and to consider three terms only.

f f(x1,,t) + [ j=1 4 Δxj xj ] f(x1,,t) f f(x1,,t) + 12 [ j=1 4 Δxj xj ] 2 f(x1,,t) (2.9)

Upon substitution and integration the function E is a function of known (assumed) initial values x1,,x4 and the unknown increments Δx1,,Δx4. It is a second order power series in the increments. To minimize the value of the square error the partial derivatives with respect to Δxi should be zero. This condition leads to four linear equations that, if the determinant is not singular, yield the values of the increments. The new value of the estimates is equal to the sum of the previous estimates and the calculated increments xi + Δ xi xi , i=14 .

If the procedure converges, the step by step procedure leads to small values of the square error, that are satisfactory for the considered problem.

Numerical examples

Example 1
The script file pwoprp03 calculates the Fourier series of a periodic soliton as a function of time for different shifts in space x and compares with solutions of approximations by trigonometric functions. The solutions when the orthogonal properties of the set of functions are not used are better.

Download
Scilab: pwoprp03.sci, unwrap.sci, ellipj.sci, ellipke.sci
Octave/Matlab: pwoprp03.m

Example 2
The script file pwoprq03 calculates the Fourier series of a periodic soliton and discusses the problem of taking s points less compared with the perfect period. The approximation is not sensitive to such errors.

Download
Scilab: pwoprq03.sci, unwrap.sci, ellipj.sci, ellipke.sci
Octave/Matlab: pwoprq03.m

Example 3
The script file pwoprr03 calculates the Fourier series of a periodic soliton and discusses the problem when additionally two and three periods are considered. Such a change does not change a solution for a perfect period.

Download
Scilab: pwoprr03.sci, ellipj.sci
Octave/Matlab: pwoprr03.m

Example 4
The script file pwoprt03 approximates damped free vibrations by the expression for linear not damped oscillations and damped vibrations. The iterations converge.

Download
Scilab: pwoprt03.sci
Octave/Matlab: pwoprt03.m

Example 5
Script file pwoprv03 is used to study the measured damped vibrations. The column matrix of measured values is denoted by Y, its elements by Y(r). We introduce the following column matrices E(r)=exp(-x3*r*dt), C(r)=cos(2*pi*x4*r*dt),S(r)=sin(2*pi*x4*r*dt), R(r)=r*dt; We introduce the following notations: EC=E.*C, ES=E.*S, REC=R.*EC, RES=R.*REC, RREC=R.*REC, RRES=R.*RES. The column matrix of errors is EY=Y-x1*EC-x2*ES, the mean square error is a scalar EJ=EY'*EY; The variance of Y is V=mean(Y'*Y) and thus the relative error is RE=sqrt(EJ/V).

Download
Scilab: pwoprv03.sci
Octave/Matlab: pwoprv03.m