mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-03-25 14:23:03 +08:00
Documentation for 0931d530ae
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.9.5"/>
|
||||
<meta name="generator" content="Doxygen 1.9.6"/>
|
||||
<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"/>
|
||||
@@ -41,7 +41,7 @@ MathJax.Hub.Config({
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.9.5 -->
|
||||
<!-- Generated by Doxygen 1.9.6 -->
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
var searchBox = new SearchBox("searchBox", "../../search/",'.html');
|
||||
@@ -120,16 +120,16 @@ Include dependency graph for ode_forward_euler.cpp:</div>
|
||||
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
|
||||
Functions</h2></td></tr>
|
||||
<tr class="memitem:abaeae8f62a018d197f0187a1c80a90fe"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="../../db/dd3/ode__forward__euler_8cpp.html#abaeae8f62a018d197f0187a1c80a90fe">problem</a> (const double &x, <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray</a>< double > *y, <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray</a>< double > *dy)</td></tr>
|
||||
<tr class="memdesc:abaeae8f62a018d197f0187a1c80a90fe"><td class="mdescLeft"> </td><td class="mdescRight">Problem statement for a system with first-order differential equations. Updates the system differential variables. <a href="../../db/dd3/ode__forward__euler_8cpp.html#abaeae8f62a018d197f0187a1c80a90fe">More...</a><br /></td></tr>
|
||||
<tr class="memdesc:abaeae8f62a018d197f0187a1c80a90fe"><td class="mdescLeft"> </td><td class="mdescRight">Problem statement for a system with first-order differential equations. Updates the system differential variables. <br /></td></tr>
|
||||
<tr class="separator:abaeae8f62a018d197f0187a1c80a90fe"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:af3adf7b092a87868917ee5fb4255192b"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="../../db/dd3/ode__forward__euler_8cpp.html#af3adf7b092a87868917ee5fb4255192b">exact_solution</a> (const double &x, <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray</a>< double > *y)</td></tr>
|
||||
<tr class="memdesc:af3adf7b092a87868917ee5fb4255192b"><td class="mdescLeft"> </td><td class="mdescRight">Exact solution of the problem. Used for solution comparison. <a href="../../db/dd3/ode__forward__euler_8cpp.html#af3adf7b092a87868917ee5fb4255192b">More...</a><br /></td></tr>
|
||||
<tr class="memdesc:af3adf7b092a87868917ee5fb4255192b"><td class="mdescLeft"> </td><td class="mdescRight">Exact solution of the problem. Used for solution comparison. <br /></td></tr>
|
||||
<tr class="separator:af3adf7b092a87868917ee5fb4255192b"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:ga195d23bbdfcb80e83c9cda45c9ad5723"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/d60/group__ode.html#ga195d23bbdfcb80e83c9cda45c9ad5723">forward_euler_step</a> (const double dx, const double x, <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray</a>< double > *y, <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray</a>< double > *dy)</td></tr>
|
||||
<tr class="memdesc:ga195d23bbdfcb80e83c9cda45c9ad5723"><td class="mdescLeft"> </td><td class="mdescRight">Compute next step approximation using the forward-Euler method. <a href="../../d6/d60/group__ode.html#ga195d23bbdfcb80e83c9cda45c9ad5723">More...</a><br /></td></tr>
|
||||
<tr class="memdesc:ga195d23bbdfcb80e83c9cda45c9ad5723"><td class="mdescLeft"> </td><td class="mdescRight">Compute next step approximation using the forward-Euler method. <br /></td></tr>
|
||||
<tr class="separator:ga195d23bbdfcb80e83c9cda45c9ad5723"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:gae0509f8843e2bc42de2abbd00a14b7b9"><td class="memItemLeft" align="right" valign="top">double </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d6/d60/group__ode.html#gae0509f8843e2bc42de2abbd00a14b7b9">forward_euler</a> (double dx, double x0, double x_max, <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray</a>< double > *y, bool save_to_file=false)</td></tr>
|
||||
<tr class="memdesc:gae0509f8843e2bc42de2abbd00a14b7b9"><td class="mdescLeft"> </td><td class="mdescRight">Compute approximation using the forward-Euler method in the given limits. <a href="../../d6/d60/group__ode.html#gae0509f8843e2bc42de2abbd00a14b7b9">More...</a><br /></td></tr>
|
||||
<tr class="memdesc:gae0509f8843e2bc42de2abbd00a14b7b9"><td class="mdescLeft"> </td><td class="mdescRight">Compute approximation using the forward-Euler method in the given limits. <br /></td></tr>
|
||||
<tr class="separator:gae0509f8843e2bc42de2abbd00a14b7b9"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:aa13517b8e5de1b75592052db7f7e237f"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="../../db/dd3/ode__forward__euler_8cpp.html#aa13517b8e5de1b75592052db7f7e237f">save_exact_solution</a> (const double &X0, const double &X_MAX, const double &step_size, const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/valarray.html">std::valarray</a>< double > &Y0)</td></tr>
|
||||
<tr class="separator:aa13517b8e5de1b75592052db7f7e237f"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
@@ -137,7 +137,7 @@ Functions</h2></td></tr>
|
||||
<tr class="separator:a0ddf1224851353fc92bfbff6f499fa97"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
</table>
|
||||
<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>
|
||||
<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">
|
||||
\begin{eqnarray*}
|
||||
@@ -154,7 +154,7 @@ 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="../../db/dd3/ode__forward__euler_8cpp.html#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>
|
||||
<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="../../db/dd3/ode__forward__euler_8cpp.html#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>
|
||||
<div class="line">dy[0] = y[1];</div>
|
||||
<div class="line">dy[1] = mu * (1.f - y[0] * y[0]) * y[1] - y[0];</div>
|
||||
</div><!-- fragment --> <dl class="section see"><dt>See also</dt><dd><a class="el" href="../../d6/dd3/ode__midpoint__euler_8cpp.html" title="Solve a multivariable first order ordinary differential equation (ODEs) using midpoint Euler method">ode_midpoint_euler.cpp</a>, <a class="el" href="../../d3/d06/ode__semi__implicit__euler_8cpp.html" title="Solve a multivariable first order ordinary differential equation (ODEs) using semi implicit Euler met...">ode_semi_implicit_euler.cpp</a> </dd></dl>
|
||||
@@ -233,7 +233,7 @@ Here is the call graph for this function:</div>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
<p >Main Function </p>
|
||||
<p>Main Function </p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 189</span> {</div>
|
||||
<div class="line"><span class="lineno"> 190</span> <span class="keywordtype">double</span> X0 = 0.f; <span class="comment">/* initial value of x0 */</span></div>
|
||||
<div class="line"><span class="lineno"> 191</span> <span class="keywordtype">double</span> X_MAX = 10.F; <span class="comment">/* upper limit of integration */</span></div>
|
||||
@@ -359,7 +359,7 @@ Here is the call graph for this function:</div>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
<p >Function to compute and save exact solution for comparison</p>
|
||||
<p>Function to compute and save exact solution for comparison</p>
|
||||
<dl class="params"><dt>Parameters</dt><dd>
|
||||
<table class="params">
|
||||
<tr><td class="paramdir">[in]</td><td class="paramname">X0</td><td>initial value of independent variable </td></tr>
|
||||
@@ -419,7 +419,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.9.5 </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.9.6 </li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user