This file is indexed.

/usr/share/doc/pyxplot/html/ex-eqnsolve.html is in pyxplot-doc 0.8.4-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta name="generator" content="plasTeX" />
<meta content="text/html; charset=utf-8" http-equiv="content-type" />
<title>PyXPlot Users' Guide: Searching for Minima and Maxima of Functions</title>

<link href="sec-time_series.html" title="Working with Time-Series Data" rel="next" />
<link href="sect0024.html" title="Solving Systems of Equations" rel="prev" />
<link href="sect0019.html" title="Performing Calculations" rel="up" />
<link rel="stylesheet" href="styles/styles.css" />
</head>
<body>

<div class="navigation">
<table cellspacing="2" cellpadding="0" width="100%">
<tr>
<td><a href="sect0024.html" title="Solving Systems of Equations"><img alt="Previous: Solving Systems of Equations" border="0" src="icons/previous.gif" width="32" height="32" /></a></td>

<td><a href="sect0019.html" title="Performing Calculations"><img alt="Up: Performing Calculations" border="0" src="icons/up.gif" width="32" height="32" /></a></td>

<td><a href="sec-time_series.html" title="Working with Time-Series Data"><img alt="Next: Working with Time-Series Data" border="0" src="icons/next.gif" width="32" height="32" /></a></td>

<td class="navtitle" align="center">PyXPlot Users' Guide</td>
<td><a href="index.html" title="Table of Contents"><img border="0" alt="" src="icons/contents.gif" width="32" height="32" /></a></td>

<td><a href="sect0255.html" title="Index"><img border="0" alt="" src="icons/index.gif" width="32" height="32" /></a></td>

<td><img border="0" alt="" src="icons/blank.gif" width="32" height="32" /></td>
</tr>
</table>
</div>

<div class="breadcrumbs">
<span>
<span>
<a href="index.html">PyXPlot Users' Guide</a> <b>:</b>
</span>

</span><span>
<span>
<a href="sect0001.html">Introduction to PyXPlot</a> <b>:</b>
</span>

</span><span>
<span>
<a href="sect0019.html">Performing Calculations</a> <b>:</b>
</span>

</span><span>

<span>
<b class="current">Searching for Minima and Maxima of Functions</b>
</span>
</span>
<hr />
</div>

<div><h1 id="ex:eqnsolve">4.10 Searching for Minima and Maxima of Functions</h1>
<p>The <a name="a0000000475" id="a0000000475"></a><a name="a0000000476" id="a0000000476"></a> <tt class="tt">minimise</tt> and <tt class="tt">maximise</tt> commands can be used to find the minima or maxima of algebraic expressions. In each case, a single algebraic expression should be supplied for optimisation, together with a comma-separated list of the variables with respect to which it should be optimised. In the following example, a minimum of the sinusoidal function <img src="images/img-0010.png" alt="$\cos (x)$" style="vertical-align:-4px; 
                                     width:47px; 
                                     height:18px" class="math gen" /> is sought: </p><p> <tt class="tt">pyxplot&gt; <b class="bf">set numerics real</b></tt><br /><tt class="tt">pyxplot&gt; <b class="bf">x=0.1</b></tt><br /><tt class="tt">pyxplot&gt; <b class="bf">minimise cos(x) via x</b></tt><br /><tt class="tt">pyxplot&gt; <b class="bf">print x/pi</b></tt><br /><tt class="tt">1</tt>  </p><p>Note that this particular example doesn’t work when complex arithmetic is enabled, since <img src="images/img-0010.png" alt="$\cos (x)$" style="vertical-align:-4px; 
                                     width:47px; 
                                     height:18px" class="math gen" /> diverges to <img src="images/img-0140.png" alt="$-\infty $" style="vertical-align:-1px; 
                                     width:30px; 
                                     height:9px" class="math gen" /> at <img src="images/img-0141.png" alt="$x=\pi +\infty i$" style="vertical-align:-1px; 
                                     width:92px; 
                                     height:13px" class="math gen" />. </p><p>Various caveats apply both to the <tt class="tt">minimise</tt> and <tt class="tt">maximise</tt> commands, as well as to the <tt class="tt">solve</tt> command. All of these commands operate by searching numerically for optimal sets of input parameters to meet the criteria set by the user. As with all numerical algorithms, there is no guarantee that the <i class="it">locally</i> optimum solutions returned are the <i class="it">globally</i> optimum solutions. It is always advisable to double-check that the answers returned agree with common sense. </p><p>These commands can often find solutions to equations when these solutions are either very large or very small, but they usually work best when the solution they are looking for is roughly of order unity. PyXPlot does have mechanisms which attempt to correct cases where the supplied initial guess turns out to be many orders of magnitude different from the true solution, but it cannot be guaranteed not to wildly overshoot and produce unexpected results in such cases. To reiterate, it is always advisable to double-check that the answers returned agree with common sense. </p><p> <span class="upshape"><span class="mdseries"><span class="rm">Finding the maximum of a blackbody curve.</span></span></span></p><div>

<table cellspacing="0" class="tabular">
<tr>

    
    <td style="border-top-style:solid; border-left:1px solid black; border-right:1px solid black; border-top-color:black; border-top-width:1px; text-align:left"><p> When a surface is heated to any given temperature <img src="images/img-0142.png" alt="$T$" style="vertical-align:0px; 
                                     width:13px; 
                                     height:12px" class="math gen" />, it radiates thermally. The amount of electromagnetic radiation emitted at any particular frequency, per unit area of surface, per unit frequency of light, is given by the Planck Law: </p><table id="a0000000477" class="equation" width="100%" cellspacing="0" cellpadding="7">
<tr>
    
    <td style="width:40%">&nbsp;</td>
    <td><img src="images/img-0143.png" alt="\[  B_\nu (\nu ,T)=\left(\frac{2h^3}{c^2}\right)\frac{\nu ^3}{\exp (h\nu /kT)-1}  \]" style="width:281px; 
                            height:45px" class="math gen" /></td>
    
    <td style="width:40%">&nbsp;</td>
    <td class="eqnnum" style="width:20%">&nbsp;</td>
</tr>
</table><p> The visible surface of the Sun has a temperature of approximately <img src="images/img-0144.png" alt="$5800\, \mathrm{K}$" style="vertical-align:0px; 
                                     width:52px; 
                                     height:13px" class="math gen" /> and radiates in such a fashion. In this example, we use the <tt class="tt">solve</tt>, <tt class="tt">minimise</tt> and <tt class="tt">maximise</tt> commands to locate the frequency of light at which it emits the most energy per unit frequency interval. This task is simplified as PyXPlot has a system-defined mathematical function <tt class="tt">Bv(nu,T)</tt> which evaluates the expression given above. </p></td>

</tr><tr>

    
    <td style="text-align:left; border-right:1px solid black; border-left:1px solid black"><p>Below, a plot is shown of the Planck Law for <img src="images/img-0145.png" alt="$T=5800\, \mathrm{K}$" style="vertical-align:0px; 
                                     width:90px; 
                                     height:13px" class="math gen" /> to aid in visualising the solution to this problem: </p></td>

</tr><tr>

    
    <td style="text-align:left; border-right:1px solid black; border-left:1px solid black"><center> 
<img src="images/img-0147.png" alt="\includegraphics[width=\textwidth ]{examples/eps/ex_eqnsolve}" style="width:" /> </center></td>

</tr><tr>

    
    <td style="text-align:left; border-right:1px solid black; border-left:1px solid black"><p>To search for the maximum of this function using the <tt class="tt">maximise</tt> command<a name="a0000000478" id="a0000000478"></a>, we must provide an initial guess to indicate that the answer sought should have units of Hz: </p></td>

</tr><tr>

    
    <td style="text-align:left; border-right:1px solid black; border-left:1px solid black"><p><tt class="tt">pyxplot&gt; <b class="bf">nu = 1e14*unit(Hz)</b></tt><br /><tt class="tt">pyxplot&gt; <b class="bf">maximise Bv(nu,5800*unit(K)) via nu</b></tt><br /><tt class="tt">pyxplot&gt; <b class="bf">print nu</b></tt><br /><tt class="tt">340.9781 THz</tt> </p></td>

</tr><tr>

    
    <td style="text-align:left; border-right:1px solid black; border-left:1px solid black"><p>This maximum could also be sought be searching for turning points in the function <img src="images/img-0149.png" alt="$B_\nu (\nu ,T)$" style="vertical-align:-4px; 
                                     width:65px; 
                                     height:18px" class="math gen" />, i.e. by solving the equation </p><table id="a0000000479" class="equation" width="100%" cellspacing="0" cellpadding="7">
<tr>
    
    <td style="width:40%">&nbsp;</td>
    <td><img src="images/img-0150.png" alt="\[  \frac{\mathrm{d}B_\nu (\nu ,T)}{\mathrm{d}\nu }=0.  \]" style="width:116px; 
                            height:39px" class="math gen" /></td>
    
    <td style="width:40%">&nbsp;</td>
    <td class="eqnnum" style="width:20%">&nbsp;</td>
</tr>
</table><p> This can be done as follows: </p></td>

</tr><tr>

    
    <td style="text-align:left; border-right:1px solid black; border-left:1px solid black"><p><tt class="tt">pyxplot&gt; <b class="bf">nu = 1e14*unit(Hz)</b></tt><br /><tt class="tt">pyxplot&gt; <b class="bf">solve diff_dnu(Bv(nu,5800*unit(K)),nu) = <img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px; 
                                     width:7px; 
                                     height:18px" class="math gen" /></b></tt><br /><tt class="tt">.......&gt; <b class="bf">         unit(0*W/Hz**2/m**2) via nu</b></tt><br /><tt class="tt">pyxplot&gt; <b class="bf">print nu</b></tt><br /><tt class="tt">340.9781 THz</tt> </p></td>

</tr><tr>

    
    <td style="border-bottom-style:solid; border-bottom-width:1px; border-left:1px solid black; border-right:1px solid black; text-align:left; border-bottom-color:black"><p>Finally, this maximum could also be found using PyXPlot’s built-in function <tt class="tt">Bvmax(T)</tt>:<br /><tt class="tt">pyxplot&gt; <b class="bf">print Bvmax(5800*unit(K))</b></tt><br /><tt class="tt">340.9781 THz</tt>  </p></td>

</tr>
</table>
</div></div>





<div class="navigation">
<table cellspacing="2" cellpadding="0" width="100%">
<tr>
<td><a href="sect0024.html" title="Solving Systems of Equations"><img alt="Previous: Solving Systems of Equations" border="0" src="icons/previous.gif" width="32" height="32" /></a></td>

<td><a href="sect0019.html" title="Performing Calculations"><img alt="Up: Performing Calculations" border="0" src="icons/up.gif" width="32" height="32" /></a></td>

<td><a href="sec-time_series.html" title="Working with Time-Series Data"><img alt="Next: Working with Time-Series Data" border="0" src="icons/next.gif" width="32" height="32" /></a></td>

<td class="navtitle" align="center">PyXPlot Users' Guide</td>
<td><a href="index.html" title="Table of Contents"><img border="0" alt="" src="icons/contents.gif" width="32" height="32" /></a></td>

<td><a href="sect0255.html" title="Index"><img border="0" alt="" src="icons/index.gif" width="32" height="32" /></a></td>

<td><img border="0" alt="" src="icons/blank.gif" width="32" height="32" /></td>
</tr>
</table>
</div>

<script language="javascript" src="icons/imgadjust.js" type="text/javascript"></script>

</body>
</html>