/usr/share/doc/pyxplot/html/sec-functions.html is in pyxplot-doc 0.9.2-4.
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 | <!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: Functions</title>
<link href="ex-funcsplice.html" title="Spliced functions" rel="next" />
<link href="sec-constants.html" title="Physical constants" rel="prev" />
<link href="sect0022.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="sec-constants.html" title="Physical constants"><img alt="Previous: Physical constants" border="0" src="icons/previous.gif" width="32" height="32" /></a></td>
<td><a href="sect0022.html" title="Performing calculations"><img alt="Up: Performing calculations" border="0" src="icons/up.gif" width="32" height="32" /></a></td>
<td><a href="ex-funcsplice.html" title="Spliced functions"><img alt="Next: Spliced functions" 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="sect0288.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="sect0022.html">Performing calculations</a> <b>:</b>
</span>
</span><span>
<span>
<b class="current">Functions</b>
</span>
</span>
<hr />
</div>
<div><h1 id="sec:functions">4.3 Functions</h1>
<p>Many standard mathematical and operating system functions are pre-defined within Pyxplot’s mathematical environment. These range from everyday examples like trigonometric functions, to very specialised functions; there is even a function to return the phase of the Moon on any given day. As with the mathematical constant, common functions are defined in the user’s default namespace, for example </p><p> <tt class="ttfamily">pyxplot> <b class="bfseries">print exp(2)</b></tt><br /><tt class="ttfamily">7.3890561</tt> </p><p>whilst others live in modules, for example </p><pre>
print ast.moonPhase( time.now() )
</pre><p>which returns the present phase of the Moon in radians, and </p><pre>
print os.path.filesize("/etc/passwd")
</pre><p>which returns the size of a file (in units of bytes, of course!). </p><p>A complete list of these functioned, sorted by module, can be found in Chapter <a href="ch-function_list.html">2</a>. Another quick way to find out some more information about a function is the print the function object, for example: </p><p> <tt class="ttfamily">pyxplot> <b class="bfseries">print log</b></tt><br /><tt class="ttfamily">log(x) returns the natural logarithm of x.</tt> </p><p>All, of Pyxplot’s built-in constants, functions and modules are contained in the module <tt class="tt">defaults</tt>, which can also be printed to view its contents: </p><pre>
print defaults
</pre><p>It is possible to access <tt class="tt">pi</tt>, for example, as <tt class="tt">defaults.pi</tt>, though in practice this syntax is very rarely needed. All of the objects in the <tt class="tt">defaults</tt> module are always accessible by name (i.e. they are always in any namespace), unless another local or global variable exists with the same name. </p><p>The user can define his own algebraic function definitions using a similar syntax to that used to declare new variables, as in the examples: </p><pre>
f() = pi
g(x) = x*sin(x)
h(x,y) = x*y
</pre><p>Function objects are just like any other variables, and can even be used as arguments to other functions: </p><p> <tt class="ttfamily">pyxplot> <b class="bfseries">f = sum</b></tt><br /><tt class="ttfamily">pyxplot> <b class="bfseries">print f</b></tt><br /><tt class="ttfamily">sum(...) returns the sum of its arguments.</tt><br /><tt class="ttfamily">pyxplot> <b class="bfseries">f = sin</b></tt><br /><tt class="ttfamily">pyxplot> <b class="bfseries">g(x,y) = x(x(y))</b></tt><br /><tt class="ttfamily">pyxplot> <b class="bfseries">print g(f,1)</b></tt><br /><tt class="ttfamily">0.74562414</tt> </p><p>User-defined functions can be undefined in the same way as any other variable, for example by typing: </p><pre>
f =
</pre><p>Where the logic required to define a particular function is greater than can be contained in a single algebraic expression, a subroutine should be used (see Section <a></a>); these allow an arbitrary numbers of lines of Pyxplot code to be executed whenever a function is evaluated. </p></div>
<div class="contents section-contents"><!--<strong>Subsections</strong>-->
<ul>
<li><a href="ex-funcsplice.html">4.3.1 Spliced functions</a>
</li>
</ul>
</div>
<div class="navigation">
<table cellspacing="2" cellpadding="0" width="100%">
<tr>
<td><a href="sec-constants.html" title="Physical constants"><img alt="Previous: Physical constants" border="0" src="icons/previous.gif" width="32" height="32" /></a></td>
<td><a href="sect0022.html" title="Performing calculations"><img alt="Up: Performing calculations" border="0" src="icons/up.gif" width="32" height="32" /></a></td>
<td><a href="ex-funcsplice.html" title="Spliced functions"><img alt="Next: Spliced functions" 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="sect0288.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>
|