# Nomogram

## Intro

[This is a page from Jonathan Dushoff’s math wiki, adapted for use as a test of my Working Markup blog-post system. Scroll down for info about how this post is made, including source code. -lw]

On this page, I use the free software environment R to construct a nomogram that I read about in a recreational math book when I was a kid. This nomogram solves quadratic equations.

## Nomogram

You can print out the nomogram, and use a ruler to read off the solutions to the quadratic equation, where the line from $\pm b$ to $c$ intersects the scale.

The example above shows the solutions to the equation ${x}^{2}-3x-5=0$. The dashed line connecting $b$ to $c$ shows the positive solution (4.2), and the dotted line connecting $-b$ to $c$ shows the negative solution (-1.2).

In this example (${x}^{2}-5x+1=0$), both solutions are positive (0.2 and 4.8), thus only the dashed line intersects the scale.

## Math

We want to draw lines from $(0,b)$ to $(1,c)$ that will pass through a point labeled with $r$, where $r$ is a root, satisfying ${r}^{2}+br+c=0$. The equation for our line is $y=b+(c-b)x$. Solve the quadratic to obtain $c=-{r}^{2}-br$, and substitute into the line equation to get $y=b-({r}^{2}+br+b)x$.

If we want all lines corresponding to $r$ to go through our point, we must find one independent of $b$. We do this by setting $x=1/(r+1)$, to yield $y=-{r}^{2}/(r+1)$.

## Code

Define and call a nomogram function.

Use make to make the example code below depend on the R environment from above (using our custom R rules).

Make a nomogram, then define and make example lines.

Here’s another example.

## Printable

## Export source code

This project is designed for reproducible research.

- This entire website (including the source text of this blog post, with all the source code included) is available for cloning at https://github.com/worden-lee/github-pages-sandbox. I’m planning to write instructions for processing it soon.
- To reproduce the full blog post you’ll need to have the following installed: Jekyll, git, R, latexml, GNU make, perl (and maybe other things - bug reports welcome).
- Here is an automatically-generated tar file of the source file contents: wmd_export.tgz. You should be able to unpack this directory and simply run ‘make example.Rout.png’ to build the first image above, and similar commands to build the other output files.
- To reproduce these outputs you will need GNU make, perl, and R installed.

To see the source text of this blog post, with the R and makefile code embedded, see https://github.com/worden-lee/github-pages-sandbox/blob/master/_posts/2014-10-15-nomogram.md.wmd.

See also a discussion of how this is put together at http://leeworden.net/lw/node/148 and http://leeworden.net/lw/node/149.