<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd" [ <!ENTITY mathml "http://www.w3.org/1998/Math/MathML"> ]>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Integrating a system of de's (Differential Equations)</title>
<meta http-equiv="Content-Type" content="text/xml; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<link rel="stylesheet" type="text/css" href="../documentation/s011.css" />
<link rel='SHORTCUT ICON' href='../documentation/images/FrameHome.ico' />
</head>

<body>

<div class="message_right">
  <a href="http://validator.w3.org/check/referer">
    <img src="http://www.w3.org/Icons/valid-xhtml11" alt="Valid
	XHTML 1.1!" height="31" width="88" />
  </a>

  <a href="http://jigsaw.w3.org/css-validator/">
    <img style="width:88px;height:31px"
       src="http://jigsaw.w3.org/css-validator/images/vcss" 
       alt="Valid CSS!" />
  </a>
  <br />
  Created 2004-01-01 &nbsp; Modified 
<!--UPDATE_DATE_BEGIN-->
2009-04-11<br />
<a class="reflocal" href="../../../../doc02.html">Chelton Evans</a>

<!--UPDATE_DATE_END-->
</div>

<h1> 
<a href="../doc.html">
<img alt="proj" src="../../../comsci/images/code.png" /> </a>
nintegration  
<a href="../../../../index.html">
<img alt="home" src="../../../comsci/images/Frame.gif" /> </a>
</h1>

<p>

<a class="reflocal2" href="#Intro">Intro</a><br />
<a class="reflocal2" href="#TODO">TODO</a><br />
<a class="reflocal2" href="#Source">Source</a><br />
<a class="reflocal2" href="#What_is_an_Infinitesimal">
  What is an Infinitesimal</a><br />
<a class="reflocal2" href="#Example">Example</a><br />
<a class="reflocal2" href="#Equation_Ordering">
  Equation Ordering</a><br />
</p>

<div class="float25">

<a id="Intro"> </a>
<h2> Intro</h2>

<p>
<a class="reflocal" href="../../../math/calculus/calc030.xml">
 Numerical Integration </a>  of a system of de's (Differential Equations).  
</p>

<p>
Integrating a system of de's (differential equations) is
 important in modeling systems and 
 hence simulating physical events. 
</p>

<p>
The <code> DEsys </code>
 is a very general numerical integration of de's class.
 It relies on the client configuring the data and 
 functions, indeed the interface needs close examination.
</p>

<p>
The class was generalized to higher dimensions making it useful.
 For systems with greater than one dimension the infinitesimals 
 will need to see other system variables,
 which are public to <code>DEsys</code>. 
</p>

</div>
<div class="float25">

<p> 
Letting the client define there own integration methods
 is really versatile, and if you want just a good one
 then use <code>RK</code> for "plug and play".
</p> 

<ul>
<li> Tested on a second order de and a two variable system.
</li>
<li> Templated component architecture. 
 Virtual functional objects used. 
</li>

</ul>

</div>

<!--UPDATE_SOURCE_TABLE-->
<!--UPDATE_SOURCE_TABLE_BEGIN-->
<div class="float25">
<a id="Source"> </a>
<h2> <a class="reflocal" href="../../download.html">Source</a> </h2>
<h3> Files </h3>
<a class="reflocal" href="Makefile">Makefile</a> <br/>
<a class="reflocal" href="desys.h">desys.h</a> <br/>
<a class="reflocal" href="desystest.cpp">desystest.cpp</a> <br/>
<a class="reflocal" href="desystest.h">desystest.h</a> <br/>
<a class="reflocal" href="desystestspring2.cpp">desystestspring2.cpp</a> <br/>
<a class="reflocal" href="desystestspring2.h">desystestspring2.h</a> <br/>
<a class="reflocal" href="main.cpp">main.cpp</a> <br/>
<a class="reflocal" href="nintegration.h">nintegration.h</a> <br/>
<br/>
<a class="reflocal" href="gnup001.txt">gnup001.txt</a> <br/>
<a class="reflocal" href="gnup002.txt">gnup002.txt</a> <br/>
<a class="reflocal" href="myfile.txt">myfile.txt</a> <br/>
<a class="reflocal" href="projcompile.txt">projcompile.txt</a> <br/>
<a class="reflocal" href="testscript001.txt">testscript001.txt</a> <br/>
<a class="reflocal" href="unittestsreport.txt">unittestsreport.txt</a> <br/>
<br/>
</div>
<div class="float25">
<h3> Doxygen </h3>
<a class="reflocal" href="../html/nintegration_2main_8cpp.html">main.cpp</a> <br/>
<a class="reflocal" href="Makefile.html"> Makefile </a> <br/>
<a class="reflocal" href="../html/classdesys.html">desys</a> <br/>
<a class="reflocal" href="../html/classdesystest.html">desystest</a> <br/>
<a class="reflocal" href="../html/classdesystestspring2.html">desystestspring2</a> <br/>
<a class="reflocal" href="../html/classnintegrationEuler.html">nintegrationEuler</a> <br/>
<a class="reflocal" href="../html/classnintegrationRK.html">nintegrationRK</a> <br/>
<a class="reflocal" href="../html/classnintegrationTrapezoidEuler.html">nintegrationTrapezoidEuler</a> <br/>
</div>
<!--UPDATE_SOURCE_TABLE_END-->

<div class="float25">

<a id="What_is_an_Infinitesimal"> </a>
<h2> What is an Infinitesimal </h2>

<p>
Something very small, a magnitude smaller than other numbers
 around. 
</p>

</div>
<div class="float25">

<a id="Example"></a>
<h2> Example </h2>

<p class="equ">
<math xmlns="&mathml;">
  <mi>y''</mi>
  <mo>+</mo>
  <mi>y</mi>
  <mo>=</mo>
  <mi>0</mi>
</math>

<br />

<math xmlns="&mathml;">
  <mi>y</mi>
  <mo>(</mo>
  <mi>0</mi>
  <mo>)</mo>
  <mo>=</mo>
  <mi>1</mi> 
</math>

 and 

<math xmlns="&mathml;">
  <mi>y'</mi>
  <mo>(</mo>
  <mi>0</mi>
  <mo>)</mo>
  <mo>=</mo>
  <mi>0</mi>
</math>

 <br />

 has the solution <br />

<math xmlns="&mathml;">
  <mi>y</mi>
  <mo>=</mo>
  <mi>cos</mi>
  <mi>x</mi>
</math>

</p>

<p>
By testing the integration methods against a known solution
 it could be determined whether the solution was being approximated.
</p>

<p>
The testing for a system of de's was done by transforming 
 the above system into a coupled system.
</p>

<p class="equ">
  Let 

<math xmlns="&mathml;">
  <mi>z</mi>
  <mo>=</mo>
  <mi>y'</mi>
</math>

 then <br />

<math xmlns="&mathml;">
  <mi>y'</mi>
  <mo>=</mo>
  <mi>z</mi>
</math>

 and 

<math xmlns="&mathml;">
  <mi>z'</mi>
  <mo>=</mo>
  <mo>-</mo>
  <mi>y</mi>
</math>

<br />

<math xmlns="&mathml;">
  <mi>y</mi>
  <mo>(</mo>
  <mi>0</mi>
  <mo>)</mo>
  <mo>=</mo>
  <mi>1</mi>
</math>

 and

<math xmlns="&mathml;">
  <mi>z</mi>
  <mo>(</mo>
  <mi>0</mi>
  <mo>)</mo>
  <mo>=</mo>
  <mi>0</mi>
</math>

</p>

</div>
<div class="float25">

<a id="History"></a>
<h2>History</h2>

<table>
<tr>
<td>
<a href="img001.png"><img src="img001.png" width="200" alt="" /></a>
<br />
<code>$ ./main prog=5 xmax=50 sample=100 h=0.0001 <br />
$ gnuplot <a class="reflocal" href="gnup002.txt">gnup002.txt</a> </code>
</td>
</tr>
</table>

</div>
<div class="float25">

<a id="Equation_Ordering"> </a>
<h2> Equation Ordering </h2>

<p>
Does the ordering of equations influence the solution?
 I conjectured that it did but the example de gave interesting
 results.
</p>

<p>
 The de solver is an order driven system (the first
 dimension is solved, then the second, ... ) its pretty
 accurate though its not the sort of thing discussed in a 
 maths degree. 
</p>

<p>
For example if you convert a single
 variable de to a system of de's, what ordering (if any)
 of variables has the highest accuracy? 
</p>

<p>
I solved the example de 3 ways. The first two were as given
 in the example where the second order de was reduced to two
 equations. These first order equations were solved.
</p>
 
<p>
The third way was as one second order de with the first
 derivative integrated and other derivatives having Euler method 
 applied. Since Euler's method was being used as the integrator
 this was exactly the same as one of the previous ways. 
 It differed not in results but implementation.
</p>

<table>
<tr> <td> x0=0.0 &nbsp; xmax=0.3 &nbsp;  h=0.01  </td> <td> </td> </tr>
<tr> <td> Error </td> <td> Method </td> </tr>
<tr> <td> .00147751 </td> <td> 2 first order equ, y and z. </td> </tr>
<tr> <td> -.00147848 </td> <td> 2 first order equ, z and y. </td> </tr>
</table>

<p>
What is surprising about these results is that if you sum the errors
 you get a number 3 orders of magnitude less. You do not have to
 be Einstein to realize that summing the two solutions and taking
 the average will give you
 possibly 3 orders of magnitude more accuracy for double the 
 cost.
</p>

</div>
<div class="float25">

<p>
TODO<br />
This is a gain. If you incorporate it into a new integrator
 it would yield one more order of magnitude to give you 4.
 So for this particular de the order of equations can be
 used.  However for 3 equations there are 3!=6 possible orderings
 and another approach may be better. Also is this some property
 of the particular equation under investigation?
</p>

<p>
Lets assume that this can be generalized so that for n 
 equations there
 are n! ways of integrating. Maybe combinations 
 or other things could
 be used to reduce this a bit. Now assume an ideal 
 parallel computer/s.
  The algorithm could be done in parallel.
</p>

<p>
The idea could be used to write new approximators 
 locally as I have 
 been inferring.  The experiment used separate integrators.  
 Is 100 places
 of accuracy possible?
</p>

</div>
<div class="float25">

<a id="TODO"></a>
<h2> TODO </h2>

<ul>

<li>Higher Order Approximators<br />
Interpolate the second derivative. y[n+1] = y[n] + hf(x[n],y[n]) + h^2/2*g(x[n],y[n],dy[n])) 
</li>
<li>Macro of 1D k'th order de's<br />
Let client just put in class name and function into macro.
</li>

<li>Orbiting planet<br />
how long before EL method breaks down, how many iterations
 before RK breaks down - no longer sinusoidal behavior.
</li>

<li>Physics problems<br />
 As time evolves use this class in simulation and
 de calculation.  <br />
 non-linear pendulum simulation<br />
 springs <br />
 wave equation <br />
 visualize by reproducing the data or plotting
 the direction field.
</li>

</ul>

</div>

</body>
</html>


