<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0" 
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
  xmlns:admin="http://webns.net/mvcb/"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:content="http://purl.org/rss/1.0/modules/content/">

<channel>
<title>davidbau.com</title>
<link>http://davidbau.com/</link>
<description>A Dabbler&apos;s Weblog</description>
<dc:language>en-us</dc:language>
<dc:creator>david.bau@gmail.com</dc:creator>
<dc:date>2010-06-20T00:18:29-05:00</dc:date>
<admin:generatorAgent rdf:resource="http://www.movabletype.org/?v=2.661" />
<sy:updatePeriod>hourly</sy:updatePeriod>
<sy:updateFrequency>1</sy:updateFrequency>
<sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>

<item>
<title>Tutorial: Root Finder</title>
<link>http://davidbau.com/archives/2010/06/20/tutorial_root_finder.html</link>
<description> A basic similar triangle problem: solve for x2. Because the two triangles are similar we know that the ratios of the lengths are the same: Multiplying through and solving for x2, we get: This formula is the core of...</description>
<guid isPermaLink="false">391@http://davidbau.com/</guid>
<dc:subject></dc:subject>
<content:encoded><![CDATA[<p><img align=right class=img-right width=180 src="/images/graph/secant-triangles.png">
A basic similar triangle problem: solve for <em>x<sub>2</sub></em>.

<p>Because the two triangles are similar we know that the ratios of the lengths are the same:

<p align=center><img style="vertical-align:-11px" src="http://chart.apis.google.com/chart?cht=tx&chl=\frac{x_0-x_2}{y_0}=\frac{x_1-x_2}{y_1}">

<p>Multiplying through and solving for <em>x<sub>2</sub></em>, we get:

<p align=center><img style="vertical-align:-12.5px" src="http://chart.apis.google.com/chart?cht=tx&chl=x_2=\frac{x_0y_1-x_1y_0}{y_1-y_0}">

<p>This formula is the core of an ancient idea for solving arbitrary equations.

<p><b>Getting out of Algebra Homework</b>

<p>In an effort to make an algebra-homework-solver, Anthony recently built a simple root-finder on his own that probed values at constant 0.1-separated values of <em>x</em>, looking for sign changes.

<p>After he worked on it for a long time, he came to me trying to explain the idea, and showing me that it did not work that well because it was too coarse.

<p>So I showed him the secant method, and we <a href="http://dabbler.org/home/01-example/root-finder.html">coded it up as a javascript example here</a>.

<p><b>The Secant Method</b>

<p>Suppose we have already made two incorrect guesses while searching for a zero of a function, and at those two values, the function passes through the points <nobr>(<em>x<sub>0</sub></em>, <em>y<sub>0</sub></em>)</nobr> and <nobr>(<em>x<sub>1</sub></em>, <em>y<sub>1</sub></em>).</nobr>  We could continue making more guesses by crawling along the number line, looking for a sign change or for a point with <em>y</em> values closer to zero.

<p>But the <b>secant method</b> tries to jump straight to the answer by drawing a straight line between the two observations and calculating the point <em>x<sub>2</sub></em> where that line crosses zero, as above.

<p>If the initial guesses are close enough, the method converges very quickly and makes mincemeat out of polynomial root finding.

<p>Hopefully Anthony will continue to work on his algebra homework by hand anyway.

<p><b>History of the Regula Falsi</b>

<p>The secant method is similar to Newton's method but does not require knowledge of derivatives or other calculus.  It is sometimes described as a finite-difference approximation to Newton's method.  However, it actually predates Newton.

<p><a href="http://scholarship.rice.edu/bitstream/handle/1911/20568/1442093.PDF">Joanna Papakonstantinou</a> has unearthed evidence that the secant method was being used by Babylonians and Egyptians in 18th century BC to solve linear relationships and by Chinese scholars to approximate nonlinear relationships in the 2nd century BC.  The idea of drawing a line between two incorrect answers to make a correct answer was called  "the rule of too much and not enough;" "the method of double false positions;" "the method of scales;" or "Regula Falsi."  It made appearances around the world in 9th century Arabic, 11th century European, 12th century Indian, and 13th century African mathematical texts.

<p><a href="http://en.wikipedia.org/wiki/Ars_Magna_(Gerolamo_Cardano)">Cardano</a> documented the modern idea of iterating the method to increase precision arbitrarily.  He used it to solve cubics in his 1545 <em>Ars Magna</em>, one hundred years before Newton was born.]]></content:encoded>
<dc:date>2010-06-20T00:18:29-05:00</dc:date>
</item>
<item>
<title>Wiki Javascript at dabbler.org</title>
<link>http://davidbau.com/archives/2010/05/28/wiki_javascript_at_dabblerorg.html</link>
<description>I have spent a few days teaching kids (a handful of 5th-8th graders) to program in Javascript. Teaching is hard. My conclusions: Kids like graphics. Drawing simple paths in SVG is a big hit. You need to take a little...</description>
<guid isPermaLink="false">390@http://davidbau.com/</guid>
<dc:subject></dc:subject>
<content:encoded><![CDATA[<p>I have spent a few days teaching kids (a handful of 5th-8th graders) to program in Javascript.  Teaching is hard.  My conclusions:</p>

<ul>
<li>Kids like graphics.  Drawing <a href="http://dabbler.org/home/01-example/path.html">simple paths in SVG</a> is a big hit.
<li>You need to take a little time to <a href="http://dabbler.org/home/01-example/brief-poem.html">learn basic HTML</a> before Javascript.
<li>The most frustrating thing for kids is getting their junkware-infested laptops to behave.
<li>Getting set up with a plaintext editor to write code is a steep climb.
</ul>

<p>I am rethinking my little curriculum.  We need a more gradual path that steps through very simple basics before jumping into more exciting things.</p>

<p>To let the kids program directly online I have posted <a href="http://dabbler.org/home/00-about/00-README.html">a collaborative learning-to-program site at dabbler.org</a> that is the simplest possible solution I could think of.</p>

<p>It is wiki in spirit: it is a self-editable website that hosts a syntax coloring programming editor and a bunch of Javascript examples.  It is a single shared collaborative space, and it has no access controls to jump through.  The kids had a terrific time sharing code with each other and stealing each others' ideas.</p>

<p><a href="http://dabbler.org/edit/guest/tryit.html">Try it if you like</a>.  <a href="http://dabbler.org/home/00-about/00-README.html"> Etiquette and explanation here</a>.</p>]]></content:encoded>
<dc:date>2010-05-28T20:43:55-05:00</dc:date>
</item>
<item>
<title>What SAT Stands For</title>
<link>http://davidbau.com/archives/2010/05/11/what_sat_stands_for.html</link>
<description>Today was an MCAS day for my kids (Massachusetts&apos;s standardized testing at school). A little discussion of such tests lead to one of the conversations that my kids hate to have with me: Anthony: &quot;What does SAT stand for?&quot; Me:...</description>
<guid isPermaLink="false">388@http://davidbau.com/</guid>
<dc:subject></dc:subject>
<content:encoded><![CDATA[<p>Today was an MCAS day for my kids (Massachusetts's standardized testing at school).  A little discussion of such tests lead to one of the conversations that my kids hate to have with me:</p>

<p><b>Anthony</b>: "What does SAT stand for?"</p>

<p><b>Me</b>: "SAT Aptitude Test."</p>

<p><b>Anthony</b>: "Hm, but then what does SAT stand for?"</p>

<p><b>Me</b>: "SAT Aptitude Test....  S.A.T.  S - SAT, A - Aptitude, T - Test."</p>

<p><b>Anthony</b>: "But why SAT?"</p>

<p><b>Me</b>: "It tests your aptitude for taking the SAT."</p>

<p><b>Anthony</b>: "I'm just going to look it up on the Internet."</p>

<p><em>(By the way, Anthony, it's true.  Here it is on the Internet, right here.)</em></p>]]></content:encoded>
<dc:date>2010-05-11T22:32:45-05:00</dc:date>
</item>
<item>
<title>Computer Club</title>
<link>http://davidbau.com/archives/2010/05/01/computer_club.html</link>
<description>I have started teaching a computer club for middle-schoolers as a test run. Five kids, grades 5-8, all with some experience programming in Lego or Scratch or something else, now learning Javascript. I want to teach them jQuery and graphics,...</description>
<guid isPermaLink="false">387@http://davidbau.com/</guid>
<dc:subject></dc:subject>
<content:encoded><![CDATA[<p>I have started teaching a computer club for middle-schoolers as a test run.  Five kids, grades 5-8, all with some experience programming in Lego or Scratch or something else, now learning Javascript.  I want to teach them jQuery and graphics, and it is going to be pretty challenging stuff.</p>

<p>Thanks to the ideas from readers of this blog, I am collecting together materials for them that might turn into a book someday.  Here it is: <a href="http://davidbau.com/javascript/learn/00-preface.html">Learning to Program in Javascript</a>.</p>

<p>The guinea pigs this time around are all boys.  The next time around I will teach Piper and her group of girl friends.</p>]]></content:encoded>
<dc:date>2010-05-01T09:31:52-05:00</dc:date>
</item>
<item>
<title>Tutorial: Cannon Game</title>
<link>http://davidbau.com/archives/2010/04/17/tutorial_cannon_game.html</link>
<description>The canonical cannon game in 80 lines of javascript: cannon-game.html (view source). Move the mouse to aim, and click to fire the cannonball. If you hit the target, it gets moved and you can test your artillery skills again. The...</description>
<guid isPermaLink="false">386@http://davidbau.com/</guid>
<dc:subject></dc:subject>
<content:encoded><![CDATA[<p>The canonical cannon game in 80 lines of javascript: <a href="http://davidbau.com/javascript/cannon-game.html">cannon-game.html</a> (<a href="http://davidbau.com/javascript/src/cannon-game.txt">view source</a>).  Move the mouse to aim, and click to fire the cannonball.  If you hit the target, it gets moved and you can test your artillery skills again.</p>

<p>The code uses a bit of trigonometry to aim the cannon and a bit of physics to provide gravity.  It introduces the idea of using timers for animation and hit-testing for collisions.  The gameplay is governed by a three-state state machine with an explicit state variable.</p>

<p>I am still looking for more ideas.  Let me know if you think of any good beginner-programmer exercises that might be able to distilled down to about 80 lines of HTML.</p>]]></content:encoded>
<dc:date>2010-04-17T07:59:30-05:00</dc:date>
</item>
<item>
<title>Tutorial: Pascal&apos;s Triangle</title>
<link>http://davidbau.com/archives/2010/04/17/tutorial_pascals_triangle.html</link>
<description>Arrays can be mysterious if you have never used them before. Here is a simple introduction: pascals-triangle.html (view source). Click on the button to compute and display the next row of Pascal&apos;s triangle. Useful for figuring out how many ways...</description>
<guid isPermaLink="false">385@http://davidbau.com/</guid>
<dc:subject></dc:subject>
<content:encoded><![CDATA[<p>Arrays can be mysterious if you have never used them before.  Here is a simple introduction: <a href="http://davidbau.com/javascript/pascals-triangle.html">pascals-triangle.html</a> (<a href="http://davidbau.com/javascript/src/pascals-triangle.txt">view source</a>).</p>

<p>Click on the button to compute and display the next row of Pascal's triangle.  Useful for figuring out how many ways to you can divide up kids into teams or for expanding powers of a binomial.</p>]]></content:encoded>
<dc:date>2010-04-17T07:59:00-05:00</dc:date>
</item>
<item>
<title>Tutorial: Custom Poem</title>
<link>http://davidbau.com/archives/2010/04/16/tutorial_custom_poem.html</link>
<description>A good candidate &quot;first program.&quot; The kids love custom-poem.html (view source), which uses document.write to produce a one-of-a-kind custom poem just for you. Refresh to get a new poem. The bits of wisdom are generated madlibs-style, by inserting a random...</description>
<guid isPermaLink="false">384@http://davidbau.com/</guid>
<dc:subject></dc:subject>
<content:encoded><![CDATA[<p>A good candidate "first program."</p>

<p>The kids love <a href="http://davidbau.com/javascript/custom-poem.html">custom-poem.html</a> (<a href="http://davidbau.com/javascript/src/custom-poem.txt">view source</a>), which uses document.write to produce a one-of-a-kind custom poem just for you.  Refresh to get a new poem.</p>

<p>The bits of wisdom are generated madlibs-style, by inserting a random choice out of of a list of words for each of several spots.  A simple idea, but the resulting poems are incredibly entertaining to the 3rd-6th grader set.</p>

<p>I chatted with one of the kids who will be in my trial "programming class," and I was floored to hear this sixth-grader say - without me mentioning jQuery at all - that he "wants to learn jQuery."  When I pointed him to Douglas Crockford's <a href="http://www.youtube.com/watch?v=hQVTIJBZook">talks</a> about the good parts of Javascript, he said, "oh yeah, I've watched that."</p>

<p>So we will definitely follow up with the more-advanced (but conceptually the same) <a href="http://davidbau.com/javascript/dynamic-poem.html">dynamic-poem.html</a> (<a href="http://davidbau.com/javascript/src/dynamic-poem.txt">view source</a>) that uses jQuery instead of document.write.  That gives the poem the ability to change itself over time.</p>]]></content:encoded>
<dc:date>2010-04-16T05:50:03-05:00</dc:date>
</item>
<item>
<title>Tutorial: Concentration</title>
<link>http://davidbau.com/archives/2010/04/15/tutorial_concentration.html</link>
<description>Another 80-line javascript tutorial: concentration.html (view source) lets you test your memory by trying to find pairs of symbols. When you miss a pair, it flips them back to black after a second. How well can you do? The program...</description>
<guid isPermaLink="false">383@http://davidbau.com/</guid>
<dc:subject></dc:subject>
<content:encoded><![CDATA[<p>Another 80-line javascript tutorial: <a href="http://davidbau.com/javascript/concentration.html">concentration.html</a> (<a href="http://davidbau.com/javascript/src/concentration.txt">view source</a>) lets you test your memory by trying to find pairs of symbols.  When you miss a pair, it flips them back to black after a second.  How well can you do?</p>

<p>The program is an example of a very simple state machine with three states: none chosen, a first item is chosen, and a second item is chosen.</p>

<p>For symbols the game uses a bunch of cute and cryptic Unicode glyphs.  This works fine on Windows with its Unicode Times New Roman font.  Let me know if this is problematic on other platforms.</p>]]></content:encoded>
<dc:date>2010-04-15T01:41:45-05:00</dc:date>
</item>
<item>
<title>Tutorial: Histogram</title>
<link>http://davidbau.com/archives/2010/04/13/tutorial_histogram.html</link>
<description>Another javascript tutorial: histogram.html (view source) is a program to let you play with the probability distribution of rolling five dice. Its code is a brief demonstration of how to call Math.random() and how to organize basic coordinate geometry on...</description>
<guid isPermaLink="false">382@http://davidbau.com/</guid>
<dc:subject></dc:subject>
<content:encoded><![CDATA[<p>Another javascript tutorial: <a href="http://davidbau.com/javascript/histogram.html">histogram.html</a> (<a href="http://davidbau.com/javascript/src/histogram.txt">view source</a>) is a program to let you play with the probability distribution of rolling five dice.  Its code is a brief demonstration of how to call Math.random() and how to organize basic coordinate geometry on the screen.</p>]]></content:encoded>
<dc:date>2010-04-13T05:53:04-05:00</dc:date>
</item>
<item>
<title>Tutorial: Maze Maker</title>
<link>http://davidbau.com/archives/2010/04/12/tutorial_maze_maker.html</link>
<description>The tutorial maze-maker.html (view source) is an introduction to functions. It breaks down the work for drawing a random maze into five functions: fillsquares sets up a global array with a grid of SVG squares. setcolor sets the color of...</description>
<guid isPermaLink="false">381@http://davidbau.com/</guid>
<dc:subject></dc:subject>
<content:encoded><![CDATA[<p>The tutorial <a href="http://davidbau.com/javascript/maze-maker.html">maze-maker.html</a> (<a href="http://davidbau.com/javascript/src/maze-maker.txt">view source</a>) is an introduction to functions.</p>

<p>It breaks down the work for drawing a random maze into five functions:</p>

<ul>
<li>fillsquares sets up a global array with a grid of SVG squares.
<li>setcolor sets the color of a single square at position (x, y).
<li>getcolor returns the color of a single square at position (x, y).
<li>shuffled returns a shuffled copy of an array.
<li>makemaze draws a random maze in the grid using recursion.
</ul>

<p>The program is begging to be extended by adding a maze solver.</p>

<p>Maze-making and maze-solving is a good excuse for explaining recursion.  Any ideas for a gentler (but interesting) introduction to functions?</p>]]></content:encoded>
<dc:date>2010-04-12T03:01:05-05:00</dc:date>
</item>
<item>
<title>Tutorial: Tic Tac Toe</title>
<link>http://davidbau.com/archives/2010/04/10/tutorial_tic_tac_toe.html</link>
<description>Continuing with the javascript tutorials - tic-tac-toe.html (view source) is an example of a bare-bones board game AI. It uses recursion to fully explore the tic-tac-toe tree and play a perfect game against you. The code is short, but I...</description>
<guid isPermaLink="false">380@http://davidbau.com/</guid>
<dc:subject></dc:subject>
<content:encoded><![CDATA[<p>Continuing with the javascript tutorials - <a href="http://davidbau.com/javascript/tic-tac-toe.html">tic-tac-toe.html</a> (<a href="http://davidbau.com/javascript/src/tic-tac-toe.txt">view source</a>) is an example of a bare-bones board game AI.</p>

<p>It uses recursion to fully explore the tic-tac-toe tree and play a perfect game against you.  The code is short, but I am concerned it is probably too difficult for kids to understand.  The other problem is that (at least on my laptop) IE is too slow to run the AI on move #1 without a "script appears hung" warning.</p>

<p>Nevertheless, "how to program Tic-Tac-Toe" is an extremely common request from the kids, so it goes into the pile of examples.</p>

<p>Let me know if you come up with a way of simplifying the code.</p>]]></content:encoded>
<dc:date>2010-04-10T11:56:11-05:00</dc:date>
</item>
<item>
<title>Tutorial: Mastermind</title>
<link>http://davidbau.com/archives/2010/04/09/tutorial_mastermind.html</link>
<description>Terran implemented a nice 80-line Mastermind implementation in javascript here. It is a pretty interesting example, and I like it a lot. In an attempt to simplify it, I made a jquery version of it here: mastermind.html (view source). The...</description>
<guid isPermaLink="false">379@http://davidbau.com/</guid>
<dc:subject></dc:subject>
<content:encoded><![CDATA[<p>Terran implemented a nice 80-line Mastermind implementation in javascript <a href="http://www.consistent.org/terran/2010/mastermind.html">here</a>.</p>

<p>It is a pretty interesting example, and I like it a lot.  In an attempt to simplify it, I made a jquery version of it here: <a href="http://davidbau.com/javascript/mastermind.html">mastermind.html</a> (<a href="http://davidbau.com/javascript/src/mastermind.txt">view source</a>).  The jquery version has a slightly different flavor - less string-hacking and more conceptual stuff.</p>

<p>Unfortunately, I do not think the jquery conversion makes the code easier to understand for a beginner.  It uses too many idioms and so it is probably harder.</p>

<p>But maybe it is useful as an advanced example some jquery and javascript tricks.  What do you think?  Is there a simpler way?</p>]]></content:encoded>
<dc:date>2010-04-09T10:42:01-05:00</dc:date>
</item>
<item>
<title>Tutorial: Polygon Drawing</title>
<link>http://davidbau.com/archives/2010/04/06/tutorial_polygon_drawing.html</link>
<description>Continuing the Javascript tutorial series, based on MWinser&apos;s observation that &apos;drawing simple graphs&apos; was a launching off point for him. Here is a simpler variant: polygon-drawing.html is a 50-line program (view source) that lets you experiment with drawing polygons on...</description>
<guid isPermaLink="false">378@http://davidbau.com/</guid>
<dc:subject></dc:subject>
<content:encoded><![CDATA[<p>Continuing the Javascript tutorial series, based on MWinser's observation that 'drawing simple graphs' was a launching off point for him.</p>

<p>Here is a simpler variant: <a href="http://davidbau.com/javascript/polygon-drawing.html">polygon-drawing.html</a> is a 50-line program (<a href="http://davidbau.com/javascript/src/polygon-drawing.txt">view source</a>) that lets you experiment with drawing polygons on the screen.  The user can click or enter SVG path syntax directly.</p>

<p>It is an introduction to using mouse events with jQuery, SVG paths, and Raphael.</p>]]></content:encoded>
<dc:date>2010-04-06T07:31:33-05:00</dc:date>
</item>
<item>
<title>Tutorial: Caesar Cipher</title>
<link>http://davidbau.com/archives/2010/04/05/tutorial_caesar_cipher.html</link>
<description>Another javascript tutorial for middle-schoolers, based on Shakeel&apos;s idea. The short file caesar-cipher.html implements a simple Caesar Cipher in javascript, rotating letters of cleartext into ciphertext by shifting them by a fixed number. The idea of this tutorial is to...</description>
<guid isPermaLink="false">377@http://davidbau.com/</guid>
<dc:subject></dc:subject>
<content:encoded><![CDATA[<p>Another javascript tutorial for middle-schoolers, based on Shakeel's idea.  The short file <a href="http://davidbau.com/javascript/caesar-cipher.html">caesar-cipher.html</a> implements a simple <a href="http://www.google.com/search?q=caesar+cipher&btnI">Caesar Cipher</a> in javascript, rotating letters of cleartext into ciphertext by shifting them by a fixed number.</p>

<p>The idea of this tutorial is to be a gentle introduction to event-based programming.  The encryption code runs every time a keyup event is received on any of the input boxes.  (<a href="http://davidbau.com/javascript/src/caesar-cipher.txt">view source</a>)</p>

<p>I decided to use <b>indexOf</b>/<b>charAt</b> instead of <b>charCodeAt</b>/<b>fromCharCode</b> do do the conversion between letters and numbers, because there are fewer edge cases in the code, and it means there's one fewer concept to worry about.</p>]]></content:encoded>
<dc:date>2010-04-05T06:49:35-05:00</dc:date>
</item>
<item>
<title>Tutorial: Guess My Number</title>
<link>http://davidbau.com/archives/2010/03/31/tutorial_guess_my_number.html</link>
<description>Continuing the Javascript tutorial series. The guess-my-number.html program is truly a straightforward example of 1978 programming style, with an interactive prompt that blocks the program flow to have the user guess a secret number. (view source) Not very modern, but...</description>
<guid isPermaLink="false">376@http://davidbau.com/</guid>
<dc:subject></dc:subject>
<content:encoded><![CDATA[<p>Continuing the Javascript tutorial series.  The <a href="http://davidbau.com/javascript/guess-my-number.html">guess-my-number.html</a> program is truly a straightforward example of 1978 programming style, with an interactive prompt that blocks the program flow to have the user guess a secret number.  (<a href="http://davidbau.com/javascript/src/guess-my-number.txt">view source</a>)</p>

<p>Not very modern, but a classic first program.  Javascript certainly permits this style.</p>

<p>Any other ideas?  What other "good first programs" are there?</p>

<p>I feel like I'm looking for some intersection between "what is understandable" to a sixth grader and "what is cool" to the same set.</p>]]></content:encoded>
<dc:date>2010-03-31T21:58:53-05:00</dc:date>
</item>


</channel>
</rss>