<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Alasdair&#039;s musings</title>
	<atom:link href="http://amca01.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://amca01.wordpress.com</link>
	<description>Life, mathematics teaching</description>
	<lastBuildDate>Tue, 03 Nov 2009 12:12:28 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='amca01.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/60451efeee73827a456d4384efb970da?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Alasdair&#039;s musings</title>
		<link>http://amca01.wordpress.com</link>
	</image>
			<item>
		<title>Vigen&#232;re and Kasiski</title>
		<link>http://amca01.wordpress.com/2009/11/03/vigenre-and-kasiski/</link>
		<comments>http://amca01.wordpress.com/2009/11/03/vigenre-and-kasiski/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 12:11:36 +0000</pubDate>
		<dc:creator>amca01</dc:creator>
				<category><![CDATA[Cryptography]]></category>
		<category><![CDATA[Sage]]></category>

		<guid isPermaLink="false">http://amca01.wordpress.com/?p=536</guid>
		<description><![CDATA[Most writers of cryptography texts, to my mind, spend a disproportionate amount of time and space carefully discussing the cryptanalysis of the Vigen&#232;re cipher.  Maybe it&#8217;s because this is the first &#8220;non-trivial&#8221; cipher most students learn, and its cryptanalysis is also slightly non-trivial.  Anyway, who am I to buck this trend?  So [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&blog=3321115&post=536&subd=amca01&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Most writers of cryptography texts, to my mind, spend a disproportionate amount of time and space carefully discussing the cryptanalysis of the Vigen&egrave;re cipher.  Maybe it&#8217;s because this is the first &#8220;non-trivial&#8221; cipher most students learn, and its cryptanalysis is also slightly non-trivial.  Anyway, who am I to buck this trend?  So this post shows how to do it in Sage.</p>
<p>First, the cipher itself.  It&#8217;s a <em>polyalphabetic</em> cipher, where each letter of the plaintext is shifted by an amount given by a keyword; this key being repeated as much as required:</p>
<p><code><br />
T H I S I S T H E P L A I N T E X T T O B E E N C R Y P T E D<br />
K E Y W O R D K E Y W O R D K E Y W O R D K E Y W O R D K E Y<br />
</code></p>
<p>In this example, and using the correspondence A=0, B=1 up to Y=24, Z=25, we see that every seventh letter is shifted by the same amount: letters in the 1st, 8th, 15th, 22nd positions are shifted by K=10; letters in the 2nd, 9th, 16th 23rd positions are shifted by E=4, and so on.  The resulting ciphertext is</p>
<p><code><br />
D L G O W J W R I N H O Z Q D I V P H F E O I L Y F P S D I B<br />
</code></p>
<p>What makes this cipher seem so strong is that similar letters in the plaintext are not necessarily encrypted to the same letters in the ciphertext: notice for example that the first two I&#8217;s are encrypted to Y and O; and that similar letters in the ciphertext do not necessarily correspond to the same letters in the plaintext.</p>
<p>However, if the length <img src='http://s3.wordpress.com/latex.php?latex=n&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='n' title='n' class='latex' /> of the keyword can be determined, then we know that every <img src='http://s1.wordpress.com/latex.php?latex=n&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='n' title='n' class='latex' />th letter is shifted by the same amount.  If there are enough letters to perform a frequency analysis (and using the fact that the most common letter in English text is E), then the value of the shift can be found.  One way of determining the keyword length is to shift the ciphertext by a given amount and check all the coincidences (equality of letters) between the ciphertext and its shift.  A shift with a large number of coincidences may be the length of the keyword.  This method is called <em>Kasiski&#8217;s method</em> after its 19th century discoverer.</p>
<p>For an example, I have a very long ciphertext which has been obtained with a Vigen&egrave;re cipher.  You can see it <a href="http://amca01.wordpress.com/2009/11/03/ciphertext/">here</a>.  Anyway, it&#8217;s nearly 20,000 characters long.  To find the length of the keyword which was used, the first step is to write a little program to perform a cyclic shift of a string:</p>
<pre>
def cshift(str,n):
   slen=len(str)
   return str[n:slen+1]+str[0:n]
</pre>
<p>Now to find the coincidences with different shifts:</p>
<pre>
sage: clen=len(ct)
sage: for i in range(20):
    ctx=cshift(ct,i)
    coin=0
    for j in range(clen):
        if ct[j]==ctx[j]:
            coin=coin+1
    print i,coin
</pre>
<p>and this returns the output:</p>
<p><code><br />
0 19369<br />
1 683<br />
2 782<br />
3 791<br />
4 728<br />
5 675<br />
6 655<br />
7 1284<br />
8 712<br />
9 734<br />
10 718<br />
11 764<br />
12 708<br />
13 718<br />
14 1192<br />
15 709<br />
16 716<br />
17 734<br />
18 792<br />
19 697<br />
</code></p>
<p>Neglecting the first output, we see that the greatest number of coincidences occur for shifts of 7 and 14.  This would seem to indicate that the keyword has length 7.</p>
<p>Now we break up the ciphertext into seven groups:</p>
<pre>
sage: ct7s=['','','','','','','']
sage: sage: for i in range(clen):
    ct7s[i%7]=ct7s[i%7]+ct[i]
</pre>
<p>The next step is to find which of the letters is most common in each group.  Here&#8217;s one way:</p>
<pre>
sage: alph='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
sage: for i in alph:
    print i, ct7s[0].count(i)
</pre>
<p>which produces</p>
<pre>
A 1
B 71
C 1
D 217
E 41
F 78
G 123
H 366
I 64
J 52
K 160
L 192
M 2
N 27
O 102
P 86
Q 187
R 196
S 40
T 2
U 167
V 188
W 236
X 74
Y 23
Z 71
</pre>
<p>from which it is obvious that the most common letter in this group is H.  Repeating this same procedure for the other six groups enables us to build up a table of the most common letter in each group:</p>
<pre>
0 H
1 M
2 G
3 O
4 I
5 R
6 W
</pre>
<p>(Of course, this entire process can be easily automated; on the other hand it&#8217;s quite nice to do everything separately one step at a time.)  Now, the most common letter in English is E, which has the value 4.  If H corresponds to E, that means that for group 0, there has been a shift of 3, which corresponds to the letter D.  This is the first letter of the keyword.  And in fact every other letter of the keyword can be obtained by shifting back by 4 from each common letter.  This produces the keyword
<pre>DICKENS.</pre>
<p>Applying this to decrypt the ciphertext produces:</p>
<pre>
WHETHERISHALLTURNOUTTOBETHEHEROOFMYOWNLIFEORWHETHERTHATSTATION
WILLBEHELDBYANYBODYELSETHESEPAGESMUSTSHOW
...
BOURNEOFALLSUCHTRAVELLERSANDTHEMOUNDABOVETHEASHESANDTHEDUST
THATONCEWASHEWITHOUTWHOMIHADNEVERBEEN
</pre>
<p>- it&#8217;s the first chapter of &#8220;David Copperfield&#8221;, by Charles Dickens, in uppercase with all punctuation removed.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amca01.wordpress.com/536/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amca01.wordpress.com/536/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amca01.wordpress.com/536/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amca01.wordpress.com/536/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amca01.wordpress.com/536/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amca01.wordpress.com/536/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amca01.wordpress.com/536/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amca01.wordpress.com/536/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amca01.wordpress.com/536/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amca01.wordpress.com/536/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&blog=3321115&post=536&subd=amca01&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://amca01.wordpress.com/2009/11/03/vigenre-and-kasiski/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b6bb720c28219294cf31d0693ed47388?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amca01</media:title>
		</media:content>
	</item>
		<item>
		<title>A graphical and numerical approach to teaching calculus</title>
		<link>http://amca01.wordpress.com/2009/10/15/a-graphical-and-numerical-approach-to-teaching-calculus/</link>
		<comments>http://amca01.wordpress.com/2009/10/15/a-graphical-and-numerical-approach-to-teaching-calculus/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 12:38:13 +0000</pubDate>
		<dc:creator>amca01</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://amca01.wordpress.com/?p=522</guid>
		<description><![CDATA[I&#8217;m thinking about teaching calculus using Matlab.  This is far from being a new idea &#8211; people have been using Matlab in their teaching for as long as Matlab has existed &#8211; but it must be admitted that as far as calculus is concerned, Matlab is probably less well equipped than a computer algebra [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&blog=3321115&post=522&subd=amca01&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I&#8217;m thinking about teaching calculus using <a href="http://www.mathworks.com">Matlab</a>.  This is far from being a new idea &#8211; people have been using Matlab in their teaching for as long as Matlab has existed &#8211; but it must be admitted that as far as calculus is concerned, Matlab is probably less well equipped than a computer algebra system such as <a href="http://www.maplesoft.com">Maple</a>, <a href="http://www.wolfram.com">Mathematica</a>, or the open source <a href="http://maxima.sourceforge.net/">Maxima</a> and <a href="http://www.sagemath.org/">Sage</a>.  This is of course because Matlab is primarily a numeric and computational system, whereas Maple, Mathematica and the others are symbolic systems.  And calculus, being primarily analytical and symbolic, is better served by them.</p>
<p>That being said, I think that in fact Matlab &#8211; used only for computation and graphics &#8211; could be used to great effect in a calculus course.  Note that the new versions of Matlab contain the <a href="http://www.mathworks.com/products/symbolic/">Symbolic Math Toolbox</a>, which provides a Matlab interface to the CAS <a href="http://www.sciface.com/technology.php">MuPAD</a>.  However, I&#8217;m rather against using MuPAD-in-Matlab.  For one thing, it seems to be a fairly clumsy interface.  And you have to declare variables as being symbolic, so as not to confuse Matlab with its own (numeric) variables.  I think if you want to use a symbolic system, then do just that.  If you want a numeric system, do just that.</p>
<p>My feeling is that using plain old unadorned Matlab would be a great help to engineering students, for whom the bulk of their computing is Matlab based.  I think introducing symbolic computation would only add to their cognitive load, without necessarily helping their mathematical understanding.  So my thoughts are to introduce the standard calculus material &#8211; limits, derivatives, integrals and their applications &#8211; analytically, and then use the numeric and graphical capabilities of Matlab to explore and enhance that material.  And in fact there&#8217;s a lot you can do.</p>
<p>Here&#8217;s a small sample.</p>
<p><strong>Limits</strong></p>
<p>Limits can easily be explored numerically in Matlab.  For example, the old warhorse</p>
<p><img src='http://s2.wordpress.com/latex.php?latex=%5Cdisplaystyle%7B%5Clim_%7Bx%5Cto+0%7D%5Cfrac%7B%5Csin+x%7D%7Bx%7D%7D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='\displaystyle{\lim_{x\to 0}\frac{\sin x}{x}}' title='\displaystyle{\lim_{x\to 0}\frac{\sin x}{x}}' class='latex' /></p>
<p>You could simply, for example, enter:</p>
<pre>
&gt;&gt; x = 0.1
&gt;&gt; sin(x)/x
</pre>
<p>and then replace x with 0.01, 0.001, and so on, and see what happens to the values of the function.  You could first set</p>
<pre>
&gt;&gt; format long
</pre>
<p>to give you more decimal places.</p>
<p>Rather than entering a new x value each time, you could do it all in one go:</p>
<pre>
&gt;&gt; x = [0.1; 0.01; 0.001; 0.0001; 0.00001]
&gt;&gt; sin(x)./x
</pre>
<p>but this presupposes that students understand the &#8220;dot&#8221; notation of Matlab.  Maybe you could define the function first:</p>
<pre>
f = @(x) sin(x)/x
</pre>
<p>and then apply it to your vector x:</p>
<pre>
arrayfun(f,x)
</pre>
<p>And of course if you wanted you could create the vector x using</p>
<pre>
x = 0.1.^[1:5]'
</pre>
<p>but this last assumes a certain knowledge of Matlab&#8217;s workings.  I would certainly teach function definition (such as above), and the command <tt>arrayfun</tt>.</p>
<p><strong>Newton&#8217;s method</strong></p>
<p>Who does not love and teach</p>
<p><img src='http://s3.wordpress.com/latex.php?latex=%5Cdisplaystyle%7Bx%5Cleftarrow+x-%5Cfrac%7Bf%28x%29%7D%7Bf%27%28x%29%7D%7D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='\displaystyle{x\leftarrow x-\frac{f(x)}{f&#039;(x)}}' title='\displaystyle{x\leftarrow x-\frac{f(x)}{f&#039;(x)}}' class='latex' />?</p>
<p>Matlab is at a disadvantage here &#8211; without the symbolic toolbox, it can&#8217;t compute symbolic derivatives.  However, it can perform differentiation of polynomials (treated as vectors of their coefficients).  So we start here.  For example, let&#8217;s solve</p>
<p><img src='http://s1.wordpress.com/latex.php?latex=x%5E5%2Bx%5E2-1%3D0&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='x^5+x^2-1=0' title='x^5+x^2-1=0' class='latex' /></p>
<p>using Newton&#8217;s method, with a starting value of <img src='http://s2.wordpress.com/latex.php?latex=x%3D0.8&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='x=0.8' title='x=0.8' class='latex' />  First, we define the function and its derivative:</p>
<pre>
&gt;&gt; p = [1 0 0 1 0 -1]
&gt;&gt; f = @(x) polyval(p,x)
&gt;&gt; df = @(x) polyval(polyder(p),x)
</pre>
<p>Putting this together into a Newton&#8217;s rule function:</p>
<pre>
&gt;&gt; nr = @(x) x-f(x)/df(x)
</pre>
<p>Now we can start using it.  First the easy way:</p>
<pre>
&gt;&gt; 0.8
&gt;&gt; nr(ans)
   0.808859649122807
&gt;&gt; nr(ans)
   0.808730628358884
&gt;&gt; nr(ans)
   0.808730600479393
</pre>
<p>for as long as we like.</p>
<p>Next, a slightly more sophisticated way:</p>
<pre>
&gt;&gt; a = [0.8]
&gt;&gt; for i=1:6 a=[a(:);nr(a(i))];end
&gt;&gt; a

   0.80000000000000
   0.80885964912281
   0.80873062835888
   0.80873060047939
   0.80873060047939
   0.80873060047939
   0.80873060047939
</pre>
<p>For Newton&#8217;s method applied to non polynomial functions, you could enter the function and its derivative yourself:</p>
<pre>
&gt;&gt; f = @(x) exp(x)-x^2
&gt;&gt; df = @(x) exp(x)-2*x
</pre>
<p>and then proceed as above.</p>
<p><strong>Drawing tangent lines</strong></p>
<p>Again, first enter the function and its derivative:</p>
<pre>
&gt;&gt; f = @(x) exp(-x^2)
&gt;&gt; df = @(x) -2*x*exp(-x^2)
</pre>
<p>Given an <img src='http://s3.wordpress.com/latex.php?latex=x&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='x' title='x' class='latex' /> value, we can determine the values of the function and derivative at that point, and construct the tangent line:</p>
<pre>
&gt;&gt; a = 1.2
&gt;&gt; fa = f(a)
&gt;&gt; dfa = df(a)
&gt;&gt; t = @(x) dfa*(x-a)+fa
</pre>
<p>and we can sketch both together:</p>
<pre>
&gt;&gt; ezplot(f, [0,2])
&gt;&gt; hold on
&gt;&gt; ezplot(t,[0,2])
</pre>
<p><strong>Simpson&#8217;s rule</strong></p>
<p>There are, at a conservative estimate, about 42,897 versions of Simpson&#8217;s rule in Matlab.  I want to keep it as simple as possible, and not use any clever Matlab tricks.  So here&#8217;s one way to calculate</p>
<p><img src='http://s1.wordpress.com/latex.php?latex=%5Cdisplaystyle%7B%5Cint%5E1_0e%5E%7B-x%5E2%7D%5C%2Cdx%7D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='\displaystyle{\int^1_0e^{-x^2}\,dx}' title='\displaystyle{\int^1_0e^{-x^2}\,dx}' class='latex' />.</p>
<p>First set up the function, the limits of integration, and the number of times Simpson&#8217;s rule will be used:</p>
<pre>
&gt;&gt; a = 0
&gt;&gt; b = 1
&gt;&gt; f = @(x) exp(-x^2)
&gt;&gt; n = 4
</pre>
<p>Now we set up the nodes (where the integral will be evaluated):</p>
<pre>
&gt;&gt; x = linspace(a,b,2*n+1)
&gt;&gt; h = (b-a)/(2*n)
</pre>
<p>and the weights &#8211; we can either just enter them by hand:</p>
<pre>
&gt;&gt; w = [1 4 2 4 2 4 2 4 2 4 1]
</pre>
<p>or</p>
<pre>
&gt;&gt; w = zeros(1,2*n+1)
&gt;&gt; for i=1:n w(2*i-1:2*i+1)=w(2*i-1:2*i+1)+[1 4 1];end
</pre>
<p>Now put it all together:</p>
<pre>
&gt;&gt; s = sum(w.*arrayfun(f,x))*h/3

     0.74682612052747
</pre>
<p>The last could of course be done as a single matrix product:</p>
<pre>
&gt;&gt; s = w*arrayfun(f,x))'*h/3
</pre>
<p>but I think the first method is conceptually easier.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amca01.wordpress.com/522/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amca01.wordpress.com/522/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amca01.wordpress.com/522/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amca01.wordpress.com/522/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amca01.wordpress.com/522/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amca01.wordpress.com/522/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amca01.wordpress.com/522/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amca01.wordpress.com/522/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amca01.wordpress.com/522/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amca01.wordpress.com/522/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&blog=3321115&post=522&subd=amca01&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://amca01.wordpress.com/2009/10/15/a-graphical-and-numerical-approach-to-teaching-calculus/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b6bb720c28219294cf31d0693ed47388?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amca01</media:title>
		</media:content>
	</item>
		<item>
		<title>Animated graphics in mathematics education</title>
		<link>http://amca01.wordpress.com/2009/10/04/animated-graphics-in-mathematics-education/</link>
		<comments>http://amca01.wordpress.com/2009/10/04/animated-graphics-in-mathematics-education/#comments</comments>
		<pubDate>Sat, 03 Oct 2009 14:09:10 +0000</pubDate>
		<dc:creator>amca01</dc:creator>
				<category><![CDATA[Maths teaching]]></category>
		<category><![CDATA[Sage]]></category>

		<guid isPermaLink="false">http://amca01.wordpress.com/?p=508</guid>
		<description><![CDATA[As far as I know, there&#8217;s been little research done on this topic, although it seems to me that animations could be enormously helpful in facilitating the learning of some mathematics.  Think, for example, of the &#8220;limit of secants&#8221; method for defining a derivative:

I know that when I teach elementary calculus I draw a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&blog=3321115&post=508&subd=amca01&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>As far as I know, there&#8217;s been little research done on this topic, although it seems to me that animations could be enormously helpful in facilitating the learning of some mathematics.  Think, for example, of the &#8220;limit of secants&#8221; method for defining a derivative:</p>
<p><img src='http://s2.wordpress.com/latex.php?latex=%5Cdisplaystyle%7Bf%27%28a%29%3D%5Clim_%7Bx%5Cto+a%7D%5Cfrac%7Bf%28x%29-f%28a%29%7D%7Bx-a%7D%7D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='\displaystyle{f&#039;(a)=\lim_{x\to a}\frac{f(x)-f(a)}{x-a}}' title='\displaystyle{f&#039;(a)=\lim_{x\to a}\frac{f(x)-f(a)}{x-a}}' class='latex' /></p>
<p>I know that when I teach elementary calculus I draw a curve, and try to show by means of diagrams that as <img src='http://s3.wordpress.com/latex.php?latex=x&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='x' title='x' class='latex' /> slides along the curve to <img src='http://s1.wordpress.com/latex.php?latex=a&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='a' title='a' class='latex' />, the secant &#8220;approaches&#8221; the tangent to the curve at <img src='http://s2.wordpress.com/latex.php?latex=a&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='a' title='a' class='latex' />.  Some students, if not fully convinced, give the impression that there is merit in this argument; other students sit there with their &#8220;when will this be finished?&#8221; look on their faces.  This seems to be a place where some interactive or animated graphics would be very helpful.</p>
<p>Most computer algebra systems now provide some support for animation; if they don&#8217;t they should.  Interestingly, when CAS&#8217;s are compared, graphics usually are not considered.  Way back in the late 1990&#8217;s, when Michael Wester was producing his monumental review of CAS&#8217;s (of which an earlier version can be found <a href="http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.50.7380">here</a>), they were treated as problem solving black boxes: problem goes in; solution comes out.  The best CAS was the one which solved (correctly!) the greatest number of problems from the broadest number of topics.  And this style seems to have permeated CAS comparisons ever since.  As far as I know, very few reviews have investigated the graphics capabilities of such systems.  One which did was <a href="http://www.math.caltech.edu/people/simon.html">Barry Simon&#8217;s</a> &#8220;Symbolic Math Powerhouses Revisited&#8221;, which is available as the first chapter in Wester&#8217;s <a href="http://www.amazon.com/Computer-Algebra-Systems-Practical-Guide/dp/0471983535/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1254577251&amp;sr=1-1">Computer Algebra Systems, A Practical Guide</a>.</p>
<p>I think that most mathematics educators are simply unwilling to come to grips with the technology which enables such graphics to be produced, but in fact most modern software makes this very easy.</p>
<p>As an example, I&#8217;m going to show how to produce a <a href="http://en.wikipedia.org/wiki/Cycloid">cycloid</a> in Sage.  Sage contains an &#8220;animate&#8221; command, which simply runs though a list of graphics objects, displaying them one after the other.  To draw my cycloid, I&#8217;m going to need three such lists:</p>
<ol>
<li>The moving circle.</li>
<li>The point on the circle&#8217;s circumference.</li>
<li>The cycloid as drawn by that point.</li>
</ol>
<p>And of course I need the equation of the cycloid, which is easiest given parametrically:</p>
<p><img src='http://s3.wordpress.com/latex.php?latex=x%3Dt-%5Csin%28t%29&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='x=t-\sin(t)' title='x=t-\sin(t)' class='latex' /><br />
<img src='http://s1.wordpress.com/latex.php?latex=y%3D1-%5Ccos%28t%29&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='y=1-\cos(t)' title='y=1-\cos(t)' class='latex' /></p>
<p>So here&#8217;s how to produce the three graphics objects above:</p>
<pre>
step = 0.3
v = []
for t in srange(0,2*pi,step):
    v.append(circle((t,1),1))
a = animate(v, xmin=-1, ymin=0, xmax=8, ymax=2, figsize=[9,2])
</pre>
<p>There should be no surprises here; &#8220;v&#8221; is a list, which is filled up with circles all with different centres.  And the points:</p>
<pre>
w = []
for t in srange(0,2*pi,step):
    w.append(point((t-sin(t),1-cos(t)),pointsize=20))
b = animate(w, xmin=-1, ymin=0, xmax=8, ymax=2, figsize=[9,2])
</pre>
<p>Note here we use the parametric equations to plot the points.  And finally the cycloid itself: we draw it as a sequence of lines from the previous to the current point:</p>
<pre>
L = Graphics()
x = []
for t in srange(0,2*pi,step):
    L += line([(t-step-sin(t-step),1-cos(t-step)),(t-sin(t),1-cos(t))], rgbcolor=(1,0,0), thickness=2)
    x.append(L)
c = animate(x, xmin=-1, ymin=0, xmax=8, ymax=2, figsize=[9,2])
</pre>
<p>To display this animation, we simply display all of a, b and c together:</p>
<pre>
(a+b+c).show()
</pre>
<p>You can see the animation <a href="http://amca01.files.wordpress.com/2009/10/cycloid.gif">here</a>.</p>
<p>Now that wasn&#8217;t so hard, was it?</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amca01.wordpress.com/508/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amca01.wordpress.com/508/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amca01.wordpress.com/508/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amca01.wordpress.com/508/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amca01.wordpress.com/508/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amca01.wordpress.com/508/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amca01.wordpress.com/508/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amca01.wordpress.com/508/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amca01.wordpress.com/508/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amca01.wordpress.com/508/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&blog=3321115&post=508&subd=amca01&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://amca01.wordpress.com/2009/10/04/animated-graphics-in-mathematics-education/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b6bb720c28219294cf31d0693ed47388?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amca01</media:title>
		</media:content>
	</item>
		<item>
		<title>Book Review: &#8220;A Computational Introduction to Number Theory and Algebra&#8221; by Victor Shoup, 2nd ed.</title>
		<link>http://amca01.wordpress.com/2009/10/03/book-review-a-computational-introduction-to-number-theory-and-algebra-by-victor-shoup-2nd-ed/</link>
		<comments>http://amca01.wordpress.com/2009/10/03/book-review-a-computational-introduction-to-number-theory-and-algebra-by-victor-shoup-2nd-ed/#comments</comments>
		<pubDate>Sat, 03 Oct 2009 00:00:07 +0000</pubDate>
		<dc:creator>amca01</dc:creator>
				<category><![CDATA[Cryptography]]></category>
		<category><![CDATA[Maths teaching]]></category>

		<guid isPermaLink="false">http://amca01.wordpress.com/?p=501</guid>
		<description><![CDATA[I wrote this review a few months ago for &#8220;Computing Reviews&#8221;, who&#8217;ve published it.  But for the benefit of those who don&#8217;t have access to these reviews, here it is.

Occasionally it&#8217;s a pleasure to find a book which is so masterful, so well written, that it has all the hallmarks of the classic.  [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&blog=3321115&post=501&subd=amca01&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I wrote this review a few months ago for &#8220;Computing Reviews&#8221;, who&#8217;ve published it.  But for the benefit of those who don&#8217;t have access to these reviews, here it is.</p>
<hr />
Occasionally it&#8217;s a pleasure to find a book which is so masterful, so well written, that it has all the hallmarks of the classic.  This is such a book.  Shoup has set himself a difficult task &#8211; to bring the reader up to speed with number theory and algebra, starting &#8220;from scratch&#8221; &#8211; and he has succeeded magnificently.  My main complaint with the book is that it is not longer, but as Shoup himself regretfully observes in the introduction, to keep to a reasonable size, some important topics had to be omitted.</p>
<p>Many books on computational number theory present the theory as a sort of smorgasbord of algorithms: primality testing, factorization, discrete logarithms, modular square and n-th roots.  Shoup steers clear of this recipe based approach, and instead places the entire theory into a formal algebraic setting.  This allows not only for elegance of exposition and a remarkable clarity, but provides the entire book with a structural homogeneity.</p>
<p>Even though &#8220;some topics could simply not be covered&#8221;, the range of topics presented is wide.  The book is geared towards students of cryptography and coding theory, and the material has been chosen to be most relevant to those disciplines.</p>
<p>The books starts with several of standard integer based number theory: divisibility, congruences and modular arithmetic, including quadratic residues (but reciprocity is treated later), large integer arithmetic, Euclid&#8217;s algorithm and its association with the Chinese remainder theorem, and a brief discussion of the RSA cryptosystem, including a particularly elegant proof of its correctness.  All this material is standard to many other texts, yet rarely treated with as much care as here, in spite of the relative brevity. These first few chapters contain as much mathematics as many cryptography texts, and yet at this stage we are not yet one fifth into the book!  Another chapter discusses the distribution of primes, including a proof of Bertrand&#8217;s postulate and a discussion of the prime number theorem.  Given the importance of primes to modern cryptography, these may be considered vital topics, and it is refreshing to see them treated so well.</p>
<p>These first chapters set the scene, so to speak, for the number theory with which the text is concerned.  However, much of the subsequent material is discussed in terms of the general theory of groups and rings.  Primitive roots, for example, are not discussed as such, but in terms of generators of the non-zero residues of integers modulo a prime.  Although this approach might seem at first to be unnecessarily obtuse, it is in fact the most natural way of introducing these algorithms, as it places them squarely in a generalized algebraic theory.  The text, as we would expect, contains several chapters discussing the basic theory of abelian groups and rings, including a fine proof of the fundamental theorem of the structure of finite abelian groups as<br />
a sum of cyclic groups.</p>
<p>What makes this book unique is the way that several different mathematical strands &#8211; number theory and algebra &#8211; are  interwoven and made into a masterful whole.  As well as rings and fields, there is much linear algebra (modules, vector spaces and matrices), as well as a considerable amount on probability distributions and probabilistic algorithms, culminating in the Miller-Rabin test for primality and a few applications.</p>
<p>The book ends with some chapters on finite fields and their various algorithms, and a chapter on the AKS deterministic primality test, for which the author carefully observes that the probabilistic Miller-Rabin test is much faster, and hence should be preferred for all practical purposes.  However, as an ingenious use of much number theory and algebra, the AKS algorithm is a lovely example with which to finish the text.</p>
<p>Although the text requires not much specific mathematical background, I would hesitate to use it except in an advanced class, or for students whose mathematical ability was already high.  The material moves swiftly &#8211; while never compromising rigour &#8211; and the multiple strands assume considerable ability on the part of the reader.  I was pleased to see copious exercises; a student who has completed the book and mastered the exercises will be in a very strong position to embark on some advanced studies.  The author does not recommend any specific chapter sequences for a semester&#8217;s study, but clearly an astute teacher could pull some parts from this text for an initial course of study, and complete the text in an advanced course.</p>
<p>One regrettable omission is that of the use of any computational tools, either the author&#8217;s own C++ NTL library for  computational number theory and algebra, or the use of a computer algebra system.  A companion volume, or material on the author&#8217;s website, discussing some implementation issues, would be most welcome.  We note in passing that thanks to the   generosity of the publishers, the entire text is available under a Creative Commons licence on the author&#8217;s site <a href="http://www.shoup.net">http://www.shoup.net</a>.</p>
<p>This is a truly magnificent text, deserving of a place on the shelves of any mathematician or computer scientist working in  these areas.  I hope it has a long life and many further editions.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amca01.wordpress.com/501/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amca01.wordpress.com/501/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amca01.wordpress.com/501/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amca01.wordpress.com/501/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amca01.wordpress.com/501/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amca01.wordpress.com/501/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amca01.wordpress.com/501/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amca01.wordpress.com/501/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amca01.wordpress.com/501/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amca01.wordpress.com/501/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&blog=3321115&post=501&subd=amca01&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://amca01.wordpress.com/2009/10/03/book-review-a-computational-introduction-to-number-theory-and-algebra-by-victor-shoup-2nd-ed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b6bb720c28219294cf31d0693ed47388?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amca01</media:title>
		</media:content>
	</item>
		<item>
		<title>An anagram measure</title>
		<link>http://amca01.wordpress.com/2009/09/30/an-anagram-measure/</link>
		<comments>http://amca01.wordpress.com/2009/09/30/an-anagram-measure/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 03:33:27 +0000</pubDate>
		<dc:creator>amca01</dc:creator>
				<category><![CDATA[Sage]]></category>

		<guid isPermaLink="false">http://amca01.wordpress.com/?p=488</guid>
		<description><![CDATA[Those like me with a love of the byways of the English language, or with a love of cryptic crosswords, will no doubt have collected over the years a private trove of single word anagrams.  One of my favourites (because both words are common) is
ORCHESTRA, CARTHORSE
Clearly smaller words are likely to have more anagrams [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&blog=3321115&post=488&subd=amca01&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Those like me with a love of the byways of the English language, or with a love of cryptic crosswords, will no doubt have collected over the years a private trove of single word anagrams.  One of my favourites (because both words are common) is</p>
<p>ORCHESTRA, CARTHORSE</p>
<p>Clearly smaller words are likely to have more anagrams than longer ones:</p>
<p>OPST, POTS, POST, STOP, SPOT, TOPS</p>
<p>From the <a href="http://www.anagrammy.com/anagrams/faq6.html">Anagrams FAQ</a> comes this lovely example, of almost familiar words (at least, they are not scientific or technical terms):</p>
<p>INTERROGATIVES, REINVESTIGATOR, TERGIVERSATION</p>
<p>From an <a href="http://programmingpraxis.com/2009/04/10/anagrams/">anagrams programming page</a>:</p>
<p>ANGOR, ARGON, GORAN, GRANO, GROAN, NAGOR, ORANG, ORGAN, ROGAN</p>
<p>several of which are unfamiliar to me as English words.  I&#8217;m not allowing proper names.</p>
<p>How can we measure the &#8220;anagrammability&#8221; of a set of letters?  Some account should be given to the number of anagrams, and to the length of the word.  A long word with only two anagrams should get a higher score than a small word with many.  Let <img src='http://s2.wordpress.com/latex.php?latex=n&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='n' title='n' class='latex' /> be the number of letters, and <img src='http://s3.wordpress.com/latex.php?latex=k&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='k' title='k' class='latex' /> the number of (single word) English anagrams.  My anagrammability measure (discussed with my eldest son) is:</p>
<p><img src='http://s1.wordpress.com/latex.php?latex=%28k-1%29n%5E2&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='(k-1)n^2' title='(k-1)n^2' class='latex' />.</p>
<p>This gives a score of zero if there are no anagrams other than the word itself, and is weighted for large words.</p>
<p>With the examples above:</p>
<p>ORCHESTRA: 81<br />
OPST: 80<br />
INTERROGATIVES: 392<br />
ANGOR: 200</p>
<p>According to the <a href="http://www.anagrammy.com/anagrams/faq7.html">Anagrams FAQ</a> again, the set of letters with the most one word anagrams is AEINRST with:</p>
<p>ANESTRI, ASTERIN, ERANIST, NASTIER, RATINES, RESIANT, RESTAIN, RETAINS, RETINAS, RETSINA, SAINTER, STAINER, STARNIE, STEARIN</p>
<p>for a score of 637.  (I&#8217;ve never seen some of these words before, but apparently they can all be found in Merriam-Webster&#8217;s unabridged dictionary).</p>
<p>It&#8217;s not hard to experiment with anagrams in Sage; all you need is a wordlist, which you can read in, turn into a list and strip the trailing non-printing characters.  You can download a list of 109582 words <a href="http://www.sil.org/linguistics/wordlists/english/wordlist/wordsEn.txt">here</a>, then save it as, say,</p>
<pre>words.txt</pre>
<p>.<br />
Then:</p>
<pre>f = open("words.txt","r")
nwords = f.readlines()
words = []
for i in nwords:
   words.append(i.strip('\r\n'))
</pre>
<p>Then we can write a simple program which given any string, checks if each permutation is in the list we&#8217;ve just created:</p>
<pre>def find_anagrams(myword):
   anagrams=[]
   for i in permutations(myword):
       anagrams.append(join(i,""))
   for i in anagrams:
       if i in words:
           print i
</pre>
<p>For example:</p>
<pre>sage: find_anagrams('opst')
opts
post
pots
spot
stop
tops
sage: find_anagrams('aeirnst')
retains
retinas
retsina
nastier
stainer
stearin
sage: find_anagrams('organ')
orang
organ
groan
argon
</pre>
<p>Clearly this wordlist doesn&#8217;t include all the words listed earlier.  Clearly also this method is hideously inefficient &#8211; it creates all the possible anagrams first, and then checks if each one is in the wordlist.  A much better method, for words of say, 8 letters or longer, would be to first set up the wordlist into sublists of words with the same number of letters.  Then for your entered word, you simply check if each word in your list is an anagram of your entered word.</p>
<p>And here&#8217;s how to do that.  First we discover that the longest word in our list has 28 letters:</p>
<pre>words = [[] for i in range(28)]
for i in nwords:
   li=len(i)
   words[li-3].append(i.strip('\r\n'))
</pre>
<p>and a little procedure to test anagrams:</p>
<pre>def isanagram(w1,w2):
    l1=list(w1)
    l2=list(w2)
    l1.sort()
    l2.sort()
    return l1==l2
</pre>
<p>and finally the program to find anagrams in our New Improved List:</p>
<pre>def find2_anagrams(myword):
    lm=len(myword);
    for i in words[lm-1]:
        if isanagram(i,myword):
            print i
</pre>
<p>A quick test of it:</p>
<pre>sage: find2_anagrams('retains')
nastier
retains
retinas
retsina
stainer
stearin
</pre>
<p>This is <em>much</em> faster than the first method.</p>
<p><strong>Addendum</strong></p>
<p>Running this over the entire word list, the highest scoring group of letters I found was AEIGLNRT, with</p>
<p>ALERTING, ALTERING, INTEGRAL, RELATING, TANGLIER, TRIANGLE</p>
<p>for a score of 320.</p>
<p>A much longer list of words is that created as part of the <a href="http://en.wikipedia.org/wiki/Moby_Project">Moby Project</a>; &#8220;Moby Words&#8221; can be downloaded from <a href="http://icon.shef.ac.uk/Moby/">this page</a>, and the file single.txt contains a splendid 354,984 words.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amca01.wordpress.com/488/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amca01.wordpress.com/488/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amca01.wordpress.com/488/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amca01.wordpress.com/488/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amca01.wordpress.com/488/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amca01.wordpress.com/488/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amca01.wordpress.com/488/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amca01.wordpress.com/488/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amca01.wordpress.com/488/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amca01.wordpress.com/488/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&blog=3321115&post=488&subd=amca01&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://amca01.wordpress.com/2009/09/30/an-anagram-measure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b6bb720c28219294cf31d0693ed47388?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amca01</media:title>
		</media:content>
	</item>
		<item>
		<title>Provably secure hash functions</title>
		<link>http://amca01.wordpress.com/2009/09/28/provably-secure-hash-functions/</link>
		<comments>http://amca01.wordpress.com/2009/09/28/provably-secure-hash-functions/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 10:02:20 +0000</pubDate>
		<dc:creator>amca01</dc:creator>
				<category><![CDATA[Cryptography]]></category>
		<category><![CDATA[Sage]]></category>

		<guid isPermaLink="false">http://amca01.wordpress.com/?p=464</guid>
		<description><![CDATA[As you may know, a cryptographic hash function is a function  which produces a string of fixed length irrespective of the size of the input .  Security of such functions consists of three requirements:

The function must be pre-image resistant.  That is, given a value , it should not be computationally feasible to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&blog=3321115&post=464&subd=amca01&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>As you may know, a <em>cryptographic hash function</em> is a function <img src='http://s1.wordpress.com/latex.php?latex=H%28m%29&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='H(m)' title='H(m)' class='latex' /> which produces a string of fixed length irrespective of the size of the input <img src='http://s2.wordpress.com/latex.php?latex=m&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='m' title='m' class='latex' />.  Security of such functions consists of three requirements:</p>
<ol>
<li>The function must be <em>pre-image resistant</em>.  That is, given a value <img src='http://s3.wordpress.com/latex.php?latex=h%3DH%28m%29&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='h=H(m)' title='h=H(m)' class='latex' />, it should not be computationally feasible to find the input <img src='http://s1.wordpress.com/latex.php?latex=m&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='m' title='m' class='latex' />.</li>
<li>The function must satisfy <em>weak collision resistance</em>; given an input <img src='http://s2.wordpress.com/latex.php?latex=m&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='m' title='m' class='latex' /> and hash <img src='http://s3.wordpress.com/latex.php?latex=h%3DH%28m%29&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='h=H(m)' title='h=H(m)' class='latex' /> it should be computatoinally infeasible to find another input <img src='http://s1.wordpress.com/latex.php?latex=m%27&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='m&#039;' title='m&#039;' class='latex' /> for which <img src='http://s2.wordpress.com/latex.php?latex=H%28m%27%29%3DH%28m%29&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='H(m&#039;)=H(m)' title='H(m&#039;)=H(m)' class='latex' />.</li>
<li>The function must satisfy <em>strong collision resistance</em>;  it should be computatoinally infeasible to find any two inputs <img src='http://s3.wordpress.com/latex.php?latex=m&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='m' title='m' class='latex' /> and <img src='http://s1.wordpress.com/latex.php?latex=m%27&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='m&#039;' title='m&#039;' class='latex' /> for which <img src='http://s2.wordpress.com/latex.php?latex=H%28m%27%29%3DH%28m%29&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='H(m&#039;)=H(m)' title='H(m&#039;)=H(m)' class='latex' />.</li>
</ol>
<p>In addition, for practical purposes, such a function should be fast to compute.</p>
<p>One place where hash functions are used are in message signatures.  Suppose Alice wishes to send a message <img src='http://s3.wordpress.com/latex.php?latex=m&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='m' title='m' class='latex' /> to Bob, and wants to sign it.  Because of the low efficiency of message signing, it&#8217;s much faster to sign a hash of the message.  Here is how this is done: </p>
<ol>
<li>Alice hashes the message <img src='http://s1.wordpress.com/latex.php?latex=h%3DH%28m%29&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='h=H(m)' title='h=H(m)' class='latex' />, and signs <img src='http://s2.wordpress.com/latex.php?latex=h&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='h' title='h' class='latex' /> with her private key to obtain the signature <img src='http://s3.wordpress.com/latex.php?latex=s&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='s' title='s' class='latex' />.  She sends <img src='http://s1.wordpress.com/latex.php?latex=m&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='m' title='m' class='latex' /> and <img src='http://s2.wordpress.com/latex.php?latex=s&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='s' title='s' class='latex' /> to Bob.</li>
<li>Bob hashes the received message <img src='http://s3.wordpress.com/latex.php?latex=m%27&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='m&#039;' title='m&#039;' class='latex' /> to obtain <img src='http://s1.wordpress.com/latex.php?latex=h%27%3DH%28m%27%29&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='h&#039;=H(m&#039;)' title='h&#039;=H(m&#039;)' class='latex' /> and verifies the signature <img src='http://s2.wordpress.com/latex.php?latex=s&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='s' title='s' class='latex' /> against the hash <img src='http://s3.wordpress.com/latex.php?latex=h%27&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='h&#039;' title='h&#039;' class='latex' /> using Alice&#8217;s public key.  If it works out he accepts the message as being genuinely from Alice.</li>
</ol>
<p>If the hash function were not collision resistant, then an intermediate malicious person, Mallory, could produce a message <img src='http://s1.wordpress.com/latex.php?latex=m%27%27&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='m&#039;&#039;' title='m&#039;&#039;' class='latex' /> with the same hash as <img src='http://s2.wordpress.com/latex.php?latex=m&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='m' title='m' class='latex' />, and send <img src='http://s3.wordpress.com/latex.php?latex=m%27%27&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='m&#039;&#039;' title='m&#039;&#039;' class='latex' /> and <img src='http://s1.wordpress.com/latex.php?latex=s&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='s' title='s' class='latex' /> along to Bob.  Bob would verify this new message <img src='http://s2.wordpress.com/latex.php?latex=m%27%27&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='m&#039;&#039;' title='m&#039;&#039;' class='latex' /> because hashing it would produce a value verifiable by the signature <img src='http://s3.wordpress.com/latex.php?latex=s&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='s' title='s' class='latex' />.</p>
<p>We note that for any hash function, there are only a finite number of hashes, yet there are an infinite number of possible messages, so collisions certainly exist.  The point is that such collisions must be hard to find.  In general, given a hash function of <img src='http://s1.wordpress.com/latex.php?latex=n&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='n' title='n' class='latex' /> bits, we should not expect to be able to find a collision in less than <img src='http://s2.wordpress.com/latex.php?latex=2%5E%7Bn%2F2%7D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='2^{n/2}' title='2^{n/2}' class='latex' /> brute-force trials.</p>
<p>Most hash functions are built on an ad hoc basis, where the bits of the message are nicely mixed to produce the hash.  But this means that security is hard to prove.  And in fact only a few years ago, one of the most popular hash functions, <a href="http://en.wikipedia.org/wiki/SHA_hash_functions">SHA-1</a>, was shown to be less secure than its length (160 bits) suggested: collisions could be found in only <img src='http://s3.wordpress.com/latex.php?latex=2%5E%7B69%7D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='2^{69}' title='2^{69}' class='latex' /> tests, rather than the brute-force number of <img src='http://s1.wordpress.com/latex.php?latex=2%5E%7B80%7D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='2^{80}' title='2^{80}' class='latex' />.  So the search for a &#8220;good&#8221; hash function has become a hot topic, with various different functions undergoing intense scrutiny and analysis to become the new SHA-3.  See <a href="http://ehash.iaik.tugraz.at/wiki/The_SHA-3_Zoo">The SHA-3 Zoo</a> for details.  At the same time there is renewed interest in hash functions which can be proven to be secure by being based on well-known &#8220;hard&#8221; problems, such as integer factorization, discrete logarithms, or the subset-sum problem.</p>
<p><strong>Shamir&#8217;s hash function</strong></p>
<p>This is one of the oldest, and simplest such functions.  Let <img src='http://s2.wordpress.com/latex.php?latex=p&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='p' title='p' class='latex' /> and <img src='http://s3.wordpress.com/latex.php?latex=q&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='q' title='q' class='latex' /> be two large primes, and let <img src='http://s1.wordpress.com/latex.php?latex=%5Calpha&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='\alpha' title='\alpha' class='latex' /> have order <img src='http://s2.wordpress.com/latex.php?latex=%5Clambda%28n%29%3D%5Cmbox%7Blcm%7D%28p-1%2Cq-1%29&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='\lambda(n)=\mbox{lcm}(p-1,q-1)' title='\lambda(n)=\mbox{lcm}(p-1,q-1)' class='latex' /> in <img src='http://s3.wordpress.com/latex.php?latex=%5CBbb%7BZ%7D_n&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='\Bbb{Z}_n' title='\Bbb{Z}_n' class='latex' />.  For an input <img src='http://s1.wordpress.com/latex.php?latex=x&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='x' title='x' class='latex' /> we define</p>
<p><img src='http://s2.wordpress.com/latex.php?latex=H%28x%29%3D%5Calpha%5Ex%5Cpmod%7Bn%7D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='H(x)=\alpha^x\pmod{n}' title='H(x)=\alpha^x\pmod{n}' class='latex' />.</p>
<p>To see that this is collision resistant, suppose we have two inputs <img src='http://s3.wordpress.com/latex.php?latex=x&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='x' title='x' class='latex' /> and <img src='http://s1.wordpress.com/latex.php?latex=y&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='y' title='y' class='latex' /> for which</p>
<p><img src='http://s2.wordpress.com/latex.php?latex=%5Calpha%5Ex%3D%5Calpha%5Ey%5Cpmod%7Bn%7D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='\alpha^x=\alpha^y\pmod{n}' title='\alpha^x=\alpha^y\pmod{n}' class='latex' />.</p>
<p>It follows that</p>
<p><img src='http://s3.wordpress.com/latex.php?latex=%5Calpha%5E%7Bx-y%7D%3D1%5Cpmod%7Bn%7D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='\alpha^{x-y}=1\pmod{n}' title='\alpha^{x-y}=1\pmod{n}' class='latex' /></p>
<p>or that</p>
<p><img src='http://s1.wordpress.com/latex.php?latex=x-y%3D0%5Cpmod%7B%5Clambda%28n%29%7D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='x-y=0\pmod{\lambda(n)}' title='x-y=0\pmod{\lambda(n)}' class='latex' />.</p>
<p>In other words, finding a collision is equivalent to determining the value of <img src='http://s2.wordpress.com/latex.php?latex=%5Clambda%28n%29&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='\lambda(n)' title='\lambda(n)' class='latex' />, which requires factorising <img src='http://s3.wordpress.com/latex.php?latex=n&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='n' title='n' class='latex' />.</p>
<p><strong>Chaum, van Heijst, Pfitzmann hash function</strong></p>
<p>Another classic: let <img src='http://s1.wordpress.com/latex.php?latex=q&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='q' title='q' class='latex' /> be a large prime such that <img src='http://s2.wordpress.com/latex.php?latex=p%3D2q%2B1&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='p=2q+1' title='p=2q+1' class='latex' /> is also prime, and let <img src='http://s3.wordpress.com/latex.php?latex=%5Calpha&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='\alpha' title='\alpha' class='latex' />, <img src='http://s1.wordpress.com/latex.php?latex=%5Cbeta&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='\beta' title='\beta' class='latex' /> be two primitive roots of <img src='http://s2.wordpress.com/latex.php?latex=p&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='p' title='p' class='latex' /> for which the discrete log <img src='http://s3.wordpress.com/latex.php?latex=log_%5Calpha%5Cbeta%5Cpmod%7Bp%7D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='log_\alpha\beta\pmod{p}' title='log_\alpha\beta\pmod{p}' class='latex' /> is computationally difficult.  Inputs to this function are pairs <img src='http://s1.wordpress.com/latex.php?latex=%28x%2Cy%29&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='(x,y)' title='(x,y)' class='latex' /> where <img src='http://s2.wordpress.com/latex.php?latex=x%3Cq&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='x&lt;q' title='x&lt;q' class='latex' /> and <img src='http://s3.wordpress.com/latex.php?latex=y%3Cq&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='y&lt;q' title='y&lt;q' class='latex' />.  Then:</p>
<p><img src='http://s1.wordpress.com/latex.php?latex=H%28x%29%3D%5Calpha%5Ex%5Cbeta%5Eb%5Cpmod%7Bp%7D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='H(x)=\alpha^x\beta^b\pmod{p}' title='H(x)=\alpha^x\beta^b\pmod{p}' class='latex' />.</p>
<p>Following <a href="http://books.google.com.au/books?id=JEpVP9FC4o4C&amp;lpg=PP1&amp;pg=PP1#v=onepage&amp;q=&amp;f=false">Buchmann</a>, we can show that finding a collision is equivalent to finding the discrete log.  Suppose we have a collision; that is two pairs <img src='http://s2.wordpress.com/latex.php?latex=%28x%2Cy%29&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='(x,y)' title='(x,y)' class='latex' /> and <img src='http://s3.wordpress.com/latex.php?latex=%28w%2Cz%29&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='(w,z)' title='(w,z)' class='latex' /> with the same hash:</p>
<p><img src='http://s1.wordpress.com/latex.php?latex=%5Calpha%5Ex%5Cbeta%5Ey%3D%5Calpha%5Ew%5Cbeta%5Ez%5Cpmod%7Bp%7D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='\alpha^x\beta^y=\alpha^w\beta^z\pmod{p}' title='\alpha^x\beta^y=\alpha^w\beta^z\pmod{p}' class='latex' />.</p>
<p>This can be rewritten as</p>
<p><img src='http://s2.wordpress.com/latex.php?latex=%5Calpha%5E%7Bx-w%7D%3D%5Cbeta%5E%7Bz-y%7D%5Cpmod%7Bp%7D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='\alpha^{x-w}=\beta^{z-y}\pmod{p}' title='\alpha^{x-w}=\beta^{z-y}\pmod{p}' class='latex' />.</p>
<p>Suppose that <img src='http://s3.wordpress.com/latex.php?latex=%5Clambda%3Dlog_%5Calpha%5Cbeta%5Cpmod%7Bp%7D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='\lambda=log_\alpha\beta\pmod{p}' title='\lambda=log_\alpha\beta\pmod{p}' class='latex' />, so that</p>
<p><img src='http://s1.wordpress.com/latex.php?latex=%5Calpha%5E%7Bx-w%7D%3D%5Calpha%5E%7B%5Clambda%28z-y%29%7D%5Cpmod%7Bp%7D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='\alpha^{x-w}=\alpha^{\lambda(z-y)}\pmod{p}' title='\alpha^{x-w}=\alpha^{\lambda(z-y)}\pmod{p}' class='latex' />.</p>
<p>Since <img src='http://s2.wordpress.com/latex.php?latex=%5Calpha&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='\alpha' title='\alpha' class='latex' /> is a primitive root of <img src='http://s3.wordpress.com/latex.php?latex=p&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='p' title='p' class='latex' />, it follows that</p>
<p><img src='http://s1.wordpress.com/latex.php?latex=x-w%3D%5Clambda%28z-y%29%5Cpmod%7Bp-1%7D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='x-w=\lambda(z-y)\pmod{p-1}' title='x-w=\lambda(z-y)\pmod{p-1}' class='latex' />  (*).</p>
<p>This means that <img src='http://s2.wordpress.com/latex.php?latex=d%3D%5Cmbox%7Bgcd%7D%28z-b%2Cp-1%29&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='d=\mbox{gcd}(z-b,p-1)' title='d=\mbox{gcd}(z-b,p-1)' class='latex' /> must divide <img src='http://s3.wordpress.com/latex.php?latex=x-w&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='x-w' title='x-w' class='latex' />.  Since each of <img src='http://s1.wordpress.com/latex.php?latex=z&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='z' title='z' class='latex' /> and <img src='http://s2.wordpress.com/latex.php?latex=y&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='y' title='y' class='latex' /> is less than <img src='http://s3.wordpress.com/latex.php?latex=q&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='q' title='q' class='latex' />, then <img src='http://s1.wordpress.com/latex.php?latex=%7Cz-y%7C%3Cq&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='|z-y|&lt;q' title='|z-y|&lt;q' class='latex' />, and since <img src='http://s2.wordpress.com/latex.php?latex=p-1%3D2q&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='p-1=2q' title='p-1=2q' class='latex' />, the only two possible values for <img src='http://s3.wordpress.com/latex.php?latex=d&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='d' title='d' class='latex' /> are 1 or 2.  From Buchmann (with slightly changed notation):</p>
<p>&quot;If <img src='http://s1.wordpress.com/latex.php?latex=d%3D1&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='d=1' title='d=1' class='latex' />, the equation (*) has a unique solution modulo <img src='http://s2.wordpress.com/latex.php?latex=p-1&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='p-1' title='p-1' class='latex' />.  The discrete logarithm <img src='http://s3.wordpress.com/latex.php?latex=%5Clambda&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='\lambda' title='\lambda' class='latex' /> can be determined as the smallest nonnegative solution of this congruence.  If <img src='http://s1.wordpress.com/latex.php?latex=d%3D2&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='d=2' title='d=2' class='latex' /> the congruence has two different solutions mod <img src='http://s2.wordpress.com/latex.php?latex=p-1&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='p-1' title='p-1' class='latex' /> and the discrete logarithm can be found by trying both.&quot;</p>
<p><strong>Knapsack-based hash functions</strong></p>
<p>The <a href="http://en.wikipedia.org/wiki/Merkle-Hellman_knapsack_cryptosystem">Merkle-Hellman additive knapsack system</a> is something of a modern classic: one of the first public key cryptosystems to be proposed; very fast; based on a well known NP-complete problem (the subset-sum problem); and one of the first to be broken.  But knapsacks, because of their elegance and because of the difficulty of the underlying problem, are profoundly attractive to cryptographers, and although every knapsack system is broken usually within a very short time of its publication (an exception was the Chor-Rivest system, which held out a bit longer before it fell), new ones are constantly being proposed.</p>
<p>An early knapsack based hash function was that of Damg&aring;rd.  Let <img src='http://s3.wordpress.com/latex.php?latex=a_i&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='a_i' title='a_i' class='latex' /> be a list of length <img src='http://s1.wordpress.com/latex.php?latex=n&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='n' title='n' class='latex' /> of randomly chosen integers, and let the input be a binary string <img src='http://s2.wordpress.com/latex.php?latex=m_1m_2m_3%5Cldots+m_n&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='m_1m_2m_3\ldots m_n' title='m_1m_2m_3\ldots m_n' class='latex' /> of the same length.  Then the hash is defined as</p>
<p><img src='http://s3.wordpress.com/latex.php?latex=%5Csum_%7Bi%3D1%7D%5Enm_ia_i&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='\sum_{i=1}^nm_ia_i' title='\sum_{i=1}^nm_ia_i' class='latex' />.</p>
<p>By the difficulty of the subset-sum problem, this should be secure.  However, it is vulnerable to the same attack which brought down the original Merkle-Hellman system.</p>
<p>More recently, <a href="http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.17.8479">Impagliazzo and Naor</a> have shown how to construct knapsack hashes which are as provably secure as the subset-sum problem.  In particular, they require that if there are <img src='http://s1.wordpress.com/latex.php?latex=n&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='n' title='n' class='latex' /> numbers, then the length <img src='http://s2.wordpress.com/latex.php?latex=l%28n%29&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='l(n)' title='l(n)' class='latex' /> of each number be less than <img src='http://s3.wordpress.com/latex.php?latex=n&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='n' title='n' class='latex' />.  The attack mentioned above is not valid in this case.  The paper shows that finding collisions is equivalent to solving the subsem-sum problem for the set <img src='http://s1.wordpress.com/latex.php?latex=a_i&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='a_i' title='a_i' class='latex' /> of numbers and the target sum <img src='http://s2.wordpress.com/latex.php?latex=T&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='T' title='T' class='latex' />.</p>
<p><strong>The Z&eacute;mor-Tillich hash function</strong></p>
<p>This is one of the newest provably secure hash functions, and has been the subject of some intense research and investigation.  You can read the original paper <a href="http://dsns.csie.nctu.edu.tw/research/crypto/HTML/PDF/C94/40.PDF">here</a>.  It remains, with some reservations, a very strong hash function.  It is easy to describe.</p>
<p>Let <img src='http://s3.wordpress.com/latex.php?latex=%5Cmathbb%7BZ%7D_2%28x%29%2Fq%28x%29&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='\mathbb{Z}_2(x)/q(x)' title='\mathbb{Z}_2(x)/q(x)' class='latex' /> be a finite field of order <img src='http://s1.wordpress.com/latex.php?latex=2%5En&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='2^n' title='2^n' class='latex' />, and let <img src='http://s2.wordpress.com/latex.php?latex=%5Calpha&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='\alpha' title='\alpha' class='latex' /> be a root of <img src='http://s3.wordpress.com/latex.php?latex=q%28x%29&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='q(x)' title='q(x)' class='latex' />.  Define the two matrices</p>
<p><img src='http://s1.wordpress.com/latex.php?latex=A_0%3D%5Cleft%5B%5Cbegin%7Barray%7D%7Bcc%7D%5Calpha%261%5C%5C1%260%5Cend%7Barray%7D%5Cright%5D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='A_0=\left[\begin{array}{cc}\alpha&amp;1\\1&amp;0\end{array}\right]' title='A_0=\left[\begin{array}{cc}\alpha&amp;1\\1&amp;0\end{array}\right]' class='latex' />, <img src='http://s2.wordpress.com/latex.php?latex=A_1%3D%5Cleft%5B%5Cbegin%7Barray%7D%7Bcc%7D%5Calpha%26%5Calpha%2B1%5C%5C1%261%5Cend%7Barray%7D%5Cright%5D.&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='A_1=\left[\begin{array}{cc}\alpha&amp;\alpha+1\\1&amp;1\end{array}\right].' title='A_1=\left[\begin{array}{cc}\alpha&amp;\alpha+1\\1&amp;1\end{array}\right].' class='latex' /></p>
<p>Let the input be a binary string <img src='http://s3.wordpress.com/latex.php?latex=m_1m_2m_3%5Cldots+m_k&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='m_1m_2m_3\ldots m_k' title='m_1m_2m_3\ldots m_k' class='latex' /> of arbitrary length.  Then the hash is defined as</p>
<p><img src='http://s1.wordpress.com/latex.php?latex=%5Cprod_%7Bi%3D1%7D%5EkA_%7Bm_i%7D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='\prod_{i=1}^kA_{m_i}' title='\prod_{i=1}^kA_{m_i}' class='latex' />.</p>
<p>The collision resistance can be shown to be based on the property that matrix multiplication is associative  but not commutative (which has led to some generalizations over other non-abelian semi-groups.)</p>
<p>Here&#8217;s a little example in Sage:</p>
<p><code><br />
sage: F. = GF(2)[]<br />
sage: K.&lt;a&gt; = GF(2^10, name='a', modulus=x^10+x^7+1)<br />
sage: A=[matrix([[a,1],[1,0]]),matrix([[a,a+1],[1,1]])]<br />
sage: pl="Now is the winter of our discontent, made glorious summer by this sun of York."<br />
sage: ps=map(ord,pl)<br />
sage: pf=flatten(map(lambda x:Integer(x).bits(),ps))<br />
sage: prod([A[pf[i]] for i in range(len(pf))])<br />
</code></p>
<p>giving as hash the matrix</p>
<p><img src='http://s2.wordpress.com/latex.php?latex=%5Cleft%5B%5Cbegin%7Barray%7D%7Bll%7Da%5E%7B9%7D+%2B+a%5E%7B6%7D+%2B+a%5E%7B4%7D+%2B+a%5E%7B3%7D+%2B+a%5E%7B2%7D+%2B+a+%26+a%5E%7B9%7D+%2B+a%5E%7B8%7D+%2B+a%5E%7B7%7D+%2B+a%5E%7B6%7D+%2B+a%5E%7B5%7D+%2B+a%5E%7B4%7D+%2B+a+%2B+1+%5C%5Ca%5E%7B9%7D+%2B+a%5E%7B3%7D+%2B+a%5E%7B2%7D+%2B+a+%26+a%5E%7B8%7D+%2B+a%5E%7B7%7D+%2B+a%5E%7B5%7D+%2B+a+%2B+1%5Cend%7Barray%7D%5Cright%5D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='\left[\begin{array}{ll}a^{9} + a^{6} + a^{4} + a^{3} + a^{2} + a &amp; a^{9} + a^{8} + a^{7} + a^{6} + a^{5} + a^{4} + a + 1 \\a^{9} + a^{3} + a^{2} + a &amp; a^{8} + a^{7} + a^{5} + a + 1\end{array}\right]' title='\left[\begin{array}{ll}a^{9} + a^{6} + a^{4} + a^{3} + a^{2} + a &amp; a^{9} + a^{8} + a^{7} + a^{6} + a^{5} + a^{4} + a + 1 \\a^{9} + a^{3} + a^{2} + a &amp; a^{8} + a^{7} + a^{5} + a + 1\end{array}\right]' class='latex' /></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amca01.wordpress.com/464/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amca01.wordpress.com/464/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amca01.wordpress.com/464/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amca01.wordpress.com/464/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amca01.wordpress.com/464/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amca01.wordpress.com/464/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amca01.wordpress.com/464/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amca01.wordpress.com/464/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amca01.wordpress.com/464/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amca01.wordpress.com/464/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&blog=3321115&post=464&subd=amca01&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://amca01.wordpress.com/2009/09/28/provably-secure-hash-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b6bb720c28219294cf31d0693ed47388?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amca01</media:title>
		</media:content>
	</item>
		<item>
		<title>The Digital Signature Algorithm in Maxima and Sage</title>
		<link>http://amca01.wordpress.com/2009/09/08/the-digital-signature-algorithm-in-maxima-and-sage/</link>
		<comments>http://amca01.wordpress.com/2009/09/08/the-digital-signature-algorithm-in-maxima-and-sage/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 04:52:57 +0000</pubDate>
		<dc:creator>amca01</dc:creator>
				<category><![CDATA[Computation]]></category>
		<category><![CDATA[Cryptography]]></category>
		<category><![CDATA[Maxima]]></category>
		<category><![CDATA[Sage]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://amca01.wordpress.com/?p=445</guid>
		<description><![CDATA[The Digital Signature Algorithm, also known as the Digital Signature Standard is, as it name implies, a standard for digital signatures.  Most digital signature algorithms work by reversing a public key cryptosystem: a message is signed with the sender&#8217;s private key, and the signature is verified using the sender&#8217;s public key.  The DSA [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&blog=3321115&post=445&subd=amca01&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>The <em>Digital Signature Algorithm</em>, also known as the <em>Digital Signature Standard</em> is, as it name implies, a standard for digital signatures.  Most digital signature algorithms work by reversing a public key cryptosystem: a message is signed with the sender&#8217;s private key, and the signature is verified using the sender&#8217;s public key.  The DSA is based on the El Gamal scheme, with a few extras thrown in for extra security, and to make the signatures smaller.</p>
<p>It is set up with four values: a large prime <img src='http://s1.wordpress.com/latex.php?latex=p&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='p' title='p' class='latex' />, a prime <img src='http://s2.wordpress.com/latex.php?latex=q&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='q' title='q' class='latex' /> which is a factor of <img src='http://s3.wordpress.com/latex.php?latex=p-1&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='p-1' title='p-1' class='latex' />, a primitive root <img src='http://s1.wordpress.com/latex.php?latex=a&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='a' title='a' class='latex' /> of <img src='http://s2.wordpress.com/latex.php?latex=p&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='p' title='p' class='latex' />, and a value <img src='http://s3.wordpress.com/latex.php?latex=g&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='g' title='g' class='latex' /> defined by</p>
<p><img src='http://s1.wordpress.com/latex.php?latex=g%3Da%5E%7B%28p-1%29%2Fq%7D+%5Cbmod+p&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='g=a^{(p-1)/q} \bmod p' title='g=a^{(p-1)/q} \bmod p' class='latex' />.</p>
<p>For security, <img src='http://s2.wordpress.com/latex.php?latex=p&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='p' title='p' class='latex' /> is recommended to be at least 154 digits, and <img src='http://s3.wordpress.com/latex.php?latex=q&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='q' title='q' class='latex' /> at least 48 digits. </p>
<p>Alice, the sender, chooses as her private key any value <img src='http://s1.wordpress.com/latex.php?latex=A%3Cq-1&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='A&lt;q-1' title='A&lt;q-1' class='latex' /> and calculates</p>
<p><img src='http://s2.wordpress.com/latex.php?latex=B%3Dg%5EA+%5Cbmod+p&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='B=g^A \bmod p' title='B=g^A \bmod p' class='latex' /></p>
<p>as her public key.  This is secure, by the discrete logarithm problem.  The public key consists of the values <img src='http://s3.wordpress.com/latex.php?latex=%28p%2Cq%2Cg%2CB%29&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='(p,q,g,B)' title='(p,q,g,B)' class='latex' /> and the private key is the value <img src='http://s1.wordpress.com/latex.php?latex=A&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='A' title='A' class='latex' />.</p>
<p>Given a message <img src='http://s2.wordpress.com/latex.php?latex=m&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='m' title='m' class='latex' />, a signature is computed as follows:</p>
<p>Alice chooses at random <img src='http://s3.wordpress.com/latex.php?latex=k&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='k' title='k' class='latex' /> for which <img src='http://s1.wordpress.com/latex.php?latex=0%3Ck%3Cq-1&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='0&lt;k&lt;q-1' title='0&lt;k&lt;q-1' class='latex' />.  She then computes:</p>
<p><img src='http://s2.wordpress.com/latex.php?latex=r+%3D+%28g%5Ek%5Cpmod%7Bp%7D%29%5Cpmod%7Bq%7D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='r = (g^k\pmod{p})\pmod{q}' title='r = (g^k\pmod{p})\pmod{q}' class='latex' /></p>
<p><img src='http://s3.wordpress.com/latex.php?latex=s+%3D+k%5E%7B-1%7D%28m%2BAr%29%5Cpmod%7Bq%7D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='s = k^{-1}(m+Ar)\pmod{q}' title='s = k^{-1}(m+Ar)\pmod{q}' class='latex' /></p>
<p>and the two values <img src='http://s1.wordpress.com/latex.php?latex=%28r%2Cs%29&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='(r,s)' title='(r,s)' class='latex' /> are the signature of the message <img src='http://s2.wordpress.com/latex.php?latex=m&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='m' title='m' class='latex' />.  We are assuming here that <img src='http://s3.wordpress.com/latex.php?latex=m%3Cp&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='m&lt;p' title='m&lt;p' class='latex' />; as in general most messages will be much larger, it is customary to sign not the message itself, but a cryptographic hash of the message, which will be a string of some fixed length (and shorter than <img src='http://s1.wordpress.com/latex.php?latex=p&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='p' title='p' class='latex' /> ).</p>
<p>To verify the signature, Bob (the receiver) calculates the following values:</p>
<p><img src='http://s2.wordpress.com/latex.php?latex=x+%3D+s%5E%7B-1%7Dm%5Cpmod%7Bq%7D%2C&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='x = s^{-1}m\pmod{q},' title='x = s^{-1}m\pmod{q},' class='latex' /></p>
<p><img src='http://s3.wordpress.com/latex.php?latex=y+%3D+s%5E%7B-1%7Dr%5Cpmod%7Bq%7D%2C&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='y = s^{-1}r\pmod{q},' title='y = s^{-1}r\pmod{q},' class='latex' /></p>
<p><img src='http://s1.wordpress.com/latex.php?latex=v+%3D+%28g%5ExB%5Ey%5Cpmod%7Bp%7D%29%5Cpmod%7Bq%7D.&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='v = (g^xB^y\pmod{p})\pmod{q}.' title='v = (g^xB^y\pmod{p})\pmod{q}.' class='latex' /></p>
<p>If <img src='http://s2.wordpress.com/latex.php?latex=v%3Dr&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='v=r' title='v=r' class='latex' /> then he accepts the signature.</p>
<p>To see why this works, note that from the definition of <img src='http://s3.wordpress.com/latex.php?latex=s&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='s' title='s' class='latex' />, we can write</p>
<p><img src='http://s1.wordpress.com/latex.php?latex=m%3D%28-Ar%2Bks%29%5Cpmod%7Bq%7D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='m=(-Ar+ks)\pmod{q}' title='m=(-Ar+ks)\pmod{q}' class='latex' /></p>
<p>and by multiplying through by <img src='http://s2.wordpress.com/latex.php?latex=s%5E%7B-1%7D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='s^{-1}' title='s^{-1}' class='latex' /> we obtain:</p>
<p><img src='http://s3.wordpress.com/latex.php?latex=s%5E%7B-1%7Dm%3D%28-Ars%5E%7B-1%7D%2Bk%29%5Cpmod%7Bq%7D.&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='s^{-1}m=(-Ars^{-1}+k)\pmod{q}.' title='s^{-1}m=(-Ars^{-1}+k)\pmod{q}.' class='latex' /></p>
<p>This last equation can be written</p>
<p><img src='http://s1.wordpress.com/latex.php?latex=k%3D+s%5E%7B-1%7Dm%2BArs%5E%7B-1%7D%5Cpmod%7Bq%7D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='k= s^{-1}m+Ars^{-1}\pmod{q}' title='k= s^{-1}m+Ars^{-1}\pmod{q}' class='latex' /></p>
<p><img src='http://s2.wordpress.com/latex.php?latex=%3D+x%2BAy%5Cpmod%7Bq%7D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='= x+Ay\pmod{q}' title='= x+Ay\pmod{q}' class='latex' />.</p>
<p>Now we have</p>
<p><img src='http://s3.wordpress.com/latex.php?latex=r+%3D+%28g%5Ek%5Cpmod%7Bp%7D%29%5Cpmod%7Bq%7D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='r = (g^k\pmod{p})\pmod{q}' title='r = (g^k\pmod{p})\pmod{q}' class='latex' /></p>
<p><img src='http://s1.wordpress.com/latex.php?latex=++%3D+%28g%5E%7Bx%2BAy%7D%5Cpmod%7Bp%7D%29%5Cpmod%7Bq%7D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='  = (g^{x+Ay}\pmod{p})\pmod{q}' title='  = (g^{x+Ay}\pmod{p})\pmod{q}' class='latex' /></p>
<p><img src='http://s2.wordpress.com/latex.php?latex=+%3D+%28g%5Ex%28g%5EA%29%5Ey%5Cpmod%7Bp%7D%29%5Cpmod%7Bq%7D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt=' = (g^x(g^A)^y\pmod{p})\pmod{q}' title=' = (g^x(g^A)^y\pmod{p})\pmod{q}' class='latex' /></p>
<p><img src='http://s3.wordpress.com/latex.php?latex=+%3D+%28g%5ExB%5Ey%5Cpmod%7Bp%7D%29%5Cpmod%7Bq%7D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt=' = (g^xB^y\pmod{p})\pmod{q}' title=' = (g^xB^y\pmod{p})\pmod{q}' class='latex' /></p>
<p><img src='http://s1.wordpress.com/latex.php?latex=+%3D+v.&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt=' = v.' title=' = v.' class='latex' /></p>
<p>This algorithm has the advantage that its security is of order length of <img src='http://s2.wordpress.com/latex.php?latex=p&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='p' title='p' class='latex' />, but the signature values are much smaller &#8211; the size of <img src='http://s3.wordpress.com/latex.php?latex=q&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='q' title='q' class='latex' />.</p>
<p>Now let&#8217;s look at this algorithm in both Maxima and Sage.</p>
<p><strong>Maxima</strong></p>
<p>We start by creating <img src='http://s1.wordpress.com/latex.php?latex=p&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='p' title='p' class='latex' /> and <img src='http://s2.wordpress.com/latex.php?latex=q&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='q' title='q' class='latex' />.  We will need to factor <img src='http://s3.wordpress.com/latex.php?latex=p-1&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='p-1' title='p-1' class='latex' /> both to find a value of <img src='http://s1.wordpress.com/latex.php?latex=q&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='q' title='q' class='latex' />, and to find its primitive root.  So we start by attempting to factor a few randomly chosen large primes, until we have a prime <img src='http://s2.wordpress.com/latex.php?latex=p&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='p' title='p' class='latex' /> for which <img src='http://s3.wordpress.com/latex.php?latex=p-1&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='p-1' title='p-1' class='latex' /> can be factored, and which also has a reasonably large prime factor <img src='http://s1.wordpress.com/latex.php?latex=q&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='q' title='q' class='latex' />.</p>
<p>We will use smaller values both of <img src='http://s2.wordpress.com/latex.php?latex=p&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='p' title='p' class='latex' /> and <img src='http://s3.wordpress.com/latex.php?latex=q&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='q' title='q' class='latex' /> than the algorithm requires, just to show how it works.  </p>
<p><code>(%i1) p:next_prime(random(10^80));<br />
(%i2) factor(p-1);</code></p>
<p>After a few tries, I found</p>
<p>p = 182842970179003336959233156794188485625560973915508949565601<br />
89183057229685434897<br />
q = 525970797581619193760592144581011744537</p>
<p>Maxima doesn&#8217;t have a built-in command to find primitive roots, but one can easily be written, using the fact that a primitive root a is a number for which</p>
<p><img src='http://s1.wordpress.com/latex.php?latex=a%5E%7B%28p-1%29%2Ft%7D++%5Cneq+1+%5Cbmod%7Bp%7D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='a^{(p-1)/t}  \neq 1 \bmod{p}' title='a^{(p-1)/t}  \neq 1 \bmod{p}' class='latex' /></p>
<p>for all prime factors <img src='http://s2.wordpress.com/latex.php?latex=t&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='t' title='t' class='latex' /> of <img src='http://s3.wordpress.com/latex.php?latex=p-1&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='p-1' title='p-1' class='latex' />.  Here is one such program:</p>
<p><code>primroot(p):=block(<br />
  [f:ifactors(p-1),n,i:1],<br />
  if not(primep(p)) then error("Your number is not prime"),<br />
  n:length(f),<br />
  do (<br />
      i:i+1,<br />
      if not member(1,makelist(power_mod(i,(p-1)/f[j][1],p),j,1,n)) then<br />
      return(i)<br />
      )<br />
    );<br />
</code></p>
<p>So:</p>
<p><code>(%i3) a:primroot(p);<br />
(%o3)               5<br />
(%i4) g:power_mod(a,(p-1)/q,p);<br />
</code></p>
<p>The private/public key pairs:</p>
<p><code>(%i5) A:random(q-1);<br />
(%i6) B:power_mod(g,A,p);</code></p>
<p>Now we can choose a random message a sign it (for ease we won&#8217;t show the outputs, which are just long numbers):</p>
<p><code>(%i7) m:random(p);<br />
(%i8) k:random(q-1);<br />
(%i9) r:mod(power_mod(g,k,p),q);<br />
(%i10) s:mod(inv_mod(k,q)*(m+A*r),q);<br />
</code></p>
<p>Now to verify the signature:</p>
<p><code>(%i11) x:mod(inv_mod(s,q)*m,q);<br />
(%i12) y:mod(inv_mod(s,q)*r,q);<br />
(%i13) v:mod(mod(power_mod(g,x,p)*power_mod(B,y,p),p),q);<br />
(%i14) is(v=r)<br />
(%o14)         true<br />
</code></p>
<p><strong>Sage</strong></p>
<p>As with Maxima, we start by finding <img src='http://s1.wordpress.com/latex.php?latex=p&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='p' title='p' class='latex' /> and <img src='http://s2.wordpress.com/latex.php?latex=q&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='q' title='q' class='latex' />.  We simply repeat</p>
<p><code>sage: p=next_prime(randint(1,10^80))<br />
sage: factor(p-1)</code></p>
<p>until we find values we want.  I found</p>
<p><code>p =<br />
530156743088749972013047250493987281452419479410412138<br />
17513510820559804089810293<br />
q= 2199623526308059394919085303004156101</code></p>
<p>Then </p>
<p><code>sage: a=Mod(primitive_root(p),p)</code></p>
<p>returns 5.  The extra <code>Mod( ,p)</code> ensures that the type of <img src='http://s3.wordpress.com/latex.php?latex=a&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='a' title='a' class='latex' /> is an element of the<br />
ring of integers modulo <img src='http://s1.wordpress.com/latex.php?latex=p&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='p' title='p' class='latex' /> <img src='http://s2.wordpress.com/latex.php?latex=%5Cmathbb%7BZ%7D_p&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='\mathbb{Z}_p' title='\mathbb{Z}_p' class='latex' />:</p>
<p><code>sage: parent(a)<br />
Ring of integers modulo 530156743088749972013047250493987281<br />
45241947941041213817513510820559804089810293</code></p>
<p>Now we can calculate the other values we need:</p>
<p><code>sage: g=a^((p-1)/q)<br />
sage: g<br />
530156743088749972013047250493987281211397896967807817<br />
18309906946321326881261201</code></p>
<p>and the private/public key pairs:</p>
<p><code>sage: A=randint(1,q-1);A<br />
617088481431564693290032924639855166L,<br />
sage: B=g^A;B<br />
1052251014343945276262934677066619589736007844895332445<br />
1397254657133312260200438</code></p>
<p>Note that because of Sage&#8217;s handling of types, we don&#8217;t have to fuss with &#8220;power_mod&#8221;; since the type of <img src='http://s3.wordpress.com/latex.php?latex=a&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='a' title='a' class='latex' /> is &#8220;element of <img src='http://s1.wordpress.com/latex.php?latex=%5Cmathbb%7BZ%7D_p&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='\mathbb{Z}_p' title='\mathbb{Z}_p' class='latex' />&#8220;, so automatically are <img src='http://s2.wordpress.com/latex.php?latex=g&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='g' title='g' class='latex' /> and <img src='http://s3.wordpress.com/latex.php?latex=B&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='B' title='B' class='latex' />, and powers are thus computed quickly, using the modular exponentiation algorithm.</p>
<p>Let&#8217;s choose a message, which will be any value less than <img src='http://s1.wordpress.com/latex.php?latex=p&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='p' title='p' class='latex' />:</p>
<p><code>sage: m=randint(1,p)</code></p>
<p>and sign it (as with Maxima we won&#8217;t show any of the values):</p>
<p><code>sage: k=randint(1,q-1)<br />
sage: r=mod(g^k,q)<br />
sage: s=(m+A*r)/k</code></p>
<p>since <img src='http://s2.wordpress.com/latex.php?latex=g&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='g' title='g' class='latex' /> is in the ring <img src='http://s3.wordpress.com/latex.php?latex=%5Cmathbb%7BZ%7D_p&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='\mathbb{Z}_p' title='\mathbb{Z}_p' class='latex' />, we need to change <img src='http://s1.wordpress.com/latex.php?latex=r&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='r' title='r' class='latex' /> to be in the ring <img src='http://s2.wordpress.com/latex.php?latex=%5Cmathbb%7BZ%7D_q&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='\mathbb{Z}_q' title='\mathbb{Z}_q' class='latex' />.  This<br />
will force <img src='http://s3.wordpress.com/latex.php?latex=s&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='s' title='s' class='latex' /> to be also in this ring, so there is no need for any explicit calls to number theoretic functions.</p>
<p>Now we can verify the signature:</p>
<p><code>sage: x=m/s<br />
sage: y=r/s<br />
sage: v=mod(g^x*B^y,q)<br />
sage: v==r<br />
True</code></p>
<p>Neat.</p>
<p>Both Maxima and Sage provide all the necessary functionality to compute and verify a digital signature (well, nearly all; we had to write our own program for primitive roots in Maxima), but of the two, Sage certainly allows for easier commands, with its mathematical types.  For example:</p>
<p>Maxima: <code>y:mod(inv_mod(s,q)*r,q);</code><br />
Sage:   <code>y=r/s</code></p>
<p>Maxima: <code>v:mod(mod(power_mod(g,x,p)*power_mod(B,y,p),p),q);</code><br />
Sage:   <code>v=mod(g^x*B^y,q)</code></p>
<p><strong>Addendum: the use of &#8220;modulus&#8221; in Maxima</strong></p>
<p>Richard Fateman (see comments below) pointed out that my comparison above is in fact incorrect.  Maxima allows for very neat commands by use of &#8220;modulus&#8221;, which if set to any prime number, will effect all subsequent rational expressions.  For example:</p>
<pre>(%i1) modulus:97;
(%i2) a:rat(5);
(%i3) a^75;
(%o3)                  -34</pre>
<p>We see that the output is given in &#8220;balanced&#8221; form, where the residues are balanced about zero.  However,. in Maxima modulus is a global property &#8211; it applies to all rational expressions, whereas in Sage different variables can have different modular types.  However, by a judicious change of modulus, we can simplify the Maxima commands considerably.  To show how to do this, we will deal with some very small numbers, so as to be able to show the outputs.  We will use <img src='http://s1.wordpress.com/latex.php?latex=p%3D1031%2C+q%3D103&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='p=1031, q=103' title='p=1031, q=103' class='latex' />, and the primitive root <img src='http://s2.wordpress.com/latex.php?latex=a%3D14&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='a=14' title='a=14' class='latex' /> of <img src='http://s3.wordpress.com/latex.php?latex=p&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='p' title='p' class='latex' />.  First, the setup phase.  Since everything here is done modulo <img src='http://s1.wordpress.com/latex.php?latex=p&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='p' title='p' class='latex' />, we will use this as the modulus value:</p>
<pre>(%i1) p:1031;
(%o1)                   1031
(%i2) q:103;
(%o2)                    103
(%i3) modulus:p;
(%o3)                   1031
(%i4) a:rat(14);
(%o4)                     14
(%i5) g:a^((p-1)/q);
(%o5)                    320
(%i6) A:rat(70);
(%o6)                     70
(%i7) B:g^A;
(%o8)                     48</pre>
<p>Now to sign a message <img src='http://s2.wordpress.com/latex.php?latex=m%3D500&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='m=500' title='m=500' class='latex' /> using the &#8220;random&#8221; value <img src='http://s3.wordpress.com/latex.php?latex=k%3D25&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='k=25' title='k=25' class='latex' />:</p>
<pre>(%i9) m:500;
(%o9)                    500
(%i10) k:25;
(%o10)                    25
(%i11) r:mod(g^k,q);
(%o11)                    95</pre>
<p>At this stage we are going to start performing operations modulo <img src='http://s1.wordpress.com/latex.php?latex=q&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='q' title='q' class='latex' />, so we change the modulus:</p>
<pre>(%i12) modulus:q;
(%o12)                  103
(%i13) s:(m+A*r)/k;
(%o13)                  -23</pre>
<p>We have thus created the signature (with balanced modulo values); now for the verification:</p>
<pre>(%i14) x:m/s;
(%o14)                   32
(%i15) y:r/s;
(%o15)                  -31</pre>
<p>To compute the final value we&#8217;ll change the modulus once more:</p>
<pre>(%i16) modulus:p;
(%o16)                1031
(%i17) v:mod(g^x*B^y,q);
(%o17)                  95
(%i18) is(v=r);
(%o18)                true</pre>
<p>and we&#8217;re done, all with very simple commands.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amca01.wordpress.com/445/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amca01.wordpress.com/445/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amca01.wordpress.com/445/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amca01.wordpress.com/445/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amca01.wordpress.com/445/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amca01.wordpress.com/445/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amca01.wordpress.com/445/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amca01.wordpress.com/445/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amca01.wordpress.com/445/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amca01.wordpress.com/445/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&blog=3321115&post=445&subd=amca01&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://amca01.wordpress.com/2009/09/08/the-digital-signature-algorithm-in-maxima-and-sage/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b6bb720c28219294cf31d0693ed47388?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amca01</media:title>
		</media:content>
	</item>
		<item>
		<title>Solving quadratic equations geometrically</title>
		<link>http://amca01.wordpress.com/2009/08/18/solving-quadratic-equations-geometrically/</link>
		<comments>http://amca01.wordpress.com/2009/08/18/solving-quadratic-equations-geometrically/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 09:26:42 +0000</pubDate>
		<dc:creator>amca01</dc:creator>
				<category><![CDATA[Computation]]></category>
		<category><![CDATA[Maths teaching]]></category>
		<category><![CDATA[Visualization]]></category>

		<guid isPermaLink="false">http://amca01.wordpress.com/?p=424</guid>
		<description><![CDATA[I vaguely recall some years ago having seen a nonogram for solving quadratic equations, and I thought it may be a fun thing to do with my students.  I couldn&#8217;t find what I was looking for, but I did come across a lovely result which seems to have been first noted by a French [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&blog=3321115&post=424&subd=amca01&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I vaguely recall some years ago having seen a <a href="http://en.wikipedia.org/wiki/Nomogram">nonogram</a> for solving quadratic equations, and I thought it may be a fun thing to do with my students.  I couldn&#8217;t find what I was looking for, but I did come across a lovely result which seems to have been first noted by a French artillery captain named M. E. Lill (see <a href="http://www.pballew.net/Lill_cir.doc">http://www.pballew.net/Lill_cir.doc</a> for a more complete history).  It can be stated as follows:</p>
<p style="padding-left:30px;padding-right:30px;"><em>Let the quadratic <img src='http://s1.wordpress.com/latex.php?latex=x%5E2%2Bbx%2Bc%3D0&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='x^2+bx+c=0' title='x^2+bx+c=0' class='latex' /> have real roots.  Then the circle whose diameter has endpoints <img src='http://s2.wordpress.com/latex.php?latex=%280%2C1%29&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='(0,1)' title='(0,1)' class='latex' /> and <img src='http://s3.wordpress.com/latex.php?latex=%28-b%2Cc%29&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='(-b,c)' title='(-b,c)' class='latex' /> cuts the <img src='http://s1.wordpress.com/latex.php?latex=x&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='x' title='x' class='latex' />-axis at the root values.</em></p>
<p>We note in passing that the quadratic given is completely general, for any quadratic can be reduced to that form by dividing through by the leading coefficient.  Here are &#8220;Lill circles&#8221; for the quadratic equations <img src='http://s2.wordpress.com/latex.php?latex=x%5E2-3x%2B2%3D0&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='x^2-3x+2=0' title='x^2-3x+2=0' class='latex' />:</p>
<p><img title="lill1" src="http://amca01.files.wordpress.com/2009/08/lill1.png" alt="lill1" /></p>
<p>and <img src='http://s3.wordpress.com/latex.php?latex=x%5E2-2x-3%3D0&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='x^2-2x-3=0' title='x^2-2x-3=0' class='latex' />:</p>
<p><img title="lill2" src="http://amca01.files.wordpress.com/2009/08/lill2.png" alt="lill2" /></p>
<p>I like this result.  It seems (at first glance) to be slightly mysterious; it is a wonderful mixture of algebra and geometry, and it&#8217;s not <em>quite</em> obvious.  In fact, the proof is very simple, and is an elementary application of Euclid&#8217;s result that the angle in a semi-circle is a right angle.</p>
<p>Consider the first diagram above, without the circle, but with two extra lines:</p>
<p><img src="http://amca01.files.wordpress.com/2009/08/lill3.png" alt="lill3" title="lill3" width="266" height="159" class="alignnone size-full wp-image-437" /></p>
<p>Since the angle <img src='http://s1.wordpress.com/latex.php?latex=AOB&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='AOB' title='AOB' class='latex' /> is a right angle, the bottom two triangles are similar, and so</p>
<p><img src='http://s2.wordpress.com/latex.php?latex=%5Cdisplaystyle%7B%5Cfrac%7Bx%7D%7B1%7D%3D%5Cfrac%7Bc%7D%7Bb-x%7D%7D&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='\displaystyle{\frac{x}{1}=\frac{c}{b-x}}' title='\displaystyle{\frac{x}{1}=\frac{c}{b-x}}' class='latex' />.</p>
<p>Multiplying this fraction out produces <img src='http://s3.wordpress.com/latex.php?latex=x%28b-x%29%3Dc&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='x(b-x)=c' title='x(b-x)=c' class='latex' /> which can be rearranged to produce <img src='http://s1.wordpress.com/latex.php?latex=x%5E2-bx%2Bc%3D0&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='x^2-bx+c=0' title='x^2-bx+c=0' class='latex' />.  Since in this diagram the upper right point is <img src='http://s2.wordpress.com/latex.php?latex=%28-%28-b%29%2Cc%29%3D%28b%2Cc%29&#038;bg=ffffff&#038;fg=333333&#038;s=0' alt='(-(-b),c)=(b,c)' title='(-(-b),c)=(b,c)' class='latex' /> this finishes the proof.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amca01.wordpress.com/424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amca01.wordpress.com/424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amca01.wordpress.com/424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amca01.wordpress.com/424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amca01.wordpress.com/424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amca01.wordpress.com/424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amca01.wordpress.com/424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amca01.wordpress.com/424/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amca01.wordpress.com/424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amca01.wordpress.com/424/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&blog=3321115&post=424&subd=amca01&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://amca01.wordpress.com/2009/08/18/solving-quadratic-equations-geometrically/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b6bb720c28219294cf31d0693ed47388?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amca01</media:title>
		</media:content>

		<media:content url="http://amca01.files.wordpress.com/2009/08/lill1.png" medium="image">
			<media:title type="html">lill1</media:title>
		</media:content>

		<media:content url="http://amca01.files.wordpress.com/2009/08/lill2.png" medium="image">
			<media:title type="html">lill2</media:title>
		</media:content>

		<media:content url="http://amca01.files.wordpress.com/2009/08/lill3.png" medium="image">
			<media:title type="html">lill3</media:title>
		</media:content>
	</item>
		<item>
		<title>The Mathematics Change Plan, take 2</title>
		<link>http://amca01.wordpress.com/2009/08/04/the-mathematics-change-plan-take-2/</link>
		<comments>http://amca01.wordpress.com/2009/08/04/the-mathematics-change-plan-take-2/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 04:24:11 +0000</pubDate>
		<dc:creator>amca01</dc:creator>
				<category><![CDATA[Maths teaching]]></category>

		<guid isPermaLink="false">http://amca01.wordpress.com/?p=418</guid>
		<description><![CDATA[or, 
Why upper management is innumerate
I haven&#8217;t written much lately, because I&#8217;m still smarting over my University&#8217;s intransigence over the Mathematics Change Plan.  The basis of the argument seemed to be: enrolments in Computer Science have been falling (yes, that&#8217;s true), and since Mathematics staff make up about half of the old Department of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&blog=3321115&post=418&subd=amca01&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>or, </p>
<p><strong>Why upper management is innumerate</strong></p>
<p>I haven&#8217;t written much lately, because I&#8217;m still smarting over my University&#8217;s intransigence over the Mathematics Change Plan.  The basis of the argument seemed to be: enrolments in Computer Science have been falling (yes, that&#8217;s true), and since Mathematics staff make up about half of the old Department of Computer Science and Mathematics, their numbers must be vastly in excess; that is &#8220;surplus to requirements&#8221;.</p>
<p>However, that argument holds no water, because the bulk of mathematics teaching is to external students: engineering students, teacher education students, science (biology, chemistry) students, nursing students, and so on.  And in fact almost every subject we have taught over the past four or five years has obtained the bulk of its students from cohorts other than computer science.  In fact, if comp sci folded, it would make negligible difference to the student numbers in mathematics/statistics subjects, and no difference at all to (maths) staffing requirements.</p>
<p>I have spent some time putting together a spreadsheet, which provides the breakdown of all staffing hours and student numbers.  It turns out that this year we are teaching a total of 2550 hours (a far cry from the 2100 in the Plan).  When our Head of School was presented by our Union with our spreadsheet, and asked to justify his own numbers, he was unable to do so.  Now call me old-fashioned, but I would have thought that if you are signing a document which speaks of sacking staff, you would be pretty sure about the numbers on which your argument was based.  Apparently not here.</p>
<p>It also turns out that under the new funding for students in maths/stats subjects, every student we teach brings $1185 in income to the School.  Multiply that by the 1410 students we teach, and you get $1,670,850.  Now, a rule of thumb is that staff salaries should amount to no more than 80% of income.  We cost about $1,200,000 (give or take a bit &#8211; and that includes on-costs), which is far less than 80% of our income.  </p>
<p>Let&#8217;s suppose that we still get rid of three full-time effective (FTE) staff, which is the current plan, according to a form letter from our Head.  Currently we have nine staff teaching maths, of which group some also teach physics, some computer science and some engineering.  So the total FTE maths staff is about 7.5.  Reduce that by three and you get 4.5.  Not rocket science, is it?  And how do you cover 2550 hours/year with 4.5 staff? &#8211; by using vast numbers of sessionals, that&#8217;s how!  But the University requires less than 20% of its numbers to be covered by sessionals.</p>
<p>The Union is mystified about the University&#8217;s continued persistence with the Plan &#8211; we have patiently explained why the original Plan was based on faulty reasoning derived from incorrect numbers &#8211; and our arguments are clear, and what&#8217;s more, backed up with fully justifiable figures derived from the University&#8217;s timetables and student database.</p>
<p>And yet the madness continues&#8230;</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amca01.wordpress.com/418/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amca01.wordpress.com/418/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amca01.wordpress.com/418/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amca01.wordpress.com/418/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amca01.wordpress.com/418/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amca01.wordpress.com/418/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amca01.wordpress.com/418/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amca01.wordpress.com/418/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amca01.wordpress.com/418/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amca01.wordpress.com/418/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&blog=3321115&post=418&subd=amca01&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://amca01.wordpress.com/2009/08/04/the-mathematics-change-plan-take-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b6bb720c28219294cf31d0693ed47388?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amca01</media:title>
		</media:content>
	</item>
		<item>
		<title>The &#8220;Mathematics Change Plan&#8221;</title>
		<link>http://amca01.wordpress.com/2009/06/13/the-mathematics-change-plan/</link>
		<comments>http://amca01.wordpress.com/2009/06/13/the-mathematics-change-plan/#comments</comments>
		<pubDate>Sat, 13 Jun 2009 02:15:45 +0000</pubDate>
		<dc:creator>amca01</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://amca01.wordpress.com/?p=405</guid>
		<description><![CDATA[With various attempts to save money, my university has started issuing &#8220;change plans&#8221; for various disciplines and employment groups.  Just this last week the administration has released a Mathematics Change Plan, a Nursing and Midwifery Change Plan, a Science Change Plan, and a Technical Staff Change Plan.  My concern is with the Mathematics [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&blog=3321115&post=405&subd=amca01&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>With various attempts to save money, my <a href="http://www.vu.edu.au">university</a> has started issuing &#8220;change plans&#8221; for various disciplines and employment groups.  Just this last week the administration has released a Mathematics Change Plan, a Nursing and Midwifery Change Plan, a Science Change Plan, and a Technical Staff Change Plan.  My concern is with the Mathematics Change Plan, because it affects me more than the others.</p>
<p>I have rarely seen a document so specious, badly thought out, and based on such poor reasoning.  All the change plans are based on the same template, the main differences between them being the numbers used to draw their conclusions.  For mathematics, the main changes are to reduce staff by five: a full professor and a lecturer associated with the <a href="http://www.staff.vu.edu.au/RGMIA/">RGMIA research group</a>, and three full time teaching staff (or equivalent) from the rest.</p>
<p>Now, there is no doubt that student numbers, and associated teaching hours have fallen over the past few years &#8211; but less so in Mathematics, with its service teaching to engineering, science, and education than in some other disciplines &#8211; and probably some changes are required.  But the loss of five staff?</p>
<p>Let&#8217;s first look at the teaching hours.  The document makes note of a change in total teaching hours from 2178 to 1944.  That&#8217;s a loss of 234 hours.  Given two 12 week semesters, and an average teaching load of 12 contact hours per week, that&#8217;s less than one full time staff member.  Note that an original report (we&#8217;ve had two reports in the past year) counts the number of mathematics teaching staff at 10.4 (effectively 10, as the 0.4 counts for a staff member with no teaching), so if the change plan were to be implemented we would have five staff teaching 1944 hours.   That works out, over 24 teaching weeks in the year, at 16.2 contact hours per week &#8211; an impossible work load for any academic with the hope of doing any research, planning or development.</p>
<p>One of the two reports recommends &#8220;disaggregating&#8221; mathematics and computer science &#8211; up until recently, we were all together in the School of Computer Science and Mathematics.  Leaving aside the wisdom of this idea (which is quite lost on me) it is in practice almost impossible to achieve, as many teaching staff, such as myself, have taught into both disciplines.  Over the past few years I&#8217;ve taught calculus, discrete mathematics, mathematical cryptography, digital image processing, network security, as well as supervising research students, mainly from our coursework Masters in Computer Science.  So am I a mathematician or a computer scientist?  I&#8217;ve avoided being pigeon-holed, and I&#8217;m not alone &#8211; many of my colleagues also teach as much computing as mathematics.</p>
<p>Student numbers.  Because the disaggregation has not yet happened, it is very difficult to separate mathematics numbers from computer science.  And in fact the biggest single drop in numbers (which the Change Plan notes) was in fact caused by a drop in numbers from the Comp Sci Masters program a few years ago.  But this is a program which contains no mathematics!  No report, or this Change Plan, has made the effort to go beyond total student numbers to numbers specific to individual disciplines.</p>
<p>RGMIA.  This is not a formal Research Centre of the University, but rather an informal grouping of local and international academics (about 1300 of them) all with similar interests.  A <a href="http://jipam.vu.edu.au/">refereed journal</a> is published, and the <a href="http://www.staff.vu.edu.au/RGMIA/dragomir/">Chair of RGMIA</a> is an internationally renowned scholar, with hundreds of papers and books to his credit.  He was appointed as a research and teaching academic some years ago, and has built up RGMIA with his many international contacts, and by his own research excellence, obtaining nothing from the University aside from a lecturer to help run the Journal.  How is he being repaid for his selfless dedication to the University? &#8211; by having his position being made redundant even while the Change Plan is officially still in draft status!  Even though he himself, officially, is not being made redundant, his position is, which means that either he has to reapply for another position, or take a &#8220;voluntary departure&#8221; package.  Either way, it&#8217;s shoddy treatment.</p>
<p>Equity.  The University has had a mission to provide high quality post-secondary education to the Western suburbs of Melbourne.  These are suburbs with a high proportion of blue-collar workers, and low socio-economic status, and the University, with its value-added programs, has always had many students from this area.  In fact the University has the highest percentage of any Australian university of students who are the first in their family to attend university.  The Mathematics staff have for many years worked diligently to provide multiple entry points into the university&#8217;s programs, as well as some highly regarded outreach programs, and some programs to upskill secondary school mathematics teachers.  All these programs and good work will die if the Change Plan is to proceed.</p>
<p>The university seems bent on destroying mathematics as a valid, valued and valuable teaching and learning discipline, and in ruining the goodwill of its teaching staff, and engendering a spirit of disinterestedness and cynicism.  Well, it&#8217;s doing an excellent job.</p>
<hr />
I&#8217;ve been doing some work on the number of hours taught over last few years, and looking very carefully at the staffing spreadsheets.  Well, here are the <em>actual</em> numbers:</p>
<p>2006: 2388<br />
2007: 2140<br />
2008: 2340</p>
<p>So much for falling numbers!  And owing to the funding cuts, three staff members who have retired during that time have not been replaced.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amca01.wordpress.com/405/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amca01.wordpress.com/405/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amca01.wordpress.com/405/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amca01.wordpress.com/405/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amca01.wordpress.com/405/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amca01.wordpress.com/405/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amca01.wordpress.com/405/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amca01.wordpress.com/405/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amca01.wordpress.com/405/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amca01.wordpress.com/405/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&blog=3321115&post=405&subd=amca01&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://amca01.wordpress.com/2009/06/13/the-mathematics-change-plan/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b6bb720c28219294cf31d0693ed47388?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">amca01</media:title>
		</media:content>
	</item>
	</channel>
</rss>