/usr/share/doc/axiom-doc/hypertex/cryptoclass1.xhtml is in axiom-hypertex-data 20120501-8.
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 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | <?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:m="http://www.w3.org/1998/Math/MathML">
<head>
<meta http-equiv="Content-Type" content="text/html" charset="us-ascii"/>
<title>Axiom Documentation</title>
<style>
html {
background-color: #ECEA81;
}
body {
margin: 0px;
padding: 0px;
}
div.command {
color:red;
}
div.center {
color:blue;
}
div.reset {
visibility:hidden;
}
div.mathml {
color:blue;
}
input.subbut {
background-color:#ECEA81;
border: 0;
color:green;
font-family: "Courier New", Courier, monospace;
}
input.noresult {
background-color:#ECEA81;
border: 0;
color:black;
font-family: "Courier New", Courier, monospace;
}
span.cmd {
color:green;
font-family: "Courier New", Courier, monospace;
}
pre {
font-family: "Courier New", Courier, monospace;
}
</style>
</head>
<body>
<div align="center"><img align="middle" src="doctitle.png"/></div>
<hr/>
<center>
<h2>RCM3720 Cryptography, Network and Computer Security</h2>
<h3>Laboratory Class 1: Introduction to Axiom</h3>
</center>
<hr/>
<b>Numbers and arithmetic</b>
<ul>
<li> You can treat Axiom like a glorified calculator. Enter the following:
<ul>
<li> <span class="cmd">3+5</span></li>
<li> <span class="cmd">5*7</span></li>
<li> <span class="cmd">2^3/3^5</span></li>
<li> <span class="cmd">(3^4)^5</span></li>
<li> <span class="cmd">3^(4^5)</span></li>
</ul>
</li>
<li> What happens if you enter the last command without the brackets?</li>
<li> To obtain the factorial <tt>n!</tt>, use the Axiom command
<tt>factorial</tt>:
<ul>
<li> <span class="cmd">factorial(10)</span></li>
</ul>
</li>
<li> By trial and error, find the smallest number whose factorial
ends in six zeros.
</li>
</ul>
<b>Lists</b>
<ul>
<li> Assignment is done using "<tt>:=</tt>"
where the <i>colon-equals</i> symbols are
used for assigning a particular object to a variable.
<ul>
<li> <span class="cmd">var:=3</span></li>
</ul>
</li>
<li> Lists are created using square brackets;
<ul>
<li> <span class="cmd">mylist1:=[k^2 for k in 1..10]</span></li>
</ul>
</li>
<li> We can operate on all elements of a list using the
<tt>reduce</tt> command:
<ul>
<li> <span class="cmd">reduce(+,mylist1)</span></li>
<li> <span class="cmd">reduce(*,mylist2)</span></li>
</ul>
</li>
<li> Of course, these could be done as single commands:
<ul>
<li> <span class="cmd">reduce(+,[k^2 for k in 1..10])</span></li>
<li> <span class="cmd">reduce(*,[1/j for j in 5..15])</span></li>
</ul>
</li>
<li> Notice how the last result is given as a single large fraction. To
obtain a decimal result we can do either of two things:
<ol>
<li> Convert the output to be of type ``Float'':
<ul>
<li> <span class="cmd">reduce(*,[1/j for j in 5..15])::Float</span></li>
<li> Two colons can be used to change the type of an object.</li>
</ul>
</li>
<li> Use floats in the initial command:
<ul>
<li> <span class="cmd">reduce(*,[1.0/j for j in 5..15])</span></li>
</ul>
</li>
</ol>
</li>
<li> Using lists, add up the first 1000 integers.</li>
<li> By trial and error, find the smallest number <i>n</i> for which
the sum of the first <i>n</i> reciprocals is bigger than 8.
</li>
<li> We can also add numbers by using the <tt>sum</tt> function; here's how
to add the first 100 reciprocals:
<ul>
<li> <span class="cmd">sum(1.0/k,k = 1..100)</span></li>
</ul>
</li>
</ul>
<b>Functions and maps</b>
<ul>
<li> We shall create a simple function, and apply it to <tt>mylist1</tt> from
above:
<ul>
<li> <span class="cmd">f(x) == x-2</span></li>
<li> <span class="cmd">map(f,mylist1)</span></li>
</ul>
</li>
<li> Supposing we want to subtract 2 from every element of a list without
having to create a function first. In this case we can use the
"mapping" symbols:
<ul>
<li> <span class="cmd">map(x +-> x-2,mylist1)</span></li>
</ul>
</li>
<li> Create a list called <tt>nums</tt> containing all the integers from 1
to 100. Now we shall create a simple function <tt>f(x)</tt> which
returns <tt>x</tt> if it is prime, and 0 otherwise. The Axiom
function <tt>prime?</tt> tests for primality:
<ul>
<li> <span class="cmd">f(x)==if prime?(x) then x else 0</span></li>
</ul>
</li>
<li> Now apply this function <tt>f</tt> to <tt>nums</tt>.
Remove all the zeros:
<i>(% refers to the output of the last command.)</i>
<ul>
<li> <span class="cmd">remove(0,%)</span></li>
</ul>
</li>
<li> and determine how many primes there are, using the hash symbol #
which can be used to count the number of elements in a list:
<ul>
<li> <span class="cmd">#%</span></li>
</ul>
</li>
<li> These last commands can be done as a single command:
<ul>
<li> <span class="cmd">#remove(0,map(f,nums))</span></li>
</ul>
</li>
<li> Use the last command to create a function called <tt>numprimes</tt>
which will count the number of primes below any given integer.
</li>
<li> How many primes are there less than 1000? Less than 10000?</li>
<li> Alternatively, we can list all the primes below 100 by creating our
list using the "such that" operator---a vertical stroke:
<ul>
<li> <span class="cmd">[k for k in 1..100 | prime?(k)]</span></li>
</ul>
</li>
<li> or we could just return the length of the list:
<ul>
<li> <span class="cmd">#[k for k in 1..100 | prime?(k)]</span></li>
</ul>
</li>
<li> Use this approach to create a function called <tt>numprimes2</tt>
which will count the number of primes below any given integer.
</li>
<li>How many primes are there less than 2000? Less than 15000?</li>
</ul>
<b>Housekeeping</b><br/>
Axiom contains many commands for managing your workspace and your
environment; such commands are all prefixed with a right parenthesis.
<ul>
<li> Sometimes you need to clear a variable, say a variable <tt>x</tt>:
<ul>
<li> <span class="cmd">)clear properties x</span></li>
</ul>
</li>
<li> Most commands of this sort can be abbreviated using their
first two letters:
<ul>
<li> <span class="cmd">)cl pr x</span></li>
</ul>
</li>
<li> To clean out everything:
<ul>
<li> <span class="cmd">)cl all</span></li>
</ul>
</li>
<li> To see what variables you've accumulated over your work:
<ul>
<li> <span class="cmd">)display names</span></li>
<li> <i>or abbreviated as</i> )d n</li>
</ul>
</li>
<li> You may have noticed earlier that Axiom poured out lots
of messages when it first "got going". These can be turned off:
<ul>
<li> <span class="cmd">)set messages autoload off</span></li>
</ul>
</li>
<li> Note here that if you just type in "<tt>)set</tt>" or its abbreviation
"<tt>)se</tt>", you'll be presented with the list of all the possible
options. Likewise "<tt>)se me</tt>" lists all possible options for
messages, and so on.
</li>
<li> Can you find the command which turns on a time function,
so gives the time to compute each command?
</li>
<li> The command "<tt>)summary</tt> gives a quick summary of these
commands.
</li>
<li> To quit Axiom, type
<ul>
<li> <span class="cmd">)quit</span></li>
</ul>
</li>
<li> or its one letter abbreviation "<tt>)q</tt>", followed by <tt>y</tt> to
confirm.
</li>
</ul>
</body>
</html>
|