<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="mathml.xsl"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg-flat.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head>
<title>Data Analysis</title>
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>

<body>

<h2>APPROXIMATION OF FUNCTIONS BY SERIES</h2>

<p>Let us approximate
<math xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>y</mi><mo>(</mo><mi>x</mi><mo>)</mo></mrow></math>
by a linear combination of functions
<math xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msub><mi>&Phi;</mi><mi>n</mi></msub><mo>(</mo><mi>x</mi><mo>)</mo></mrow></math></p>

<table class="equ"><tr>
<td class="equ">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mrow><mi>y</mi><mo>(</mo><mi>x</mi><mo>)</mo></mrow>
<mo>=</mo>
<msub><mi>a</mi><mn>1</mn></msub>
<mrow><msub><mi>&Phi;</mi><mn>1</mn></msub><mo>(</mo><mi>x</mi><mo>)</mo></mrow>
<mo>+</mo>
<mo>&hellip;</mo>
<mo>+</mo>
<msub><mi>a</mi><mi>i</mi></msub>
<mrow><msub><mi>&Phi;</mi><mi>i</mi></msub><mo>(</mo><mi>x</mi><mo>)</mo></mrow>
<mo>+</mo>
<mo>&hellip;</mo>
<mo>+</mo>
<msub><mi>a</mi><mi>n</mi></msub>
<mrow><msub><mi>&Phi;</mi><mi>n</mi></msub><mo>(</mo><mi>x</mi><mo>)</mo></mrow>
</math>
</td>
<td class="equnum">
(2.1)
</td>
</tr></table>


<p>by the least square method (the square error is minimum),</p>

<table class="equ"><tr>
<td class="equ">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mi>E</mi>
<mo>=</mo>
<munderover>
 <mo>&int;</mo>
 <mi>a</mi>
 <mi>b</mi>
</munderover>
<msup>
 <mrow><mo>[</mo>
  <mrow><mi>y</mi><mo>(</mo><mi>x</mi><mo>)</mo></mrow>
  <mo>-</mo>
  <msub><mi>a</mi><mn>1</mn></msub>
  <mrow><msub><mi>&Phi;</mi><mn>1</mn></msub><mo>(</mo><mi>x</mi><mo>)</mo></mrow>
  <mo>+</mo>
  <mo>&hellip;</mo>
  <mo>+</mo>
  <msub><mi>a</mi><mi>i</mi></msub>
  <mrow><msub><mi>&Phi;</mi><mi>i</mi></msub><mo>(</mo><mi>x</mi><mo>)</mo></mrow>
  <mo>+</mo>
  <mo>&hellip;</mo>
  <mo>+</mo>
  <msub><mi>a</mi><mi>n</mi></msub>
  <mrow><msub><mi>&Phi;</mi><mi>n</mi></msub><mo>(</mo><mi>x</mi><mo>)</mo></mrow>
 <mo>]</mo></mrow>
 <mn>2</mn>
</msup>
<mi>d</mi><mi>x</mi>
<mo>=</mo>
<mi>min</mi>
<mo>.</mo>
</math>
</td>
<td class="equnum">
(2.2)
</td>
</tr></table>


<p>For a discrete set of data <math xmlns="http://www.w3.org/1998/Math/MathML"><msub><mi>y</mi><mi>j</mi></msub></math>,
<math xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>j</mi><mo>=</mo><mn>1</mn><mo>,</mo><mn>2</mn><mo>,</mo><mo>&hellip;</mo><mo>,</mo><mi>r</mi></mrow></math>
is given by a column matrix <math xmlns="http://www.w3.org/1998/Math/MathML"><mi mathvariant="bold">Y</mi></math>,
the set of coefficients <math xmlns="http://www.w3.org/1998/Math/MathML"><msub><mi>a</mi><mi>i</mi></msub></math>
by a column matrix <math xmlns="http://www.w3.org/1998/Math/MathML"><mi mathvariant="bold">A</mi></math>,
<math xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>i</mi><mo>=</mo><mn>1</mn><mo>,</mo><mn>2</mn><mo>,</mo><mo>&hellip;</mo><mo>,</mo><mi>n</mi></mrow></math>
and a rectangular matrix <math xmlns="http://www.w3.org/1998/Math/MathML"><mi mathvariant="bold">&Phi;</mi></math>
with elements <math xmlns="http://www.w3.org/1998/Math/MathML"><msub><mi>&Phi;</mi><mrow><mi>i</mi><mi>j</mi></mrow></msub></math>
corresponds to values at points
<math xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>j</mi><mo>&Delta;</mo><mi>x</mi></mrow></math>,
in <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>i</mi></math> columns.
In the discrete case the square error is</p>

<table class="equ"><tr>
<td class="equ">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mi>E</mi>
<mo>=</mo>
<mrow>
 <munderover>
  <mo>&sum;</mo>
  <mrow><mi>j</mi><mo>=</mo><mn>1</mn></mrow>
  <mi>r</mi>
 </munderover>
</mrow>
 <msup>
  <mrow><mo>[</mo>
   <msub><mi>y</mi><mi>j</mi></msub>
   <mo>-</mo>
   <mrow>
    <munderover>
     <mo>&sum;</mo>
     <mrow><mi>i</mi><mo>=</mo><mn>1</mn></mrow>
     <mi>n</mi>
    </munderover>
    <msub> <mi>&Phi;</mi> <mrow><mi>i</mi><mi>j</mi></mrow> </msub>
    <msub> <mi>a</mi> <mi>i</mi> </msub>
   </mrow>
  <mo>]</mo></mrow>
  <mn>2</mn>
 </msup>
<mo>=</mo>
<msup>
 <mrow><mo>[</mo>
  <mi mathvariant="bold">Y</mi>
  <mo>-</mo>
  <mi mathvariant="bold">&Phi;</mi><mi mathvariant="bold">A</mi>
 <mo>]</mo></mrow>
 <mo>T</mo>
</msup>
<mrow><mo>[</mo>
 <mi mathvariant="bold">Y</mi>
 <mo>-</mo>
 <mi mathvariant="bold">&Phi;</mi><mi mathvariant="bold">A</mi>
<mo>]</mo></mrow>
<mo>=</mo>
<mi>min</mi>
<mo>.</mo>
</math>
</td>
<td class="equnum">(2.3)</td>
</tr></table>

<p>In the case <math xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>n</mi><mo>=</mo><mi>r</mi></mrow></math>,
<math xmlns="http://www.w3.org/1998/Math/MathML"><mi mathvariant="bold">&Phi;</mi></math> 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 <math xmlns="http://www.w3.org/1998/Math/MathML"><mi mathvariant="bold">A</mi></math> is the solution of
the following linear equation</p>

<table class="equ"><tr>
<td class="equ">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mi mathvariant="bold">&Phi;</mi><mi mathvariant="bold">A</mi>
<mo>=</mo>
<mi mathvariant="bold">Y</mi>
<mo>.</mo>
</math>
</td>
<td class="equnum">(2.4)</td>
</tr></table>

<p>In the case <math xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>n</mi><mo>&gt;</mo><mi>r</mi></mrow></math>
we have more equations than unknowns the differentiation with respect to 
<math xmlns="http://www.w3.org/1998/Math/MathML"><msub><mi>a</mi><mi>i</mi></msub></math>
leads to the following expression</p>

<table class="equ"><tr>
<td class="equ">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mrow>
 <munderover>
  <mo>&sum;</mo>
  <mrow><mi>j</mi><mo>=</mo><mn>1</mn></mrow>
  <mi>r</mi>
 </munderover> 
 <msub><mi>&Phi;</mi><mrow><mi>j</mi><mi>s</mi></mrow></msub>
</mrow>
<mrow>
 <munderover>
  <mo>&sum;</mo>
  <mrow><mi>i</mi><mo>=</mo><mn>1</mn></mrow>
  <mi>n</mi>
 </munderover>
 <msub><mi>&Phi;</mi><mrow><mi>j</mi><mi>i</mi></mrow></msub>
 <msub><mi>a</mi><mi>i</mi></msub>
</mrow>
<mo>=</mo>
<mrow>
 <munderover>
  <mo>&sum;</mo>
  <mrow><mi>j</mi><mo>=</mo><mn>1</mn></mrow>
  <mi>r</mi>
 </munderover>
 <msub><mi>&Phi;</mi><mrow><mi>j</mi><mi>s</mi></mrow></msub>
 <msub><mi>y</mi><mi>j</mi></msub>
</mrow>
<mo>.</mo>
</math>
</td>
<td class="equnum">(2.5)</td>
</tr></table>

<p>It corresponds to the following matrix equation</p>

<table class="equ"><tr>
<td class="equ">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
 <msup><mi mathvariant="bold">&Phi;</mi><mo>T</mo></msup>
 <mi mathvariant="bold">&Phi;</mi>
 <mi mathvariant="bold">A</mi>
 <mo>=</mo>
 <msup><mi mathvariant="bold">&Phi;</mi><mo>T</mo></msup>
 <mi mathvariant="bold">Y</mi>
<mo>.</mo>
</math>
</td>
<td class="equnum">(2.6)</td>
</tr></table>

<p>The relative error is
<math xmlns="http://www.w3.org/1998/Math/MathML">
 <msqrt>
  <mi>E</mi><mo>/</mo>
  <mrow><mo>(</mo><msup><mi mathvariant="bold">Y</mi><mo>T</mo></msup><mi mathvariant="bold">Y</mi><mo>)</mo></mrow>
 </msqrt>
</math>.</p>


<p>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</p>

<table class="equ"><tr>
<td class="equ">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mtable columnalign="left"> 
 <mtr><mtd> 
   <mrow><mi>E</mi><mo>(</mo><mi>a</mi><mo>,</mo><mi>b</mi><mo>,</mo><mi>f</mi><mo>,</mo><mi>&eta;</mi><mo>)</mo></mrow>
   <mo>=</mo>
   <mrow>
    <munderover>
     <mo>&int;</mo>
     <mi>0</mi>
     <msub><mi>t</mi><mi>k</mi></msub>
    </munderover>
    <mrow><mi>f</mi><mo>(</mo><mi>a</mi><mo>,</mo><mi>b</mi><mo>,</mo><mi>f</mi><mo>,</mo><mi>&eta;</mi><mo>,</mo><mi>t</mi><mo>)</mo></mrow>
    <mi>d</mi><mi>t</mi>
   </mrow>
 </mtd></mtr> 
 <mtr><mtd> 
   <mo>=</mo>
   <mrow>
    <munderover>
     <mo>&int;</mo>
     <mi>0</mi>
     <msub><mi>t</mi><mi>k</mi></msub>
    </munderover>
    <msup>
     <mrow><mo>[</mo>
       <mrow><mi>y</mi><mo>(</mo><mi>t</mi><mo>)</mo></mrow>
       <mo>-</mo>
       <mi>a</mi>
       <msup><mi>e</mi><mrow><mo>-</mo><mi>&eta;</mi><mi>t</mi></mrow></msup>
       <mrow><mi>cos</mi><mo>(</mo><mn>2</mn><mi>&pi;</mi><mi>f</mi><mi>t</mi><mo>)</mo></mrow>
       <mo>-</mo>
       <mi>b</mi>
       <msup><mi>e</mi><mrow><mo>-</mo><mi>&eta;</mi><mi>t</mi></mrow></msup>
       <mrow><mi>sin</mi><mo>(</mo><mn>2</mn><mi>&pi;</mi><mi>f</mi><mi>t</mi><mo>)</mo></mrow>
     <mo>]</mo></mrow>
     <mn>2</mn>
    </msup>
    <mi>d</mi><mi>t</mi>
   </mrow>
  </mtd></mtr> 
</mtable> 
</math>
</td>
<td class="equnum">(2.7)</td>
</tr></table>

<p>should be minimum. In the integral
<math xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>y</mi><mo>(</mo><mi>x</mi><mo>)</mo></mrow></math>
is known <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>a</mi></math> and
<math xmlns="http://www.w3.org/1998/Math/MathML"><mi>b</mi></math> are displacements
of the terms, <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>f</mi></math> is the
frequency in Hz and <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>&eta;</mi></math>
is the damping coefficient in 1/s. It is convenient to introduce the following notation:
<math xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msub><mi>x</mi><mn>1</mn></msub><mo>=</mo><mi>a</mi></mrow></math>,
<math xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msub><mi>x</mi><mn>2</mn></msub><mo>=</mo><mi>b</mi></mrow></math>,
<math xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msub><mi>x</mi><mn>3</mn></msub><mo>=</mo><mi>f</mi></mrow></math>,
<math xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msub><mi>x</mi><mn>4</mn></msub><mo>=</mo><mi>&eta;</mi></mrow></math>,
</p>

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

<table class="equ"><tr>
<td class="equ">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mfrac>
 <mrow><mi>&part;</mi><mi>E</mi></mrow>
 <mrow><mi>&part;</mi><msub><mi>x</mi><mi>i</mi></msub></mrow>
</mfrac>
<mo>=</mo>
<mn>0</mn>
<mo rspace="2em">,</mo>
<mi>i</mi><mo>=</mo><mn>1</mn><mo>&hellip;</mo><mn>4</mn>
</math>
</td>
<td class="equnum">(2.8)</td>
</tr></table>


<p>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.</p>

<table class="equ"><tr>
<td class="equ">
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mtable columnalign="left">
 <mtr><mtd>

 <mi>f</mi>
 <mo>&ap;</mo>
 <mrow><mi>f</mi><mo>(</mo><msub><mi>x</mi><mn>1</mn></msub><mo>,</mo><mo>&hellip;</mo><mo>,</mo><mi>t</mi><mo>)</mo></mrow>
 <mo>+</mo>
 <mrow><mo>[</mo>
  <mrow><munderover>
   <mo>&sum;</mo>
   <mrow><mi>j</mi><mo>=</mo><mn>1</mn></mrow>
   <mn>4</mn>
  </munderover></mrow>
  <mi>&Delta;</mi><msub><mi>x</mi><mi>j</mi></msub>
  <mfrac>
   <mo>&part;</mo>
   <mrow><mo>&part;</mo><msub><mi>x</mi><mi>j</mi></msub></mrow>
  </mfrac>
 <mo>]</mo></mrow>
 <mrow><mi>f</mi><mo>(</mo><msub><mi>x</mi><mn>1</mn></msub><mo>,</mo><mo>&hellip;</mo><mo>,</mo><mi>t</mi><mo>)</mo></mrow>
 </mtd></mtr>
 
 <mtr><mtd>
 <mphantom>
  <mi>f</mi>
  <mo>&ap;</mo>
  <mrow><mi>f</mi><mo>(</mo><msub><mi>x</mi><mn>1</mn></msub><mo>,</mo><mo>&hellip;</mo><mo>,</mo><mi>t</mi><mo>)</mo></mrow>
 </mphantom>
 <mo>+</mo>
 <mfrac><mn>1</mn><mn>2</mn></mfrac>
 <msup>
  <mrow><mo>[</mo>
   <mrow><munderover>
    <mo>&sum;</mo>
    <mrow><mi>j</mi><mo>=</mo><mn>1</mn></mrow>
    <mn>4</mn>
   </munderover></mrow>
   <mi>&Delta;</mi><msub><mi>x</mi><mi>j</mi></msub>
   <mfrac><mo>&part;</mo><mrow><mo>&part;</mo><msub><mi>x</mi><mi>j</mi></msub></mrow></mfrac>
  <mo>]</mo></mrow>
  <mn>2</mn>
 </msup>
 <mrow><mi>f</mi><mo>(</mo><msub><mi>x</mi><mn>1</mn></msub><mo>,</mo><mo>&hellip;</mo><mo>,</mo><mi>t</mi><mo>)</mo></mrow>
 </mtd></mtr>
</mtable>
</math>
</td>
<td class="equnum">(2.9)</td>
</tr></table>

<p>Upon substitution and integration the function <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>E</mi></math>
is a function of known (assumed) initial values
<math xmlns="http://www.w3.org/1998/Math/MathML"><msub><mi>x</mi><mn>1</mn></msub><mo>,</mo><mo>&hellip;</mo><mo>,</mo><msub><mi>x</mi><mn>4</mn></msub></math>
and the unknown increments 
<math xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mo>&Delta;</mo><msub><mi>x</mi><mn>1</mn></msub></mrow><mo>,</mo><mo>&hellip;</mo><mo>,</mo><mrow><mo>&Delta;</mo><msub><mi>x</mi><mn>4</mn></msub></mrow></math>.
It is a second order power series in the increments. To minimize the value of the square error
the partial derivatives with respect to
<math xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mo>&Delta;</mo><msub><mi>x</mi><mi>i</mi></msub></mrow></math>
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

<math xmlns="http://www.w3.org/1998/Math/MathML">
 <mrow>
  <msub><mi>x</mi><mi>i</mi></msub>
  <mo>+</mo>
  <mo>&Delta;</mo>
  <msub><mi>x</mi><mi>i</mi></msub>
  <mo>&rarr;</mo>
  <msub><mi>x</mi><mi>i</mi></msub>
  <mo>,</mo>
 </mrow>
 <mrow>
  <mi>i</mi><mo>=</mo><mn>1</mn><mo>&hellip;</mo><mn>4</mn>
 </mrow>
</math>.</p>

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


<h3>Numerical examples</h3>

<p><b>Example 1</b><br />

The script file <tt>pwoprp03</tt> 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.</p>

<p><b>Download</b><br />
Scilab: <a href="pwoprp03.sci"><tt>pwoprp03.sci</tt></a>, <a href="unwrap.sci"><tt>unwrap.sci</tt></a>, <a href="ellipj.sci"><tt>ellipj.sci</tt></a>, <a href="ellipke.sci"><tt>ellipke.sci</tt></a><br />
Octave/Matlab: <a href="pwoprp03.m"><tt>pwoprp03.m</tt></a>
</p>

<p><b>Example 2</b><br />

The script file <tt>pwoprq03</tt> 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.</p>

<p><b>Download</b><br />
Scilab: <a href="pwoprq03.sci"><tt>pwoprq03.sci</tt></a>, <a href="unwrap.sci"><tt>unwrap.sci</tt></a>, <a href="ellipj.sci"><tt>ellipj.sci</tt></a>, <a href="ellipke.sci"><tt>ellipke.sci</tt></a><br />
Octave/Matlab: <a href="pwoprq03.m"><tt>pwoprq03.m</tt></a>
</p>


<p><b>Example 3</b><br />

The script file <tt>pwoprr03</tt> 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.</p>

<p><b>Download</b><br />
Scilab: <a href="pwoprr03.sci"><tt>pwoprr03.sci</tt></a>, <a href="ellipj.sci"><tt>ellipj.sci</tt></a><br />
Octave/Matlab: <a href="pwoprr03.m"><tt>pwoprr03.m</tt></a>
</p>


<p><b>Example 4</b><br />

The script file <tt>pwoprt03</tt> approximates damped free vibrations by the
expression for linear not damped oscillations and damped vibrations.
The iterations converge.</p>

<p><b>Download</b><br />
Scilab: <a href="pwoprt03.sci"><tt>pwoprt03.sci</tt></a><br />
Octave/Matlab: <a href="pwoprt03.m"><tt>pwoprt03.m</tt></a>
</p>


<p><b>Example 5</b><br />

Script file <tt>pwoprv03</tt> 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).</p>

<p><b>Download</b><br />
Scilab: <a href="pwoprv03.sci"><tt>pwoprv03.sci</tt></a><br />
Octave/Matlab: <a href="pwoprv03.m"><tt>pwoprv03.m</tt></a>
</p>

</body>
</html>


