mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-03-24 13:53:35 +08:00
Documentation for 8a368240e2
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
||||
<meta name="generator" content="Doxygen 1.10.0"/>
|
||||
<meta name="generator" content="Doxygen 1.12.0"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>Algorithms_in_C++: numerical_methods/ode_forward_euler.cpp File Reference</title>
|
||||
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
|
||||
@@ -11,9 +11,9 @@
|
||||
<script type="text/javascript" src="../../dynsections.js"></script>
|
||||
<script type="text/javascript" src="../../clipboard.js"></script>
|
||||
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="../../resize.js"></script>
|
||||
<script type="text/javascript" src="../../navtreedata.js"></script>
|
||||
<script type="text/javascript" src="../../navtree.js"></script>
|
||||
<script type="text/javascript" src="../../resize.js"></script>
|
||||
<script type="text/javascript" src="../../cookie.js"></script>
|
||||
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="../../search/searchdata.js"></script>
|
||||
@@ -43,18 +43,23 @@ MathJax.Hub.Config({
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.10.0 -->
|
||||
<!-- Generated by Doxygen 1.12.0 -->
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
var searchBox = new SearchBox("searchBox", "../../search/",'.html');
|
||||
/* @license-end */
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
$(function() { codefold.init(1); });
|
||||
/* @license-end */
|
||||
</script>
|
||||
<script type="text/javascript" src="../../menudata.js"></script>
|
||||
<script type="text/javascript" src="../../menu.js"></script>
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
$(function() {
|
||||
initMenu('../../',true,false,'search.php','Search');
|
||||
initMenu('../../',true,false,'search.php','Search',true);
|
||||
$(function() { init_search(); });
|
||||
});
|
||||
/* @license-end */
|
||||
@@ -73,7 +78,7 @@ $(function() {
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
$(function(){initNavTree('db/dd3/ode__forward__euler_8cpp.html','../../'); initResizable(); });
|
||||
$(function(){initNavTree('db/dd3/ode__forward__euler_8cpp.html','../../'); initResizable(true); });
|
||||
/* @license-end */
|
||||
</script>
|
||||
<div id="doc-content">
|
||||
@@ -140,19 +145,19 @@ Functions</h2></td></tr>
|
||||
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
||||
<div class="textblock"><p>Solve a multivariable first order <a href="https://en.wikipedia.org/wiki/Ordinary_differential_equation" target="_blank">ordinary differential equation (ODEs)</a> using <a href="https://en.wikipedia.org/wiki/Numerical_methods_for_ordinary_differential_equations#Euler_method" target="_blank">forward Euler method</a> </p>
|
||||
<dl class="section author"><dt>Authors</dt><dd><a href="https://github.com/kvedala" target="_blank">Krishna Vedala</a> </dd></dl>
|
||||
<p>The ODE being solved is: </p><p class="formulaDsp">
|
||||
<p>The ODE being solved is: </p><p class="formulaDsp">
|
||||
\begin{eqnarray*}
|
||||
\dot{u} &=& v\\
|
||||
\dot{v} &=& -\omega^2 u\\
|
||||
\omega &=& 1\\
|
||||
[x_0, u_0, v_0] &=& [0,1,0]\qquad\ldots\text{(initial values)}
|
||||
\end{eqnarray*}
|
||||
\dot{u} &=& v\\
|
||||
\dot{v} &=& -\omega^2 u\\
|
||||
\omega &=& 1\\
|
||||
[x_0, u_0, v_0] &=& [0,1,0]\qquad\ldots\text{(initial values)}
|
||||
\end{eqnarray*}
|
||||
</p>
|
||||
<p> The exact solution for the above problem is: </p><p class="formulaDsp">
|
||||
<p> The exact solution for the above problem is: </p><p class="formulaDsp">
|
||||
\begin{eqnarray*}
|
||||
u(x) &=& \cos(x)\\
|
||||
v(x) &=& -\sin(x)\\
|
||||
\end{eqnarray*}
|
||||
u(x) &=& \cos(x)\\
|
||||
v(x) &=& -\sin(x)\\
|
||||
\end{eqnarray*}
|
||||
</p>
|
||||
<p> The computation results are stored to a text file <code>forward_euler.csv</code> and the exact soltuion results in <code>exact.csv</code> for comparison. <img src="https://raw.githubusercontent.com/TheAlgorithms/C-Plus-Plus/docs/images/numerical_methods/ode_forward_euler.svg" alt="Implementation solution" style="pointer-events: none;" class="inline"/></p>
|
||||
<p>To implement <a href="https://en.wikipedia.org/wiki/Van_der_Pol_oscillator" target="_blank">Van der Pol oscillator</a>, change the <a class="el" href="#abaeae8f62a018d197f0187a1c80a90fe" title="Problem statement for a system with first-order differential equations. Updates the system differenti...">problem</a> function to: </p><div class="fragment"><div class="line"><span class="keyword">const</span> <span class="keywordtype">double</span> mu = 2.0;</div>
|
||||
@@ -169,7 +174,7 @@ v(x) &=& -\sin(x)\\
|
||||
<tr>
|
||||
<td class="memname">void exact_solution </td>
|
||||
<td>(</td>
|
||||
<td class="paramtype">const double &</td> <td class="paramname"><span class="paramname"><em>x</em>, </span></td>
|
||||
<td class="paramtype">const double &</td> <td class="paramname"><span class="paramname"><em>x</em></span>, </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramkey"></td>
|
||||
@@ -210,12 +215,12 @@ Here is the call graph for this function:</div>
|
||||
<tr>
|
||||
<td class="memname">int main </td>
|
||||
<td>(</td>
|
||||
<td class="paramtype">int</td> <td class="paramname"><span class="paramname"><em>argc</em>, </span></td>
|
||||
<td class="paramtype">int</td> <td class="paramname"><span class="paramname"><em>argc</em></span>, </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramkey"></td>
|
||||
<td></td>
|
||||
<td class="paramtype">char *</td> <td class="paramname"><span class="paramname"><em>argv</em>[]</span> )</td>
|
||||
<td class="paramtype">char *</td> <td class="paramname"><span class="paramname"><em>argv</em></span>[] )</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
@@ -266,12 +271,12 @@ Here is the call graph for this function:</div>
|
||||
<tr>
|
||||
<td class="memname">void problem </td>
|
||||
<td>(</td>
|
||||
<td class="paramtype">const double &</td> <td class="paramname"><span class="paramname"><em>x</em>, </span></td>
|
||||
<td class="paramtype">const double &</td> <td class="paramname"><span class="paramname"><em>x</em></span>, </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramkey"></td>
|
||||
<td></td>
|
||||
<td class="paramtype"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray</a>< double > *</td> <td class="paramname"><span class="paramname"><em>y</em>, </span></td>
|
||||
<td class="paramtype"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray</a>< double > *</td> <td class="paramname"><span class="paramname"><em>y</em></span>, </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramkey"></td>
|
||||
@@ -308,17 +313,17 @@ Here is the call graph for this function:</div>
|
||||
<tr>
|
||||
<td class="memname">void save_exact_solution </td>
|
||||
<td>(</td>
|
||||
<td class="paramtype">const double &</td> <td class="paramname"><span class="paramname"><em>X0</em>, </span></td>
|
||||
<td class="paramtype">const double &</td> <td class="paramname"><span class="paramname"><em>X0</em></span>, </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramkey"></td>
|
||||
<td></td>
|
||||
<td class="paramtype">const double &</td> <td class="paramname"><span class="paramname"><em>X_MAX</em>, </span></td>
|
||||
<td class="paramtype">const double &</td> <td class="paramname"><span class="paramname"><em>X_MAX</em></span>, </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramkey"></td>
|
||||
<td></td>
|
||||
<td class="paramtype">const double &</td> <td class="paramname"><span class="paramname"><em>step_size</em>, </span></td>
|
||||
<td class="paramtype">const double &</td> <td class="paramname"><span class="paramname"><em>step_size</em></span>, </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramkey"></td>
|
||||
@@ -386,7 +391,7 @@ Here is the call graph for this function:</div>
|
||||
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
||||
<ul>
|
||||
<li class="navelem"><a class="el" href="../../dir_9c6faab82c22511b50177aa2e38e2780.html">numerical_methods</a></li><li class="navelem"><a class="el" href="../../db/dd3/ode__forward__euler_8cpp.html">ode_forward_euler.cpp</a></li>
|
||||
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.10.0 </li>
|
||||
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.12.0 </li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user