<?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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" 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>Fri, 20 Jan 2012 03:48:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='amca01.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Alasdair&#039;s musings</title>
		<link>http://amca01.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://amca01.wordpress.com/osd.xml" title="Alasdair&#039;s musings" />
	<atom:link rel='hub' href='http://amca01.wordpress.com/?pushpress=hub'/>
		<item>
		<title>The promise of CAS calculators</title>
		<link>http://amca01.wordpress.com/2012/01/13/the-promise-of-cas-calculators/</link>
		<comments>http://amca01.wordpress.com/2012/01/13/the-promise-of-cas-calculators/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 13:10:59 +0000</pubDate>
		<dc:creator>amca01</dc:creator>
				<category><![CDATA[Maths teaching]]></category>
		<category><![CDATA[high school mathematics]]></category>
		<category><![CDATA[mathematics students]]></category>
		<category><![CDATA[teaching mathematics]]></category>

		<guid isPermaLink="false">http://amca01.wordpress.com/?p=1568</guid>
		<description><![CDATA[I&#8217;m always confused about the best computing environment for teaching mathematics, and over the years I&#8217;ve used Derive, Maple, Maxima, Axiom, Sage, and Matlab. All these have great qualities, and Matlab in particular is the tool of choice for engineering education, as it is for engineering practice. But there is as yet no similar standard [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&amp;blog=3321115&amp;post=1568&amp;subd=amca01&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m always confused about the best computing environment for teaching mathematics, and over the years I&#8217;ve used <a href="http://en.wikipedia.org/wiki/Derive_(computer_algebra_system)">Derive</a>, <a href="http://www.maplesoft.com/">Maple</a>, <a href="http://maxima.sourceforge.net/">Maxima</a>, <a href="http://axiom-developer.org/">Axiom</a>, <a href="http://www.sagemath.org/">Sage</a>, and <a href="http://www.mathworks.com.au/index.html">Matlab</a>.  All these have great qualities, and Matlab in particular is the tool of choice for engineering education, as it is for engineering practice.  But there is as yet no similar standard for mathematics teaching.  Aside from engineering, most of my mathematics students are studying either education (with a mathematics method, to enable them to teach upper high school mathematics), or science students, mainly chemists and environmental scientists, who need a little maths in their courses.</p>
<p>We have been using Maple reasonably successfully for years.  However, there are some significant problems with its use:</p>
<ol>
<li>It is very expensive, and the yearly license is becoming prohibitive in an environment where serious cost-cutting is necessary.  (Let&#8217;s face it, if I had to choose between ditching some software, or ditching me, I&#8217;d go for the software!)</li>
<li>In our subjects we only use a tiny fraction of Maple&#8217;s functionality.  This is of course not an issue with open source software.</li>
<li>Students can&#8217;t play with Maple outside the laboratories; we aren&#8217;t in a position to buy a heap of student licenses and sell them on to the students.</li>
<li>Once they leave the University, the students are never likely to use Maple again in their professional lives.</li>
</ol>
<p>The last problem could be countered by saying that the experience and skills gained in learning Maple are in themselves valuable.  But this is a tack I&#8217;ve heard used too many times to justify the learning of mathematics itself.  Basically it comes down to &#8220;Why do we have to learn this &lt;expletive&gt;?&#8221;  &#8220;Because it&#8217;s GOOD FOR YOU!&#8221;  I&#8217;m not fully convinced, and neither are the students.</p>
<p>Somebody said some years ago that the best adjuncts for learning mathematics are what the students can carry with them.  I&#8217;ve been trying to track down the source of this wisdom, and so far have failed.  Laptops/netbooks with, say Maxima, could indeed overcome the cost of Maple (and of course we could ditch Maple for Maxima, or Sage), and provide a learning environment which can go anywhere.  But not all of my students own, or can afford, such machines.  Many do, but not all.  Some students of course now have tablets (iPads, or less often an Android tablet) but as yet there&#8217;s no powerful mathematics software native for any tablet environment.</p>
<p>Sage can of course be used online, as can Wolfram Alpha, but I don&#8217;t believe the latter is a good teaching tool: it&#8217;s just an answer-giving device; you can&#8217;t really play with it, extend it, insert your own programs, use the output of one command as an input to another, etc.</p>
<p>So what I&#8217;m looking for is a cheap, carry-everywhere mathematical tool.</p>
<p>Enter the new generation of CAS Calculators.  There are a few on the market, of which the Texas Instruments <a href="http://education.ti.com/calculators/products/US/Nspire-Family/">TI-nspire</a>, and the Casio <a href="http://edu.casio.com/products/classpad/cp_v302/">ClassPad</a>, are pre-eminent.  Here they are side by side:</p>
<p><img width="174" height="360" src="http://cdn.coolest-gadgets.com/wp-content/uploads/ti-nspire-cx.jpg" alt="TI-nspire" /><img src="http://www.casio.edu.shriro.com.au/images/classpad/001.png" alt="Casio ClassPad" /></p>
<p>I&#8217;m not going to go into the pros and cons of each one; they both have vocal supporters and detractors, but in many ways they solve my difficulty of finding the right software.  In particular:</p>
<ol>
<li>Many students have used these at school already, so have some exposure to them.</li>
<li>There is no tedious licensing involved.</li>
<li>These calculators are powerful enough to deal with pretty much all of the sort of mathematics we teach (calculus, linear algebra, numerical methods etc).</li>
<li>It is easy to extend the calculators with further libraries or your own functions and programs.  And there are lots more out there on the Internet. For example, some TI-nspire programs can be found <a href="http://www.ticalc.org/pub/nspire/basic/math/">here</a>. </li>
<li>Once in schools, teachers will be using these in their own classrooms.</li>
<li>A scientist out in the field is more likely to be able to carry a calculator along than a laptop fitted out with mathematical software.</li>
</ol>
<p>I&#8217;m very excited about these nifty new tools, and I intend to be exploring them with my students this year.  Stay tuned!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amca01.wordpress.com/1568/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amca01.wordpress.com/1568/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amca01.wordpress.com/1568/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amca01.wordpress.com/1568/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amca01.wordpress.com/1568/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amca01.wordpress.com/1568/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amca01.wordpress.com/1568/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amca01.wordpress.com/1568/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amca01.wordpress.com/1568/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amca01.wordpress.com/1568/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amca01.wordpress.com/1568/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amca01.wordpress.com/1568/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amca01.wordpress.com/1568/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amca01.wordpress.com/1568/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&amp;blog=3321115&amp;post=1568&amp;subd=amca01&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amca01.wordpress.com/2012/01/13/the-promise-of-cas-calculators/feed/</wfw:commentRss>
		<slash:comments>1</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://cdn.coolest-gadgets.com/wp-content/uploads/ti-nspire-cx.jpg" medium="image">
			<media:title type="html">TI-nspire</media:title>
		</media:content>

		<media:content url="http://www.casio.edu.shriro.com.au/images/classpad/001.png" medium="image">
			<media:title type="html">Casio ClassPad</media:title>
		</media:content>
	</item>
		<item>
		<title>In a tropical garden</title>
		<link>http://amca01.wordpress.com/2011/12/28/in-a-tropical-garden/</link>
		<comments>http://amca01.wordpress.com/2011/12/28/in-a-tropical-garden/#comments</comments>
		<pubDate>Tue, 27 Dec 2011 14:06:09 +0000</pubDate>
		<dc:creator>amca01</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://amca01.wordpress.com/?p=1556</guid>
		<description><![CDATA[I just realized I haven&#8217;t posted since early November. That&#8217;s no way to win friends and influence people. And in fact I&#8217;ve done very little mathematical thinking in that time. I have however, been on holiday, some of the pics of which you can see here. So in lieu of some mathematics, here&#8217;s a poem [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&amp;blog=3321115&amp;post=1556&amp;subd=amca01&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I just realized I haven&#8217;t posted since early November. That&#8217;s no way to win friends and influence people.  And in fact I&#8217;ve done very little mathematical thinking in that time.  I have however, been on holiday, some of the pics of which you can see <a href="https://picasaweb.google.com/103300800603683402072/PortDouglas2011">here</a>. So in lieu of some mathematics, here&#8217;s a poem I wrote inspired by the superb tropical gardens of our house. It&#8217;s inspired by <a href="http://en.wikipedia.org/wiki/Andrew_Marvell">Andrew Marvell</a>&#8216;s great poem &#8220;<a href="http://www.luminarium.org/sevenlit/marvell/garden.htm">The Garden</a>&#8221; which if you don&#8217;t know, you should read.</p>
<p><strong>In a Tropical Garden (after Marvell)</strong></p>
<p>The warm air tells me to relax<br />
Unreachable by mail or fax,<br />
The vibrant sun with brilliant rays<br />
Erases thoughts of care-filled days.<br />
The water splashing in the pool<br />
Appears and sounds both fresh and cool.<br />
Upon my back I close my eyes<br />
And rest with happy heartfelt sighs.</p>
<p>The spider weaves her busy snare,<br />
Small insects quarrel in the air,<br />
Bright parrots flash between the trees<br />
Whose leaves are still for lack of breeze,<br />
Beyond the pool I hear the frogs<br />
Who croak and jump beside their logs:<br />
To all these I&#8217;m an honoured guest<br />
And all encourage me to rest.</p>
<p>Above my head the palm fronds sway<br />
And whisper in my ear to stay,<br />
To bide my time in dappled shade<br />
And let my cares and worries fade -<br />
The flowers and the waving ferns<br />
To treat my eyes do take their turns;<br />
Relaxed, at ease, in such surrounds -<br />
No softer bed than these sweet grounds.</p>
<p>How wondrous are the garden&#8217;s fruits:<br />
Bananas, lychees, bamboo shoots,<br />
The mango trees above me drop<br />
Into my lap their sumptuous crop;<br />
The durian, and mangosteen,<br />
Of all the fruits the king and queen:<br />
Into my tastebuds they enmesh<br />
The sweetness of their luscious flesh.</p>
<p>Why do I try so hard at work,<br />
Harsh lighting keeping out the murk?<br />
Commuting there by tedious miles<br />
To push round papers, memos, files.<br />
I do no harm, but little good,<br />
And far less than I wish I could,<br />
And always I&#8217;ve myself deceived<br />
That some small good I have achieved.</p>
<p>But here I can, by gradual stages<br />
Forget about time-sheets and wages,<br />
Agendas, meetings, all such things<br />
Just drift away as if on wings.<br />
No more reminders or alarms<br />
Just floral scents like magic charms.<br />
No clock here strikes its busy hours;<br />
I simply lie and smell the flowers.</p>
<p>This garden&#8217;s made with such success<br />
Out of primeval wilderness,<br />
The gardener and his sweaty team<br />
Have worked for months to make this dream:<br />
To keep the wilderness at bay<br />
They need to battle every day;<br />
Let down their guard but once and then:<br />
The jungle claims its ground again.</p>
<p>This place is artificial, sure<br />
And yet I love it even more,<br />
The air is humid, hot and still,<br />
I lie beneath a leafy frill,<br />
There&#8217;s no place better for my brain<br />
To loosen from a year&#8217;s strain;<br />
With restful dozing, dawn &#8217;til late,<br />
I let my mind rejuvenate.</p>
<p>(December, 2011)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amca01.wordpress.com/1556/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amca01.wordpress.com/1556/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amca01.wordpress.com/1556/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amca01.wordpress.com/1556/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amca01.wordpress.com/1556/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amca01.wordpress.com/1556/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amca01.wordpress.com/1556/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amca01.wordpress.com/1556/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amca01.wordpress.com/1556/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amca01.wordpress.com/1556/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amca01.wordpress.com/1556/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amca01.wordpress.com/1556/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amca01.wordpress.com/1556/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amca01.wordpress.com/1556/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&amp;blog=3321115&amp;post=1556&amp;subd=amca01&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amca01.wordpress.com/2011/12/28/in-a-tropical-garden/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 sestina</title>
		<link>http://amca01.wordpress.com/2011/11/21/the-sestina/</link>
		<comments>http://amca01.wordpress.com/2011/11/21/the-sestina/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 10:17:04 +0000</pubDate>
		<dc:creator>amca01</dc:creator>
				<category><![CDATA[Sage]]></category>

		<guid isPermaLink="false">http://amca01.wordpress.com/?p=1549</guid>
		<description><![CDATA[A sestina is a poetic form consisting of six stanzas of six lines each, followed by an &#8220;envoi&#8221; of three lines. In each stanza, the six words at the end of the line are the same, but in a different order. So if the six lines in the first stanza end 123456, then the orders [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&amp;blog=3321115&amp;post=1549&amp;subd=amca01&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A sestina is a poetic form consisting of six stanzas of six lines each, followed by an &#8220;envoi&#8221; of three lines.  In each stanza, the six words at the end of the line are the same, but in a different order.  So if the six lines in the first stanza end 123456, then the orders of the line endings for the next five stanzas are 615243, 364125, 532614, 451362, and 246531.  You can read more at the <a href="http://en.wikipedia.org/wiki/Sestina">wikipedia page</a>, and see an example by Anthony Hecht <a href="http://www.uni.edu/~gotera/CraftOfPoetry/sestina.html">here</a>, and one by Ezra Pound <a href="http://homepages.wmich.edu/~cooneys/poems/Pound.altaf.html">here</a>.  The form is supposed to have been invented by one <a href="http://en.wikipedia.org/wiki/Arnaut_Daniel">Artaud Daniel</a>, a 12th century troubadour, and has been exercising the minds of poets and other verse-makers since.</p>
<p>My interest here is the permutations which are used for the line endings.  If you look carefully, you&#8217;ll see that the same permutation is used each time.  This means that the sestina can be described in terms of powers of a single permutation.  In cyclic notation, the first permutation 615243 can be written as</p>
<p><img src='http://s0.wp.com/latex.php?latex=%281%2C2%2C4%2C5%2C3%2C6%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='(1,2,4,5,3,6)' title='(1,2,4,5,3,6)' class='latex' />.</p>
<p>That is, the ending of line 1 becomes the ending of line 2 in the next stanza, the ending of line 2 becomes the ending of line 4 in the next stanza, and so on.  Here&#8217;s Sage to do all the hard work:</p>
<p><pre class="brush: python; gutter: false;">
sage: S = SymmetricGroup(6)
sage: p = S((1,2,4,5,3,6))
sage: for i in range(6): print i+1,p^i
....: 
1 ()
2 (1,2,4,5,3,6)
3 (1,4,3)(2,5,6)
4 (1,5)(2,3)(4,6)
5 (1,3,4)(2,6,5)
6 (1,6,3,5,4,2)
</pre></p>
<p>Look at stanza 5 for example,  The permutation is 451362.  This means that 1 goes to the third place, 2 to the sixth place, 3 to the fourth place and so on.  But this is given by the cycles</p>
<p><img src='http://s0.wp.com/latex.php?latex=%281%2C3%2C4%29%282%2C6%2C5%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='(1,3,4)(2,6,5)' title='(1,3,4)(2,6,5)' class='latex' />.</p>
<p>If we want to print out the permutations as given above, that is easy:</p>
<p><pre class="brush: python; gutter: false;">
sage: q = p.inverse()
sage: for i in range(6):
....:     qi = q^i
....:     print i+1,[qi(i) for i in range(1,7)]
....:     
1 [1, 2, 3, 4, 5, 6]
2 [6, 1, 5, 2, 4, 3]
3 [3, 6, 4, 1, 2, 5]
4 [5, 3, 2, 6, 1, 4]
5 [4, 5, 1, 3, 6, 2]
6 [2, 4, 6, 5, 3, 1]
</pre></p>
<p>The sestina can now described as follows: in stanza <img src='http://s0.wp.com/latex.php?latex=n&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='n' title='n' class='latex' />, the permutations of the line endings are given by <img src='http://s0.wp.com/latex.php?latex=p%5E%7Bn-1%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='p^{n-1}' title='p^{n-1}' class='latex' /> where <img src='http://s0.wp.com/latex.php?latex=p+%3D+%281%2C2%2C4%2C5%2C3%2C6%29%5Cin+S_6&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='p = (1,2,4,5,3,6)&#92;in S_6' title='p = (1,2,4,5,3,6)&#92;in S_6' class='latex' />.  I wonder how much of the theory of permutation groups was known to Artaud Daniel?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amca01.wordpress.com/1549/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amca01.wordpress.com/1549/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amca01.wordpress.com/1549/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amca01.wordpress.com/1549/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amca01.wordpress.com/1549/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amca01.wordpress.com/1549/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amca01.wordpress.com/1549/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amca01.wordpress.com/1549/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amca01.wordpress.com/1549/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amca01.wordpress.com/1549/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amca01.wordpress.com/1549/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amca01.wordpress.com/1549/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amca01.wordpress.com/1549/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amca01.wordpress.com/1549/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&amp;blog=3321115&amp;post=1549&amp;subd=amca01&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amca01.wordpress.com/2011/11/21/the-sestina/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>Computing from the command line</title>
		<link>http://amca01.wordpress.com/2011/10/21/computing-from-the-command-line/</link>
		<comments>http://amca01.wordpress.com/2011/10/21/computing-from-the-command-line/#comments</comments>
		<pubDate>Fri, 21 Oct 2011 03:17:09 +0000</pubDate>
		<dc:creator>amca01</dc:creator>
				<category><![CDATA[Computation]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://amca01.wordpress.com/?p=1522</guid>
		<description><![CDATA[Like many die-hard, old-school Linux users I have an inordinate fondness for the command line, and would rather use a command line interface than a snazzy GUI. This post is about how to use the command line to perform simple arithmetic computations, and a few examples of slightly more advanced mathematics. There are many times [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&amp;blog=3321115&amp;post=1522&amp;subd=amca01&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Like many die-hard, old-school Linux users I have an inordinate fondness for the command line, and would rather use a command line interface than a snazzy GUI. This post is about how to use the command line to perform simple arithmetic computations, and a few examples of slightly more advanced mathematics.  There are many times when I just want an immediate answer to a (usually simple) computation without powering up <a href="http://www.gnu.org/software/octave/">Octave</a> or <a href="http://www.sagemath.org/">Sage</a>, both of which use up sometimes overloaded memory.  I&#8217;m assuming the use of the <a href="http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29">Bash shell</a>.</p>
<p><b>Use of <tt>expr</tt></b></p>
<p>For simple integer computations, the <tt>expr</tt> command is sufficient. Here are a few examples:</p>
<p><pre class="brush: bash; gutter: false;">
home:$ expr $[3+4]
7
home:$ expr $[5**6]
15625
home:$ expr $[100/17]
5
</pre></p>
<p>Because the Bash shell only allows integers as input and output, a division will always be rounded down.</p>
<p><b>Use of <tt>bc</tt></b></p>
<p>To obtain fractional output, and to use more mathematical functions, the command <tt>bc</tt> may be used. This should be available on all Linux distributions, and is a remarkably powerful calculator. See an old article of mine <a href="http://www.linuxjournal.com/article/2544">here</a> for an introduction to it.</p>
<p>Any expression can be piped to <tt>bc</tt> for computation, and if <tt>bc</tt> is invoked with <tt>bc -l</tt>, this loads a mathematics library which includes the functions <tt>a(x)</tt>, <tt>s(x)</tt>, <tt>c(x)</tt>, <tt>e(x)</tt>, <tt>l(x)</tt>,<tt>j(n,x)</tt>, for inverse tangent, sin, cos, exponential function, natural logarithm and Bessel function of order <img src='http://s0.wp.com/latex.php?latex=n&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='n' title='n' class='latex' /> respectively. You can read the <a href="http://x-bc.sourceforge.net/man_bc.html">man page for bc</a> online.</p>
<p>So here are some examples of the use of <tt>bc</tt>:</p>
<p><pre class="brush: bash; gutter: false;">
home:$ echo &quot;1/3+4/7&quot; | bc -l
.90476190476190476190
home:$ echo &quot;2^100&quot; | bc
1267650600228229401496703205376
home:$ echo &quot;scale=100;4*a(1)&quot; | bc -l
3.14159265358979323846264338327950288419716939937510\
58209749445923078164062862089986280348253421170676
</pre></p>
<p>The value <tt>scale</tt> is an internal variable which gives the number of figures after the decimal point.  Alternatively, we can use this syntax:</p>
<p><pre class="brush: bash; gutter: false;">
home:$ bc -l &lt;&lt;&lt; &quot;pi=4*a(1);s(pi/5)&quot;
.58778525229247312915
home:$ bc -l &lt;&lt;&lt; &quot;e(l(100)/3)&quot;
4.64158883361277889236
</pre></p>
<p>This last calculation, of course, uses <img src='http://s0.wp.com/latex.php?latex=exp%28x%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='exp(x)' title='exp(x)' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=ln%28x%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='ln(x)' title='ln(x)' class='latex' /> to compute the cube root of 100.</p>
<p>Because <tt>bc</tt> is a fully featured programming language, you can write programs to perform other functions: a huge number of such functions can be found <a href="http://www.numbertheory.org/gnubc/bc_programs.html">here</a> and <a href="http://phodd.net/gnu-bc/">here</a>.  Suppose we put a handful of useful functions in a file called <tt>stuff.bc</tt> and include in our file <tt>.bashrc</tt> the line</p>
<p><tt> alias b="bc -l /path/to/stuff.bc"</tt></p>
<p>Then we&#8217;re able to do things like this:</p>
<p><pre class="brush: bash; gutter: false;">
home:$ b &lt;&lt;&lt; &quot;gcd(1001,161)&quot;
7
home:$ b &lt;&lt;&lt; &quot;bin(100,50)&quot;
100891344545564193334812497256
home:$ b &lt;&lt;&lt; &quot;fact(100)&quot;
9332621544394415268169923885626670049071596826438\
1621468592963895217599993229915608941463976156518\
2862536979208272237582511852109168640000000000000\
00000000000
</pre></p>
<p>(assuming that our file contains commands for the greatest common divisor, binomial coefficients, and factorials.)</p>
<p><b>Use of <tt>calc</tt></b></p>
<p>A newer and even more powerful computational language is provided by <tt><a href="http://isthe.com/chongo/tech/comp/calc/">calc</a></tt>.  It has far more built-in commands than <tt>bc</tt>, as you can see <a href="http://isthe.com/chongo/tech/comp/calc/calc-builtin.html">here</a>.  It can be used interactively (as can <tt>bc</tt>) but here we are interested in its use as a command-line calculator.  Here&#8217;s a couple of examples:</p>
<p><pre class="brush: bash; gutter: false;">
home:$ calc '100!'
        933262154439441526816992388562667004907159682643816214685
92963895217599993229915608941463976156518286253697920827223758251
185210916864000000000000000000000000
home:$ calc 'sin(pi()/5)'
	0.58778525229247312917
</pre></p>
<p>Just as <tt>scale</tt> can be used to increase the number of decimal points in <tt>bc</tt>, so <tt>epsilon</tt> is used in <tt>calc</tt> for the real precision, and <tt>display</tt> changes the number of displayed digits.  Here&#8217;s an example, to compute the <a href="http://mathworld.wolfram.com/AlmostInteger.html">almost integer</a> value </p>
<p><img src='http://s0.wp.com/latex.php?latex=e%5E%7B%5Cpi%5Csqrt%7B163%7D%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='e^{&#92;pi&#92;sqrt{163}}' title='e^{&#92;pi&#92;sqrt{163}}' class='latex' />.</p>
<p><pre class="brush: bash; gutter: false;">
home:$ calc 'exp(pi()*sqrt(163))'
	262537412640768743.99035456305787674737
</pre></p>
<p>This is not quite as close as it should be, so we&#8217;ll increase the internal precision, which at the moment is <img src='http://s0.wp.com/latex.php?latex=10%5E%7B-20%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='10^{-20}' title='10^{-20}' class='latex' />:</p>
<p><pre class="brush: bash; gutter: false;">
home:$ calc 'log(1/epsilon())'
	20
home:$ calc 'epsilon(1e-40);exp(pi()*sqrt(163))'
	0.00000000000000000001
	~262537412640768743.99999999999925007260
</pre></p>
<p><pre class="brush: bash; gutter: false;">

</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amca01.wordpress.com/1522/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amca01.wordpress.com/1522/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amca01.wordpress.com/1522/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amca01.wordpress.com/1522/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amca01.wordpress.com/1522/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amca01.wordpress.com/1522/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amca01.wordpress.com/1522/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amca01.wordpress.com/1522/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amca01.wordpress.com/1522/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amca01.wordpress.com/1522/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amca01.wordpress.com/1522/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amca01.wordpress.com/1522/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amca01.wordpress.com/1522/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amca01.wordpress.com/1522/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&amp;blog=3321115&amp;post=1522&amp;subd=amca01&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amca01.wordpress.com/2011/10/21/computing-from-the-command-line/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 note on regression</title>
		<link>http://amca01.wordpress.com/2011/10/11/a-note-on-regression/</link>
		<comments>http://amca01.wordpress.com/2011/10/11/a-note-on-regression/#comments</comments>
		<pubDate>Tue, 11 Oct 2011 00:50:17 +0000</pubDate>
		<dc:creator>amca01</dc:creator>
				<category><![CDATA[Computation]]></category>
		<category><![CDATA[Maths teaching]]></category>

		<guid isPermaLink="false">http://amca01.wordpress.com/?p=1497</guid>
		<description><![CDATA[In Matlab and similar matrix oriented systems such as Octave and Scilab, the backslash operator can be used to solve systems of linear equations. Thus to solve, for example we would enter: If the matrix is not square, then the backslash operator solves the associated linear least squares regression problem, using the equation where is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&amp;blog=3321115&amp;post=1497&amp;subd=amca01&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://www.mathworks.com">Matlab</a> and similar matrix oriented systems such as <a href="http://www.gnu.org/software/octave/">Octave</a> and <a href="http://www.scilab.org/">Scilab</a>, the backslash operator can be used to solve systems of linear equations.  Thus to solve, for example</p>
<p><img src='http://s0.wp.com/latex.php?latex=x-y%2B2z%3D3&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x-y+2z=3' title='x-y+2z=3' class='latex' /></p>
<p><img src='http://s0.wp.com/latex.php?latex=2x%2B2y-z%3D-1&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='2x+2y-z=-1' title='2x+2y-z=-1' class='latex' /></p>
<p><img src='http://s0.wp.com/latex.php?latex=x-3y%2Bz%3D2&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x-3y+z=2' title='x-3y+z=2' class='latex' /></p>
<p>we would enter:</p>
<p><pre class="brush: matlabkey; light: true;">
&gt;&gt; A = [1 -1 2;2 2 -1;1 -3 1]
&gt;&gt; b = [3;-1;2]
&gt;&gt; A\b
ans =

   0.28571
  -0.14286
   1.28571
</pre></p>
<p>If the matrix <img src='http://s0.wp.com/latex.php?latex=A&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='A' title='A' class='latex' /> is not square, then the backslash operator solves the associated linear least squares regression problem, using the equation</p>
<p><img src='http://s0.wp.com/latex.php?latex=%28X%5ETX%29A%3DX%5ETz&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='(X^TX)A=X^Tz' title='(X^TX)A=X^Tz' class='latex' /></p>
<p>where <img src='http://s0.wp.com/latex.php?latex=X&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='X' title='X' class='latex' /> is the matrix containing the independent variables, <img src='http://s0.wp.com/latex.php?latex=z&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='z' title='z' class='latex' /> is the matrix containing the dependent variables, and <img src='http://s0.wp.com/latex.php?latex=A&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='A' title='A' class='latex' /> are the coefficients of the best fit linear function obtained using least squares.</p>
<p>For example, suppose we create random array of <img src='http://s0.wp.com/latex.php?latex=x&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x' title='x' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=y&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='y' title='y' class='latex' /> and a variable <img src='http://s0.wp.com/latex.php?latex=z&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='z' title='z' class='latex' /> which is approximately equal to <img src='http://s0.wp.com/latex.php?latex=a_1%2Ba_2x%2Ba_3y&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='a_1+a_2x+a_3y' title='a_1+a_2x+a_3y' class='latex' />:</p>
<p><pre class="brush: matlabkey; light: true;">
&gt;&gt; N = 5
&gt;&gt; [x,y] = meshgrid(1:N);
&gt;&gt; z = randn(N)+3*(randn()*x+randn()*y);
&gt;&gt; X = [ones(N^2,1),x(:),y(:)]
&gt;&gt; Z = z(:);
&gt;&gt; A = X\Z
A =

   0.97722
   2.99300
   0.70215
</pre></p>
<p>To show that these values are in fact the same as that obtained with <img src='http://s0.wp.com/latex.php?latex=%28X%5ETX%29A%3DX%5ETz&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='(X^TX)A=X^Tz' title='(X^TX)A=X^Tz' class='latex' />:</p>
<p><pre class="brush: matlabkey; light: true;">
&gt;&gt; inv(X'*X)*X'*Z
ans =

   0.97722
   2.99300
   0.70215
</pre></p>
<p>Now we can see how close the best fit values are to the <img src='http://s0.wp.com/latex.php?latex=z&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='z' title='z' class='latex' /> values:</p>
<p><pre class="brush: matlabkey; light: true;">
&gt;&gt; &gt; r = A(1)+A(2)*x(:)+A(3)*y(:);
&gt;&gt; [z(:),r,abs(z(:)-r)]
ans =

    4.780556    4.672364    0.108192
    6.130427    5.374509    0.755918
    7.459690    6.076654    1.383036
    7.336100    6.778800    0.557300
    4.672154    7.480945    2.808791
    7.323456    7.665366    0.341910
    9.637936    8.367511    1.270425
   10.092996    9.069656    1.023340
   11.415496    9.771802    1.643694
    8.659346   10.473947    1.814601
   11.073199   10.658368    0.414831
   10.165530   11.360513    1.194983
   12.077467   12.062658    0.014809
   11.450084   12.764804    1.314720
   12.881417   13.466949    0.585532
   12.402667   13.651370    1.248703
   14.885301   14.353515    0.531786
   14.859297   15.055660    0.196363
   16.480020   15.757806    0.722215
   16.656739   16.459951    0.196788
   15.183698   16.644372    1.460674
   16.990119   17.346517    0.356398
   18.229809   18.048662    0.181147
   19.423194   18.750808    0.672387
   21.299761   19.452953    1.846808
</pre></p>
<p>Here&#8217;s a quick proof of the formula <img src='http://s0.wp.com/latex.php?latex=%28X%5ETX%29A%3DX%5ETz&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='(X^TX)A=X^Tz' title='(X^TX)A=X^Tz' class='latex' />.  Suppose we have variables <img src='http://s0.wp.com/latex.php?latex=x_i&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x_i' title='x_i' class='latex' />, <img src='http://s0.wp.com/latex.php?latex=y_i&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='y_i' title='y_i' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=z_i&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='z_i' title='z_i' class='latex' /> and we wish to express <img src='http://s0.wp.com/latex.php?latex=z&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='z' title='z' class='latex' /> as a linear function of <img src='http://s0.wp.com/latex.php?latex=x&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x' title='x' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=y&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='y' title='y' class='latex' />:</p>
<p><img src='http://s0.wp.com/latex.php?latex=z+%3D+a%2Bbx%2Bcy&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='z = a+bx+cy' title='z = a+bx+cy' class='latex' /></p>
<p>in such a way that the sum of squares:</p>
<p><img src='http://s0.wp.com/latex.php?latex=S%3D%5Csum%28a%2Bbx_i%2Bcy_i-z_i%29%5E2&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='S=&#92;sum(a+bx_i+cy_i-z_i)^2' title='S=&#92;sum(a+bx_i+cy_i-z_i)^2' class='latex' /></p>
<p>is minimized.  To do this we simply differentiate <img src='http://s0.wp.com/latex.php?latex=S&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='S' title='S' class='latex' /> with respect to <img src='http://s0.wp.com/latex.php?latex=a&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='a' title='a' class='latex' />, <img src='http://s0.wp.com/latex.php?latex=b&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='b' title='b' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=c&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='c' title='c' class='latex' />, and solve the system in which each derivative is set equal to zero.  </p>
<p>Differentiating with respect to <img src='http://s0.wp.com/latex.php?latex=x&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x' title='x' class='latex' />, and dividing by two, produces</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Csum%28a%2Bbx_i%2Bcy_i-z_i%29x_i+%3D+0&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;sum(a+bx_i+cy_i-z_i)x_i = 0' title='&#92;sum(a+bx_i+cy_i-z_i)x_i = 0' class='latex' /></p>
<p>Similarly (<img src='http://s0.wp.com/latex.php?latex=dS%2Fdb%3D0&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='dS/db=0' title='dS/db=0' class='latex' />):</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Csum%28a%2Bbx_i%2Bcy_i-z_i%29y_i+%3D+0&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;sum(a+bx_i+cy_i-z_i)y_i = 0' title='&#92;sum(a+bx_i+cy_i-z_i)y_i = 0' class='latex' /></p>
<p>and for <img src='http://s0.wp.com/latex.php?latex=dS%2Fdc%3D0&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='dS/dc=0' title='dS/dc=0' class='latex' />:</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Csum%28a%2Bbx_i%2Bcy_i-z_i%29+%3D+0&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;sum(a+bx_i+cy_i-z_i) = 0' title='&#92;sum(a+bx_i+cy_i-z_i) = 0' class='latex' /></p>
<p>This can be written in matrix form as:</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7B%5Cleft%5B%5Cbegin%7Barray%7D%7Bccc%7D%5Csum+x_i%5E2%26%5Csum+x_iy_i%26%5Csum+x_i%5C%5C+%5Csum+x_iy_i%26%5Csum+y_i%5E2%26%5Csum+y_i%5C%5C+%5Csum+x_i%26%5Csum+y_i%26%5Csum+1%5Cend%7Barray%7D%5Cright%5D%5Cleft%5B%5Cbegin%7Barray%7D%7Bc%7Da%5C%5Cb%5C%5Cc%5Cend%7Barray%7D%5Cright%5D%3D%5Cleft%5B%5Cbegin%7Barray%7D%7Bc%7D%5Csum+x_iz_i%5C%5C+%5Csum+y_iz_i%5C%5C+%5Csum+z_i%5Cend%7Barray%7D%5Cright%5D%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{&#92;left[&#92;begin{array}{ccc}&#92;sum x_i^2&amp;&#92;sum x_iy_i&amp;&#92;sum x_i&#92;&#92; &#92;sum x_iy_i&amp;&#92;sum y_i^2&amp;&#92;sum y_i&#92;&#92; &#92;sum x_i&amp;&#92;sum y_i&amp;&#92;sum 1&#92;end{array}&#92;right]&#92;left[&#92;begin{array}{c}a&#92;&#92;b&#92;&#92;c&#92;end{array}&#92;right]=&#92;left[&#92;begin{array}{c}&#92;sum x_iz_i&#92;&#92; &#92;sum y_iz_i&#92;&#92; &#92;sum z_i&#92;end{array}&#92;right]}' title='&#92;displaystyle{&#92;left[&#92;begin{array}{ccc}&#92;sum x_i^2&amp;&#92;sum x_iy_i&amp;&#92;sum x_i&#92;&#92; &#92;sum x_iy_i&amp;&#92;sum y_i^2&amp;&#92;sum y_i&#92;&#92; &#92;sum x_i&amp;&#92;sum y_i&amp;&#92;sum 1&#92;end{array}&#92;right]&#92;left[&#92;begin{array}{c}a&#92;&#92;b&#92;&#92;c&#92;end{array}&#92;right]=&#92;left[&#92;begin{array}{c}&#92;sum x_iz_i&#92;&#92; &#92;sum y_iz_i&#92;&#92; &#92;sum z_i&#92;end{array}&#92;right]}' class='latex' /></p>
<p>Now define the vectors:</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cmathbf%7Bx%7D%3D%5Bx_1%5C%3B+x_2%5C%3B%5Cldots%5C%3B+x_n%5D%5ET&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;mathbf{x}=[x_1&#92;; x_2&#92;;&#92;ldots&#92;; x_n]^T' title='&#92;mathbf{x}=[x_1&#92;; x_2&#92;;&#92;ldots&#92;; x_n]^T' class='latex' /></p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cmathbf%7By%7D%3D%5By_1%5C%3B+y_2%5C%3B%5Cldots%5C%3B+y_n%5D%5ET&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;mathbf{y}=[y_1&#92;; y_2&#92;;&#92;ldots&#92;; y_n]^T' title='&#92;mathbf{y}=[y_1&#92;; y_2&#92;;&#92;ldots&#92;; y_n]^T' class='latex' /></p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cmathbf%7Bz%7D%3D%5Bz_1%5C%3B+z_2%5C%3B%5Cldots%5C%3B+z_n%5D%5ET&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;mathbf{z}=[z_1&#92;; z_2&#92;;&#92;ldots&#92;; z_n]^T' title='&#92;mathbf{z}=[z_1&#92;; z_2&#92;;&#92;ldots&#92;; z_n]^T' class='latex' /></p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cmathbf%7B1%7D%3D%5B1%5C%3B+1%5C%3B%5Cldots%5C%3B+1%5D%5ET&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;mathbf{1}=[1&#92;; 1&#92;;&#92;ldots&#92;; 1]^T' title='&#92;mathbf{1}=[1&#92;; 1&#92;;&#92;ldots&#92;; 1]^T' class='latex' /></p>
<p>And so the matrix equation above can be written as</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7B%5Cleft%5B%5Cbegin%7Barray%7D%7Bccc%7D%5Cmathbf%7Bx%7D%5ET%5Cmathbf%7Bx%7D%26%5Cmathbf%7Bx%7D%5ET%5Cmathbf%7By%7D%26%5Cmathbf%7Bx%7D%5ET%5Cmathbf%7B1%7D%5C%5C+%5Cmathbf%7Bx%7D%5ET%5Cmathbf%7By%7D%26%5Cmathbf%7By%7D%5ET%5Cmathbf%7By%7D%26%5Cmathbf%7By%7D%5ET%5Cmathbf%7B1%7D%5C%5C+%5Cmathbf%7Bx%7D%5ET%5Cmathbf%7B1%7D%26%5Cmathbf%7By%7D%5ET%5Cmathbf%7B1%7D%26%5Cmathbf%7B1%7D%5ET%5Cmathbf%7B1%7D%5Cend%7Barray%7D%5Cright%5D%5Cleft%5B%5Cbegin%7Barray%7D%7Bc%7Da%5C%5Cb%5C%5Cc%5Cend%7Barray%7D%5Cright%5D%3D%5Cleft%5B%5Cbegin%7Barray%7D%7Bc%7D%5Cmathbf%7Bx%7D%5ET%5Cmathbf%7Bz%7D%5C%5C+%5Cmathbf%7By%7D%5ET%5Cmathbf%7Bz%7D%5C%5C+%5Cmathbf%7Bz%7D%5ET%5Cmathbf%7B1%7D%5Cend%7Barray%7D%5Cright%5D%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{&#92;left[&#92;begin{array}{ccc}&#92;mathbf{x}^T&#92;mathbf{x}&amp;&#92;mathbf{x}^T&#92;mathbf{y}&amp;&#92;mathbf{x}^T&#92;mathbf{1}&#92;&#92; &#92;mathbf{x}^T&#92;mathbf{y}&amp;&#92;mathbf{y}^T&#92;mathbf{y}&amp;&#92;mathbf{y}^T&#92;mathbf{1}&#92;&#92; &#92;mathbf{x}^T&#92;mathbf{1}&amp;&#92;mathbf{y}^T&#92;mathbf{1}&amp;&#92;mathbf{1}^T&#92;mathbf{1}&#92;end{array}&#92;right]&#92;left[&#92;begin{array}{c}a&#92;&#92;b&#92;&#92;c&#92;end{array}&#92;right]=&#92;left[&#92;begin{array}{c}&#92;mathbf{x}^T&#92;mathbf{z}&#92;&#92; &#92;mathbf{y}^T&#92;mathbf{z}&#92;&#92; &#92;mathbf{z}^T&#92;mathbf{1}&#92;end{array}&#92;right]}' title='&#92;displaystyle{&#92;left[&#92;begin{array}{ccc}&#92;mathbf{x}^T&#92;mathbf{x}&amp;&#92;mathbf{x}^T&#92;mathbf{y}&amp;&#92;mathbf{x}^T&#92;mathbf{1}&#92;&#92; &#92;mathbf{x}^T&#92;mathbf{y}&amp;&#92;mathbf{y}^T&#92;mathbf{y}&amp;&#92;mathbf{y}^T&#92;mathbf{1}&#92;&#92; &#92;mathbf{x}^T&#92;mathbf{1}&amp;&#92;mathbf{y}^T&#92;mathbf{1}&amp;&#92;mathbf{1}^T&#92;mathbf{1}&#92;end{array}&#92;right]&#92;left[&#92;begin{array}{c}a&#92;&#92;b&#92;&#92;c&#92;end{array}&#92;right]=&#92;left[&#92;begin{array}{c}&#92;mathbf{x}^T&#92;mathbf{z}&#92;&#92; &#92;mathbf{y}^T&#92;mathbf{z}&#92;&#92; &#92;mathbf{z}^T&#92;mathbf{1}&#92;end{array}&#92;right]}' class='latex' /></p>
<p>This can be written as</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7B%5Cleft%5B%5Cbegin%7Barray%7D%7Bc%7D%5Cmathbf%7Bx%7D%5ET%5C%5C+%5Cmathbf%7By%7D%5ET%5C%5C+%5Cmathbf%7B1%7D%5ET%5Cend%7Barray%7D%5Cright%5D%5Cleft%5B%5Cbegin%7Barray%7D%7Bccc%7D%5Cmathbf%7Bx%7D%5ET%26+%5Cmathbf%7By%7D%5ET%26+%5Cmathbf%7B1%7D%5ET%5Cend%7Barray%7D%5Cright%5D%5Cleft%5B%5Cbegin%7Barray%7D%7Bc%7Da%5C%5Cb%5C%5Cc%5Cend%7Barray%7D%5Cright%5D%3D%5Cleft%5B%5Cbegin%7Barray%7D%7Bc%7D%5Cmathbf%7Bx%7D%5ET%5C%5C+%5Cmathbf%7By%7D%5ET%5C%5C+%5Cmathbf%7B1%7D%5ET%5Cend%7Barray%7D%5Cright%5D%5Cleft%5B%5Cbegin%7Barray%7D%7Bc%7D%5Cmathbf%7Bz%7D%5Cend%7Barray%7D%5Cright%5D%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{&#92;left[&#92;begin{array}{c}&#92;mathbf{x}^T&#92;&#92; &#92;mathbf{y}^T&#92;&#92; &#92;mathbf{1}^T&#92;end{array}&#92;right]&#92;left[&#92;begin{array}{ccc}&#92;mathbf{x}^T&amp; &#92;mathbf{y}^T&amp; &#92;mathbf{1}^T&#92;end{array}&#92;right]&#92;left[&#92;begin{array}{c}a&#92;&#92;b&#92;&#92;c&#92;end{array}&#92;right]=&#92;left[&#92;begin{array}{c}&#92;mathbf{x}^T&#92;&#92; &#92;mathbf{y}^T&#92;&#92; &#92;mathbf{1}^T&#92;end{array}&#92;right]&#92;left[&#92;begin{array}{c}&#92;mathbf{z}&#92;end{array}&#92;right]}' title='&#92;displaystyle{&#92;left[&#92;begin{array}{c}&#92;mathbf{x}^T&#92;&#92; &#92;mathbf{y}^T&#92;&#92; &#92;mathbf{1}^T&#92;end{array}&#92;right]&#92;left[&#92;begin{array}{ccc}&#92;mathbf{x}^T&amp; &#92;mathbf{y}^T&amp; &#92;mathbf{1}^T&#92;end{array}&#92;right]&#92;left[&#92;begin{array}{c}a&#92;&#92;b&#92;&#92;c&#92;end{array}&#92;right]=&#92;left[&#92;begin{array}{c}&#92;mathbf{x}^T&#92;&#92; &#92;mathbf{y}^T&#92;&#92; &#92;mathbf{1}^T&#92;end{array}&#92;right]&#92;left[&#92;begin{array}{c}&#92;mathbf{z}&#92;end{array}&#92;right]}' class='latex' /></p>
<p>This is clearly the same as the equation <img src='http://s0.wp.com/latex.php?latex=%28X%5ETX%29A%3DX%5ETz&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='(X^TX)A=X^Tz' title='(X^TX)A=X^Tz' class='latex' />, and is obviously true for any number of independent variables.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amca01.wordpress.com/1497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amca01.wordpress.com/1497/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amca01.wordpress.com/1497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amca01.wordpress.com/1497/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amca01.wordpress.com/1497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amca01.wordpress.com/1497/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amca01.wordpress.com/1497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amca01.wordpress.com/1497/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amca01.wordpress.com/1497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amca01.wordpress.com/1497/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amca01.wordpress.com/1497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amca01.wordpress.com/1497/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amca01.wordpress.com/1497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amca01.wordpress.com/1497/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&amp;blog=3321115&amp;post=1497&amp;subd=amca01&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amca01.wordpress.com/2011/10/11/a-note-on-regression/feed/</wfw:commentRss>
		<slash:comments>1</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>Ruth-Aaron pairs</title>
		<link>http://amca01.wordpress.com/2011/09/20/ruth-aaron-pairs/</link>
		<comments>http://amca01.wordpress.com/2011/09/20/ruth-aaron-pairs/#comments</comments>
		<pubDate>Tue, 20 Sep 2011 04:08:00 +0000</pubDate>
		<dc:creator>amca01</dc:creator>
				<category><![CDATA[Computation]]></category>
		<category><![CDATA[Sage]]></category>

		<guid isPermaLink="false">http://amca01.wordpress.com/?p=1487</guid>
		<description><![CDATA[On May 25, 1935, at Forbes Field in Pittsburgh, Babe Ruth hit his 714th (and last) home run, setting a record for major league baseball which would stand unchallenged for nearly 40 years. The record was broken on April 8, 1974 by Hank Aaron who hit his 715th home run. (He went on to hit [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&amp;blog=3321115&amp;post=1487&amp;subd=amca01&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>On May 25, 1935, at Forbes Field in Pittsburgh, Babe Ruth hit his 714th (and last) home run, setting a record for major league baseball which would stand unchallenged for nearly 40 years.  The record was broken on April 8, 1974 by <a href="http://en.wikipedia.org/wiki/Hank_Aaron">Hank Aaron</a> who hit his 715th home run.  (He went on to hit a total of 755 home runs.  This record has since been broken by <a href="http://en.wikipedia.org/wiki/Barry_bonds">Barry Bonds</a> with 762 home runs, and those three: Ruth, Aaron, Bonds, are the only three players ever to hit more than 700 home runs in major league baseball.)</p>
<p>Not long after Aaron&#8217;s 715th homer, <a href="http://en.wikipedia.org/wiki/Carl_Pomerance">Carl Pomerance</a>, then at the University of Georgia, and two others, noticed two facts about the numbers 714 and 715:</p>
<ol>
<li>The two numbers between them factored into the first seven primes:
<p><img src='http://s0.wp.com/latex.php?latex=714+%3D+2%5Ccdot+3%5Ccdot+7%5Ccdot+17&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='714 = 2&#92;cdot 3&#92;cdot 7&#92;cdot 17' title='714 = 2&#92;cdot 3&#92;cdot 7&#92;cdot 17' class='latex' /></p>
<p>and</p>
<p><img src='http://s0.wp.com/latex.php?latex=715+%3D+5%5Ccdot+11%5Ccdot+13&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='715 = 5&#92;cdot 11&#92;cdot 13' title='715 = 5&#92;cdot 11&#92;cdot 13' class='latex' />.</li>
<li>The sums of the prime factors of each were the same:
<p><img src='http://s0.wp.com/latex.php?latex=2%2B3%2B7%2B17+%3D+5%2B11%2B13+%3D+29.&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='2+3+7+17 = 5+11+13 = 29.' title='2+3+7+17 = 5+11+13 = 29.' class='latex' /></li>
</ol>
<p>Pomerance and his colleagues wrote a paper called &#8220;<a href="http://www.trottermath.net/numthry/ruth714.html">714 and 715</a>&#8221; which he <a href="http://www.math.dartmouth.edu/~carlp/PDF/paper130.pdf">later described</a> as &#8220;humorous&#8221; discussing these numbers.  This paper, had the effect of catching the eye of Paul Erdős, who suggested that he visit Pomerance in Georgia, thus starting a long and fruitful collaboration between the two (at least 40 joint papers).</p>
<p>In honour of the two baseball players, two consecutive integers the sum of whose prime factors (with multiplicity) are equal, are called <em>Ruth-Aaron pairs</em>.  It&#8217;s not hard to set up a brute force program to list them:</p>
<p><pre class="brush: python; gutter: false;">
sage: def S(n): return sum(i*j for i,j in factor(n))
....: 
sage: for k in range(1,100000):
....:     if S(k)==S(k+1):
....:         print k
....:         
5
8
15
77
125
714
948
1330
1520
1862
2491
3248
4185
4191
5405
5560
5959
6867
8280
8463
10647
12351
</pre><br />
&#8230; and so on.  This sequence is <a href="http://oeis.org/A039752">A039752</a> in the <a href="http://oeis.org">OEIS</a>.</p>
<p>It is not yet known whether there are infinite Ruth-Aaron pairs, but it is known, thanks to Pomerance and Erdős, that they are quite rare; in fact <a href="http://www.math.dartmouth.edu/~carlp/PDF/paper130.pdf">Pomerance proved</a> that for any integer <img src='http://s0.wp.com/latex.php?latex=x&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x' title='x' class='latex' />, the number of integers <img src='http://s0.wp.com/latex.php?latex=n%3Cx&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='n&lt;x' title='n&lt;x' class='latex' /> for which <img src='http://s0.wp.com/latex.php?latex=S%28n%29%3DS%28n%2B1%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='S(n)=S(n+1)' title='S(n)=S(n+1)' class='latex' /> was bounded as</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7BO%5Cleft%28%5Cfrac%7Bx%28%5Clog%5Clog+x%29%5E4%7D%7B%28%5Clog+x%29%5E2%7D%5Cright%29%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{O&#92;left(&#92;frac{x(&#92;log&#92;log x)^4}{(&#92;log x)^2}&#92;right)}' title='&#92;displaystyle{O&#92;left(&#92;frac{x(&#92;log&#92;log x)^4}{(&#92;log x)^2}&#92;right)}' class='latex' /></p>
<p>and that the sum of the reciprocals was bounded.</p>
<p>In 1995 Emory University awarded honorary degrees to both Aaron and Erdős.  Pomerance, who was then at Emory, asked for a baseball &#8211; several had been provided for Aaron to sign &#8211; and asked both Aaron and Erdős to sign it. &#8220;I joke that Aaron should have Erdős-number 1 since, though he does not have a joint paper with Erdős, he does have a joint baseball.&#8221;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amca01.wordpress.com/1487/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amca01.wordpress.com/1487/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amca01.wordpress.com/1487/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amca01.wordpress.com/1487/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amca01.wordpress.com/1487/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amca01.wordpress.com/1487/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amca01.wordpress.com/1487/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amca01.wordpress.com/1487/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amca01.wordpress.com/1487/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amca01.wordpress.com/1487/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amca01.wordpress.com/1487/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amca01.wordpress.com/1487/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amca01.wordpress.com/1487/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amca01.wordpress.com/1487/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&amp;blog=3321115&amp;post=1487&amp;subd=amca01&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amca01.wordpress.com/2011/09/20/ruth-aaron-pairs/feed/</wfw:commentRss>
		<slash:comments>1</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 best Matlab alternative</title>
		<link>http://amca01.wordpress.com/2011/08/31/the-best-matlab-alternative/</link>
		<comments>http://amca01.wordpress.com/2011/08/31/the-best-matlab-alternative/#comments</comments>
		<pubDate>Tue, 30 Aug 2011 13:18:49 +0000</pubDate>
		<dc:creator>amca01</dc:creator>
				<category><![CDATA[Computation]]></category>
		<category><![CDATA[Maths teaching]]></category>

		<guid isPermaLink="false">http://amca01.wordpress.com/?p=1471</guid>
		<description><![CDATA[Matlab is probably as close as you&#8217;ll find these days to an international standard for numerical computations. It seems to be taught at almost all universities in one form or another, is loved by engineers, and contains many thousands of lines of highly optimised code. And as well as the base package, there are lots [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&amp;blog=3321115&amp;post=1471&amp;subd=amca01&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.mathworks.com.au/products/matlab/index.html">Matlab</a> is probably as close as you&#8217;ll find these days to an international standard for numerical computations. It seems to be taught at almost all universities in one form or another, is loved by engineers, and contains many thousands of lines of highly optimised code. And as well as the base package, there are lots of toolboxes: add-ons which provide functionality in particular areas: <a href="http://www.mathworks.com.au/products/image/">image processing</a>, <a href="http://www.mathworks.com.au/products/daq/">data acquisition</a>, <a href="http://www.mathworks.com.au/products/curvefitting/">curve fitting</a> and <a href="http://www.mathworks.com.au/products/index.html">lots more</a>.</p>
<p>Matlab&#8217;s interface, general ease of use, power, and extensibility have made it deservedly popular, and it has spawned a vast publishing industry.</p>
<p>As a teaching tool, though, it suffers from one major defect: it&#8217;s <em>very</em> expensive. And the add-on toolboxes add to its cost.</p>
<p>There&#8217;s therefore the need of a low-cost &#8211; preferably open-source &#8211; alternative, which can be used by students as a sort of drop-in replacement for experimentation at home, or on their own laptops.</p>
<p>Here is my list of requirements for such an alternative:</p>
<ol>
<li>It must install under Windows. This is absolutely necessary for me, at least, since most of my students use Windows. A very few use OSX, and hardly any use Linux.</li>
<li>It must, as far as possible, be identical in use with Matlab. The commands should be the same, and simple scripts and functions should transfer between the two with no effort.</li>
<li>It should have a reasonably nice interface, as similar as possible to Matlab&#8217;s own. A basic command line only interface running in a terminal won&#8217;t cut it with my students.</li>
</ol>
<p>Note that I&#8217;m personally satisfied with a lot less. I have, for example, no problems with a terminal text-based interface and in fact do most of my own computing from just such. However, I&#8217;m interested in making things as easy as possible for my own students, many of whom are not hugely computer-savvy.</p>
<p><strong>The alternatives</strong></p>
<p>There are three alternatives: <a href="http://www.gnu.org/software/octave/">Octave</a>, <a href="http://freemat.sourceforge.net/">Freemat</a>, and <a href="http://www.scilab.org/">Scilab</a>. A little bit about each one.</p>
<p><strong>Octave</strong> (more properly GNU Octave) has been around since about 1998, or 1992, depending on how you measure it, and was conceived and initially developed by John Eaton at the University of Wisconsin–Madison to support a course in chemical reactor design. It&#8217;s named after one of Eaton&#8217;s professors, Octave Levenspiel, who apparently had a genius at &#8220;back of envelope&#8221; calculations. Anyway, you can read about it on its <a href="http://en.wikipedia.org/wiki/GNU_Octave">wikipedia page</a>. As of now, it is up to version 3.2.4, and is a highly mature product, with an emphasis on Matlab compatibility, and supported by an army of users and developers. There are also many add-on <a href="http://octave.sourceforge.net/packages.php">packages</a>.</p>
<p><strong>Freemat</strong> has been in development since about 2004, mainly by one person, Samit Basu, with help from some others. It seems to have sprung into life very quickly. I can&#8217;t find anything online about its history or provenance, but my guess is that it&#8217;s a fork or the continuation of some older project. It exists in forms for windows, Linux and MacOS, and has the most Matlab-like interface of all of them. It has a small <a href="http://en.wikipedia.org/wiki/FreeMat">wikipedia page</a>.</p>
<p><strong>Scilab</strong> is in some ways the worthiest alternative to Matlab, in terms of raw power, development (mostly at <a href="http://en.wikipedia.org/wiki/Inria">INRIA,</a> France), and add-on packages. It also has installers for Windows, MacOS and Linux.</p>
<p>There are of course several good comparisons of these software tools, of which &#8220;A Comparative Evaluation of Matlab, Octave, Freemat, and Scilab for Research and Teaching&#8221; by Neeraj Sharma and Matthias K. Gobbert from the University of Maryland is probably the most far reaching. You can read it <a href="http://userpages.umbc.edu/~gobbert/papers/SharmaGobbertTR2010.pdf">here</a>. They don&#8217;t make any conclusions as such, but one or two comments are made, such as</p>
<p style="padding-left:30px;">&#8220;The syntax of Octave and FreeMat is identical to that of Matlab in our tests. However, we found during our tests that FreeMat lacks a number of functions, such as <tt>kron</tt> for Kronecker products, <tt>pcg</tt> for the conjugate gradient method, and <tt>mesh</tt> for three-dimensional plotting. Otherwise, FreeMat is very much compatible with Matlab. Even though Scilab is designed for Matlab users to smoothly utilize the package and has a m-file translator, it often still requires manual conversions.
<p style="padding-left:30px;">The tests in this work lead us to conclude that the packages Octave and FreeMat are most compatible with Matlab, since they use the same syntax and have the native capability of running m-files. Among these two packages, Octave is a significantly more mature software and has significantly more functions available for use.&#8221;</p>
<p>For numerical solutions of differential equations, the authors state:</p>
<p style="padding-left:30px;">&#8220;Matlab, Octave, and Scilab have state-of-the-art variable-order, variable-timestep methods for both non-stiff and stiff ODEs available, with Matlab’s implementation being the richest and its stiff solvers being possibly more efficient. FreeMat is clearly significantly weaker than the other packages in that it does not provide a state-of-the-art ODE solver, particularly not for stiff problems.&#8221;</p>
<p>Another nice comparison (with lots of screenshots) is at <a href="http://www.dedoimedo.com">http://www.dedoimedo.com</a>, and is a 2010 discussion on <a href="http://www.dedoimedo.com/computers/scientific-new.html">scientific computing</a>.  Here&#8217;s the conclusion, to save you the trouble of actually opening a web page yourself:</p>
<p style="padding-left:30px;">&#8220;All three programs have their merits. For Windows users, the simplest choice is FreeMat, while Octave is the most powerful and best run on Linux. Scilab works better on Windows, but it is not fully compatible with Matlab language and requires more effort to master, while leveraging these disadvantages with the fleet of toolboxes and Scicos.</p>
<p style="padding-left:30px;">The best thing is, you can use them all together. But if you want to be picky, then I&#8217;d recommend you start with FreeMat and Octave and move on to Scilab when you gain enough expertise. &#8220;</p>
<p><strong>Some more comments</strong></p>
<p>Freemat seems to be suffering a lack of development, as this chart from <a href="http://www.ohloh.net/">ohloh.net</a> shows:</p>
<p><a href="http://amca01.files.wordpress.com/2011/08/freemat_ohloh.png"><img src="http://amca01.files.wordpress.com/2011/08/freemat_ohloh.png?w=468&#038;h=332" alt="" title="freemat_ohloh" width="468" height="332" class="aligncenter size-full wp-image-1476" /></a></p>
<p>Its current version &#8211; 4.0 &#8211; while very nice in many ways, has been static now for nearly two years.  Interestingly enough, if you enter &#8220;help hist&#8221; at the Freemat prompt, you are told that this file was &#8220;adopted&#8221; in Freemat from Octave.  This begs the question: how much of Octave has been ported into Freemat?  Another problem with Freemat is a seeming low number of users; it simply does not have the large user base of Octave or Scilab.</p>
<p>If compatibility with Matlab was not a concern, then Scilab would be the tool of choice.  As well, Scilab comes with <a href="http://www.scicos.org/">Scicos</a>, a dynamic systems modeller similar in style to Matlab&#8217;s <a href="http://www.mathworks.com/products/simulink/index.html">Simulink</a>.  Neither of the other two systems has such functionality.  However, Scilab is different enough from Matlab to make conversions between the two (especially of functions and programs) not entirely trivial.  There is a conversion program, but like most other conversion programs, it&#8217;s a bit hit or miss.  Differences between Matlab and Scilab are given <a href="http://www.infoclearinghouse.com/files/scilab19.pdf">here</a>.  One thing which always annoyed me in Scilab was that the <tt>whos</tt> command (which in the other systems gives a list of the user&#8217;s variables, with types and sizes), here gives the list of <em>all</em> variables, including built in ones such as <tt>%pi</tt> and <tt>%i</tt>.</p>
<p>Octave does not come with any nice interface.  However, several third-party interfaces are being produced, of which the most promising for Windows users is <a href="http://sites.google.com/site/guioctave/">GUI Octave</a>.   Another fine looking interface is that provided by <a href="http://xoctave.webs.com">Xoctave</a>, which at the moment does not seem to be as mature a product as GUI Octave.</p>
<p><strong>Conclusion</strong></p>
<p>Given all the above, my choice is clear: Octave with GUI Octave ticks all the boxes.  Almost everything you can do with Matlab can be done in Octave.  In fact I use Octave almost exclusively: for various reasons I can&#8217;t have Matlab installed on my office computer at work, so all my &#8220;Matlab preparation&#8221; is in fact done with Octave.  This is the system which I&#8217;m recommending to my students.  Try it yourself!  You may be pleasantly surprised.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amca01.wordpress.com/1471/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amca01.wordpress.com/1471/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amca01.wordpress.com/1471/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amca01.wordpress.com/1471/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amca01.wordpress.com/1471/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amca01.wordpress.com/1471/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amca01.wordpress.com/1471/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amca01.wordpress.com/1471/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amca01.wordpress.com/1471/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amca01.wordpress.com/1471/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amca01.wordpress.com/1471/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amca01.wordpress.com/1471/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amca01.wordpress.com/1471/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amca01.wordpress.com/1471/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&amp;blog=3321115&amp;post=1471&amp;subd=amca01&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amca01.wordpress.com/2011/08/31/the-best-matlab-alternative/feed/</wfw:commentRss>
		<slash:comments>7</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/2011/08/freemat_ohloh.png" medium="image">
			<media:title type="html">freemat_ohloh</media:title>
		</media:content>
	</item>
		<item>
		<title>Interlaced eigenvalues</title>
		<link>http://amca01.wordpress.com/2011/08/22/interlaced-eigenvalues/</link>
		<comments>http://amca01.wordpress.com/2011/08/22/interlaced-eigenvalues/#comments</comments>
		<pubDate>Mon, 22 Aug 2011 12:17:03 +0000</pubDate>
		<dc:creator>amca01</dc:creator>
				<category><![CDATA[Computation]]></category>

		<guid isPermaLink="false">http://amca01.wordpress.com/?p=1454</guid>
		<description><![CDATA[An engineering colleague asked me recently to investigate the relationship between the eigenvalues of a matrix and the eigenvalues of its principal submatrices. This is not an area I know much about, so I started off doing a web search. And I learned about a remarkable fact which goes back to Cauchy: Suppose is an [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&amp;blog=3321115&amp;post=1454&amp;subd=amca01&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>An engineering colleague asked me recently to investigate the relationship between the eigenvalues of a matrix and the eigenvalues of its principal submatrices. This is not an area I know much about, so I started off doing a web search. And I learned about a remarkable fact which goes back to Cauchy:</p>
<p style="padding-left:30px;">Suppose <img src='http://s0.wp.com/latex.php?latex=A&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='A' title='A' class='latex' /> is an <img src='http://s0.wp.com/latex.php?latex=n%5Ctimes+n&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='n&#92;times n' title='n&#92;times n' class='latex' /> Hermitian matrix, with eigenvalues</p>
<p style="padding-left:30px;"><img src='http://s0.wp.com/latex.php?latex=%5Clambda_1%5Cle%5Clambda_2%5Cle%5Clambda_3%5Cle%5Ccdots%5Cle%5Clambda_n&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;lambda_1&#92;le&#92;lambda_2&#92;le&#92;lambda_3&#92;le&#92;cdots&#92;le&#92;lambda_n' title='&#92;lambda_1&#92;le&#92;lambda_2&#92;le&#92;lambda_3&#92;le&#92;cdots&#92;le&#92;lambda_n' class='latex' /></p>
<p style="padding-left:30px;">and suppose that <img src='http://s0.wp.com/latex.php?latex=B&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='B' title='B' class='latex' /> is obtained from <img src='http://s0.wp.com/latex.php?latex=A&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='A' title='A' class='latex' /> by removing row and column <img src='http://s0.wp.com/latex.php?latex=i&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='i' title='i' class='latex' /> for some <img src='http://s0.wp.com/latex.php?latex=1%5Cle+i%5Cle+n&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='1&#92;le i&#92;le n' title='1&#92;le i&#92;le n' class='latex' />. Then the eigenvalues of <img src='http://s0.wp.com/latex.php?latex=B&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='B' title='B' class='latex' /></p>
<p style="padding-left:30px;"><img src='http://s0.wp.com/latex.php?latex=%5Cmu_1%5Cle%5Cmu_2%5Cle%5Cmu_3%5Cle%5Ccdots%5Cle%5Cmu_%7Bn-1%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;mu_1&#92;le&#92;mu_2&#92;le&#92;mu_3&#92;le&#92;cdots&#92;le&#92;mu_{n-1}' title='&#92;mu_1&#92;le&#92;mu_2&#92;le&#92;mu_3&#92;le&#92;cdots&#92;le&#92;mu_{n-1}' class='latex' /></p>
<p style="padding-left:30px;">satisfy the interlacing</p>
<p style="padding-left:30px;"><img src='http://s0.wp.com/latex.php?latex=%5Clambda_1%5Cle+%5Cmu_1%5Cle%5Clambda_2%5Cle+%5Cmu_2%5Cle%5Clambda_3%5Cle%5Cmu_3%5Cle%5Ccdots%5Cle%5Cmu_%7Bn-1%7D%5Cle%5Clambda_n&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;lambda_1&#92;le &#92;mu_1&#92;le&#92;lambda_2&#92;le &#92;mu_2&#92;le&#92;lambda_3&#92;le&#92;mu_3&#92;le&#92;cdots&#92;le&#92;mu_{n-1}&#92;le&#92;lambda_n' title='&#92;lambda_1&#92;le &#92;mu_1&#92;le&#92;lambda_2&#92;le &#92;mu_2&#92;le&#92;lambda_3&#92;le&#92;mu_3&#92;le&#92;cdots&#92;le&#92;mu_{n-1}&#92;le&#92;lambda_n' class='latex' />.</p>
<p>The shortest proof of this result is due to the late <a href="http://orient.bowdoin.edu/orient/article.php?date=2010-02-05&amp;section=1&amp;id=3">Steve Fisk</a> of Bowdoin College, who is probably best known in the wider mathematical world for his &#8220;proof from the book&#8221; of <a href="http://en.wikipedia.org/wiki/Art_gallery_problem">Chvátal&#8217;s art gallery theorem</a>. His proof (of Cauchy&#8217;s interlacing theorem, not the art gallery theorem) can be found <a href="http://arxiv.org/pdf/math/0502408">here</a>. Fisk&#8217;s proof, as you can see, is based on a result of Hermite, which claims that the roots of two polynomials <img src='http://s0.wp.com/latex.php?latex=f&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='f' title='f' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=g&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='g' title='g' class='latex' /> interlace if and only if all the roots of <img src='http://s0.wp.com/latex.php?latex=f%2B%5Calpha+g&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='f+&#92;alpha g' title='f+&#92;alpha g' class='latex' /> are real, for all <img src='http://s0.wp.com/latex.php?latex=%5Calpha%5Cin%5Cmathbb%7BR%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;alpha&#92;in&#92;mathbb{R}' title='&#92;alpha&#92;in&#92;mathbb{R}' class='latex' />. For a complete proof of this result, from which the eigenvalues result is deduced as a corollary, see Fisk&#8217;s &#8220;<a href="http://arxiv.org/pdf/math/0612833">Polynomials, roots, and interlacing</a>&#8220;.</p>
<p>Another proof uses the min-max theorem, of which a full account is given by <a href="http://terrytao.wordpress.com/2010/01/12/254a-notes-3a-eigenvalues-and-sums-of-hermitian-matrices/">Terry Tao</a>.</p>
<p><strong>A little experiment</strong></p>
<p>We shall use <a href="http://www.mathworks.com/products/matlab/">Matlab</a>/<a href="http://www.gnu.org/software/octave/">Octave</a> here, and instead of general Hermitian matrices we shall restrict ourselves to real symmetric matrices.</p>
<p>If <img src='http://s0.wp.com/latex.php?latex=D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='D' title='D' class='latex' /> is a diagonal matrix, then its entries will be its eigenvalues, and if <img src='http://s0.wp.com/latex.php?latex=Q&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='Q' title='Q' class='latex' /> is an orthogonal matrix of the same size as <img src='http://s0.wp.com/latex.php?latex=D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='D' title='D' class='latex' /> then</p>
<p><img src='http://s0.wp.com/latex.php?latex=QDQ%5ET&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='QDQ^T' title='QDQ^T' class='latex' /></p>
<p>will be a symmetric matrix with the same eigenvalues as <img src='http://s0.wp.com/latex.php?latex=D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='D' title='D' class='latex' />. We can construct an orthogonal matrix using this result of <a href="http://en.wikipedia.org/wiki/Arthur_Cayley">Cayley</a>: if <img src='http://s0.wp.com/latex.php?latex=S&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='S' title='S' class='latex' /> is a skew-symmetric matrix, then</p>
<p><img src='http://s0.wp.com/latex.php?latex=%28S-I%29%5E%7B-1%7D%28S%2BI%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='(S-I)^{-1}(S+I)' title='(S-I)^{-1}(S+I)' class='latex' /></p>
<p>is orthogonal. The proof requires some elementary matrix algebra; see <a href="http://planetmath.org/encyclopedia/CayleyTransform.html">here</a>.  Here&#8217;s the experiment:</p>
<p><pre class="brush: matlabkey; light: true;">
&gt;&gt; n = 4;
&gt;&gt; D = diag(1:n);
&gt;&gt; R = rand(n);
&gt;&gt; S = R - R';
&gt;&gt; Q = inv(S-eye(n))*(S+eye(n));
&gt;&gt; M = Q*D*Q'
M =

   2.1146941  -0.8411071  -0.5795664   0.1635006
  -0.8411071   3.0320881  -0.7959547  -0.7357826
  -0.5795664  -0.7959547   2.6104766  -0.0025486
   0.1635006  -0.7357826  -0.0025486   2.2427411

&gt;&gt; sort(eig(full(M))')
ans =

   1.0000   2.0000   3.0000   4.0000

&gt;&gt; i = ceil(n*rand);
&gt;&gt; N = M; N(i,:)=[]; N(:,i)=[];
&gt;&gt; sort(eig(full(N))')
ans =

   1.5021   2.0328   3.8546
</pre></p>
<p>Note that each eigenvalue of <img src='http://s0.wp.com/latex.php?latex=N&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N' title='N' class='latex' /> is between two consecutive eigenvalues of <img src='http://s0.wp.com/latex.php?latex=M&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='M' title='M' class='latex' />.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amca01.wordpress.com/1454/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amca01.wordpress.com/1454/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amca01.wordpress.com/1454/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amca01.wordpress.com/1454/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amca01.wordpress.com/1454/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amca01.wordpress.com/1454/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amca01.wordpress.com/1454/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amca01.wordpress.com/1454/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amca01.wordpress.com/1454/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amca01.wordpress.com/1454/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amca01.wordpress.com/1454/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amca01.wordpress.com/1454/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amca01.wordpress.com/1454/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amca01.wordpress.com/1454/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&amp;blog=3321115&amp;post=1454&amp;subd=amca01&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amca01.wordpress.com/2011/08/22/interlaced-eigenvalues/feed/</wfw:commentRss>
		<slash:comments>1</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 tangent identity</title>
		<link>http://amca01.wordpress.com/2011/07/18/a-tangent-identity/</link>
		<comments>http://amca01.wordpress.com/2011/07/18/a-tangent-identity/#comments</comments>
		<pubDate>Mon, 18 Jul 2011 03:59:54 +0000</pubDate>
		<dc:creator>amca01</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://amca01.wordpress.com/?p=1434</guid>
		<description><![CDATA[We all know that the Chebyshev polynomials of the first kind can be defined as When I was fiddling about with identities associated with Machin&#8217;s formula I came across an identity for tangents, which I&#8217;m sure is well known, but which I&#8217;d never seen before. Here it is: This can be more precisely written as [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&amp;blog=3321115&amp;post=1434&amp;subd=amca01&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>We all know that the <a href="http://en.wikipedia.org/wiki/Chebyshev_polynomials">Chebyshev polynomials of the first kind</a> can be defined as</p>
<p><img src='http://s0.wp.com/latex.php?latex=T_n%28x%29%3D%5Ccos%28n%5Ccos%5E%7B-1%7Dx%29.&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='T_n(x)=&#92;cos(n&#92;cos^{-1}x).' title='T_n(x)=&#92;cos(n&#92;cos^{-1}x).' class='latex' /></p>
<p>When I was fiddling about with identities associated with <a href="http://amca01.wordpress.com/2011/06/14/machins-formula/">Machin&#8217;s formula</a> I came across an identity for tangents, which I&#8217;m sure is well known, but which I&#8217;d never seen before.  Here it is:</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7B%5Ctan%28n%5Ctan%5E%7B-1%7Dx%29%3D%5Cfrac%7B%5Cdisplaystyle%7B%7Bn%5Cchoose+1%7Dx-%7Bn%5Cchoose+3%7Dx%5E3%2B%7Bn%5Cchoose+5%7Dx%5E5-%5Ccdots%7D%7D%7B%5Cdisplaystyle%7B%7Bn%5Cchoose+0%7D-%7Bn%5Cchoose+2%7Dx%5E2%2B%7Bn%5Cchoose+4%7Dx%5E4-%5Ccdots%7D%7D%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{&#92;tan(n&#92;tan^{-1}x)=&#92;frac{&#92;displaystyle{{n&#92;choose 1}x-{n&#92;choose 3}x^3+{n&#92;choose 5}x^5-&#92;cdots}}{&#92;displaystyle{{n&#92;choose 0}-{n&#92;choose 2}x^2+{n&#92;choose 4}x^4-&#92;cdots}}}' title='&#92;displaystyle{&#92;tan(n&#92;tan^{-1}x)=&#92;frac{&#92;displaystyle{{n&#92;choose 1}x-{n&#92;choose 3}x^3+{n&#92;choose 5}x^5-&#92;cdots}}{&#92;displaystyle{{n&#92;choose 0}-{n&#92;choose 2}x^2+{n&#92;choose 4}x^4-&#92;cdots}}}' class='latex' /></p>
<p>This can be more precisely written as follows:</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7B%5Ctan%282k%5Ctan%5E%7B-1%7Dx%29%3D%5Cfrac%7B%5Cdisplaystyle%7B%5Csum_%7Bi%3D0%7D%5E%7Bk-1%7D%28-1%29%5Ei%7B2k%5Cchoose+2i%2B1%7Dx%5E%7B2i%2B1%7D%7D%7D%7B%5Cdisplaystyle%7B%5Csum_%7Bi%3D0%7D%5Ek%28-1%29%5Ei%7B2k%5Cchoose+2i%7Dx%5E%7B2i%7D%7D%7D%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{&#92;tan(2k&#92;tan^{-1}x)=&#92;frac{&#92;displaystyle{&#92;sum_{i=0}^{k-1}(-1)^i{2k&#92;choose 2i+1}x^{2i+1}}}{&#92;displaystyle{&#92;sum_{i=0}^k(-1)^i{2k&#92;choose 2i}x^{2i}}}}' title='&#92;displaystyle{&#92;tan(2k&#92;tan^{-1}x)=&#92;frac{&#92;displaystyle{&#92;sum_{i=0}^{k-1}(-1)^i{2k&#92;choose 2i+1}x^{2i+1}}}{&#92;displaystyle{&#92;sum_{i=0}^k(-1)^i{2k&#92;choose 2i}x^{2i}}}}' class='latex' /></p>
<p>and</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7B%5Ctan%28%282k%2B1%29%5Ctan%5E%7B-1%7Dx%29%3D%5Cfrac%7B%5Cdisplaystyle%7B%5Csum_%7Bi%3D0%7D%5Ek%28-1%29%5Ei%7B2k%2B1%5Cchoose+2i%2B1%7Dx%5E%7B2i%2B1%7D%7D%7D%7B%5Cdisplaystyle%7B%5Csum_%7Bi%3D0%7D%5Ek%28-1%29%5Ei%7B2k%2B1%5Cchoose+2i%7Dx%5E%7B2i%7D%7D%7D%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{&#92;tan((2k+1)&#92;tan^{-1}x)=&#92;frac{&#92;displaystyle{&#92;sum_{i=0}^k(-1)^i{2k+1&#92;choose 2i+1}x^{2i+1}}}{&#92;displaystyle{&#92;sum_{i=0}^k(-1)^i{2k+1&#92;choose 2i}x^{2i}}}}' title='&#92;displaystyle{&#92;tan((2k+1)&#92;tan^{-1}x)=&#92;frac{&#92;displaystyle{&#92;sum_{i=0}^k(-1)^i{2k+1&#92;choose 2i+1}x^{2i+1}}}{&#92;displaystyle{&#92;sum_{i=0}^k(-1)^i{2k+1&#92;choose 2i}x^{2i}}}}' class='latex' /></p>
<p>And these two identities can be shoehorned into one ugly (but general!) expression:</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7B%5Ctan%28n%5Ctan%5E%7B-1%7Dx%29%3D%5Cfrac%7B%5Cdisplaystyle%7B%5Csum_%7Bi%3D0%7D%5E%7B%5Clfloor+%28n-1%29%2F2%5Crfloor%7D%28-1%29%5Ei%7Bn%5Cchoose+2i%2B1%7Dx%5E%7B2i%2B1%7D%7D%7D%7B%5Cdisplaystyle%7B%5Csum_%7Bi%3D0%7D%5E%7B%5Clfloor+n%2F2+%5Crfloor%7D%28-1%29%5Ei%7Bn%5Cchoose+2i%7Dx%5E%7B2i%7D%7D%7D%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{&#92;tan(n&#92;tan^{-1}x)=&#92;frac{&#92;displaystyle{&#92;sum_{i=0}^{&#92;lfloor (n-1)/2&#92;rfloor}(-1)^i{n&#92;choose 2i+1}x^{2i+1}}}{&#92;displaystyle{&#92;sum_{i=0}^{&#92;lfloor n/2 &#92;rfloor}(-1)^i{n&#92;choose 2i}x^{2i}}}}' title='&#92;displaystyle{&#92;tan(n&#92;tan^{-1}x)=&#92;frac{&#92;displaystyle{&#92;sum_{i=0}^{&#92;lfloor (n-1)/2&#92;rfloor}(-1)^i{n&#92;choose 2i+1}x^{2i+1}}}{&#92;displaystyle{&#92;sum_{i=0}^{&#92;lfloor n/2 &#92;rfloor}(-1)^i{n&#92;choose 2i}x^{2i}}}}' class='latex' /></p>
<p>The identity is not hard to prove by induction.  As <img src='http://s0.wp.com/latex.php?latex=T&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='T' title='T' class='latex' /> is already used for the Chebyshev polynomials, we shall write <img src='http://s0.wp.com/latex.php?latex=G_k%28x%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='G_k(x)' title='G_k(x)' class='latex' /> for <img src='http://s0.wp.com/latex.php?latex=%5Ctan%28k%5Ctan%5E%7B-1%7Dx%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;tan(k&#92;tan^{-1}x)' title='&#92;tan(k&#92;tan^{-1}x)' class='latex' /> and then write</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7BG_k%28x%29%3D%5Cfrac%7BN_k%28x%29%7D%7BD_k%28x%29%7D%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{G_k(x)=&#92;frac{N_k(x)}{D_k(x)}}' title='&#92;displaystyle{G_k(x)=&#92;frac{N_k(x)}{D_k(x)}}' class='latex' /></p>
<p>(where <img src='http://s0.wp.com/latex.php?latex=N%2CD&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N,D' title='N,D' class='latex' /> stands for numerator and denominator respectively.)  Then by the addition formula for <img src='http://s0.wp.com/latex.php?latex=%5Ctan%28x%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;tan(x)' title='&#92;tan(x)' class='latex' />, we have</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7BG_%7Bk%2B1%7D%28x%29%3D%5Cfrac%7Bx%2BG_k%28x%29%7D%7B1-xG_k%28x%29%7D%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{G_{k+1}(x)=&#92;frac{x+G_k(x)}{1-xG_k(x)}}' title='&#92;displaystyle{G_{k+1}(x)=&#92;frac{x+G_k(x)}{1-xG_k(x)}}' class='latex' />.</p>
<p>Writing <img src='http://s0.wp.com/latex.php?latex=G_k&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='G_k' title='G_k' class='latex' /> on the right in terms of <img src='http://s0.wp.com/latex.php?latex=N_k&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='N_k' title='N_k' class='latex' /> and <img src='http://s0.wp.com/latex.php?latex=D_k&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='D_k' title='D_k' class='latex' />, and then multiplying through by <img src='http://s0.wp.com/latex.php?latex=D_k&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='D_k' title='D_k' class='latex' /> produces</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7BG_%7Bk%2B1%7D%28x%29%3D%5Cfrac%7BxD_k%28x%29%2BN_k%28x%29%7D%7BD_k%28x%29-xN_k%28x%29%7D%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{G_{k+1}(x)=&#92;frac{xD_k(x)+N_k(x)}{D_k(x)-xN_k(x)}}' title='&#92;displaystyle{G_{k+1}(x)=&#92;frac{xD_k(x)+N_k(x)}{D_k(x)-xN_k(x)}}' class='latex' />.</p>
<p>Recall that</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7BN_k%28x%29%3D%7Bk%5Cchoose+1%7Dx-%7Bk%5Cchoose+3%7Dx%5E3%2B%7Bk%5Cchoose+5%7Dx%5E5-%5Ccdots%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{N_k(x)={k&#92;choose 1}x-{k&#92;choose 3}x^3+{k&#92;choose 5}x^5-&#92;cdots}' title='&#92;displaystyle{N_k(x)={k&#92;choose 1}x-{k&#92;choose 3}x^3+{k&#92;choose 5}x^5-&#92;cdots}' class='latex' /></p>
<p>and</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7BD_k%28x%29%3D%7Bk%5Cchoose+0%7D-%7Bk%5Cchoose+2%7Dx%5E2%2B%7Bk%5Cchoose+4%7Dx%5E4-%5Ccdots%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{D_k(x)={k&#92;choose 0}-{k&#92;choose 2}x^2+{k&#92;choose 4}x^4-&#92;cdots}' title='&#92;displaystyle{D_k(x)={k&#92;choose 0}-{k&#92;choose 2}x^2+{k&#92;choose 4}x^4-&#92;cdots}' class='latex' /></p>
<p>Now consider the the numerator of <img src='http://s0.wp.com/latex.php?latex=G_%7Bk%2B1%7D%28x%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='G_{k+1}(x)' title='G_{k+1}(x)' class='latex' />:</p>
<p><img src='http://s0.wp.com/latex.php?latex=xD_k%28x%29%2BN_k%28x%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='xD_k(x)+N_k(x)' title='xD_k(x)+N_k(x)' class='latex' />.</p>
<p>The coefficient of <img src='http://s0.wp.com/latex.php?latex=x%5E%7B2i%2B1%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x^{2i+1}' title='x^{2i+1}' class='latex' /> will be</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7B%28-1%29%5Ei%7Bk%5Cchoose+2i%7D%2B%28-1%29%5Ei%7Bk%5Cchoose+2i%2B1%7D%3D%28-1%29%5Ei%7Bk%2B1%5Cchoose+2i%2B1%7D%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{(-1)^i{k&#92;choose 2i}+(-1)^i{k&#92;choose 2i+1}=(-1)^i{k+1&#92;choose 2i+1}}' title='&#92;displaystyle{(-1)^i{k&#92;choose 2i}+(-1)^i{k&#92;choose 2i+1}=(-1)^i{k+1&#92;choose 2i+1}}' class='latex' />.</p>
<p>The denominator of <img src='http://s0.wp.com/latex.php?latex=G_%7Bk%2B1%7D%28x%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='G_{k+1}(x)' title='G_{k+1}(x)' class='latex' /> is</p>
<p><img src='http://s0.wp.com/latex.php?latex=D_k%28x%29-xN_k%28x%29&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='D_k(x)-xN_k(x)' title='D_k(x)-xN_k(x)' class='latex' /></p>
<p>and the coefficient of <img src='http://s0.wp.com/latex.php?latex=x%5E%7B2i%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='x^{2i}' title='x^{2i}' class='latex' /> will be</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7B%28-1%29%5Ei%7Bk%5Cchoose+2i%7D%2B%28-1%29%5Ei%7Bk%5Cchoose+2i-1%7D%3D%28-1%29%5Ei%7Bk%2B1%5Cchoose+2i%7D%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{(-1)^i{k&#92;choose 2i}+(-1)^i{k&#92;choose 2i-1}=(-1)^i{k+1&#92;choose 2i}}' title='&#92;displaystyle{(-1)^i{k&#92;choose 2i}+(-1)^i{k&#92;choose 2i-1}=(-1)^i{k+1&#92;choose 2i}}' class='latex' />.</p>
<p>Note that the constant coefficient is</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7B%7Bk%5Cchoose+0%7D%3D%7Bk%2B1%5Cchoose+0%7D%7D.&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{{k&#92;choose 0}={k+1&#92;choose 0}}.' title='&#92;displaystyle{{k&#92;choose 0}={k+1&#92;choose 0}}.' class='latex' /></p>
<p>These results, plus the trivial result for <img src='http://s0.wp.com/latex.php?latex=k%3D1&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='k=1' title='k=1' class='latex' />, prove the identity.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amca01.wordpress.com/1434/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amca01.wordpress.com/1434/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amca01.wordpress.com/1434/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amca01.wordpress.com/1434/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amca01.wordpress.com/1434/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amca01.wordpress.com/1434/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amca01.wordpress.com/1434/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amca01.wordpress.com/1434/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amca01.wordpress.com/1434/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amca01.wordpress.com/1434/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amca01.wordpress.com/1434/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amca01.wordpress.com/1434/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amca01.wordpress.com/1434/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amca01.wordpress.com/1434/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&amp;blog=3321115&amp;post=1434&amp;subd=amca01&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amca01.wordpress.com/2011/07/18/a-tangent-identity/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>Machin&#8217;s formula</title>
		<link>http://amca01.wordpress.com/2011/06/14/machins-formula/</link>
		<comments>http://amca01.wordpress.com/2011/06/14/machins-formula/#comments</comments>
		<pubDate>Tue, 14 Jun 2011 07:35:00 +0000</pubDate>
		<dc:creator>amca01</dc:creator>
				<category><![CDATA[Computation]]></category>
		<category><![CDATA[Maths teaching]]></category>

		<guid isPermaLink="false">http://amca01.wordpress.com/?p=1391</guid>
		<description><![CDATA[I suppose everybody will have come across Machin&#8217;s formula: or in its cotangent form: . This formula was used by Machin to calculate to 100 decimal places: an impressive feat of hand computation. According to this excellent article on the history of the formula, Machin started by first observing that and so that should be [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&amp;blog=3321115&amp;post=1391&amp;subd=amca01&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I suppose everybody will have come across Machin&#8217;s formula:</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7B4%5Ctan%5E%7B-1%7D%5Cleft%28%5Cfrac%7B1%7D%7B5%7D%5Cright%29-%5Ctan%5E%7B-1%7D%5Cleft%28%5Cfrac%7B1%7D%7B239%7D%5Cright%29%3D%5Cfrac%7B%5Cpi%7D%7B4%7D%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{4&#92;tan^{-1}&#92;left(&#92;frac{1}{5}&#92;right)-&#92;tan^{-1}&#92;left(&#92;frac{1}{239}&#92;right)=&#92;frac{&#92;pi}{4}}' title='&#92;displaystyle{4&#92;tan^{-1}&#92;left(&#92;frac{1}{5}&#92;right)-&#92;tan^{-1}&#92;left(&#92;frac{1}{239}&#92;right)=&#92;frac{&#92;pi}{4}}' class='latex' /></p>
<p>or in its cotangent form:</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7B4%5Ccot%5E%7B-1%7D5-%5Ccot%5E%7B-1%7D239%3D%5Cfrac%7B%5Cpi%7D%7B4%7D%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{4&#92;cot^{-1}5-&#92;cot^{-1}239=&#92;frac{&#92;pi}{4}}' title='&#92;displaystyle{4&#92;cot^{-1}5-&#92;cot^{-1}239=&#92;frac{&#92;pi}{4}}' class='latex' />.</p>
<p>This formula was used by Machin to calculate <img src='http://s0.wp.com/latex.php?latex=%5Cpi&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;pi' title='&#92;pi' class='latex' /> to 100 decimal places: an impressive feat of hand computation.</p>
<p>According to this <a href="http://www.math.usma.edu/people/rickey/talks/10-03-13-HPM-DC-Machin/10-03-13-HPM_DC_Machin.pdf">excellent article</a> on the history of the formula, Machin started by first observing that</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7B%5Ctan%5Cfrac%7B%5Cpi%7D%7B16%7D%5Capprox%5Cfrac%7B1%7D%7B5%7D%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{&#92;tan&#92;frac{&#92;pi}{16}&#92;approx&#92;frac{1}{5}}' title='&#92;displaystyle{&#92;tan&#92;frac{&#92;pi}{16}&#92;approx&#92;frac{1}{5}}' class='latex' /></p>
<p>and so that</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7B4%5Ctan%5E%7B-1%7D%5Cleft%28%5Cfrac%7B1%7D%7B5%7D%5Cright%29%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{4&#92;tan^{-1}&#92;left(&#92;frac{1}{5}&#92;right)}' title='&#92;displaystyle{4&#92;tan^{-1}&#92;left(&#92;frac{1}{5}&#92;right)}' class='latex' /></p>
<p>should be close to <img src='http://s0.wp.com/latex.php?latex=%5Cpi%2F4&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;pi/4' title='&#92;pi/4' class='latex' />.  In passing, it&#8217;s worth noting that <a href="http://www-history.mcs.st-and.ac.uk/Biographies/Machin.html">John Machin</a> (1680 &#8211; 1751) was far more than just a name attached to a single formula.  He was the Professor of Astronomy at Gresham College, London; supplied Newton with some Lunar material for the third edition of his <em>Principia</em>; and was considered by Newton to be the &#8220;best geometer&#8221;.</p>
<p>In fact it&#8217;s not hard to prove Machin&#8217;s formula directly.  Here&#8217;s a simple-minded approach using the cotangent version and the standard addition formula:</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cdisplaystyle%7B%5Ccot%28a%5Cpm+b%29%3D%5Cfrac%7B%5Ccot+a%5Ccot+b%5Cmp+1%7D%7B%5Ccot+b%5Cpm%5Ccot+a%7D%7D.&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;displaystyle{&#92;cot(a&#92;pm b)=&#92;frac{&#92;cot a&#92;cot b&#92;mp 1}{&#92;cot b&#92;pm&#92;cot a}}.' title='&#92;displaystyle{&#92;cot(a&#92;pm b)=&#92;frac{&#92;cot a&#92;cot b&#92;mp 1}{&#92;cot b&#92;pm&#92;cot a}}.' class='latex' /></p>
<p>What we&#8217;ll do is to take the cotangent of both sides:</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Ccot%284%5Ccot%5E%7B-1%7D5-%5Ccot%5E%7B-1%7D239%29%3D1&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;cot(4&#92;cot^{-1}5-&#92;cot^{-1}239)=1' title='&#92;cot(4&#92;cot^{-1}5-&#92;cot^{-1}239)=1' class='latex' /></p>
<p>and use the cotangent addition formula to expand the left hand side.</p>
<p>First note that if <img src='http://s0.wp.com/latex.php?latex=a%3Db%3D5&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='a=b=5' title='a=b=5' class='latex' /> then</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cbegin%7Barray%7D%7Bcrl%7D++%5Ccot%282%5Ccot%5E%7B-1%7D5%29%26%3D%26%5Cdisplaystyle%7B%5Cfrac%7B25-1%7D%7B10%7D%7D%5C%5C%5B4mm%5D++%26%3D%26%5Cdisplaystyle%7B%5Cfrac%7B12%7D%7B5%7D%7D.++%5Cend%7Barray%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;begin{array}{crl}  &#92;cot(2&#92;cot^{-1}5)&amp;=&amp;&#92;displaystyle{&#92;frac{25-1}{10}}&#92;&#92;[4mm]  &amp;=&amp;&#92;displaystyle{&#92;frac{12}{5}}.  &#92;end{array}' title='&#92;begin{array}{crl}  &#92;cot(2&#92;cot^{-1}5)&amp;=&amp;&#92;displaystyle{&#92;frac{25-1}{10}}&#92;&#92;[4mm]  &amp;=&amp;&#92;displaystyle{&#92;frac{12}{5}}.  &#92;end{array}' class='latex' /></p>
<p>Then it follows that</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cbegin%7Barray%7D%7Bcrl%7D++%5Ccot%284%5Ccot%5E%7B-1%7D5%29%26%3D%26%5Cdisplaystyle%7B%5Cfrac%7B%5Cdisplaystyle%7B%5Cfrac%7B144%7D%7B25%7D-1%7D%7D%7B%5Cdisplaystyle%7B%5Cfrac%7B24%7D%7B5%7D%7D%7D%7D%5C%5C%5B4mm%5D++%26%3D%26%5Cdisplaystyle%7B%5Cfrac%7B144-25%7D%7B120%7D%7D%5C%5C%5B4mm%5D++%26%3D%26%5Cdisplaystyle%7B%5Cfrac%7B119%7D%7B120%7D.%7D++%5Cend%7Barray%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;begin{array}{crl}  &#92;cot(4&#92;cot^{-1}5)&amp;=&amp;&#92;displaystyle{&#92;frac{&#92;displaystyle{&#92;frac{144}{25}-1}}{&#92;displaystyle{&#92;frac{24}{5}}}}&#92;&#92;[4mm]  &amp;=&amp;&#92;displaystyle{&#92;frac{144-25}{120}}&#92;&#92;[4mm]  &amp;=&amp;&#92;displaystyle{&#92;frac{119}{120}.}  &#92;end{array}' title='&#92;begin{array}{crl}  &#92;cot(4&#92;cot^{-1}5)&amp;=&amp;&#92;displaystyle{&#92;frac{&#92;displaystyle{&#92;frac{144}{25}-1}}{&#92;displaystyle{&#92;frac{24}{5}}}}&#92;&#92;[4mm]  &amp;=&amp;&#92;displaystyle{&#92;frac{144-25}{120}}&#92;&#92;[4mm]  &amp;=&amp;&#92;displaystyle{&#92;frac{119}{120}.}  &#92;end{array}' class='latex' /></p>
<p>Finally, applying the cotangent to the left hand side of Machin&#8217;s formula:</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5Cbegin%7Barray%7D%7Bcrl%7D++%5Ccot%284%5Ccot%5E%7B-1%7D5-%5Ccot%5E%7B-1%7D239%29%26%3D%26%5Cdisplaystyle%7B%5Cfrac%7B%5Cdisplaystyle%7B%5Cfrac%7B119%7D%7B120%7D239%2B1%7D%7D%7B%5Cdisplaystyle%7B239-%5Cfrac%7B119%7D%7B120%7D%7D%7D%7D%5C%5C%5B4mm%5D++%26%3D%26%5Cdisplaystyle%7B%5Cfrac%7B%28119%29%28239%29%2B120%7D%7B%28120%29%28239%29-119%7D%7D%5C%5C%5B4mm%5D++%26%3D%261.++%5Cend%7Barray%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;begin{array}{crl}  &#92;cot(4&#92;cot^{-1}5-&#92;cot^{-1}239)&amp;=&amp;&#92;displaystyle{&#92;frac{&#92;displaystyle{&#92;frac{119}{120}239+1}}{&#92;displaystyle{239-&#92;frac{119}{120}}}}&#92;&#92;[4mm]  &amp;=&amp;&#92;displaystyle{&#92;frac{(119)(239)+120}{(120)(239)-119}}&#92;&#92;[4mm]  &amp;=&amp;1.  &#92;end{array}' title='&#92;begin{array}{crl}  &#92;cot(4&#92;cot^{-1}5-&#92;cot^{-1}239)&amp;=&amp;&#92;displaystyle{&#92;frac{&#92;displaystyle{&#92;frac{119}{120}239+1}}{&#92;displaystyle{239-&#92;frac{119}{120}}}}&#92;&#92;[4mm]  &amp;=&amp;&#92;displaystyle{&#92;frac{(119)(239)+120}{(120)(239)-119}}&#92;&#92;[4mm]  &amp;=&amp;1.  &#92;end{array}' class='latex' /></p>
<p><strong>New formulas from old</strong></p>
<p>There are an infinite number of &#8220;Machin-type&#8221; formulas, consisting of linear combinations of cotangents of integers whose sum is <img src='http://s0.wp.com/latex.php?latex=%5Cpi%2F4&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;pi/4' title='&#92;pi/4' class='latex' />.  And up until recently they were the favorite method of computing <img src='http://s0.wp.com/latex.php?latex=%5Cpi&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;pi' title='&#92;pi' class='latex' /> to large numbers of digits.  (More recently, techniques based on the arithmetic-geometric men have been used.)</p>
<p>Using the useful notation <img src='http://s0.wp.com/latex.php?latex=%5C%7Bx%5C%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;{x&#92;}' title='&#92;{x&#92;}' class='latex' /> for <img src='http://s0.wp.com/latex.php?latex=%5Ccot%5E%7B-1%7D+x&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;cot^{-1} x' title='&#92;cot^{-1} x' class='latex' /> Machin&#8217;s formula can be written as</p>
<p><img src='http://s0.wp.com/latex.php?latex=4%5C%7B5%5C%7D-%5C%7B239%5C%7D%3D%5C%7B1%5C%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='4&#92;{5&#92;}-&#92;{239&#92;}=&#92;{1&#92;}' title='4&#92;{5&#92;}-&#92;{239&#92;}=&#92;{1&#92;}' class='latex' />.</p>
<p>Another formula, which is almost trivial and is attributed to Euler, is</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5C%7B2%5C%7D%2B%5C%7B3%5C%7D%3D%5C%7B1%5C%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;{2&#92;}+&#92;{3&#92;}=&#92;{1&#92;}' title='&#92;{2&#92;}+&#92;{3&#92;}=&#92;{1&#92;}' class='latex' />.</p>
<p>To form new formulas from old, the following general result has been attributed to the ever-surprising <a href="http://en.wikipedia.org/wiki/Lewis_Carroll">Charles Lutwidge Dodgson</a>:</p>
<p><img src='http://s0.wp.com/latex.php?latex=%5C%7Bx%2B%5Calpha%5C%7D%2B%5C%7Bx%2B%5Cbeta%5C%7D%3D%5C%7Bx%5C%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;{x+&#92;alpha&#92;}+&#92;{x+&#92;beta&#92;}=&#92;{x&#92;}' title='&#92;{x+&#92;alpha&#92;}+&#92;{x+&#92;beta&#92;}=&#92;{x&#92;}' class='latex' /> if <img src='http://s0.wp.com/latex.php?latex=%5Calpha%5Cbeta%3Dx%5E2%2B1&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;alpha&#92;beta=x^2+1' title='&#92;alpha&#92;beta=x^2+1' class='latex' />.</p>
<p>(That formula, and its attribution, can be found in &#8220;The enhancement of Machin&#8217;s formula by Todd&#8217;s process&#8221; by Michael Wetherfield, <em>The Mathematical Gazette</em>, Vol. 80, No. 488 (Jul., 1996), pp. 333-344.)</p>
<p>Here, for example, are a few &#8220;Dodgson formulas&#8221; (the first one of which is Euler&#8217;s):</p>
<ol>
<li><img src='http://s0.wp.com/latex.php?latex=%5C%7B2%5C%7D%2B%5C%7B3%5C%7D%3D%5C%7B1%5C%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;{2&#92;}+&#92;{3&#92;}=&#92;{1&#92;}' title='&#92;{2&#92;}+&#92;{3&#92;}=&#92;{1&#92;}' class='latex' />.</li>
<li><img src='http://s0.wp.com/latex.php?latex=%5C%7B3%5C%7D%2B%5C%7B7%5C%7D%3D%5C%7B2%5C%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;{3&#92;}+&#92;{7&#92;}=&#92;{2&#92;}' title='&#92;{3&#92;}+&#92;{7&#92;}=&#92;{2&#92;}' class='latex' />.</li>
<li><img src='http://s0.wp.com/latex.php?latex=%5C%7B5%5C%7D%2B%5C%7B8%5C%7D%3D%5C%7B3%5C%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;{5&#92;}+&#92;{8&#92;}=&#92;{3&#92;}' title='&#92;{5&#92;}+&#92;{8&#92;}=&#92;{3&#92;}' class='latex' />.</li>
<li><img src='http://s0.wp.com/latex.php?latex=%5C%7B7%5C%7D%2B%5C%7B18%5C%7D%3D%5C%7B5%5C%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;{7&#92;}+&#92;{18&#92;}=&#92;{5&#92;}' title='&#92;{7&#92;}+&#92;{18&#92;}=&#92;{5&#92;}' class='latex' />.</li>
<li><img src='http://s0.wp.com/latex.php?latex=%5C%7B8%5C%7D%2B%5C%7B57%5C%7D%3D%5C%7B7%5C%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;{8&#92;}+&#92;{57&#92;}=&#92;{7&#92;}' title='&#92;{8&#92;}+&#92;{57&#92;}=&#92;{7&#92;}' class='latex' />.</li>
</ol>
<p>By a happy merry-go-round of substitutions, infinite numbers of Machin-type formulas can be developed.  Here is an example from Wetherfield&#8217;s paper.</p>
<ol>
<li>Substitute equation 2 above into equation 1 to obtain
<p><img src='http://s0.wp.com/latex.php?latex=2%5C%7B3%5C%7D%2B%5C%7B7%5C%7D%3D%5C%7B1%5C%7D.&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='2&#92;{3&#92;}+&#92;{7&#92;}=&#92;{1&#92;}.' title='2&#92;{3&#92;}+&#92;{7&#92;}=&#92;{1&#92;}.' class='latex' /></p>
<p>(This is known as <em>Hutton&#8217;s formula</em>.)</li>
<li>Now substitute in equation 3:
<p><img src='http://s0.wp.com/latex.php?latex=2%28%5C%7B5%5C%7D%2B%5C%7B8%5C%7D%29%2B%5C%7B7%5C%7D%3D%5C%7B1%5C%7D.&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='2(&#92;{5&#92;}+&#92;{8&#92;})+&#92;{7&#92;}=&#92;{1&#92;}.' title='2(&#92;{5&#92;}+&#92;{8&#92;})+&#92;{7&#92;}=&#92;{1&#92;}.' class='latex' /></p>
<p>and eliminate <img src='http://s0.wp.com/latex.php?latex=%5C%7B8%5C%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;{8&#92;}' title='&#92;{8&#92;}' class='latex' /> by using equation 5:</p>
<p><img src='http://s0.wp.com/latex.php?latex=2%28%5C%7B5%5C%7D%2B%5C%7B7%5C%7D-%5C%7B57%5C%7D%29%2B%5C%7B7%5C%7D%3D%5C%7B1%5C%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='2(&#92;{5&#92;}+&#92;{7&#92;}-&#92;{57&#92;})+&#92;{7&#92;}=&#92;{1&#92;}' title='2(&#92;{5&#92;}+&#92;{7&#92;}-&#92;{57&#92;})+&#92;{7&#92;}=&#92;{1&#92;}' class='latex' /></p>
<p>or</p>
<p><img src='http://s0.wp.com/latex.php?latex=2%5C%7B5%5C%7D%2B3%5C%7B7%5C%7D-2%5C%7B57%5C%7D%3D%5C%7B1%5C%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='2&#92;{5&#92;}+3&#92;{7&#92;}-2&#92;{57&#92;}=&#92;{1&#92;}' title='2&#92;{5&#92;}+3&#92;{7&#92;}-2&#92;{57&#92;}=&#92;{1&#92;}' class='latex' />.</li>
<li>Now use equation 4 to eliminate  <img src='http://s0.wp.com/latex.php?latex=%5C%7B7%5C%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;{7&#92;}' title='&#92;{7&#92;}' class='latex' />:
<p><img src='http://s0.wp.com/latex.php?latex=2%5C%7B5%5C%7D%2B3%28%5C%7B5%5C%7D-%5C%7B18%5C%7D%29-2%5C%7B57%5C%7D%3D%5C%7B1%5C%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='2&#92;{5&#92;}+3(&#92;{5&#92;}-&#92;{18&#92;})-2&#92;{57&#92;}=&#92;{1&#92;}' title='2&#92;{5&#92;}+3(&#92;{5&#92;}-&#92;{18&#92;})-2&#92;{57&#92;}=&#92;{1&#92;}' class='latex' />.</p>
<p>or</p>
<p><img src='http://s0.wp.com/latex.php?latex=5%5C%7B5%5C%7D-3%5C%7B18%5C%7D-2%5C%7B57%5C%7D%3D%5C%7B1%5C%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='5&#92;{5&#92;}-3&#92;{18&#92;}-2&#92;{57&#92;}=&#92;{1&#92;}' title='5&#92;{5&#92;}-3&#92;{18&#92;}-2&#92;{57&#92;}=&#92;{1&#92;}' class='latex' />.</li>
<li>Multiply by 4:
<p><img src='http://s0.wp.com/latex.php?latex=20%5C%7B5%5C%7D-12%5C%7B18%5C%7D-8%5C%7B57%5C%7D%3D4%5C%7B1%5C%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='20&#92;{5&#92;}-12&#92;{18&#92;}-8&#92;{57&#92;}=4&#92;{1&#92;}' title='20&#92;{5&#92;}-12&#92;{18&#92;}-8&#92;{57&#92;}=4&#92;{1&#92;}' class='latex' />.</li>
<p>and eliminate <img src='http://s0.wp.com/latex.php?latex=%5C%7B5%5C%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='&#92;{5&#92;}' title='&#92;{5&#92;}' class='latex' /> by using Machin&#8217;s formula:</p>
<p><img src='http://s0.wp.com/latex.php?latex=5%28%5C%7B1%5C%7D%2B%5C%7B239%5C%7D%29-12%5C%7B18%5C%7D-8%5C%7B57%5C%7D%3D4%5C%7B1%5C%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='5(&#92;{1&#92;}+&#92;{239&#92;})-12&#92;{18&#92;}-8&#92;{57&#92;}=4&#92;{1&#92;}' title='5(&#92;{1&#92;}+&#92;{239&#92;})-12&#92;{18&#92;}-8&#92;{57&#92;}=4&#92;{1&#92;}' class='latex' />
</ol>
<p>This last formula can be written</p>
<p><img src='http://s0.wp.com/latex.php?latex=12%5C%7B18%5C%7D%2B8%5C%7B57%5C%7D-5%5C%7B239%5C%7D%3D%5C%7B1%5C%7D&amp;bg=ffffff&amp;fg=333333&amp;s=0' alt='12&#92;{18&#92;}+8&#92;{57&#92;}-5&#92;{239&#92;}=&#92;{1&#92;}' title='12&#92;{18&#92;}+8&#92;{57&#92;}-5&#92;{239&#92;}=&#92;{1&#92;}' class='latex' /></p>
<p>which is a Machin-type formula known as <em>Gauss&#8217;s formula</em>.  Masses of other formulas can be found <a href="http://www.seriesmathstudy.com/sumOfArctangents.htm">here</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/amca01.wordpress.com/1391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/amca01.wordpress.com/1391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/amca01.wordpress.com/1391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/amca01.wordpress.com/1391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/amca01.wordpress.com/1391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/amca01.wordpress.com/1391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/amca01.wordpress.com/1391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/amca01.wordpress.com/1391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/amca01.wordpress.com/1391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/amca01.wordpress.com/1391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/amca01.wordpress.com/1391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/amca01.wordpress.com/1391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/amca01.wordpress.com/1391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/amca01.wordpress.com/1391/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=amca01.wordpress.com&amp;blog=3321115&amp;post=1391&amp;subd=amca01&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://amca01.wordpress.com/2011/06/14/machins-formula/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>
