<?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/"
	>

<channel>
	<title>Math-Blog &#187; Tutorial</title>
	<atom:link href="http://math-blog.com/category/tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>http://math-blog.com</link>
	<description>Mathematics is wonderful!</description>
	<lastBuildDate>Tue, 01 May 2012 21:25:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Using Octave, a Free MATLAB Alternative</title>
		<link>http://math-blog.com/2011/01/24/using-octave-a-free-matlab-alternative/</link>
		<comments>http://math-blog.com/2011/01/24/using-octave-a-free-matlab-alternative/#comments</comments>
		<pubDate>Mon, 24 Jan 2011 17:09:14 +0000</pubDate>
		<dc:creator>John F. McGowan, Ph.D.</dc:creator>
				<category><![CDATA[Applied Math]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://math-blog.com/?p=834</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://math-blog.com/2011/01/24/using-octave-a-free-matlab-alternative/' addthis:title='Using Octave, a Free MATLAB Alternative '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>Introduction Octave is a free, both free as in beer and free as in speech, MATLAB compatible numerical programming tool available under the GNU General Public License. MATLAB, an abbreviation for “Matrix Laboratory”, is currently the most widely used commercial, proprietary numerical programming tool. Even a single license for the MATLAB software is a substantial [...]<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://math-blog.com/2011/01/24/using-octave-a-free-matlab-alternative/' addthis:title='Using Octave, a Free MATLAB Alternative ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>
Possibly related articles:<ol>
<li><a href='http://math-blog.com/2011/01/17/octave-an-alternative-to-the-high-cost-of-matlab/' rel='bookmark' title='Octave: An Alternative to the High Cost of MATLAB'>Octave: An Alternative to the High Cost of MATLAB</a></li>
<li><a href='http://math-blog.com/2007/06/02/3-awesome-free-math-programs/' rel='bookmark' title='3 awesome free Math programs'>3 awesome free Math programs</a></li>
<li><a href='http://math-blog.com/2010/12/30/free-kindle-math-books/' rel='bookmark' title='Free Kindle Math Books'>Free Kindle Math Books</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://math-blog.com/2011/01/24/using-octave-a-free-matlab-alternative/' addthis:title='Using Octave, a Free MATLAB Alternative '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div><p><strong>Introduction</strong></p>
<p><a href="http://www.gnu.org/software/octave/" target="_blank">Octave </a>is a free, both free as in beer and free as in speech, <a href="http://www.mathworks.com/products/matlab/" target="_blank">MATLAB </a>compatible numerical programming tool available under the GNU General Public License. MATLAB, an abbreviation for “Matrix Laboratory”, is currently the most widely used commercial, proprietary numerical programming tool. Even a single license for the MATLAB software is a substantial cost. MATLAB is essentially a scripting language similar to Perl, Python, or PHP with a comprehensive, highly integrated set of numerical, statistical, mathematical, and graphical functions including, for example, the Fourier transform, matrix inversion, and histograms. In part because MATLAB has become the de facto industry standard for numerical programming, Octave is of particular interest to individuals, companies, and organizations engaged in numerical and mathematical programming and research and development.</p>
<p>At this time (2011), there is considerable interest in using machine learning and other advanced mathematical techniques to increase sales by detecting and predicting the buying patterns of end users of mobile devices such as iPhones and Android phones, social networks such as Facebook and LinkedIn, and search engines such as Google and Yahoo. Octave has long been used for data analysis, modeling, and machine learning. In addition to its extensive built-in features, Octave has <a href="http://octave.sourceforge.net/" target="_blank">add on packages</a> for optimization and mathematical model fitting, econometrics, signal processing, image processing, neural networks, and a number of other areas used in the &#8220;mobile social search&#8221; space. Octave is also well suited for the development and implementation of algorithms for image and video compression, audio compression, image and video processing, audio processing, speech recognition, pattern recognition, artificial intelligence, design and simulation of machines, and many other practical uses.</p>
<p>In general, it is faster and easier to develop mathematical algorithms in Octave and similar tools than compiled languages such as C, C++, and Fortran. Because research and development usually involves large amounts of trial and error, Octave and similar tools have been used traditionally to prototype algorithms, analyze data from experiments, and so forth, and only occasionally for &#8220;production code&#8221; or commercial products. Traditionally, once a proof of concept existed in Octave or a similar tool, it was often translated to a faster compiled language such as C, C++, or Fortran, often a time consuming, tedious, and costly process. Octave today is quite fast and modern computers are extremely fast and inexpensive, so that there are many projects, such as data mining in the backend of a web site, that can probably skip the time consuming and costly step of conversion to a compiled language. In the future, just in time (JIT) compilers and similar capabilities will probably be added to Octave and similar tools so that the remaining speed difference between Octave and traditional compiled languages such as C, C++, and Fortran will vanish.</p>
<p>A significant problem with using Octave and many other free programs is making Octave work cost-effectively with other programs. It is rarely possible to use Octave for real-world projects as a purely standalone program. It is often necessary to share data and transfer the control flow between Octave and other programs including operating systems, databases, spreadsheets, web sites, and so forth. Many programs, especially proprietary programs, achieve customer lock-in through custom, sometimes secret, data formats and so forth. Microsoft Office is notorious for introducing new Office file formats with each &#8220;upgrade&#8221; that are not backward compatible with earlier versions of Office. Thus, users find themselves receiving spreadsheets, documents, and so forth that they cannot read with their old version of Office, forcing an &#8220;upgrade&#8221; at substantial cost.</p>
<p>This proliferation of ever-changing data formats, API&#8217;s, programming languages, and miscellaneous other standards, presents a continual problem for using free software. End users often spend hours, even days or weeks, figuring out how to convert from one format to another. Software developers often spend hours, days, weeks, and even months writing functions to read and write unsupported formats, whether new or old. This makes it difficult for end users or software developers to add real value by inventing substantive new features, capabilities, and algorithms.</p>
<p>This article covers a number of methods, specific commands and specific programs to make Octave work cost-effectively with other programs. There are many excellent on-line and published documents on the syntax of Octave and its add-on packages. Readers with specific questions of this type are referred to the excellent existing documentation. Rather, this article discusses some of the issues with making Octave work with other programs that are often not covered explicitly or well in the standard Octave or free software literature.</p>
<p><strong>Using Simple Human Readable Files to Reduce Costs</strong></p>
<p>There are a number of advantages to using simple human readable files (typically ASCII or UTF8) such as standard tab delimited files or comma separated values (CSV) files to export data, import data, and store data. One can view the files in any text editor or word processor. Most programs such as spreadsheets, databases, and many others can easily read and write tab-delimited and comma separated values (CSV) files. Many scripting languages have direct support for tab-delimited and sometimes comma separated values files. Essentially all computer programming languages can easily read and write tab-delimited files; it is just a few lines of code. Essentially all computer programming languages can read and write comma separated values files; it requires more programming, more lines of code, but it can be done. Octave can read and write tab delimited files using its built-in <em>dlmread </em>and <em>dlmwrite </em>functions. Octave can also read and write comma separated values files using its built-in <em>csvread </em>and <em>csvwrite </em>functions.</p>
<p>Historically, disk drives were small. Networks had very limited bandwidth. Computers had limited speed to read and process files. Hence, binary file formats had very clear advantages over bulkier human readable formats such as tab delimited files. With terabyte drives, 100 Megabit per second networks, and inexpensive 3 GHz multi-core computers, this is much less true today. Thus, there is a strong case for using simple human readable file formats such as tab delimited files to reduce high end user and development costs, avoid customer lock-in (a costly proposition if you are the customer), and limit the costly perpetual upgrade cycle to genuine improvements in the products and services.</p>
<p>Simple human readable files, notably tab delimited files, enable users and developers to share data between Octave and other programs quickly and easily. There are a few caveats to be aware of.</p>
<p>First, the basic data type in Octave is a &#8220;matrix,&#8221; originally a double precision two-dimensional array. The MATLAB/Octave &#8220;matrix&#8221; has been extended to multiple dimensions and also to support characters and strings. The character/string support in MATLAB and Octave is something of a patch. Thus, the <em>dlmread </em>and <em>dlmwrite </em>commands in Octave handle matrices or arrays of numbers fine but map character strings in tab-delimited files to zero (0). This is often not an issue for the numerical programming and analysis that Octave is usually used for. The string and text manipulation capabilities in Octave are limited, so one should consider other tools such as Perl, Python, or Ruby for heavily text or string oriented work.</p>
<p>The precision of floating point numbers can be an issue using human readable files such as tab delimited files that represent floating point numbers as character strings such as &#8220;1.123456&#8243; or &#8220;1.1234567890123456&#8243;. Octave, MATLAB, and most computer programs use the IEEE-754 standard for floating point numbers, or extensions of this standard. In this standard, a single precision floating point number (e.g. a float in the C family of programming languages) requires six decimal digits after the decimal point to represent the floating point number as a character string such as &#8220;1.123456&#8243;. An IEEE-754 double precision floating point number requires 16 decimal digits after the decimal point to represent the double as a character string such &#8220;1.1234567890123456&#8243;.</p>
<p>Many programs and programming languages default to writing floating point numbers as character strings with six decimal digits such as &#8220;1.123456&#8243;. For example, the standard printf() function in the C programming language defaults to six decimal digits of precisoin when its %f format specifier for floating point numbers is used:</p>
<pre class="mathcode">double value = 1.12345678901234456;
print("my number: %f\n", value); // defaults to six decimal digits of precision</pre>
<p>usually prints:</p>
<pre class="mathcode">my number: 1.123456</pre>
<p>Thus, if a mathematical algorithm in Octave depends on double precision, it may be necessary to prepare a human readable input data file with 16 decimal digit character strings for the floating point numbers.</p>
<p>In Octave, one can use the command format long to display numbers at full precision:</p>
<pre class="mathcode">Octave&gt;format long</pre>
<p><strong>Exchanging Binary Files Between Octave and Other Programs</strong></p>
<p>Octave supports a relatively small set of binary file formats directly. This is a common problem with free software. Both users and software developers can find themselves spending hours, days, even weeks on occasion (time is money) converting to and from other binary formats used by other programs. There are however a number of free programs that can quickly convert between a wide range of binary formats, thus greatly reducing or eliminating this overhead.</p>
<p>The free <a href="http://www.gimp.org/" target="_blank">GIMP </a>(The GNU Image Manipulation Program) program can read and write nearly all widely used still image file formats and many obscure still image formats. GIMP is available as both pre-compiled binaries and source code for all three major computing platforms: Microsoft Windows, Linux/Unix, and Mac OS X.</p>
<p>The widely used, free <a href="http://audacity.sourceforge.net/" target="_blank">Audacity </a>audio-editing program can read and write raw audio files, Microsoft uncompressed WAV files, and the open <a href="http://www.vorbis.com/" target="_blank">Ogg Vorbis</a> audio file format. By default Audacity can read MP3 audio files but it cannot write them due to the onerous MP3 licensing restrictions. Users can install the <a href="http://lame.sourceforge.net/" target="_blank">LAME </a>MP3 encoding library on all three major computing platforms &#8212; Microsoft Windows, Linux/Unix, and Mac OS X &#8212; and then Audacity can use this add on library to encode audio as MP3. Audacity is available as source code and precompiled binaries for all three major computing platforms.</p>
<p>The widely used, free <a href="http://sox.sourceforge.net/" target="_blank">sox </a>(Sound Exchange) audio conversion utility can read and write a broad range of audio formats. Like Audacity, it needs the LAME encoding library to be separately installed to encode MP3 files due to the MP3 licensing restrictions. Users should consider using the free <em>ogg vorbis</em> audio format to avoid the MP3 licensing issues altogether. <em>sox </em>is available as both source code and precompiled binaries for all three major computing platforms.</p>
<p>The widely used, (mostly) free <a href="http://ffmpeg.org/" target="_blank">ffmpeg </a>video and image sequence conversion utility can read and write a broad range of video file formats. Like Audacity and sox, certain video encoding formats have licensing restrictions. Again, users may wish to consider the free <a href="http://www.theora.org/" target="_blank">ogg theora</a> video format to avoid some of the licensing issues with better known video formats such as h.264.</p>
<p><strong>Installing Octave Add-On Packages</strong></p>
<p>Octave has extensive built-in capabilities. It also has a large number of add-on packages available through the <a href="http://octave.sourceforge.net/" target="_blank">Octave Forge </a>project and web site. These include an extensive library of standard optimization functions such as the Nelder-Mead method used in model fitting, statistics, signal processing, econometrics, and so forth. Some of the Octave Forge packages are rather limited, but a number are very extensive and a number extend Octave&#8217;s compatibility with MATLAB.</p>
<p>For example, MATLAB has a function <em>xcorr </em>which computes the cross-correlation of a data series or data set. Octave does not have xcorr in its base set of built-in functions. There are a number of implementations of <em>xcorr </em>on the web as <em>xcorr.m</em> files, but <em>xcorr </em>is also found in the Octave Forge <em>signal </em>package which provides a large number of standard signal processing functions.</p>
<p>The author found the explanations of the Octave pkg install procedure on the Octave and Octave Forge web sites a bit confusing. Here is a fuller explanation. Octave packages are downloaded as standard <em>*.tar.gz</em> gzipped (compressed) Unix <em>tar </em>(tape archive) files. The Unix <em>tar </em>(tape archive) command combines a group of files and/or folders and their contents into a single huge file without compressing the files. They are loosely concatenated together. Historically, the <em>tar</em> command was used to store files, folders, even entire file systems on backup tapes. The Unix <em>gzip </em>utility compresses files. On Unix, a <em>*.tar.gz </em>or <em>*.tgz</em> file is a file that has been <em>tarred </em>and then compressed using <em>gzip</em>. The Octave packages are distributed as <em>*.tar.gz </em>files.</p>
<p>Octave has a built in command<em> pkg install</em> which installs the packages. NOTE: <em>pkg install</em> works directly on<em> *.tar.gz</em> or <em>*.tar </em>files. There is no need to uncompress or unpack the<em> *.tar</em> or <em>*tar.gz</em> files. On the Macintosh, the Mac OS may automatically unzip the file when downloaded, creating a <em>*.tar</em> file.</p>
<p>In Octave, simply switch the folder where the<em> *.tar.gz</em> or<em> *.tar</em> file has been downloaded, then type</p>
<pre class="mathcode">Octave&gt; pkg install package-name.tar.gz</pre>
<p>or</p>
<pre class="mathcode">Octave&gt; pkg install pakcage-name.tar</pre>
<p>if the operating system has automatically unzipped the package.</p>
<p>The Octave<em> pkg install</em> command will automatically create the folders for the new package in the Octave installation and copy the package files to these folders and perform all other setup.</p>
<p>Many Octave packages contain C, C++, or Fortran source code. Octave automatically installs a compiler when it is installed. It can compile these files. There is no need for the Octave user to compile them by hand, run the make utility or anything like that. Octave has a built-in <em>mkoctfile </em>command to compile C, C++, or Fortran extensions to Octave and add them to the built-in commands of Octave. The Octave <em>pkg install</em> command will run mkoctfile if needed to build and install the package. On the Macintosh (see below) it may be necessary to modify the <em>mkoctfile </em>command to install many of the Octave packages.</p>
<p><strong>Extending Octave with Fast, Compiled Languages</strong></p>
<p>Developers may want to extend Octave by adding C, C++, or Fortran programs to the built-in functions of Octave. This may be done because the compiled programs will be faster to execute than Octave or to add existing C, C++, or Fortran code to Octave.</p>
<pre class="mathcode">mkoctfile [-options] file</pre>
<p>The <em>mkoctfile </em>function compiles source code written in C, C++, or Fortran. Depending on the options used with <em>mkoctfile</em>, the compiled code can be called within Octave or can be used as a stand-alone application. <em>mkoctfile </em>can be called from the shell prompt or from the Octave prompt.</p>
<p><strong>Making Octave Work with Emacs</strong></p>
<p>Emacs is a widely used free source-code and text editor. <a href="http://www.gnu.org/software/emacs/" target="_blank">Emacs </a>is available on all three major computing platforms: Microsoft Windows, Unix/Linux, and Mac OS. The author has had good experiences using the free <a href="http://aquamacs.org/" target="_blank">Aquamacs </a>version of Emacs on the Macintosh. Emacs has an &#8220;everything including the kitchen-sink&#8221; philosophy. Emacs has extensive built-in capabilities. There is extensive and excellent on-line and published documentation on Emacs. Again, this article will only discuss some key gotchas that are likely to arise using Emacs in combination with Octave.</p>
<p>Emacs has a MATLAB mode for editing MATLAB or Octave source code. The MATLAB code editing mode handles indenting, highlights keywords, and so forth. Emacs also has an<a href="http://en.wikipedia.org/wiki/Objective-C" target="_blank"> Objective C</a> mode. Since Objective C &#8220;method&#8221; or &#8220;message&#8221; source files also use the <em>.m</em> file extension used by MATLAB and Octave, this can cause problems. There is also an Objective C mode for Emacs. The author has encountered versions of Emacs configured to use the Objective C mode for <em>.m </em>files and other versions of Emacs configured to use the MATLAB mode for .m files.</p>
<p>The Emacs user can explicitly switch to the MATLAB mode by typing Meta-X where the mysterious Emacs Meta key is usually the Escape (Esc) key on most keyboards and then typing <em>matlab-mode</em> at the Emacs command prompt.</p>
<p>If the matlab mode is not preinstalled in the user&#8217;s version of Emacs, one can get an Emacs MATLAB mode add on package from the web, for example at <a href="http://www.mathworks.com/matlabcentral/fileexchange/104" target="_blank">http://www.mathworks.com/matlabcentral/fileexchange/104</a></p>
<p>Emacs can be reconfigured to use the MATLAB mode automatically for .m files instead of the Objective C mode if needed.</p>
<p>As discussed, in addition to source code, it is often necessary to share data between Octave and other programs. Simple human readable file formats such as the common tab delimited file format or simple uncompressed binary file formats such as Microsoft WAV audio files are often the easiest and most cost-effective way to do this. Working with files of this type sometimes requires examining the files, for example to detect or rule out errors such as non-printing characters or incorrect header information. Emacs can be used to do this.</p>
<p>Emacs has a couple of special modes that are useful for examining data files and sometimes source code. Emacs has a hexadecimal viewer/editor mode that can be invoked by typing <em>hexl-mode</em> at the Emacs command prompt. The Emacs <em>hexl-mode</em> is useful for examining binary file formats and occasionally human readable formats. Emacs has a special whitespace mode that displays whitespace characters such as tab, carriage return, newline, and so forth. Type <em>whitespace-mode</em> at the Emacs command prompt. This can useful for examining human readable data files and also source code files where the whitespace characters may be incorrect or confusing.</p>
<p><strong>Making Octave Work on the Macintosh</strong></p>
<p>There are a couple of gotchas to making Octave work on the Macintosh platform. By default, on MacOS X, Octave is not set up to display plots through the X server on the Macintosh. It is necessary to set an environment variable so that Octave can display plots. This is done by entering the following command at the Octave prompt.</p>
<pre class="mathcode">Octave&gt; setenv GNUTERM 'x11'</pre>
<p>By default, Octave uses the <em>gnuplot </em>package, which it installs if needed, to display plots. This environment variable tells <em>gnuplot </em>to use &#8216;x11&#8242;, the X Windows server on the Macintosh, to display plots.</p>
<p>As discussed above, Octave has a large number of add-on packages available through the Octave Forge web site. By default, a number of these packages do not build and install correctly on MacOS. One gets a cryptic error. This is because the mkoctfile command in Octave defaults to building 64 bit versions on the Macintosh. This can be fixed by adding the lines:</p>
<pre class="mathcode">CFLAGS="-m32 ${CFLAGS}"
FFLAGS="-m32 ${FFLAGS}"
CPPFLAGS="-m32 ${CPPFLAGS}"
CXXFLAGS="-m32 ${CXXFLAGS}"
LDFLAGS="-m32 ${LDFLAGS}"</pre>
<p>in the file Octave.app/Contents/Resources/bin/mkoctfile-3.2.3 just after the &#8220;set -e&#8221; line. The problem is that in Snow Leopard (code name for a recent version of Mac OS X) compilers try always to build in 64bit, while the libraries shipped with Octave are 32 bit. The <em>-m32</em> flag forces the compiler to build 32 bit programs.</p>
<p><strong>Screen Capture with Octave</strong></p>
<p>Using Octave or similar programs often involves making plots, histograms, and other graphics that the user wants or needs to share with others, attach to e-mails, embed in publications, and so forth. One quick way to do this on Microsoft Windows and Macintosh platforms is through the built-in screen capture capabilities of the operating system and the gnuplot package used by Octave.</p>
<p>On Microsoft Windows, there is a &#8220;Print Screen&#8221; button on keyboards that will capture the entire screen to the MS Windows clipboard. One can then use GIMP or many other image editors to create a file from the contents of the clipboard. One can then edit the image file to select desired regions and so forth. On MS Windows, the gnuplot display window has a window capture feature. One can type Control-C in the plot window to capture the plot window to the Windows clipboard. One can also select the plot window menu by clicking the icon in the upper left corner of the plot window, then &#8220;Options&#8221; from the menu, and then &#8220;Copy to Clipboard&#8221; from the Options menu.</p>
<p>The Macintosh has a number of keyboard shortcuts to capture either the entire screen or a region of the screen to the clipboard or to a file on the Macintosh desktop. These keyboard shortcuts are (Apple Command)-Shift-3 to capture the entire screen to a file on the Desktop, (Apple Command Key)-Shift-4 to capture a region to a file on the Desktop, (Apple Command Key)-Control-Shift-3 to capture the entire screen to the Macintosh clipboard, and (Apple Command Key)-Control-Shift-4 to capture a region to the Macintosh clipboard. The region commands turn the mouse cursor into a cross-hairs icon; the user can select a region to capture by clicking and dragging on the screen with the cross hairs.</p>
<p><strong>Conclusion</strong></p>
<p>Octave is free, both free as in beer and free as in speech. Octave has many virtues, notably that it is mostly compatible with MATLAB, which is currently the de facto standard for numerical and mathematical programming. Octave can be used to quickly develop software for a wide range of practical problems including the prediction of buying patterns, image and signal processing, pure and applied scientific research, and the invention and design of new machines, to name only a few. With the tools, methods, and commands discussed above, it is possible to make Octave work quickly and cost-effectively with a wide range of other programs on all three major computing platforms: MS Windows, Linux/Unix, and Macintosh.</p>
<p>© 2011 John F. McGowan</p>
<p><strong>About the Author</strong></p>
<p><em>John F. McGowan, Ph.D</em>. is a software developer, research scientist, and consultant. He works primarily in the area of complex algorithms that embody advanced mathematical and logical concepts, including speech recognition and video compression technologies. He has extensive experience developing software in C, C++, Visual Basic, Mathematica, MATLAB, and many other programming languages. He is probably best known for his AVI Overview, an Internet FAQ (Frequently Asked Questions) on the Microsoft AVI (Audio Video Interleave) file format. He has worked as a contractor at NASA Ames Research Center involved in the research and development of image and video processing algorithms and technology. He has published articles on the origin and evolution of life, the exploration of Mars (anticipating the discovery of methane on Mars), and cheap access to space. He has a Ph.D. in physics from the University of Illinois at Urbana-Champaign and a B.S. in physics from the California Institute of Technology (Caltech). He can be reached at<a href="mailto://jmcgowan11@earthlink.net"> jmcgowan11@earthlink.net</a>.</p>
<p><strong>Sponsor&#8217;s message</strong>: Check out <a href="https://www.e-junkie.com/ecom/gb.php?cl=61573&amp;c=ib&amp;aff=129997">Math Better Explained</a>, an insightful ebook and screencast series that will help you see math in a new light and experience more of those awesome &#8220;aha!&#8221; moments when ideas suddenly click.</p>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://math-blog.com/2011/01/24/using-octave-a-free-matlab-alternative/' addthis:title='Using Octave, a Free MATLAB Alternative ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div><p>Possibly related articles:<ol>
<li><a href='http://math-blog.com/2011/01/17/octave-an-alternative-to-the-high-cost-of-matlab/' rel='bookmark' title='Octave: An Alternative to the High Cost of MATLAB'>Octave: An Alternative to the High Cost of MATLAB</a></li>
<li><a href='http://math-blog.com/2007/06/02/3-awesome-free-math-programs/' rel='bookmark' title='3 awesome free Math programs'>3 awesome free Math programs</a></li>
<li><a href='http://math-blog.com/2010/12/30/free-kindle-math-books/' rel='bookmark' title='Free Kindle Math Books'>Free Kindle Math Books</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://math-blog.com/2011/01/24/using-octave-a-free-matlab-alternative/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Developing Math Intuition</title>
		<link>http://math-blog.com/2011/01/13/developing-math-intuition/</link>
		<comments>http://math-blog.com/2011/01/13/developing-math-intuition/#comments</comments>
		<pubDate>Thu, 13 Jan 2011 20:00:22 +0000</pubDate>
		<dc:creator>Antonio Cangiano</dc:creator>
				<category><![CDATA[Essential Math]]></category>
		<category><![CDATA[Suggested Reading]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://math-blog.com/?p=814</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://math-blog.com/2011/01/13/developing-math-intuition/' addthis:title='Developing Math Intuition '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>Today Kalid Azad released a premium edition of his well-received Math Better Explained ebook. This brand new edition (available for a limited time for just $47) boasts a screencast for each of the 12 chapters in the book, as well as a 3-part interview about developing your mathematical intuition with Scott H Young, who has [...]<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://math-blog.com/2011/01/13/developing-math-intuition/' addthis:title='Developing Math Intuition ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>
Possibly related articles:<ol>
<li><a href='http://math-blog.com/2007/05/26/what-kind-of-math-did-they-teach-you/' rel='bookmark' title='What kind of Math did they teach you?'>What kind of Math did they teach you?</a></li>
<li><a href='http://math-blog.com/2010/03/15/math-books-reviewed-and-classified-by-area-of-mathematics/' rel='bookmark' title='Math Books reviewed and classified by area of mathematics'>Math Books reviewed and classified by area of mathematics</a></li>
<li><a href='http://math-blog.com/2008/12/22/the-nicest-math-book-i-own/' rel='bookmark' title='The nicest math book I own'>The nicest math book I own</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://math-blog.com/2011/01/13/developing-math-intuition/' addthis:title='Developing Math Intuition '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Today Kalid Azad released a premium edition of his well-received <a href="https://www.e-junkie.com/ecom/gb.php?cl=61573&#038;c=ib&#038;aff=129997">Math Better Explained</a> ebook.</p>
<p>This brand new edition (available for a limited time for just $47) boasts a screencast for each of the 12 chapters in the book, as well as a 3-part interview about developing your mathematical intuition with Scott H Young, who has written extensively about study techniques. The package also includes a PDF version of the book, a worksheet, and slides/image as a zip file.</p>
<p>We were provided early access to the material, and have found the ebook + screencasts combo to be highly effective in conveying fundamental mathematical concepts that will serve you well for years to come.</p>
<p>To celebrate the announcement, and as a Math Blog exclusive, today we are publishing an excerpt from <a href="https://www.e-junkie.com/ecom/gb.php?cl=61573&#038;c=ib&#038;aff=129997">the book</a> here. It covers how to develop math intuition and the great importance this skill plays in the field of mathematics. Enjoy!</p>
<h2>Developing Math Intuition</h2>
<p>Our initial exposure to an idea shapes our intuition. And our intuition impacts how much we enjoy a subject. What do I mean?<br />
Suppose we want to define a “cat”:</p>
<ul>
<li><strong>Caveman definition</strong>: A furry animal with claws, teeth, a tail, 4 legs, that purrs when happy and hisses when angry. . .</li>
<li><strong>Evolutionary definition</strong>: Mammalian descendants of a certain species (F. catus), sharing certain characteristics. . .</li>
<li><strong>Modern definition</strong>: You call those definitions? Cats are animals sharing the following DNA: ACATACATACATACAT. . .</li>
</ul>
<p>The modern definition is precise, sure. But is it the best? Is it what you’d teach a child learning the word? Does it give better insight into the “catness” of the animal? Not really. The modern definition is useful, but after getting an understanding of what a cat is. It shouldn’t be our starting point.</p>
<p>Unfortunately, math understanding seems to follow the DNA pattern. We’re taught the modern, rigorous definition and not the insights that led up to it. We’re left with arcane formulas (DNA) but little understanding of what the idea is.</p>
<p>Let’s approach ideas from a different angle. I imagine a circle: the center is the idea you’re studying, and along the outside are the facts describing it. We start in one corner, with one fact or insight, and work our way around to develop our understanding. Cats have common physical traits leads to Cats have a common ancestor leads to A species can be identified by certain portions of DNA. Aha! I can see how the modern definition evolved from the caveman one.</p>
<p>But not all starting points are equal. The right perspective makes math click — and the mathematical “cavemen” who first found an idea often had an enlightening viewpoint. Let’s learn how to build our intuition.</p>
<h3>1.1	What is a Circle?</h3>
<p>Time for a math example: How do you define a circle?</p>
<div align="center">
<a href="http://math-blog.com/wp-content/uploads/2011/01/defining_a_circle.png"><img src="http://math-blog.com/wp-content/uploads/2011/01/defining_a_circle.png" alt="Defining a Circle" title="Defining a Circle" width="519" height="572" class="aligncenter size-full wp-image-815" /></a>
</div>
<p>There are seemingly countless definitions. Here’s a few:</p>
<ul>
<li>The most symmetric 2-d shape possible</li>
<li>The shape that gets the most area for the least perimeter (the isoperimeter property)</li>
<li>All points in a plane the same distance from a given point (drawn with a compass, or a pencil on a string)</li>
<li>The points (x,y) in the equation x<sup>2</sup> + y<sup>2</sup> = r<sup>2</sup> (analytic version of the geometric definition above)</li>
<li>The points in the equation r · sin(t),r · cos(t), for all t (really analytic version)</li>
<li>The shape whose tangent line is always perpendicular to the position vector (physical interpretation)</li>
</ul>
<p>The list goes on, but here’s the key: the facts all describe the same idea! It’s like saying 1, one, uno, eins, “the solution to 2x + 3 = 5” or “the number of noses on your face” — just different names for the idea of unity.</p>
<p>But these initial descriptions are important — they shape our intuition. Because we see circles in the real world before the classroom, we understand their “roundness”. No matter what fancy equation we see (x<sup>2</sup> + y<sup>2</sup> = r<sup>2</sup>), we know deep inside that a circle is round. If we graphed that equation and it appeared square, or lopsided, we’d know there was a mistake.</p>
<p>As children, we learn the caveman definition of a circle (a really round thing), which gives us a comfortable intuition. We can see that every point on our “round thing” is the same distance from the center. x<sup>2</sup> + y<sup>2</sup> = r<sup>2</sup> is the analytic way of expressing that fact (using the Pythagorean theorem for distance). We started in one corner, with our intuition, and worked our way around to the formal definition.</p>
<p>Other ideas aren’t so lucky. Do we instinctively see the growth of e, or is it an abstract definition? Do we realize the rotation of i, or is it an artificial, useless idea?</p>
<h3>1.2	A Strategy For Developing Insight</h3>
<p>I still have to remind myself about the deeper meaning of e and i — which seems as absurd as “remembering” that a circle is round or what a cat looks like! It should be the natural insight we start with.</p>
<p>Missing the big picture drives me crazy: math is about ideas — formulas are just a way to express them. Once the central concept is clear, the equations snap into place. Here’s a strategy that has helped me:</p>
<ul>
<li><strong>Step 1</strong>: Find the central theme of a math concept. This can be difficult, but try starting with its history. Where was the idea first used? What was the discoverer doing? This use may be different from our modern interpretation and application.</li>
<li><strong>Step 2</strong>: Explain a property/fact using the theme. Use the theme to make an analogy to the formal definition. If you’re lucky, you can translate the math equation (x<sup>2</sup> + y<sup>2</sup> = r<sup>2</sup>) into a plain-english statement (“All points the same distance from the center”).</li>
<li><strong>Step 3</strong>: Explore related properties using the same theme. Once you have an analogy or interpretation that works, see if it applies to other properties. Sometimes it will, sometimes it won’t (and you’ll need a new insight), but you’d be surprised what you can discover.</li>
</ul>
<p>Let’s try it out.</p>
<h3>1.3	A Real Example: Understanding e</h3>
<p>Understanding the number e has been a major battle. e appears everywhere in science, and has numerous definitions, yet rarely clicks in a natural way. Let’s build some insight around this idea. The following section has several equations, which are simply ways to describe ideas. Even if the equation is gibberish, there’s a plain-english concept behind it. Here’s a few common definitions of e:</p>
<div align="center">
<a href="http://math-blog.com/wp-content/uploads/2011/01/faces_of_e.png"><img src="http://math-blog.com/wp-content/uploads/2011/01/faces_of_e.png" alt="Faces of e" title="Faces of e" width="478" height="503" class="aligncenter size-full wp-image-816" /></a>
</div>
<p>The first step is to find a theme. Looking at e’s history, it seems it has some- thing to do with growth or interest rates. e was discovered when performing business calculations (not abstract mathematical conjectures) so “interest” (growth) is a possible theme.</p>
<p>Let’s look at the first definition, in the upper left. The key jump, for me, was to realize how much this looked like the formula for compound interest. In fact, it is the interest formula when you compound 100% interest for 1 unit of time, compounding as fast as possible. The chapter on e describes this interpretation.</p>
<p><strong>Definition 1</strong>: Define e as 100% compound growth at the smallest increment possible.</p>
<p>Let’s look at the second definition: an infinite series of terms, getting smaller and smaller. What could this be?</p>
<p align="center">
<img src='http://math-blog.com/wp-content/latex/pictures/dee259cd3524881c208d4974a4bd291a.png' title='\displaystyle e = \frac{1}{0!} + \frac{1}{1!} + \frac{1}{2!} + \frac{1}{3!} + \ldots' alt='\displaystyle e = \frac{1}{0!} + \frac{1}{1!} + \frac{1}{2!} + \frac{1}{3!} + \ldots' align=absmiddle>
</p>
<p>After noodling this over using the theme of “interest” we see this definition shows the components of compound interest. Now, insights don’t come instantly — this insight might strike after brainstorming “What could 1 + 1 + 1/2 + 1/6 + . . . ” represent when talking about growth?”</p>
<p>Well, the first term (1 = 1/0!, remembering that 0! is 1) is your principal, the original amount. The next term (1 = 1/1!) is the “direct” interest you earned — 100% of 1. The next term (0.5 = 1/2!) is the amount of money your interest made (“2nd-level interest”). The following term (.1666 = 1/3!) is your “3rd-level interest” — how much money your interest’s interest earned!</p>
<p>Money earns money, which earns money, which earns money, and so on — the sequence separates out these contributions (the chapter on e describes how Mr. Blue, Mr. Green &#038; Mr. Red grow independently). There’s much more to say, but that’s the “growth-focused” understanding of that idea.</p>
<p><strong>Definition 2</strong>: Define e by the contributions each piece of interest makes.</p>
<p>Neato. Now to the third, shortest definition. What does it mean? Instead of thinking “derivative” (which turns your brain into equation-crunching mode), think about what it means. The feeling of the equation. Make it your friend.</p>
<p align="center">
<img src='http://math-blog.com/wp-content/latex/pictures/cb1ac3f3c046fbb15f789980b0682191.png' title='\displaystyle \frac{d}{dx}Blah = Blah' alt='\displaystyle \frac{d}{dx}Blah = Blah' align=absmiddle>
</p>
<p>It’s the calculus way of saying “Your rate of growth is equal to your current amount”. Well, growing at your current amount would be a 100% interest rate, right? And by always growing it means you are always calculating interest – it’s another way of describing continuously compound interest!</p>
<p><strong>Definition 3</strong>: Define e as always growing by 100% of your current value.</p>
<p>Nice — e is the number where you’re always growing by exactly your current amount (100%), not 1% or 200%.</p>
<p>Time for the last definition — it’s a tricky one. Here’s my interpretation: Instead of describing how much you grew, why not say how long it took?</p>
<p>If you’re at 1 and growing at 100%, it takes 1 unit of time to get from 1 to 2. But once you’re at 2, and growing 100%, it means you’re growing at 2 units per unit time! So it only takes 1/2 unit of time to go from 2 to 3. Going from 3 to 4 only takes 1/3 unit of time, and so on.</p>
<p>The time needed to grom from 1 to A is the time from 1 to 2, 2 to 3, 3 to 4. . . and so on, until you get to A. The first definition defines the natural log (ln) as shorthand for this “time to grow” computation.</p>
<p>ln(a) is simply the time to grow from 1 to a. We then say that e is the number that takes exactly 1 unit of time to grow to. Said another way, e is is the amount of growth after waiting exactly 1 unit of time!</p>
<p><strong>Definition 4</strong>: Define the time needed to grow continuously from 1 to as ln(a). e is the amount of growth you have after 1 unit of time.</p>
<p>Whablamo! These are four different ways to describe the mysterious e. Once we have the core idea (“e is about 100% continuous growth”), the crazy equations snap into place — it’s possible to translate calculus into English. Math is about ideas!</p>
<h3>1.4	What’s the Moral?</h3>
<p>In math class, we often start with the last, most complex idea. It’s no wonder we’re confused: we’re showing students DNA and expecting them to see a cat. I’ve learned a few lessons from this approach, and it underlies how I understand and explain math:</p>
<ul>
<li>Search for insights and apply them. That first intuitive insight can help everything else snap into place. Start with a definition that makes sense and “walk around the circle” to find others.</li>
<li>Be resourceful. Banging your head against an idea is no fun. If it doesn’t click, come at it from different angles. There’s another book, another article, another person who explains it in a way that makes sense to you.</li>
<li>It’s ok to be visual. We think of math as rigid and analytic — but visual interpretations are ok! Do what develops your understanding. Imaginary numbers were puzzling until their geometric interpretation came to light, decades after their initial discovery. Looking at equations all day didn’t help mathematicians “get” what they were about.</li>
</ul>
<p>Math becomes difficult and discouraging when we focus on definitions over understanding. Remember that the modern definition is the most advanced step of thought, not necessarily the starting point. Don’t be afraid to approach a concept from a funny angle — figure out the plain-English sentence behind the equation. Happy math.</p>
<p align="center"><a href="https://www.e-junkie.com/ecom/gb.php?cl=61573&#038;c=ib&#038;aff=129997">Order the book and screencasts.</a></p>
<p><em>Disclaimer: The links to Math Better Explained contain our referrer id.</em></p>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://math-blog.com/2011/01/13/developing-math-intuition/' addthis:title='Developing Math Intuition ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div><p>Possibly related articles:<ol>
<li><a href='http://math-blog.com/2007/05/26/what-kind-of-math-did-they-teach-you/' rel='bookmark' title='What kind of Math did they teach you?'>What kind of Math did they teach you?</a></li>
<li><a href='http://math-blog.com/2010/03/15/math-books-reviewed-and-classified-by-area-of-mathematics/' rel='bookmark' title='Math Books reviewed and classified by area of mathematics'>Math Books reviewed and classified by area of mathematics</a></li>
<li><a href='http://math-blog.com/2008/12/22/the-nicest-math-book-i-own/' rel='bookmark' title='The nicest math book I own'>The nicest math book I own</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://math-blog.com/2011/01/13/developing-math-intuition/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>13 Useful Math Cheat Sheets</title>
		<link>http://math-blog.com/2008/09/20/13-useful-math-cheat-sheets/</link>
		<comments>http://math-blog.com/2008/09/20/13-useful-math-cheat-sheets/#comments</comments>
		<pubDate>Sat, 20 Sep 2008 16:42:20 +0000</pubDate>
		<dc:creator>Antonio Cangiano</dc:creator>
				<category><![CDATA[Applied Math]]></category>
		<category><![CDATA[Math Education]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://math-blog.com/?p=55</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://math-blog.com/2008/09/20/13-useful-math-cheat-sheets/' addthis:title='13 Useful Math Cheat Sheets '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>Cheat sheets can be very useful and make for great posters around your room. The following is a collection of 13 cheat sheets for several mathematical topics and programs: General Math Cheat Sheet (iPaper and other formats) Elementary Algebra Cheat Sheet (PDF) Trigonometry Cheat Sheet (PDF) Calculus Cheat Sheet (PDF) Derivatives and Integrals Cheat Sheet [...]<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://math-blog.com/2008/09/20/13-useful-math-cheat-sheets/' addthis:title='13 Useful Math Cheat Sheets ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>
Possibly related articles:<ol>
<li><a href='http://math-blog.com/2007/12/04/where-math-blog-is-headed/' rel='bookmark' title='Where Math-Blog is headed'>Where Math-Blog is headed</a></li>
<li><a href='http://math-blog.com/2007/06/04/a-10-minute-tutorial-for-solving-math-problems-with-maxima/' rel='bookmark' title='A 10 minute tutorial for solving Math problems with Maxima'>A 10 minute tutorial for solving Math problems with Maxima</a></li>
<li><a href='http://math-blog.com/2007/06/02/3-awesome-free-math-programs/' rel='bookmark' title='3 awesome free Math programs'>3 awesome free Math programs</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://math-blog.com/2008/09/20/13-useful-math-cheat-sheets/' addthis:title='13 Useful Math Cheat Sheets '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div><p>Cheat sheets can be very useful and make for great posters around your room. The following is a collection of 13 cheat sheets for several mathematical topics and programs:</p>
<ol>
<li><a href="http://www.scribd.com/doc/4549/Math-cheat-sheet-by-Dr-Seiden">General Math Cheat Sheet</a> (iPaper and other formats)</li>
<li><a href="http://tutorial.math.lamar.edu/pdf/Algebra_Cheat_Sheet.pdf">Elementary Algebra Cheat Sheet</a> (PDF)</li>
<li><a href="http://tutorial.math.lamar.edu/pdf/Trig_Cheat_Sheet.pdf">Trigonometry Cheat Sheet</a> (PDF)</li>
<li><a href="http://tutorial.math.lamar.edu/pdf/Calculus_Cheat_Sheet_All.pdf">Calculus Cheat Sheet</a> (PDF)</li>
<li><a href="http://tutorial.math.lamar.edu/pdf/Common_Derivatives_Integrals.pdf">Derivatives and Integrals Cheat Sheet</a> (PDF)</li>
<li><a href="http://tutorial.math.lamar.edu/pdf/Laplace_Table.pdf">Laplace Transforms Cheat Sheet</a> (PDF)</li>
<li><a href="http://www.glump.net/content/abstract_algebra_cheat">Abstract Algebra Cheat Sheet</a> (PDF)</li>
<li><a href="http://kom.aau.dk/project/sipcom/SIPCom06/semester7/FP7-5/prob-cheat-sheet.pdf">Probability Theory Cheat Sheet</a> (PDF)</li>
<li><a href="http://web.mit.edu/18.06/www/MATLAB/matlab-cheatsheet.pdf">Matlab Cheat Sheet</a> (PDF)</li>
<li><a href="http://www.uoregon.edu/~joe/mathematica-cheat-sheet.pdf">Mathematica Cheat Sheet</a> (PDF)</li>
<li><a href="http://math.mtsac.edu/resources/maple11_cheatsheet1.pdf">Maple Cheat Sheet</a> (PDF)</li>
<li><a href="http://math-blog.com/2007/06/04/a-10-minute-tutorial-for-solving-math-problems-with-maxima/">Maxima Cheat Sheet</a> (HTML web page)</li>
<li><a href="http://stdout.org/~winston/latex/">LaTeX Cheat Sheet</a> (several formats)</li>
</ol>
<p>And since most of us like to show our math pride off when out and about as well, Amazon sells this awesome <a href="http://math-blog.com/go/?B000QHGDSU">Math Cheat Sheet T-shirt</a><img src="http://www.assoc-amazon.com/e/ir?t=antoniocangia-20&#038;l=as2&#038;o=1&#038;a=B000QHGDSU" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> with formulas on both sides (Also available for <a href="http://math-blog.com/go/?B000QHEPL2">Science</a> and <a href="http://math-blog.com/go/?B001CP5UGG">Engineering</a>). How awesome is this? <img src='http://math-blog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p align="center"><a href="http://math-blog.com/go/?B000QHGDSU"><img src="http://math-blog.com/wp-content/uploads/2008/09/math-t-shirt.jpg" alt="Math Cheat Sheet T-shirt" title="How awesome is this?" border="0" /></a>
</p>
<p><strong>Sponsor&#8217;s message</strong>: Looking for online algebra homework solutions? <a href="http://www.assignmentexpert.com/math/algebra.html">Algebra help</a> at AssignmentExpert.com! Solve your problems right now.</p>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://math-blog.com/2008/09/20/13-useful-math-cheat-sheets/' addthis:title='13 Useful Math Cheat Sheets ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div><p>Possibly related articles:<ol>
<li><a href='http://math-blog.com/2007/12/04/where-math-blog-is-headed/' rel='bookmark' title='Where Math-Blog is headed'>Where Math-Blog is headed</a></li>
<li><a href='http://math-blog.com/2007/06/04/a-10-minute-tutorial-for-solving-math-problems-with-maxima/' rel='bookmark' title='A 10 minute tutorial for solving Math problems with Maxima'>A 10 minute tutorial for solving Math problems with Maxima</a></li>
<li><a href='http://math-blog.com/2007/06/02/3-awesome-free-math-programs/' rel='bookmark' title='3 awesome free Math programs'>3 awesome free Math programs</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://math-blog.com/2008/09/20/13-useful-math-cheat-sheets/feed/</wfw:commentRss>
		<slash:comments>35</slash:comments>
		</item>
		<item>
		<title>Getting started with gnuplot</title>
		<link>http://math-blog.com/2008/06/08/getting-started-with-gnuplot/</link>
		<comments>http://math-blog.com/2008/06/08/getting-started-with-gnuplot/#comments</comments>
		<pubDate>Sun, 08 Jun 2008 14:24:02 +0000</pubDate>
		<dc:creator>Antonio Cangiano</dc:creator>
				<category><![CDATA[Applied Math]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Suggested Reading]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[gnuplot]]></category>
		<category><![CDATA[plotting]]></category>

		<guid isPermaLink="false">http://math-blog.com/2008/06/08/getting-started-with-gnuplot/</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://math-blog.com/2008/06/08/getting-started-with-gnuplot/' addthis:title='Getting started with gnuplot '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>gnuplot is an excellent scientific package for visualizing data and plotting functions. Despite its name, it has nothing to do with the GNU project, even though it&#8217;s Open Source and entirely free. This tool is very handy whenever you need to produce production quality graphics from a given data-set (or function). It is no wonder [...]<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://math-blog.com/2008/06/08/getting-started-with-gnuplot/' addthis:title='Getting started with gnuplot ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>
No related posts.]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://math-blog.com/2008/06/08/getting-started-with-gnuplot/' addthis:title='Getting started with gnuplot '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div><p>gnuplot is an excellent scientific package for visualizing data and plotting functions. Despite its name, it has nothing to do with the <span class="caps">GNU</span> project, even though it&#8217;s Open Source and entirely free. This tool is very handy whenever you need to produce production quality graphics from a given data-set (or function). It is no wonder that in its 20+ years of existence, it&#8217;s been employed in all sorts of industries.</p>
<p>Flexible, powerful, and easy to use, gnuplot is not only handy as a stand-alone program but can be used successfully by a variety of programming languages, including but not limited to Ruby, Python and Perl. It has also been adopted as a plotting engine by Open Source programs like Maxima and <span class="caps">GNU</span> Octave. The minimal effort required to learn gnuplot is therefore a very worthwhile endeavor. Being able to visualize things as you analyze data and explore mathematics, is a very useful aid.</p>
<p>gnuplot is cross-platform, and you can <a href="http://sourceforge.net/project/showfiles.php?group_id=2055&#38;package_id=1996&#38;release_id=582819">download it</a> from SourceForge.</p>
<p>Once you have installed gnuplot, you can start the tool by simply running <code>gnuplot</code> from the shell. Getting started with the program is straightforward, given that the most basic functionalities are fairly intuitive. For example, if you wanted to plot the sin(x) function, you could run:</p>
<pre class="mathcode">
gnuplot&gt; plot sin(x)
</pre>
<p align="center"><img src='http://math-blog.com/wp-content/uploads/2008/06/gnuplot1.png' alt='gnuplot1.png' /></p>
<p>gnuplot will automatically decide for you what portions of the function should be visualized (in our case between -10 and 10 on the x axis). If you want to overwrite this, you can specify otherwise, as shown below:</p>
<pre class="mathcode">
gnuplot&gt; plot [-pi:pi] sin(x)
</pre>
<p align="center"><img src='http://math-blog.com/wp-content/uploads/2008/06/gnuplot2.png' alt='gnuplot2.png' /></p>
<p>Similarly, you can customize the plotting, by specifying a range on the y axis:</p>
<pre class="mathcode">
gnuplot&gt; plot [] [-0.5:0.5] sin(x)
</pre>
<p align="center"><img src='http://math-blog.com/wp-content/uploads/2008/06/gnuplot3.png' alt='gnuplot3.png' /></p>
<p>It is also possible to plot several functions at once:</p>
<pre class="mathcode">
gnuplot&gt; plot [-2:2] x, x**2, x**3
</pre>
<p align="center"><img src='http://math-blog.com/wp-content/uploads/2008/06/gnuplot4.png' alt='gnuplot4.png' /></p>
<p>gnuplot can draw all sorts of functions and graphics. For example, the following plots two surfaces:</p>
<pre class="mathcode">
gnuplot&gt; splot x**2+y**2, x**2-y**2
</pre>
<p align="center"><img src='http://math-blog.com/wp-content/uploads/2008/06/gnuplot5.png' alt='gnuplot5.png' /></p>
<p>What you see plotted above, is based on a sensible set of defaults, but gnuplot offers countless options to customize the appearance of your graphics.</p>
<p>gnuplot isn&#8217;t just useful for plotting mathematical functions. I often use it for plotting data that is stored in tabular format in simple text formats. For example, assume that you have collected the following data on Deaths by Major Causes in the US, from a website:</p>
<h3 align="center"><a href='http://math-blog.com/wp-content/uploads/2008/06/stats.txt' title='stats.txt'>stats.txt</a></h3>
<p>That&#8217;s a big chunk of data, but it&#8217;s not very easy to analyze. It&#8217;d be nice to be able to visualize it. Assuming you saved it in a <code>stats.txt</code> file (you can include or remove the first few lines of comments) from gnuplot you can run the following:</p>
<pre class="mathcode">
gnuplot&gt; plot "stats.txt"
</pre>
<p align="center"><img src='http://math-blog.com/wp-content/uploads/2008/06/gnuplot6.png' alt='gnuplot6.png' /></p>
<p>That&#8217;s a meaningless mess. But gnuplot is very flexible, so we can easily do much better. Let&#8217;s use the first column for x values, and each of the remaining columns as a curve of its own by running:</p>
<pre class="mathcode">

gnuplot&gt; plot "stats.txt" using 1:2 title "Heart disease" with lines, "stats.txt" using 1:3 title "Cancer" with lines, "stats.txt" using 1:4 title "Cerebro-vascular diseases" with lines, "stats.txt" using 1:5 title "Lower respiratory diseases" with lines, "stats.txt" using 1:6 title "Diabetes mellitus" with lines, "stats.txt" using 1:7 title "Influenza and pneumonia" with lines, "stats.txt" using 1:8 title "Chronic liver disease" with lines, "stats.txt" using 1:9 title "Accidents" with lines, "stats.txt" using 1:10 title "Suicide" with lines, "stats.txt" using 1:11 title "Homicide" with lines
</pre>
<p>Or it&#8217;s abbreviated version:</p>
<pre class="mathcode">
gnuplot&gt; plot "stats.txt" u 1:2 title "Heart disease" w l, "" u 1:3 title "Cancer" w l, "" u 1:4 title "Cerebro-vascular diseases" w l, "" u 1:5 title "Lower respiratory diseases" w l, "" u 1:6 title "Diabetes mellitus" w l, "" u 1:7 title "Influenza and pneumonia" w l, "" u 1:8 title "Chronic liver disease" w l, "" u 1:9 title "Accidents" w l, "" u 1:10 title "Suicide" w l, "" u 1:11 title "Homicide" w l
</pre>
<p align="center"><img src='http://math-blog.com/wp-content/uploads/2008/06/gnuplot7.png' alt='gnuplot7.png' /></p>
<p>Much better! Of course, the command above has a bit of repetition in it, but it&#8217;s justified by the flexibility of being able to pull data from different files if required, and plot some data with lines and others without (or in different styles) if we want to. To improve the appearance and legibility of the chart, let&#8217;s add a grid:</p>
<pre class="mathcode">
gnuplot&gt; set grid
gnuplot&gt; replot
</pre>
<p align="center"><img src='http://math-blog.com/wp-content/uploads/2008/06/gnuplot8.png' alt='gnuplot8.png' /></p>
<p>Nice! And notice how the <code>replot</code> command runs the last plotting directive for us, saving us some typing (or scrolling through the previous commands). To improve this further, we can also set the labels for the axis and a title for the whole chart:</p>
<pre class="mathcode">
gnuplot&gt; set xlabel "Years"
gnuplot&gt; set ylabel "Death rates per 100,000 people"
gnuplot&gt; set title "Deaths by Major Causes, 1960–2005"
gnuplot&gt; replot
</pre>
<p align="center"><img src='http://math-blog.com/wp-content/uploads/2008/06/gnuplot9.png' alt='gnuplot9.png' /><br/>(Click <a href='http://math-blog.com/wp-content/uploads/2008/06/gnuplot10.png' alt='gnuplot10.png'>here</a> for a larger version)</p>
<p>Effortlessly, we went from having some data in a text file, to a meaningful, and professional looking chart that could be used in an article or a book. Not bad. You can save it in your favorite format, by setting the output file name and the terminal type. In the example below, I specify the font type, size and its location on my Mac <span class="caps">OS X</span> system, but it&#8217;s entirely optional. If missing, the default fonts apply.</p>
<pre class="mathcode">
gnuplot&gt; set output "mychart.png"
gnuplot&gt; set terminal png font "/Library/Fonts/Times New Roman.ttf, 11"
gnuplot&gt; replot
</pre>
<p>This very short introduction should you give you a glimpse into what gnuplot can do for you, and even get you started with the tool. But gnuplot is much more than this and infinitely customizable, so you really may want to consider learning more about it. Unfortunately, despite being widely used for more than a decade, gnuplot has never had a book published about it.</p>
<p><a href="http://www.amazon.com/gp/product/1933988398?ie=UTF8&#38;tag=antoniocangia-20&#38;linkCode=as2&#38;camp=1789&#38;creative=9325&#38;creativeASIN=1933988398"><img src='http://math-blog.com/wp-content/uploads/2008/06/gnuplot.jpg' alt='gnuplot.jpg' align="right" /></a>Thankfully, <a href="http://www.manning.com/affiliate/idevaffiliate.php?id=980_0_3_14">Manning Publications</a> will be putting out a book called <a href="http://www.amazon.com/gp/product/1933988398?ie=UTF8&#38;tag=antoniocangia-20&#38;linkCode=as2&#38;camp=1789&#38;creative=9325&#38;creativeASIN=1933988398">Gnuplot in Action</a> in October. The good news is that you don&#8217;t have to wait for the dead tree version, you can <a href="http://manning.com/janert/">purchase it today</a> through the Manning Early Access Program (MEAP). 12 out of the 15 chapters are already available, so the book is pretty much complete. If you&#8217;re interested in making the best out of gnuplot, this book is a must have. You don&#8217;t have to be a mathematician or a programmer to follow along, and it&#8217;s so much more than a bunch of options for customizing your graphics. The book guides you through the best techniques for taking advantage of the tool in several common scenarios. By reading, this easy to follow book, you&#8217;ll be able to generate colorful, nifty plots and have good mastery of the tool in a very short amount of time.</p>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://math-blog.com/2008/06/08/getting-started-with-gnuplot/' addthis:title='Getting started with gnuplot ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div><p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://math-blog.com/2008/06/08/getting-started-with-gnuplot/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Polynomial Root-finding with the Jenkins-Traub Algorithm</title>
		<link>http://math-blog.com/2008/03/06/polynomial-root-finding-with-the-jenkins-traub-algorithm/</link>
		<comments>http://math-blog.com/2008/03/06/polynomial-root-finding-with-the-jenkins-traub-algorithm/#comments</comments>
		<pubDate>Thu, 06 Mar 2008 12:25:26 +0000</pubDate>
		<dc:creator>David Binner</dc:creator>
				<category><![CDATA[Applied Math]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://math-blog.com/2008/03/06/polynomial-root-finding-with-the-jenkins-traub-algorithm/</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://math-blog.com/2008/03/06/polynomial-root-finding-with-the-jenkins-traub-algorithm/' addthis:title='Polynomial Root-finding with the Jenkins-Traub Algorithm '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>The Jenkins-Traub Algorithm is a standard in the field of numerical computation of polynomial roots, fundamentally developed as a numerical algorithm specifically for the task of computing polynomial roots. In other words, (i) because it was planned from the outset for numerical purposes rather than being simply an adaptation of an analytic formula, it is [...]<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://math-blog.com/2008/03/06/polynomial-root-finding-with-the-jenkins-traub-algorithm/' addthis:title='Polynomial Root-finding with the Jenkins-Traub Algorithm ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>
No related posts.]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style " addthis:url='http://math-blog.com/2008/03/06/polynomial-root-finding-with-the-jenkins-traub-algorithm/' addthis:title='Polynomial Root-finding with the Jenkins-Traub Algorithm '  ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div><p>The Jenkins-Traub Algorithm is a standard in the field of numerical computation of polynomial roots, fundamentally developed as a numerical algorithm specifically for the task of computing polynomial roots. In other words, (i) because it was planned from the outset for numerical purposes rather than being simply an adaptation of an analytic formula, it is extremely robust, effectively minimizing the effects of computer round-off error, while (ii) also being extremely efficient compared to more general methods <em>not</em> written specifically for the task of computing polynomial roots; in fact, the algorithm converges to polynomial roots at a rate better than quadratic. Furthermore, since being introduced over thirty years ago, the algorithm has had time to be rigorously tested and has successfully proven its quality; as a result, it has gained a wide distribution as evidenced by its incorporation in commercial software products and the posting on the NETLIB website of source code for programs based on the algorithm.</p>
<h3>An Introduction to the Field of Root-finding</h3>
<p>Given a function which is defined in terms of one or more independent variables, the roots (also called zeros) of the equation are the values of the independent variable(s) for which the function equals <img src='http://math-blog.com/wp-content/latex/pictures/cfcd208495d565ef66e7dff9f98764da.png' title='0' alt='0' align=absmiddle>:</p>
<p align="center"><img src='http://math-blog.com/wp-content/latex/pictures/2b804bc8cc579fff69a79ed72e5ecbbf.png' title='\displaystyle f(z1, z2, z3, z4, z5, . . . ) = 0' alt='\displaystyle f(z1, z2, z3, z4, z5, . . . ) = 0' align=absmiddle></p>
<p>Note that, in general, the z values are complex numbers, comprised of real and imaginary components (indicated by the <img src='http://math-blog.com/wp-content/latex/pictures/865c0c0b4ab0e063e5caa3387c1a8741.png' title='i' alt='i' align=absmiddle>): <img src='http://math-blog.com/wp-content/latex/pictures/b727a8c635e22f761f8c2f2860382285.png' title='z = x + iy' alt='z = x + iy' align=absmiddle>.</p>
<p>Consider the following equation:</p>
<p align="center"><img src='http://math-blog.com/wp-content/latex/pictures/cc5893767180f79d786943b95ab4a6f1.png' title='\displaystyle 2z_{1} + 0.5z_{2}z_{3} + 3.14z_{4}^{2}+1.414\ln(z_{5})=23' alt='\displaystyle 2z_{1} + 0.5z_{2}z_{3} + 3.14z_{4}^{2}+1.414\ln(z_{5})=23' align=absmiddle></p>
<p>The values of <img src='http://math-blog.com/wp-content/latex/pictures/f48108908e4ffd156fa7e01b11ef6abf.png' title='z_{1}, z_{2}, z_{3}, z_{4}' alt='z_{1}, z_{2}, z_{3}, z_{4}' align=absmiddle> and <img src='http://math-blog.com/wp-content/latex/pictures/346b9511eb97f9d0bb57f679b6579ce3.png' title='z_{5}' alt='z_{5}' align=absmiddle> which satisfy this equation may not be possible by analytical methods, so the equation would be rearranged into the following form:</p>
<p align="center"><img src='http://math-blog.com/wp-content/latex/pictures/8083fd03025f3a1c7c91ff097935a51e.png' title='\displaystyle 2z_{1} + 0.5z_{2}z_{3} + 3.14z_{4}^{2}+1.414\ln(z_{5}) &amp;#8211; 23 = 0' alt='\displaystyle 2z_{1} + 0.5z_{2}z_{3} + 3.14z_{4}^{2}+1.414\ln(z_{5}) &amp;#8211; 23 = 0' align=absmiddle></p>
<p>which is of the form</p>
<p align="center"><img src='http://math-blog.com/wp-content/latex/pictures/6dd9f4528959b0b076d1c0a04ff9033f.png' title='\displaystyle f(z1, z2, z3, z4, z5) = 0' alt='\displaystyle f(z1, z2, z3, z4, z5) = 0' align=absmiddle></p>
<p>Once in this form (the standard form), solving the original equation becomes a matter of finding the <img src='http://math-blog.com/wp-content/latex/pictures/f48108908e4ffd156fa7e01b11ef6abf.png' title='z_{1}, z_{2}, z_{3}, z_{4}' alt='z_{1}, z_{2}, z_{3}, z_{4}' align=absmiddle> and <img src='http://math-blog.com/wp-content/latex/pictures/346b9511eb97f9d0bb57f679b6579ce3.png' title='z_{5}' alt='z_{5}' align=absmiddle> values for which f equals <img src='http://math-blog.com/wp-content/latex/pictures/cfcd208495d565ef66e7dff9f98764da.png' title='0' alt='0' align=absmiddle>, and well-developed fields of mathematics and computer science provide several root-finding techniques for solving such a problem. Note that since the theme of this article is polynomial root-finding, further examples will focus on single-variable equations, specifically, polynomials.</p>
<h3>Analytical Root-finding Techniques</h3>
<p>Consider the following quadratic equation:</p>
<p align="center"><img src='http://math-blog.com/wp-content/latex/pictures/b9b78a6e79ea0de4886f22f259ce67e9.png' title='\displaystyle f(z) = z^{2} + z &amp;#8211; 2' alt='\displaystyle f(z) = z^{2} + z &amp;#8211; 2' align=absmiddle></p>
<p>This equation is a second-degree polynomial–the highest power applied to the independent variable is 2. Consequently, this equation has two roots; an n-degree polynomial equation has n roots.</p>
<p>Because the equation is a simple polynomial, a first approach to finding its zeros might be to put the equation into the form <img src='http://math-blog.com/wp-content/latex/pictures/9e4f61c0a413b8b4f9d4aa56cdfb32c9.png' title='(z &amp;#8211; \alpha_{1})(z &amp;#8211; \alpha_{2})' alt='(z &amp;#8211; \alpha_{1})(z &amp;#8211; \alpha_{2})' align=absmiddle> and make a few educated guesses; a person could quickly determine that <img src='http://math-blog.com/wp-content/latex/pictures/ccc03b346b44565b8b1f6642caee2b62.png' title='\alpha_{1} = 1' alt='\alpha_{1} = 1' align=absmiddle> (a strictly real result) is one root of this equation. This root could then be divided out of the original polynomial</p>
<p align="center"><img src='http://math-blog.com/wp-content/latex/pictures/a37a42e471e3d8ececc490761dc1c044.png' title='\displaystyle \frac{(z^{2} + z -2)}{(z-1)} = (z+2) ' alt='\displaystyle \frac{(z^{2} + z -2)}{(z-1)} = (z+2) ' align=absmiddle></p>
<p>to yield the second root: <img src='http://math-blog.com/wp-content/latex/pictures/734fab7699f5c3a97bca37c543be7268.png' title='\alpha_{2} = -2' alt='\alpha_{2} = -2' align=absmiddle>.</p>
<p>In this simple example, the two roots were found easily; the second root was found immediately after the first one was known. However, in most real-world problems the roots of a quadratic are not found so easily. Furthermore, in problems where the original polynomial is of degree greater than two, when one root is found, the other roots do not follow immediately &#8212; more sophisticated techniques are required. </p>
<p>Among the techniques available are analytical ones, in other words, techniques that yield explicit, algebraic results. For example, in the case of a quadratic equation, explicit expressions for the two roots are possible via the Quadratic Formula: once a quadratic equation is arranged into the standard form</p>
<p align="center"><img src='http://math-blog.com/wp-content/latex/pictures/89ac0d991f93510c4e7fbba280082a98.png' title='\displaystyle \bold{a}z^{2} + \bold{b}z + \bold{c} = 0' alt='\displaystyle \bold{a}z^{2} + \bold{b}z + \bold{c} = 0' align=absmiddle></p>
<p>(<strong>a</strong>, <strong>b</strong> and <strong>c</strong> are known constants), the two roots are found via the Quadratic Formula:</p>
<p align="center"><img src='http://math-blog.com/wp-content/latex/pictures/82241ed6257a1a3939f33b8d9e92f71c.png' title='\displaystyle \alpha = \frac{{ &amp;#8211; b \pm \sqrt {b^2 &amp;#8211; 4ac} }}{{2a}}' alt='\displaystyle \alpha = \frac{{ &amp;#8211; b \pm \sqrt {b^2 &amp;#8211; 4ac} }}{{2a}}' align=absmiddle></p>
<p>The quantity within the square root sign <img src='http://math-blog.com/wp-content/latex/pictures/97c82e3b28c485dd963572b7d61f93d8.png' title='(b^2 &amp;#8211; 4ac)' alt='(b^2 &amp;#8211; 4ac)' align=absmiddle> is called the discriminant and determines whether the solution is complex or strictly real. If the discriminant is less than <img src='http://math-blog.com/wp-content/latex/pictures/cfcd208495d565ef66e7dff9f98764da.png' title='0' alt='0' align=absmiddle>, the numerator contains an imaginary component and the roots are, therefore, complex. If the discriminant is greater than or equal to <img src='http://math-blog.com/wp-content/latex/pictures/cfcd208495d565ef66e7dff9f98764da.png' title='0' alt='0' align=absmiddle>, the solutions are real. In fact, if the discriminant is <img src='http://math-blog.com/wp-content/latex/pictures/cfcd208495d565ef66e7dff9f98764da.png' title='0' alt='0' align=absmiddle>, the two roots are real and equal:</p>
<p align="center"><img src='http://math-blog.com/wp-content/latex/pictures/11098b603eb9b58104dc3a7b6a0229d4.png' title='\displaystyle \alpha_{1} = \frac{{ &amp;#8211; b + \sqrt {0} }}{{2a}} = \frac{-b}{2a}' alt='\displaystyle \alpha_{1} = \frac{{ &amp;#8211; b + \sqrt {0} }}{{2a}} = \frac{-b}{2a}' align=absmiddle></p>
<p align="center"><img src='http://math-blog.com/wp-content/latex/pictures/564dc61e8cedca34e66db4b4b756f337.png' title='\displaystyle \alpha_{2} = \frac{{ &amp;#8211; b &amp;#8211; \sqrt {0} }}{{2a}} = \frac{-b}{2a}' alt='\displaystyle \alpha_{2} = \frac{{ &amp;#8211; b &amp;#8211; \sqrt {0} }}{{2a}} = \frac{-b}{2a}' align=absmiddle></p>
<p>In addition to the Quadratic Formula for quadratic equations, analogous formulae exist for polynomials of degree three and four. However, for polynomials of degree five and higher, analytical solutions are not possible (except in special cases), only numerical solutions are possible.</p>
<h3>Numerical Root-finding Techniques</h3>
<p>For the multitude of real-world problems that are not amenable to an analytical solution, numerical root-finding is a well-developed field offering a wide variety of tools from which to choose; many computer programs written for the computation of roots are based on algorithms that make them applicable to the computation of roots of functions in addition to polynomials, and virtually all of them employ an iterative approach that terminates once the desired degree of tolerance has been achieved. For example, the bisection method is a simple and reliable method for computing roots of a function <em>when they are known ahead of time to be real only</em>. The algorithm starts with the assumption that a zero is somewhere on a user-supplied interval [a,b]. In other words, the function value f(a) is of the opposite sign of f(b) – in going from a to b, f either goes from being positive to being negative, or it goes from being negative to being positive. A point, m, in the middle of the interval [a,b] is then selected. The function is evaluated at point m: f(m). If the sign of f(m) is the same as the sign of f(a), the desired zero is not in the interval [a,m]. In this case, the interval is cut in half and the new interval becomes [m,b]. On the other hand, if the sign of f(m) is not the same as the sign of f(a), the desired zero is in the interval [a,m]. In this case, the interval is cut in half and the new interval becomes [a,m]. This process is repeated until either the interval converges to a desired tolerance or a value of f is found that is within an acceptable tolerance, in which case the value of z at this point is the value returned by the program as the root.</p>
<p>In addition to the bisection method, more elegant–and faster converging–techniques are available: the False Position method, Brent’s method, the Newton-Raphson method, the secant method, and others. The Newton-Raphson method uses the function and its derivative to quickly converge to a solution. This method is good for situations in which the derivatives are either known or can be calculated with a low computational cost. In other situations, the cost of computing derivatives may be too high. The secant method, by comparison, does not require the use of derivatives, but the calculation of each iterate requires the use of the <em>two previous iterates</em> and does not converge to a solution as quickly as the Newton-Raphson method. In some situations, this method, too, may be deemed impractical. Usually, when some thought is given to a problem, a particular technique can be applied to it that is more appropriate than another. In fact, for some problems, one technique may fail to find a solution at all, whereas another technique will succeed. For other problems, several techniques may, indeed, be able to solve the problem and the numerical analyst may select the one that is simply more computationally efficient.</p>
<h3>The Jenkins-Traub Algorithm</h3>
<p>The field of numerical root-finding is so well-developed that the use of a good-quality numerical program is recommended &#8212; when numerical results are sought &#8212; even when an analytical solution to a problem is known. In other words, even though an analytical solution to, say, the quartic equation exists, writing a computer program that simply implements the textbook formula is not recommended; computer round-off errors often render results of such programs meaningless. The use of a robust numerical program, based upon sound theory and an excellent algorithm, and coded to thoroughly deal with computer round-off errors, is the recommended action. The Jenkins-Traub Algorithm is such an algorithm; it is a three-stage, extremely effective, globally convergent algorithm designed specifically for computing the roots of polynomials.</p>
<p>Stage One is the “No Shift” stage; the main purpose of this stage is to accentuate the smaller zeros. The search for a zero is started by taking an initial guess of <img src='http://math-blog.com/wp-content/latex/pictures/cfcd208495d565ef66e7dff9f98764da.png' title='0' alt='0' align=absmiddle> for a fixed number, M, of iterations (M is usually assigned the value 5 on the basis of numerical experience<sup>(1)</sup>).</p>
<p>Stage Two is the “Fixed Shift” stage, the purpose of this stage is to separate zeros of equal or almost equal magnitude. As a starting point in this stage, the following value is used:</p>
<p align="center"><img src='http://math-blog.com/wp-content/latex/pictures/a17d4817f819d2516528794f29116712.png' title='\displaystyle s = \beta e^{i\theta}' alt='\displaystyle s = \beta e^{i\theta}' align=absmiddle></p>
<p><img src='http://math-blog.com/wp-content/latex/pictures/b0603860fcffe94e5b8eec59ed813421.png' title='\beta' alt='\beta' align=absmiddle> is a lower bound on the magnitudes of the probable zeros in the cluster. <img src='http://math-blog.com/wp-content/latex/pictures/2554a2bb846cffd697389e5dc8912759.png' title='\theta' alt='\theta' align=absmiddle> could be taken at random, since the cluster could be anywhere in the complex plane; however, in practice <img src='http://math-blog.com/wp-content/latex/pictures/2554a2bb846cffd697389e5dc8912759.png' title='\theta' alt='\theta' align=absmiddle> is usually initialized to 49°, putting s near the middle of the first quadrant of the complex plane. After a certain number of iterations, if s does not converge to a root, s is assigned a new value by increasing <img src='http://math-blog.com/wp-content/latex/pictures/2554a2bb846cffd697389e5dc8912759.png' title='\theta' alt='\theta' align=absmiddle> by 94°. Repeated attempts would have the search for a root start with points in all four quadrants of the complex plane until the search is returned to the first quadrant. Should the search, indeed, return to the first quadrant, successive cycles start at points 16° away from the starting point of the preceding cycle.</p>
<p>Stage Three is the “Variable Shift” stage, which is terminated when the computed value of the polynomial at a possible zero is less than or equal to a specified bound.</p>
<p>In addition to the three fundamental stages around which it was developed, the Jenkins-Traub Algorithm incorporates several other techniques for making it as effective as possible. One of those techniques is deflation of the polynomial by synthetic division each time a root is found. Consider the following monic polynomial:</p>
<p align="center"><img src='http://math-blog.com/wp-content/latex/pictures/d78b69de13e52f23f28ed8ab7dd43b80.png' title='\displaystyle z^n + \bold{a_{n-1}}z^{n-1}+ \bold{a_{n-2}}z^{n-2}+\bold{a_{n-3}}z^{n-3} + \ldots + \bold{a_{1}}z + \bold{a_0} = 0' alt='\displaystyle z^n + \bold{a_{n-1}}z^{n-1}+ \bold{a_{n-2}}z^{n-2}+\bold{a_{n-3}}z^{n-3} + \ldots + \bold{a_{1}}z + \bold{a_0} = 0' align=absmiddle></p>
<p>The <img src='http://math-blog.com/wp-content/latex/pictures/9dc419bbb9a662a4678c1a090acd668c.png' title='\bold{a_i}' alt='\bold{a_i}' align=absmiddle> are known constants and, in general, are complex. Now say the root <img src='http://math-blog.com/wp-content/latex/pictures/e6fd76724530625061d5edb4b37fe257.png' title='z_1' alt='z_1' align=absmiddle> (<img src='http://math-blog.com/wp-content/latex/pictures/b044195a617bae36d2ea389baf6ad1b3.png' title='z_1 = x + iy' alt='z_1 = x + iy' align=absmiddle>) has been found. Synthetic division would be employed to divide that root out of the original polynomial:</p>
<p align="center"><img src='http://math-blog.com/wp-content/latex/pictures/90adf190f9f943d12e34c6cfafebc608.png' title='\displaystyle \frac{z^n + \bold{a_{n-1}}z^{n-1}+ \bold{a_{n-2}}z^{n-2}+\bold{a_{n-3}}z^{n-3} + \ldots + \bold{a_0}}{z-z_1}' alt='\displaystyle \frac{z^n + \bold{a_{n-1}}z^{n-1}+ \bold{a_{n-2}}z^{n-2}+\bold{a_{n-3}}z^{n-3} + \ldots + \bold{a_0}}{z-z_1}' align=absmiddle></p>
<p>to yield</p>
<p align="center"><img src='http://math-blog.com/wp-content/latex/pictures/ebe14e56a45d07eb50e18649cac4a5b0.png' title='\displaystyle \bold{b_{n-1}}z^{n-1}+ \bold{b_{n-2}}z^{n-2}+\bold{a_{b-3}}z^{n-3} + \ldots + \bold{b_0}' alt='\displaystyle \bold{b_{n-1}}z^{n-1}+ \bold{b_{n-2}}z^{n-2}+\bold{a_{b-3}}z^{n-3} + \ldots + \bold{b_0}' align=absmiddle></p>
<p>The <img src='http://math-blog.com/wp-content/latex/pictures/958c9df940865912aa44359f510d0bcb.png' title='\bold{b_i}' alt='\bold{b_i}' align=absmiddle> are new constants. The root-finding process is then repeated on this new–simpler–polynomial. As each root is found, the polynomial becomes successively simpler and each successive iteration of the algorithm involves, in general, fewer computations.</p>
<p>For polynomials whose coefficients are real only, when a complex root is found (<img src='http://math-blog.com/wp-content/latex/pictures/b044195a617bae36d2ea389baf6ad1b3.png' title='z_1 = x + iy' alt='z_1 = x + iy' align=absmiddle>), an additional benefit arises: that root’s complex conjugate is also a root (<img src='http://math-blog.com/wp-content/latex/pictures/6bf0ab67689444dad49d73a309081cd8.png' title='z_2 = x &amp;#8211; iy' alt='z_2 = x &amp;#8211; iy' align=absmiddle>). In other words, two roots are computed &#8212; and the polynomial can be deflated by two degrees &#8212; in a single iteration of the algorithm. Furthermore, this deflation involves real only, rather than complex, operations; the product of these two roots is a real quadratic equation:</p>
<p align="center"><img src='http://math-blog.com/wp-content/latex/pictures/6dfd03f78475370818be38162000298c.png' title='\displaystyle (z-z_1)(z &amp;#8211; z_2) = z^2 &amp;#8211; 2xz + (x^2 + y^2)' alt='\displaystyle (z-z_1)(z &amp;#8211; z_2) = z^2 &amp;#8211; 2xz + (x^2 + y^2)' align=absmiddle></p>
<p>In this case, synthetic division is employed on the polynomial as follows:</p>
<p align="center"><img src='http://math-blog.com/wp-content/latex/pictures/90b918315bc65445b66052e03352413f.png' title='\displaystyle \frac{z^n + \bold{a_{n-1}}z^{n-1}+ \bold{a_{n-2}}z^{n-2}+\bold{a_{n-3}}z^{n-3} + \ldots + \bold{a_0}}{z^2 &amp;#8211; 2xz + (x^2 + y^2)}' alt='\displaystyle \frac{z^n + \bold{a_{n-1}}z^{n-1}+ \bold{a_{n-2}}z^{n-2}+\bold{a_{n-3}}z^{n-3} + \ldots + \bold{a_0}}{z^2 &amp;#8211; 2xz + (x^2 + y^2)}' align=absmiddle></p>
<p>In fact, for computing roots of polynomials which have only real coefficients, a modified version of the Jenkins-Traub Algorithm has been written which incorporates several features that take advantage of the characteristics of real-only polynomials to yield significant decreases in program execution time; “If the complex and real algorithms are applied to the same real polynomial, the real algorithm is about four times as fast.”<sup>(4)</sup> </p>
<p>The Jenkins-Traub Algorithm not only deflates the polynomial as roots are computed, it computes the roots roughly in order of increasing magnitude. This approach is taken because deflation of a polynomial can be unstable unless done by factors in order of increasing magnitude. By starting the search for roots with an initial guess of <img src='http://math-blog.com/wp-content/latex/pictures/cfcd208495d565ef66e7dff9f98764da.png' title='0' alt='0' align=absmiddle>, as is done in Stage One, roots are, indeed, computed roughly in order of increasing magnitude, the factors by which the polynomial is successively deflated are roughly in order of increasing magnitude &#8212; the deflation of the polynomial is made quite stable.</p>
<p>As a quick check of the effectiveness of the Jenkins-Traub Algorithm, consider a contrived numerical example:</p>
<p align="center"><img src='http://math-blog.com/wp-content/latex/pictures/ccb185ab0562e4fedfd871097ff2e89f.png' title='\displaystyle f(z) = (z &amp;#8211; 1.001)(z &amp;#8211; 0.998)(z &amp;#8211; 1.00002)(z &amp;#8211; 0.99999)' alt='\displaystyle f(z) = (z &amp;#8211; 1.001)(z &amp;#8211; 0.998)(z &amp;#8211; 1.00002)(z &amp;#8211; 0.99999)' align=absmiddle></p>
<p>The roots of this polynomial are very close and should test how effectively the algorithm discerns near-multiple roots:</p>
<p align="center">1.001<br /> 0.998<br /> 1.00002<br /> 0.99999</p>
<p>In addition, the polynomial is real-only so that readers may confirm the results with a free, ready-to-use, online Javascript program (URL given below).</p>
<p>Expanded, the test polynomial becomes</p>
<p align="center"><img src='http://math-blog.com/wp-content/latex/pictures/0e6ab8ff4166250a1de4d9a74ed7a00d.png' title='\displaystyle \displaystyle z^{4} &amp;#8211; 3.99901z^{3} + 5.9970279898z^{2} &amp;#8211; 3.9970259795802z +   ' alt='\displaystyle \displaystyle z^{4} &amp;#8211; 3.99901z^{3} + 5.9970279898z^{2} &amp;#8211; 3.9970259795802z +   ' align=absmiddle> <img src='http://math-blog.com/wp-content/latex/pictures/4286687d3ee45b514f43572025d3ff3d.png' title='0.9990079897802004' alt='0.9990079897802004' align=absmiddle></p>
<p>and the solutions computed by the Javascript root-finder follow:</p>
<p align="center">0.9980051486669109<br /> 0.9998618452719573<br /> 1.0001539207016332<br /> 1.0009890853594987</p>
<p>The program, in fact, did a very good job:
<ol>
<li>no errors were returned,</li>
<li>no erroneous imaginary components were found,</li>
<li>four distinct roots were computed, and</li>
<li>the computed roots are extremely close to the exact roots (round-off errors are unavoidable).</li>
</ol>
<h3>Conclusion</h3>
<p>Since its introduction in 1969 (in Michael Jenkins’ PhD thesis) the Jenkins-Traub Algorithm has been rigorously tested and has proven itself as an excellent algorithm for the computation of the roots of polynomials. It is extremely robust, is globally convergent for any distribution of zeros, and converges at a better than quadratic rate. Attesting to its high quality is the fact that source code for programs (written in FORTRAN) based on the algorithm have been posted on the NETLIB site, a repository of high-quality numerical programs; the complex coefficient version is posted as CPOLY (<a href="http://www.netlib.org/toms/419">http://www.netlib.org/toms/419</a>) and a real coefficient only version has been posted as RPOLY (<a href="http://www.netlib.org/toms/493">http://www.netlib.org/toms/493</a>). Translations into C++ and Javascript are also available; for example, Polynomial Root-finder (<a href="http://www.akiti.ca/PolyRootRe.html">http://www.akiti.ca/PolyRootRe.html</a>) is a Javascript translation of RPOLY and has been successfully tested with data published in Jenkins’ PhD thesis. In addition, the algorithm is incorporated in commercial software products (i.e. Mathematica). The proven effectiveness of the Jenkins-Traub Algorithm and its wide-spread distribution make it an extremely important tool in the toolbox of numerical analysts.</p>
<h3>References</h3>
<ol>
<li><a href="http://www.amazon.com/gp/product/048641454X?ie=UTF8&amp;tag=antoniocangia-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=048641454X">&#8220;A First Course in Numerical Analysis: Second Edition&#8221;</a><img src="http://www.assoc-amazon.com/e/ir?t=antoniocangia-20&amp;l=as2&amp;o=1&amp;a=048641454X" width="1" height="1" border="0" alt="" /><br /> Anthony Ralston and Philip Rabinowitz<br /> McGraw-Hill Book Company<br /> New York<br /> 1978</li>
<li> “Numerical Methods and Software”<br /> David Kahaner, Cleve Moler, Stephen Nash<br /> Prentice-Hall, Inc.<br /> Englewood Cliffs, New Jersey<br /> 1989 </li>
<li> “Numerical Recipes. The Art of Scientific Computing.”<br /> William H. Press, Brian P. Flannery, Saul A. Teukolsky, and William T. Vetterling<br /> Cambridge University Press<br /> New York<br /> 1986<br />(<a href="http://www.amazon.com/gp/product/0521880688?ie=UTF8&amp;tag=antoniocangia-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0521880688">3rd edition now available.</a><img src="http://www.assoc-amazon.com/e/ir?t=antoniocangia-20&amp;l=as2&amp;o=1&amp;a=0521880688" width="1" height="1" border="0" alt="" />)</li>
<li>Wikipedia<br /> <a href="http://en.wikipedia.org/wiki/Jenkins-Traub_Algorithm_for_Polynomial_Zeros">Jenkins-Traub Algorithm for Polynomial Zeros</a></li>
<li>Jenkins, M.A. Three-stage variable-shift iterations for the solution of polynomial equations with a posteriori error bounds for the zeros. Diss., Rep. CS 138, Comput. Sci.<br /> Dep., Stanford U., Stanford, Cal., 1969.</li>
</ol>
<p><em>This article was written by David Binner. You can visit his math site at <a href="http://akiti.ca/">http://akiti.ca</a>. If you&#8217;d like to <a href="http://math-blog.com/write-for-us/">write for Math-Blog.com</a>, please email us at <img src='http://math-blog.com/wp-content/latex/pictures/f5af898ddd3b6c56e859cf0444db773c.png' title='submissions@math-blog.com' alt='submissions@math-blog.com' align=absmiddle>.</em></p>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://math-blog.com/2008/03/06/polynomial-root-finding-with-the-jenkins-traub-algorithm/' addthis:title='Polynomial Root-finding with the Jenkins-Traub Algorithm ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div><p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://math-blog.com/2008/03/06/polynomial-root-finding-with-the-jenkins-traub-algorithm/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

