<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="HTMLFiles/pmathml.xsl"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "HTMLFiles/xhtml1-transitional.dtd">

<!-- This HTML document was created by converting a Mathematica notebook using Export. -->


<html xmlns="http://www.w3.org/1999/xhtml" class="Notebook">

<head >
<title>
  symnum.nb
</title>

<link href="../navi/css/ratk.css" rel="stylesheet" type="text/css"/>
<link href="HTMLFiles/Default.css" rel="stylesheet" type="text/css" />
</head>

<body>

<p><a href="../mma/symnum.nb">symnum.nb</a></p>

<p class="Title">
 Differentiaaliyht&auml;l&ouml;n ratkaiseminen Mathematicalla numeerisesti
</p>



<p class="Text">
 Differentiaaliyht&auml;l&ouml;n numeerisen ratkaisemisen edellytyksen&auml; on, ett&auml; kyseess&auml; on <span style='font-style: italic;'>alkuarvoprobleema</span>, ts. annettuna on sek&auml; differentiaaliyht&auml;l&ouml; ett&auml; alkuehto. Etsitt&auml;v&auml; ratkaisu on yksik&auml;sitteinen eik&auml; sis&auml;ll&auml; m&auml;&auml;r&auml;&auml;m&auml;tt&ouml;mi&auml; vakioita.
</p>



<p class="Text">
 Tarkoitusta varten on <span style='font-family: Courier;'>NDSolve</span>-komento, jonka syntaksi on hyvin samanlainen kuin algebrallisen ratkaisemisen <span style='font-family: Courier;'>DSolve</span>-komennon. Ainoana erona on, ett&auml; viimeisess&auml; argumentissa on annettava my&ouml;s muuttujan <span><math xmlns='http://www.w3.org/1998/Math/MathML'
    mathematica:form='TraditionalForm'
    xmlns:mathematica='http://www.wolfram.com/XML/'>
 <mi>x</mi>
</math></span> v&auml;li, jolla ratkaisua etsit&auml;&auml;n. Ratkaisu on mahdollista saada lausekkeen tai funktion muodossa.
</p>



<p class="Subtitle">
 Ratkaisu lausekkeena
</p>



<p class="CellLabel">
 In[1]:=
</p>



<p class="Input">
 <math xmlns='http://www.w3.org/1998/Math/MathML'>
 <mrow>
  <mi>diffyht</mi>
  <mo>=</mo>
  <mtext> </mtext>
  <mrow>
   <mrow>
    <mrow>
     <mi>y</mi>
     <mo>&apos;</mo>
    </mrow>
    <mo>[</mo>
    <mi>x</mi>
    <mo>]</mo>
   </mrow>
   <mtext> </mtext>
   <mo>==</mo>
   <mtext> </mtext>
   <mrow>
    <mrow>
     <mi>x</mi>
     <mo>^</mo>
     <mn>2</mn>
    </mrow>
    <mtext> </mtext>
    <mo>-</mo>
    <mtext> </mtext>
    <mrow>
     <mrow>
      <mi>y</mi>
      <mo>[</mo>
      <mi>x</mi>
      <mo>]</mo>
     </mrow>
     <mo>^</mo>
     <mn>2</mn>
    </mrow>
   </mrow>
  </mrow>
 </mrow>
</math>
</p>

<p class="CellLabel">
 Out[1]=
</p>



<p class="Output">
 <math xmlns='http://www.w3.org/1998/Math/MathML'>
 <mrow>
  <mrow>
   <msup>
    <mi>y</mi>
    <mo>&#8242;</mo>
   </msup>
   <mo>[</mo>
   <mi>x</mi>
   <mo>]</mo>
  </mrow>
  <mo>&#10869;</mo>
  <mrow>
   <msup>
    <mi>x</mi>
    <mn>2</mn>
   </msup>
   <mo>-</mo>
   <msup>
    <mrow>
     <mi>y</mi>
     <mo>[</mo>
     <mi>x</mi>
     <mo>]</mo>
    </mrow>
    <mn>2</mn>
   </msup>
  </mrow>
 </mrow>
</math>
</p>

<p class="CellLabel">
 In[2]:=
</p>



<p class="Input">
 <math xmlns='http://www.w3.org/1998/Math/MathML'>
 <mrow>
  <mi>alkuehto</mi>
  <mo>=</mo>
  <mtext> </mtext>
  <mrow>
   <mrow>
    <mi>y</mi>
    <mo>[</mo>
    <mn>0</mn>
    <mo>]</mo>
   </mrow>
   <mtext> </mtext>
   <mo>==</mo>
   <mtext> </mtext>
   <mn>1</mn>
  </mrow>
 </mrow>
</math>
</p>

<p class="CellLabel">
 Out[2]=
</p>



<p class="Output">
 <math xmlns='http://www.w3.org/1998/Math/MathML'>
 <mrow>
  <mrow>
   <mi>y</mi>
   <mo>[</mo>
   <mn>0</mn>
   <mo>]</mo>
  </mrow>
  <mo>&#10869;</mo>
  <mn>1</mn>
 </mrow>
</math>
</p>

<p class="CellLabel">
 In[3]:=
</p>



<p class="Input">
 <math xmlns='http://www.w3.org/1998/Math/MathML'>
 <mrow>
  <mi>ratkaisulauseke</mi>
  <mo>=</mo>
  <mtext> </mtext>
  <mrow>
   <mi>NDSolve</mi>
   <mo>[</mo>
   <mrow>
    <mrow>
     <mo>{</mo>
     <mrow>
      <mi>diffyht</mi>
      <mo>,</mo>
      <mi>alkuehto</mi>
     </mrow>
     <mo>}</mo>
    </mrow>
    <mo>,</mo>
    <mrow>
     <mi>y</mi>
     <mo>[</mo>
     <mi>x</mi>
     <mo>]</mo>
    </mrow>
    <mo>,</mo>
    <mrow>
     <mo>{</mo>
     <mrow>
      <mi>x</mi>
      <mo>,</mo>
      <mn>0</mn>
      <mo>,</mo>
      <mn>5</mn>
     </mrow>
     <mo>}</mo>
    </mrow>
   </mrow>
   <mo>]</mo>
  </mrow>
 </mrow>
</math>
</p>

<p class="CellLabel">
 Out[3]=
</p>



<p class="Output">
 <math xmlns='http://www.w3.org/1998/Math/MathML'>
 <mrow>
  <mo>{</mo>
  <mrow>
   <mo>{</mo>
   <mrow>
    <mrow>
     <mi>y</mi>
     <mo>[</mo>
     <mi>x</mi>
     <mo>]</mo>
    </mrow>
    <mo>&#8594;</mo>
    <mrow>
     <mrow>
      <mi>InterpolatingFunction</mi>
      <mo>[</mo>
      <mrow>
       <mrow>
        <mo>{</mo>
        <mrow>
         <mo>{</mo>
         <mrow>
          <mn>0.</mn>
          <mo>,</mo>
          <mn>5.</mn>
         </mrow>
         <mo>}</mo>
        </mrow>
        <mo>}</mo>
       </mrow>
       <mo>,</mo>
       <mo>&lt;&gt;</mo>
      </mrow>
      <mo>]</mo>
     </mrow>
     <mo>[</mo>
     <mi>x</mi>
     <mo>]</mo>
    </mrow>
   </mrow>
   <mo>}</mo>
  </mrow>
  <mo>}</mo>
 </mrow>
</math>
</p>

<p class="CellLabel">
 In[4]:=
</p>



<p class="Input">
 <math xmlns='http://www.w3.org/1998/Math/MathML'>
 <mrow>
  <mi>ylauseke</mi>
  <mo>=</mo>
  <mtext> </mtext>
  <mrow>
   <mrow>
    <mi>y</mi>
    <mo>[</mo>
    <mi>x</mi>
    <mo>]</mo>
   </mrow>
   <mo>/.</mo>
   <mrow>
    <mi>First</mi>
    <mo>[</mo>
    <mi>ratkaisulauseke</mi>
    <mo>]</mo>
   </mrow>
  </mrow>
 </mrow>
</math>
</p>

<p class="CellLabel">
 Out[4]=
</p>



<p class="Output">
 <math xmlns='http://www.w3.org/1998/Math/MathML'>
 <mrow>
  <mrow>
   <mi>InterpolatingFunction</mi>
   <mo>[</mo>
   <mrow>
    <mrow>
     <mo>{</mo>
     <mrow>
      <mo>{</mo>
      <mrow>
       <mn>0.</mn>
       <mo>,</mo>
       <mn>5.</mn>
      </mrow>
      <mo>}</mo>
     </mrow>
     <mo>}</mo>
    </mrow>
    <mo>,</mo>
    <mo>&lt;&gt;</mo>
   </mrow>
   <mo>]</mo>
  </mrow>
  <mo>[</mo>
  <mi>x</mi>
  <mo>]</mo>
 </mrow>
</math>
</p>

<p class="Text">
 Ratkaisu saadaan tarkkaa ratkaisua approksimoivana interpolaatiofunktiona. Hieman erikoisesta esitystavasta huolimatta t&auml;m&auml; on kuin mik&auml; tahansa muuttujan <span><math xmlns='http://www.w3.org/1998/Math/MathML'
    mathematica:form='TraditionalForm'
    xmlns:mathematica='http://www.wolfram.com/XML/'>
 <mi>x</mi>
</math></span> sis&auml;lt&auml;v&auml; lauseke:
</p>



<p class="CellLabel">
 In[5]:=
</p>



<p class="Input">
 <math xmlns='http://www.w3.org/1998/Math/MathML'>
 <mrow>
  <mi>ylauseke</mi>
  <mo>/.</mo>
  <mrow>
   <mi>x</mi>
   <mo>-&gt;</mo>
   <mn>0.8</mn>
  </mrow>
 </mrow>
</math>
</p>

<p class="CellLabel">
 Out[5]=
</p>



<p class="Output">
 <math xmlns='http://www.w3.org/1998/Math/MathML'>
 <mn>0.6897478137556293</mn>
</math>
</p>

<p class="CellLabel">
 In[6]:=
</p>



<p class="Input">
 <math xmlns='http://www.w3.org/1998/Math/MathML'>
 <mrow>
  <mi>derivlauseke</mi>
  <mo>=</mo>
  <mtext> </mtext>
  <mrow>
   <mi>D</mi>
   <mo>[</mo>
   <mrow>
    <mi>ylauseke</mi>
    <mo>,</mo>
    <mi>x</mi>
   </mrow>
   <mo>]</mo>
  </mrow>
 </mrow>
</math>
</p>

<p class="CellLabel">
 Out[6]=
</p>



<p class="Output">
 <math xmlns='http://www.w3.org/1998/Math/MathML'>
 <mrow>
  <mrow>
   <mi>InterpolatingFunction</mi>
   <mo>[</mo>
   <mrow>
    <mrow>
     <mo>{</mo>
     <mrow>
      <mo>{</mo>
      <mrow>
       <mn>0.</mn>
       <mo>,</mo>
       <mn>5.</mn>
      </mrow>
      <mo>}</mo>
     </mrow>
     <mo>}</mo>
    </mrow>
    <mo>,</mo>
    <mo>&lt;&gt;</mo>
   </mrow>
   <mo>]</mo>
  </mrow>
  <mo>[</mo>
  <mi>x</mi>
  <mo>]</mo>
 </mrow>
</math>
</p>

<p class="CellLabel">
 In[7]:=
</p>



<p class="Input">
 <math xmlns='http://www.w3.org/1998/Math/MathML'>
 <mrow>
  <mi>derivlauseke</mi>
  <mo>/.</mo>
  <mrow>
   <mi>x</mi>
   <mo>-&gt;</mo>
   <mn>0.8</mn>
  </mrow>
 </mrow>
</math>
</p>

<p class="CellLabel">
 Out[7]=
</p>



<p class="Output">
 <math xmlns='http://www.w3.org/1998/Math/MathML'>
 <mn>0.16424828872789649</mn>
</math>
</p>

<p class="CellLabel">
 In[8]:=
</p>



<p class="Input">
 <math xmlns='http://www.w3.org/1998/Math/MathML'>
 <mrow>
  <mi>Plot</mi>
  <mo>[</mo>
  <mrow>
   <mi>ylauseke</mi>
   <mo>,</mo>
   <mrow>
    <mo>{</mo>
    <mrow>
     <mi>x</mi>
     <mo>,</mo>
     <mn>0</mn>
     <mo>,</mo>
     <mn>5</mn>
    </mrow>
    <mo>}</mo>
   </mrow>
   <mo>,</mo>
   <mrow>
    <mi>AspectRatio</mi>
    <mo>-&gt;</mo>
    <mi>Automatic</mi>
   </mrow>
  </mrow>
  <mo>]</mo>
 </mrow>
</math>
</p>

<p class="Graphics">
 <img src="HTMLFiles/symnum_1.gif"  border="0"  alt="[Graphics:HTMLFiles/symnum_1.gif]"  width="288" height="282"  align="absmiddle"  />
</p>

<p class="CellLabel">
 Out[8]=
</p>



<p class="Output">
 <math xmlns='http://www.w3.org/1998/Math/MathML'>
 <mrow>
  <mo>&#8259;</mo>
  <mo>&#8290;</mo>
  <mi>Graphics</mi>
  <mo>&#8290;</mo>
  <mo>&#8259;</mo>
 </mrow>
</math>
</p>

<p class="Subtitle">
 Ratkaisu funktiona
</p>



<p class="CellLabel">
 In[9]:=
</p>



<p class="Input">
 <math xmlns='http://www.w3.org/1998/Math/MathML'>
 <mrow>
  <mi>ratkaisufunktio</mi>
  <mo>=</mo>
  <mtext> </mtext>
  <mrow>
   <mi>NDSolve</mi>
   <mo>[</mo>
   <mrow>
    <mrow>
     <mo>{</mo>
     <mrow>
      <mi>diffyht</mi>
      <mo>,</mo>
      <mi>alkuehto</mi>
     </mrow>
     <mo>}</mo>
    </mrow>
    <mo>,</mo>
    <mi>y</mi>
    <mo>,</mo>
    <mrow>
     <mo>{</mo>
     <mrow>
      <mi>x</mi>
      <mo>,</mo>
      <mn>0</mn>
      <mo>,</mo>
      <mn>5</mn>
     </mrow>
     <mo>}</mo>
    </mrow>
   </mrow>
   <mo>]</mo>
  </mrow>
 </mrow>
</math>
</p>

<p class="CellLabel">
 Out[9]=
</p>



<p class="Output">
 <math xmlns='http://www.w3.org/1998/Math/MathML'>
 <mrow>
  <mo>{</mo>
  <mrow>
   <mo>{</mo>
   <mrow>
    <mi>y</mi>
    <mo>&#8594;</mo>
    <mrow>
     <mi>InterpolatingFunction</mi>
     <mo>[</mo>
     <mrow>
      <mrow>
       <mo>{</mo>
       <mrow>
        <mo>{</mo>
        <mrow>
         <mn>0.</mn>
         <mo>,</mo>
         <mn>5.</mn>
        </mrow>
        <mo>}</mo>
       </mrow>
       <mo>}</mo>
      </mrow>
      <mo>,</mo>
      <mo>&lt;&gt;</mo>
     </mrow>
     <mo>]</mo>
    </mrow>
   </mrow>
   <mo>}</mo>
  </mrow>
  <mo>}</mo>
 </mrow>
</math>
</p>

<p class="CellLabel">
 In[10]:=
</p>



<p class="Input">
 <math xmlns='http://www.w3.org/1998/Math/MathML'>
 <mrow>
  <mi>y0</mi>
  <mo>=</mo>
  <mtext> </mtext>
  <mrow>
   <mi>y</mi>
   <mo>/.</mo>
   <mrow>
    <mi>First</mi>
    <mo>[</mo>
    <mi>ratkaisufunktio</mi>
    <mo>]</mo>
   </mrow>
  </mrow>
 </mrow>
</math>
</p>

<p class="CellLabel">
 Out[10]=
</p>



<p class="Output">
 <math xmlns='http://www.w3.org/1998/Math/MathML'>
 <mrow>
  <mi>InterpolatingFunction</mi>
  <mo>[</mo>
  <mrow>
   <mrow>
    <mo>{</mo>
    <mrow>
     <mo>{</mo>
     <mrow>
      <mn>0.</mn>
      <mo>,</mo>
      <mn>5.</mn>
     </mrow>
     <mo>}</mo>
    </mrow>
    <mo>}</mo>
   </mrow>
   <mo>,</mo>
   <mo>&lt;&gt;</mo>
  </mrow>
  <mo>]</mo>
 </mrow>
</math>
</p>

<p class="Text">
 Kyseess&auml; on aito funktio:
</p>



<p class="CellLabel">
 In[11]:=
</p>



<p class="Input">
 <math xmlns='http://www.w3.org/1998/Math/MathML'>
 <mrow>
  <mi>y0</mi>
  <mo>[</mo>
  <mn>0.8</mn>
  <mo>]</mo>
 </mrow>
</math>
</p>

<p class="CellLabel">
 Out[11]=
</p>



<p class="Output">
 <math xmlns='http://www.w3.org/1998/Math/MathML'>
 <mn>0.6897478137556293</mn>
</math>
</p>

<p class="CellLabel">
 In[12]:=
</p>



<p class="Input">
 <math xmlns='http://www.w3.org/1998/Math/MathML'>
 <mrow>
  <mrow>
   <mi>y0</mi>
   <mo>&apos;</mo>
  </mrow>
  <mo>[</mo>
  <mn>0.8</mn>
  <mo>]</mo>
 </mrow>
</math>
</p>

<p class="CellLabel">
 Out[12]=
</p>



<p class="Output">
 <math xmlns='http://www.w3.org/1998/Math/MathML'>
 <mn>0.16424828872789649</mn>
</math>
</p>

<p class="CellLabel">
 In[13]:=
</p>



<p class="Input">
 <math xmlns='http://www.w3.org/1998/Math/MathML'>
 <mrow>
  <mi>Integrate</mi>
  <mo>[</mo>
  <mrow>
   <mrow>
    <mi>y0</mi>
    <mo>[</mo>
    <mi>x</mi>
    <mo>]</mo>
   </mrow>
   <mo>,</mo>
   <mrow>
    <mo>{</mo>
    <mrow>
     <mi>x</mi>
     <mo>,</mo>
     <mn>0</mn>
     <mo>,</mo>
     <mn>5</mn>
    </mrow>
    <mo>}</mo>
   </mrow>
  </mrow>
  <mo>]</mo>
 </mrow>
</math>
</p>

<p class="CellLabel">
 Out[13]=
</p>



<p class="Output">
 <math xmlns='http://www.w3.org/1998/Math/MathML'>
 <mn>11.89544335976352</mn>
</math>
</p>

<p class="Subtitle">
 <span style='font-family: Courier;'>NDSolve</span> ja <span style='font-family: Courier;text-decoration: none;'>InterpolatingFunction</span>
</p>



<p class="Text">
 Mathematican funktio <span style='font-family: Courier;'>NDSolve</span> k&auml;ytt&auml;&auml; alkuarvoprobleeman numeeriseen ratkaisemiseen erilaisia numeerisia algoritmeja yht&auml;l&ouml;st&auml; riippuen. N&auml;iden avulla saadaan ratkaisufunktion arvoille approksimaatiot <span><math xmlns='http://www.w3.org/1998/Math/MathML'
    mathematica:form='TraditionalForm'
    xmlns:mathematica='http://www.wolfram.com/XML/'>
 <msub>
  <mi>y</mi>
  <mi>k</mi>
 </msub>
</math></span> sopivasti valituissa pisteiss&auml; <span><math xmlns='http://www.w3.org/1998/Math/MathML'
    mathematica:form='TraditionalForm'
    xmlns:mathematica='http://www.wolfram.com/XML/'>
 <msub>
  <mi>x</mi>
  <mi>k</mi>
 </msub>
</math></span>.
</p>



<p class="Text">
 Elementti <span style='font-family: Courier;'>InterpolatingFunction</span> on interpoloiva funktio, joka perustuu Lagrangen ja Hermiten interpolaatiopolynomeihin. N&auml;iden laskeminen pohjautuu&nbsp;&nbsp;ratkaisua approksimoivaan pisteist&ouml;&ouml;n <span><math xmlns='http://www.w3.org/1998/Math/MathML'
    mathematica:form='TraditionalForm'
    xmlns:mathematica='http://www.wolfram.com/XML/'>
 <mrow>
  <mo>(</mo>
  <mrow>
   <msub>
    <mi>x</mi>
    <mi>k</mi>
   </msub>
   <mo>,</mo>
   <msub>
    <mi>y</mi>
    <mi>k</mi>
   </msub>
  </mrow>
  <mo>)</mo>
 </mrow>
</math></span>. Tarkemman k&auml;sityksen interpoloivan funktion sis&auml;lt&auml;m&auml;st&auml; informaatiosta saa komennolla <span style='font-family: Courier;'>FullForm</span>:
</p>



<p class="CellLabel">
 In[14]:=
</p>



<p class="Input">
 <math xmlns='http://www.w3.org/1998/Math/MathML'>
 <mrow>
  <mrow>
   <mi>ylauseke</mi>
   <mo>//</mo>
   <mi>FullForm</mi>
  </mrow>
  <mo>;</mo>
 </mrow>
</math>
</p>

<p class="Text">
 T&auml;m&auml;n tulostus on huomattavan pitk&auml;. Sen saa n&auml;kyviin poistamalla puolipisteen edell&auml; olevan sy&ouml;tteen lopusta ja ajamalla sy&ouml;tteen uudelleen.
</p>







<p><b>Linkkej&auml;</b></p>

<p>
 <a href="../xml/perrtk.xml">yleinen ja yksitt&auml;isratkaisu</a><br/>
 <a href="../xml/peralk.xml">alkuehto</a><br/>
 <a href="../xml/numper.xml">numeerisen ratkaisemisen perusidea</a><br/>
<a href="../xml_mma/symalg.xml">ratkaiseminen Mathematicalla algebrallisesti</a><br/>
</p>

<p style='font-style: italic;'>
 SKK 30.04.2001
</p>


<hr />
<p style='font-family: Helvetica; font-size: 8pt'>Created by
<a href="http://www.wolfram.com"><span style='font-style: italic'>Mathematica</span></a>
&nbsp;(July 21, 2004) </p>

</body>

</html>
