Documentation for 8b1eab204b

This commit is contained in:
realstealthninja
2024-11-04 12:43:05 +00:00
parent 4fb6e622e9
commit a7bccf7d01
6732 changed files with 153919 additions and 365711 deletions

View File

@@ -1,3 +1,4 @@
<!-- HTML header for doxygen 1.12.0-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
@@ -5,10 +6,15 @@
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.12.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Algorithms_in_C++: numerical_methods/brent_method_extrema.cpp File Reference</title>
<title>TheAlgorithms/C++: numerical_methods/brent_method_extrema.cpp File Reference</title>
<link rel="icon" href="../../favicon.svg" type="image/x-icon" />
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@xpack-3rd-party/doxygen-awesome-css@2.2.0-1/doxygen-awesome-darkmode-toggle.js"></script>
<script type="text/javascript">
DoxygenAwesomeDarkModeToggle.init()
</script>
<script type="text/javascript" src="../../clipboard.js"></script>
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../navtreedata.js"></script>
@@ -18,14 +24,24 @@
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
jax: ["input/TeX","output/HTML-CSS"],
});
<script type="text/javascript">
window.MathJax = {
options: {
ignoreHtmlClass: 'tex2jax_ignore',
processHtmlClass: 'tex2jax_process'
},
loader: {
load: ['[tex]/ams']
},
tex: {
macros: {},
packages: ['base','configmacros','ams']
}
};
</script>
<script type="text/javascript" async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML/MathJax.js"></script>
<script type="text/javascript" id="MathJax-script" async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
<link href="../../doxygen-awesome.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
@@ -33,10 +49,11 @@ MathJax.Hub.Config({
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectlogo"><img alt="Logo" src="../../project_logo.png"/></td>
<td id="projectalign">
<div id="projectname">Algorithms_in_C++<span id="projectnumber">&#160;1.0.0</span>
<div id="projectname">TheAlgorithms/C++<span id="projectnumber">&#160;1.0.0</span>
</div>
<div id="projectbrief">Set of algorithms implemented in C++.</div>
<div id="projectbrief">All the algorithms implemented in C++</div>
</td>
</tr>
</tbody>
@@ -124,12 +141,13 @@ Include dependency graph for brent_method_extrema.cpp:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d9/d0e/brent__method__extrema_8cpp__incl.svg" width="515" height="126"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
</div><table class="memberdecls">
</div>
<p><a href="../../db/d01/brent__method__extrema_8cpp_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="define-members" name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:a525335710b53cb064ca56b936120431e" id="r_a525335710b53cb064ca56b936120431e"><td class="memItemLeft" align="right" valign="top"><a id="a525335710b53cb064ca56b936120431e" name="a525335710b53cb064ca56b936120431e"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>_USE_MATH_DEFINES</b></td></tr>
<tr class="memdesc:a525335710b53cb064ca56b936120431e"><td class="mdescLeft">&#160;</td><td class="mdescRight">required for MS Visual C++ <br /></td></tr>
<tr class="memitem:a525335710b53cb064ca56b936120431e" id="r_a525335710b53cb064ca56b936120431e"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a525335710b53cb064ca56b936120431e">_USE_MATH_DEFINES</a></td></tr>
<tr class="memdesc:a525335710b53cb064ca56b936120431e"><td class="mdescLeft">&#160;</td><td class="mdescRight">required for MS Visual C++ <br /></td></tr>
<tr class="separator:a525335710b53cb064ca56b936120431e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a002b2f4894492820fe708b1b7e7c5e70" id="r_a002b2f4894492820fe708b1b7e7c5e70"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a002b2f4894492820fe708b1b7e7c5e70">EPSILON</a></td></tr>
<tr class="memdesc:a002b2f4894492820fe708b1b7e7c5e70"><td class="mdescLeft">&#160;</td><td class="mdescRight">system accuracy limit <br /></td></tr>
@@ -137,7 +155,7 @@ Macros</h2></td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a1aa76a6d5fd4d333f9072beff1dc486b" id="r_a1aa76a6d5fd4d333f9072beff1dc486b"><td class="memItemLeft" align="right" valign="top">double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a1aa76a6d5fd4d333f9072beff1dc486b">get_minima</a> (const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/functional/function.html">std::function</a>&lt; double(double)&gt; &amp;f, double lim_a, double lim_b)</td></tr>
<tr class="memitem:a1aa76a6d5fd4d333f9072beff1dc486b" id="r_a1aa76a6d5fd4d333f9072beff1dc486b"><td class="memItemLeft" align="right" valign="top">double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a1aa76a6d5fd4d333f9072beff1dc486b">get_minima</a> (const std::function&lt; double(double)&gt; &amp;f, double lim_a, double lim_b)</td></tr>
<tr class="memdesc:a1aa76a6d5fd4d333f9072beff1dc486b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the real root of a function in the given interval. <br /></td></tr>
<tr class="separator:a1aa76a6d5fd4d333f9072beff1dc486b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1440a7779ac56f47a3f355ce4a8c7da0" id="r_a1440a7779ac56f47a3f355ce4a8c7da0"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a1440a7779ac56f47a3f355ce4a8c7da0">test1</a> ()</td></tr>
@@ -162,7 +180,27 @@ Functions</h2></td></tr>
</blockquote>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="../../d6/d7a/golden__search__extrema_8cpp.html" title="Find extrema of a univariate real function in a given interval using golden section search algorithm.">golden_search_extrema.cpp</a></dd></dl>
<dl class="section author"><dt>Author</dt><dd><a href="https://github.com/kvedala" target="_blank">Krishna Vedala</a> </dd></dl>
<p class="definition">Definition in file <a class="el" href="../../db/d01/brent__method__extrema_8cpp_source.html">brent_method_extrema.cpp</a>.</p>
</div><h2 class="groupheader">Macro Definition Documentation</h2>
<a id="a525335710b53cb064ca56b936120431e" name="a525335710b53cb064ca56b936120431e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a525335710b53cb064ca56b936120431e">&#9670;&#160;</a></span>_USE_MATH_DEFINES</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define _USE_MATH_DEFINES</td>
</tr>
</table>
</div><div class="memdoc">
<p>required for MS Visual C++ </p>
<p class="definition">Definition at line <a class="el" href="../../db/d01/brent__method__extrema_8cpp_source.html#l00016">16</a> of file <a class="el" href="../../db/d01/brent__method__extrema_8cpp_source.html">brent_method_extrema.cpp</a>.</p>
</div>
</div>
<a id="a002b2f4894492820fe708b1b7e7c5e70" name="a002b2f4894492820fe708b1b7e7c5e70"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a002b2f4894492820fe708b1b7e7c5e70">&#9670;&#160;</a></span>EPSILON</h2>
@@ -174,15 +212,15 @@ Functions</h2></td></tr>
</tr>
</table>
</div><div class="memdoc">
<b>Value:</b><div class="fragment"><div class="line"> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/sqrt.html">std::sqrt</a>( \</div>
<div class="line"> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/types/numeric_limits.html">std::numeric_limits&lt;double&gt;::epsilon</a>())</div>
<div class="ttc" id="anumeric_limits_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/types/numeric_limits.html">std::numeric_limits</a></div></div>
<div class="ttc" id="asqrt_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/numeric/math/sqrt.html">std::sqrt</a></div><div class="ttdeci">T sqrt(T... args)</div></div>
<b>Value:</b><div class="fragment"><div class="line"> std::sqrt( \</div>
<div class="line"> std::numeric_limits&lt;double&gt;::epsilon())</div>
</div><!-- fragment -->
<p>system accuracy limit </p>
<p class="definition">Definition at line <a class="el" href="../../db/d01/brent__method__extrema_8cpp_source.html#l00024">24</a> of file <a class="el" href="../../db/d01/brent__method__extrema_8cpp_source.html">brent_method_extrema.cpp</a>.</p>
<div class="fragment"><div class="line"><span class="lineno"> 24</span><span class="preprocessor">#define EPSILON \</span></div>
<div class="line"><span class="lineno"> 25</span><span class="preprocessor"> std::sqrt( \</span></div>
<div class="line"><span class="lineno"> 26</span><span class="preprocessor"> std::numeric_limits&lt;double&gt;::epsilon()) </span><span class="comment">///&lt; system accuracy limit</span></div>
<div class="line"><span class="lineno"> 26</span><span class="preprocessor"> std::numeric_limits&lt;double&gt;::epsilon()) </span></div>
</div><!-- fragment -->
</div>
</div>
@@ -196,7 +234,7 @@ Functions</h2></td></tr>
<tr>
<td class="memname">double get_minima </td>
<td>(</td>
<td class="paramtype">const <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/functional/function.html">std::function</a>&lt; double(double)&gt; &amp;</td> <td class="paramname"><span class="paramname"><em>f</em></span>, </td>
<td class="paramtype">const std::function&lt; double(double)&gt; &amp;</td> <td class="paramname"><span class="paramname"><em>f</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
@@ -221,18 +259,20 @@ Functions</h2></td></tr>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>root found in the interval </dd></dl>
<p class="definition">Definition at line <a class="el" href="../../db/d01/brent__method__extrema_8cpp_source.html#l00036">36</a> of file <a class="el" href="../../db/d01/brent__method__extrema_8cpp_source.html">brent_method_extrema.cpp</a>.</p>
<div class="fragment"><div class="line"><span class="lineno"> 37</span> {</div>
<div class="line"><span class="lineno"> 38</span> uint32_t iters = 0;</div>
<div class="line"><span class="lineno"> 39</span> </div>
<div class="line"><span class="lineno"> 40</span> <span class="keywordflow">if</span> (lim_a &gt; lim_b) {</div>
<div class="line"><span class="lineno"> 41</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/swap.html">std::swap</a>(lim_a, lim_b);</div>
<div class="line"><span class="lineno"> 41</span> std::swap(lim_a, lim_b);</div>
<div class="line"><span class="lineno"> 42</span> } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (std::abs(lim_a - lim_b) &lt;= <a class="code hl_define" href="#a002b2f4894492820fe708b1b7e7c5e70">EPSILON</a>) {</div>
<div class="line"><span class="lineno"> 43</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cerr</a> &lt;&lt; <span class="stringliteral">&quot;Search range must be greater than &quot;</span> &lt;&lt; <a class="code hl_define" href="#a002b2f4894492820fe708b1b7e7c5e70">EPSILON</a> &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 43</span> std::cerr &lt;&lt; <span class="stringliteral">&quot;Search range must be greater than &quot;</span> &lt;&lt; <a class="code hl_define" href="#a002b2f4894492820fe708b1b7e7c5e70">EPSILON</a> &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 44</span> <span class="keywordflow">return</span> lim_a;</div>
<div class="line"><span class="lineno"> 45</span> }</div>
<div class="line"><span class="lineno"> 46</span> </div>
<div class="line"><span class="lineno"> 47</span> <span class="comment">// golden ratio value</span></div>
<div class="line"><span class="lineno"> 48</span> <span class="keyword">const</span> <span class="keywordtype">double</span> M_GOLDEN_RATIO = (3.f - <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/sqrt.html">std::sqrt</a>(5.f)) / 2.f;</div>
<div class="line"><span class="lineno"> 48</span> <span class="keyword">const</span> <span class="keywordtype">double</span> M_GOLDEN_RATIO = (3.f - std::sqrt(5.f)) / 2.f;</div>
<div class="line"><span class="lineno"> 49</span> </div>
<div class="line"><span class="lineno"> 50</span> <span class="keywordtype">double</span> v = lim_a + M_GOLDEN_RATIO * (lim_b - lim_a);</div>
<div class="line"><span class="lineno"> 51</span> <span class="keywordtype">double</span> u, w = v, x = v;</div>
@@ -317,20 +357,13 @@ Functions</h2></td></tr>
<div class="line"><span class="lineno"> 130</span> iters++;</div>
<div class="line"><span class="lineno"> 131</span> } <span class="keywordflow">while</span> (std::abs(x - mid_point) &gt; (tolerance - (lim_b - lim_a) / 2.f));</div>
<div class="line"><span class="lineno"> 132</span> </div>
<div class="line"><span class="lineno"> 133</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot; (iters: &quot;</span> &lt;&lt; iters &lt;&lt; <span class="stringliteral">&quot;) &quot;</span>;</div>
<div class="line"><span class="lineno"> 133</span> std::cout &lt;&lt; <span class="stringliteral">&quot; (iters: &quot;</span> &lt;&lt; iters &lt;&lt; <span class="stringliteral">&quot;) &quot;</span>;</div>
<div class="line"><span class="lineno"> 134</span> </div>
<div class="line"><span class="lineno"> 135</span> <span class="keywordflow">return</span> x;</div>
<div class="line"><span class="lineno"> 136</span>}</div>
<div class="ttc" id="abasic_ostream_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cerr</a></div></div>
<div class="ttc" id="abrent__method__extrema_8cpp_html_a002b2f4894492820fe708b1b7e7c5e70"><div class="ttname"><a href="#a002b2f4894492820fe708b1b7e7c5e70">EPSILON</a></div><div class="ttdeci">#define EPSILON</div><div class="ttdoc">system accuracy limit</div><div class="ttdef"><b>Definition</b> brent_method_extrema.cpp:24</div></div>
<div class="ttc" id="acomposite__simpson__rule_8cpp_html_a4251b4df4748a0b9c43a48f61bdd2397"><div class="ttname"><a href="../../d4/d18/composite__simpson__rule_8cpp.html#a4251b4df4748a0b9c43a48f61bdd2397">numerical_methods::simpson_method::f</a></div><div class="ttdeci">double f(double x)</div><div class="ttdoc">A function f(x) that will be used to test the method.</div><div class="ttdef"><b>Definition</b> composite_simpson_rule.cpp:113</div></div>
<div class="ttc" id="aswap_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/algorithm/swap.html">std::swap</a></div><div class="ttdeci">T swap(T... args)</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../db/d01/brent__method__extrema_8cpp_a1aa76a6d5fd4d333f9072beff1dc486b_cgraph.svg" width="226" height="86"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
<div class="ttc" id="abrent__method__extrema_8cpp_html_a002b2f4894492820fe708b1b7e7c5e70"><div class="ttname"><a href="#a002b2f4894492820fe708b1b7e7c5e70">EPSILON</a></div><div class="ttdeci">#define EPSILON</div><div class="ttdoc">system accuracy limit</div><div class="ttdef"><b>Definition</b> <a href="../../db/d01/brent__method__extrema_8cpp_source.html#l00024">brent_method_extrema.cpp:24</a></div></div>
<div class="ttc" id="acomposite__simpson__rule_8cpp_html_a4251b4df4748a0b9c43a48f61bdd2397"><div class="ttname"><a href="../../d4/d18/composite__simpson__rule_8cpp.html#a4251b4df4748a0b9c43a48f61bdd2397">numerical_methods::simpson_method::f</a></div><div class="ttdeci">double f(double x)</div><div class="ttdoc">A function f(x) that will be used to test the method.</div><div class="ttdef"><b>Definition</b> <a href="../../d4/d18/composite__simpson__rule_8cpp_source.html#l00113">composite_simpson_rule.cpp:113</a></div></div>
</div><!-- fragment -->
</div>
</div>
<a id="ae66f6b31b5ad750f1fe042a706a4e3d4" name="ae66f6b31b5ad750f1fe042a706a4e3d4"></a>
@@ -348,10 +381,12 @@ Here is the call graph for this function:</div>
</table>
</div><div class="memdoc">
<p>Main function </p>
<p class="definition">Definition at line <a class="el" href="../../db/d01/brent__method__extrema_8cpp_source.html#l00205">205</a> of file <a class="el" href="../../db/d01/brent__method__extrema_8cpp_source.html">brent_method_extrema.cpp</a>.</p>
<div class="fragment"><div class="line"><span class="lineno"> 205</span> {</div>
<div class="line"><span class="lineno"> 206</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a>.precision(18);</div>
<div class="line"><span class="lineno"> 206</span> std::cout.precision(18);</div>
<div class="line"><span class="lineno"> 207</span> </div>
<div class="line"><span class="lineno"> 208</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;Computations performed with machine epsilon: &quot;</span> &lt;&lt; <a class="code hl_define" href="#a002b2f4894492820fe708b1b7e7c5e70">EPSILON</a></div>
<div class="line"><span class="lineno"> 208</span> std::cout &lt;&lt; <span class="stringliteral">&quot;Computations performed with machine epsilon: &quot;</span> &lt;&lt; <a class="code hl_define" href="#a002b2f4894492820fe708b1b7e7c5e70">EPSILON</a></div>
<div class="line"><span class="lineno"> 209</span> &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 210</span> </div>
<div class="line"><span class="lineno"> 211</span> <a class="code hl_function" href="#a1440a7779ac56f47a3f355ce4a8c7da0">test1</a>();</div>
@@ -360,15 +395,10 @@ Here is the call graph for this function:</div>
<div class="line"><span class="lineno"> 214</span> </div>
<div class="line"><span class="lineno"> 215</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><span class="lineno"> 216</span>}</div>
<div class="ttc" id="abrent__method__extrema_8cpp_html_a0283886819c7c140a023582b7269e2d0"><div class="ttname"><a href="#a0283886819c7c140a023582b7269e2d0">test2</a></div><div class="ttdeci">void test2()</div><div class="ttdoc">Test function to find root for the function in the interval Expected result: .</div><div class="ttdef"><b>Definition</b> brent_method_extrema.cpp:166</div></div>
<div class="ttc" id="abrent__method__extrema_8cpp_html_a1440a7779ac56f47a3f355ce4a8c7da0"><div class="ttname"><a href="#a1440a7779ac56f47a3f355ce4a8c7da0">test1</a></div><div class="ttdeci">void test1()</div><div class="ttdoc">Test function to find root for the function in the interval Expected result = 2.</div><div class="ttdef"><b>Definition</b> brent_method_extrema.cpp:144</div></div>
<div class="ttc" id="abrent__method__extrema_8cpp_html_a6d0455dd5c30adda100e95f0423c786e"><div class="ttname"><a href="#a6d0455dd5c30adda100e95f0423c786e">test3</a></div><div class="ttdeci">void test3()</div><div class="ttdoc">Test function to find maxima for the function in the interval Expected result: .</div><div class="ttdef"><b>Definition</b> brent_method_extrema.cpp:189</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../db/d01/brent__method__extrema_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg" width="422" height="135"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
<div class="ttc" id="abrent__method__extrema_8cpp_html_a0283886819c7c140a023582b7269e2d0"><div class="ttname"><a href="#a0283886819c7c140a023582b7269e2d0">test2</a></div><div class="ttdeci">void test2()</div><div class="ttdoc">Test function to find root for the function in the interval Expected result: .</div><div class="ttdef"><b>Definition</b> <a href="../../db/d01/brent__method__extrema_8cpp_source.html#l00166">brent_method_extrema.cpp:166</a></div></div>
<div class="ttc" id="abrent__method__extrema_8cpp_html_a1440a7779ac56f47a3f355ce4a8c7da0"><div class="ttname"><a href="#a1440a7779ac56f47a3f355ce4a8c7da0">test1</a></div><div class="ttdeci">void test1()</div><div class="ttdoc">Test function to find root for the function in the interval Expected result = 2.</div><div class="ttdef"><b>Definition</b> <a href="../../db/d01/brent__method__extrema_8cpp_source.html#l00144">brent_method_extrema.cpp:144</a></div></div>
<div class="ttc" id="abrent__method__extrema_8cpp_html_a6d0455dd5c30adda100e95f0423c786e"><div class="ttname"><a href="#a6d0455dd5c30adda100e95f0423c786e">test3</a></div><div class="ttdeci">void test3()</div><div class="ttdoc">Test function to find maxima for the function in the interval Expected result: .</div><div class="ttdef"><b>Definition</b> <a href="../../db/d01/brent__method__extrema_8cpp_source.html#l00189">brent_method_extrema.cpp:189</a></div></div>
</div><!-- fragment -->
</div>
</div>
<a id="a1440a7779ac56f47a3f355ce4a8c7da0" name="a1440a7779ac56f47a3f355ce4a8c7da0"></a>
@@ -388,29 +418,25 @@ Here is the call graph for this function:</div>
<p>Test function to find root for the function \(f(x)= (x-2)^2\) in the interval \([1,5]\) <br />
Expected result = 2. </p>
<p class="definition">Definition at line <a class="el" href="../../db/d01/brent__method__extrema_8cpp_source.html#l00144">144</a> of file <a class="el" href="../../db/d01/brent__method__extrema_8cpp_source.html">brent_method_extrema.cpp</a>.</p>
<div class="fragment"><div class="line"><span class="lineno"> 144</span> {</div>
<div class="line"><span class="lineno"> 145</span> <span class="comment">// define the function to minimize as a lambda function</span></div>
<div class="line"><span class="lineno"> 146</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/functional/function.html">std::function</a>&lt;double(<span class="keywordtype">double</span>)&gt; f1 = [](<span class="keywordtype">double</span> x) {</div>
<div class="line"><span class="lineno"> 146</span> std::function&lt;double(<span class="keywordtype">double</span>)&gt; f1 = [](<span class="keywordtype">double</span> x) {</div>
<div class="line"><span class="lineno"> 147</span> <span class="keywordflow">return</span> (x - 2) * (x - 2);</div>
<div class="line"><span class="lineno"> 148</span> };</div>
<div class="line"><span class="lineno"> 149</span> </div>
<div class="line"><span class="lineno"> 150</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;Test 1.... &quot;</span>;</div>
<div class="line"><span class="lineno"> 150</span> std::cout &lt;&lt; <span class="stringliteral">&quot;Test 1.... &quot;</span>;</div>
<div class="line"><span class="lineno"> 151</span> </div>
<div class="line"><span class="lineno"> 152</span> <span class="keywordtype">double</span> minima = <a class="code hl_function" href="#a1aa76a6d5fd4d333f9072beff1dc486b">get_minima</a>(f1, -1, 5);</div>
<div class="line"><span class="lineno"> 153</span> </div>
<div class="line"><span class="lineno"> 154</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; minima &lt;&lt; <span class="stringliteral">&quot;...&quot;</span>;</div>
<div class="line"><span class="lineno"> 154</span> std::cout &lt;&lt; minima &lt;&lt; <span class="stringliteral">&quot;...&quot;</span>;</div>
<div class="line"><span class="lineno"> 155</span> </div>
<div class="line"><span class="lineno"> 156</span> assert(std::abs(minima - 2) &lt; <a class="code hl_define" href="#a002b2f4894492820fe708b1b7e7c5e70">EPSILON</a>);</div>
<div class="line"><span class="lineno"> 157</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;passed\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 157</span> std::cout &lt;&lt; <span class="stringliteral">&quot;passed\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 158</span>}</div>
<div class="ttc" id="abrent__method__extrema_8cpp_html_a1aa76a6d5fd4d333f9072beff1dc486b"><div class="ttname"><a href="#a1aa76a6d5fd4d333f9072beff1dc486b">get_minima</a></div><div class="ttdeci">double get_minima(const std::function&lt; double(double)&gt; &amp;f, double lim_a, double lim_b)</div><div class="ttdoc">Get the real root of a function in the given interval.</div><div class="ttdef"><b>Definition</b> brent_method_extrema.cpp:36</div></div>
<div class="ttc" id="afunction_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/utility/functional/function.html">std::function</a></div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../db/d01/brent__method__extrema_8cpp_a1440a7779ac56f47a3f355ce4a8c7da0_cgraph.svg" width="324" height="86"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
<div class="ttc" id="abrent__method__extrema_8cpp_html_a1aa76a6d5fd4d333f9072beff1dc486b"><div class="ttname"><a href="#a1aa76a6d5fd4d333f9072beff1dc486b">get_minima</a></div><div class="ttdeci">double get_minima(const std::function&lt; double(double)&gt; &amp;f, double lim_a, double lim_b)</div><div class="ttdoc">Get the real root of a function in the given interval.</div><div class="ttdef"><b>Definition</b> <a href="../../db/d01/brent__method__extrema_8cpp_source.html#l00036">brent_method_extrema.cpp:36</a></div></div>
</div><!-- fragment -->
</div>
</div>
<a id="a0283886819c7c140a023582b7269e2d0" name="a0283886819c7c140a023582b7269e2d0"></a>
@@ -430,29 +456,25 @@ Here is the call graph for this function:</div>
<p>Test function to find root for the function \(f(x)= x^{\frac{1}{x}}\) in the interval \([-2,10]\) <br />
Expected result: \(e\approx 2.71828182845904509\). </p>
<p class="definition">Definition at line <a class="el" href="../../db/d01/brent__method__extrema_8cpp_source.html#l00166">166</a> of file <a class="el" href="../../db/d01/brent__method__extrema_8cpp_source.html">brent_method_extrema.cpp</a>.</p>
<div class="fragment"><div class="line"><span class="lineno"> 166</span> {</div>
<div class="line"><span class="lineno"> 167</span> <span class="comment">// define the function to maximize as a lambda function</span></div>
<div class="line"><span class="lineno"> 168</span> <span class="comment">// since we are maximixing, we negated the function return value</span></div>
<div class="line"><span class="lineno"> 169</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/functional/function.html">std::function</a>&lt;double(<span class="keywordtype">double</span>)&gt; func = [](<span class="keywordtype">double</span> x) {</div>
<div class="line"><span class="lineno"> 170</span> <span class="keywordflow">return</span> -<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/pow.html">std::pow</a>(x, 1.f / x);</div>
<div class="line"><span class="lineno"> 169</span> std::function&lt;double(<span class="keywordtype">double</span>)&gt; func = [](<span class="keywordtype">double</span> x) {</div>
<div class="line"><span class="lineno"> 170</span> <span class="keywordflow">return</span> -std::pow(x, 1.f / x);</div>
<div class="line"><span class="lineno"> 171</span> };</div>
<div class="line"><span class="lineno"> 172</span> </div>
<div class="line"><span class="lineno"> 173</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;Test 2.... &quot;</span>;</div>
<div class="line"><span class="lineno"> 173</span> std::cout &lt;&lt; <span class="stringliteral">&quot;Test 2.... &quot;</span>;</div>
<div class="line"><span class="lineno"> 174</span> </div>
<div class="line"><span class="lineno"> 175</span> <span class="keywordtype">double</span> minima = <a class="code hl_function" href="#a1aa76a6d5fd4d333f9072beff1dc486b">get_minima</a>(func, -2, 5);</div>
<div class="line"><span class="lineno"> 176</span> </div>
<div class="line"><span class="lineno"> 177</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; minima &lt;&lt; <span class="stringliteral">&quot; (&quot;</span> &lt;&lt; M_E &lt;&lt; <span class="stringliteral">&quot;)...&quot;</span>;</div>
<div class="line"><span class="lineno"> 177</span> std::cout &lt;&lt; minima &lt;&lt; <span class="stringliteral">&quot; (&quot;</span> &lt;&lt; M_E &lt;&lt; <span class="stringliteral">&quot;)...&quot;</span>;</div>
<div class="line"><span class="lineno"> 178</span> </div>
<div class="line"><span class="lineno"> 179</span> assert(std::abs(minima - M_E) &lt; <a class="code hl_define" href="#a002b2f4894492820fe708b1b7e7c5e70">EPSILON</a>);</div>
<div class="line"><span class="lineno"> 180</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;passed\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 180</span> std::cout &lt;&lt; <span class="stringliteral">&quot;passed\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 181</span>}</div>
<div class="ttc" id="apow_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/numeric/math/pow.html">std::pow</a></div><div class="ttdeci">T pow(T... args)</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../db/d01/brent__method__extrema_8cpp_a0283886819c7c140a023582b7269e2d0_cgraph.svg" width="324" height="110"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
</div><!-- fragment -->
</div>
</div>
<a id="a6d0455dd5c30adda100e95f0423c786e" name="a6d0455dd5c30adda100e95f0423c786e"></a>
@@ -472,27 +494,23 @@ Here is the call graph for this function:</div>
<p>Test function to find <em>maxima</em> for the function \(f(x)= \cos x\) in the interval \([0,12]\) <br />
Expected result: \(\pi\approx 3.14159265358979312\). </p>
<p class="definition">Definition at line <a class="el" href="../../db/d01/brent__method__extrema_8cpp_source.html#l00189">189</a> of file <a class="el" href="../../db/d01/brent__method__extrema_8cpp_source.html">brent_method_extrema.cpp</a>.</p>
<div class="fragment"><div class="line"><span class="lineno"> 189</span> {</div>
<div class="line"><span class="lineno"> 190</span> <span class="comment">// define the function to maximize as a lambda function</span></div>
<div class="line"><span class="lineno"> 191</span> <span class="comment">// since we are maximixing, we negated the function return value</span></div>
<div class="line"><span class="lineno"> 192</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/utility/functional/function.html">std::function</a>&lt;double(<span class="keywordtype">double</span>)&gt; func = [](<span class="keywordtype">double</span> x) { <span class="keywordflow">return</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/cos.html">std::cos</a>(x); };</div>
<div class="line"><span class="lineno"> 192</span> std::function&lt;double(<span class="keywordtype">double</span>)&gt; func = [](<span class="keywordtype">double</span> x) { <span class="keywordflow">return</span> std::cos(x); };</div>
<div class="line"><span class="lineno"> 193</span> </div>
<div class="line"><span class="lineno"> 194</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;Test 3.... &quot;</span>;</div>
<div class="line"><span class="lineno"> 194</span> std::cout &lt;&lt; <span class="stringliteral">&quot;Test 3.... &quot;</span>;</div>
<div class="line"><span class="lineno"> 195</span> </div>
<div class="line"><span class="lineno"> 196</span> <span class="keywordtype">double</span> minima = <a class="code hl_function" href="#a1aa76a6d5fd4d333f9072beff1dc486b">get_minima</a>(func, -4, 12);</div>
<div class="line"><span class="lineno"> 197</span> </div>
<div class="line"><span class="lineno"> 198</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; minima &lt;&lt; <span class="stringliteral">&quot; (&quot;</span> &lt;&lt; M_PI &lt;&lt; <span class="stringliteral">&quot;)...&quot;</span>;</div>
<div class="line"><span class="lineno"> 198</span> std::cout &lt;&lt; minima &lt;&lt; <span class="stringliteral">&quot; (&quot;</span> &lt;&lt; M_PI &lt;&lt; <span class="stringliteral">&quot;)...&quot;</span>;</div>
<div class="line"><span class="lineno"> 199</span> </div>
<div class="line"><span class="lineno"> 200</span> assert(std::abs(minima - M_PI) &lt; <a class="code hl_define" href="#a002b2f4894492820fe708b1b7e7c5e70">EPSILON</a>);</div>
<div class="line"><span class="lineno"> 201</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> &lt;&lt; <span class="stringliteral">&quot;passed\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 201</span> std::cout &lt;&lt; <span class="stringliteral">&quot;passed\n&quot;</span>;</div>
<div class="line"><span class="lineno"> 202</span>}</div>
<div class="ttc" id="acos_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/numeric/math/cos.html">std::cos</a></div><div class="ttdeci">T cos(T... args)</div></div>
</div><!-- fragment --><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><iframe scrolling="no" frameborder="0" src="../../db/d01/brent__method__extrema_8cpp_a6d0455dd5c30adda100e95f0423c786e_cgraph.svg" width="324" height="110"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
</div><!-- fragment -->
</div>
</div>
</div><!-- contents -->