## Posts Tagged ‘square roots’

### Visualizing Elementary Calculus: Graphs, Tangents, Derivatives

April 17, 2011

The derivative as the slope of a graph is standard fare, and it’s important for visualizing calculus.

### The Derivative as Slope

Let’s look at the graph of $y=x^2$.

If we take a point on this graph, for example (2,4), the y-value is the square of the x-value.

If look at a nearby point, those values have changed by $\textrm{d}y$ and $\textrm{d}x$ respectively. We can visualize those changes like this:

$\textrm{d}y$ and $\textrm{d}x$ are supposed to represent tiny changes, so we better bring the points in close to each other and zoom in. Any reasonable curve looks like a straight line when you zoom in on it enough, including this one. As far as these nearby points are concerned, $y = x^2$ is a line, and they are on it. That line is called the tangent line. Here it is:

The value of $\textrm{d}y/\textrm{d}x$ is the derivative of y with respect to x, but in this context it is also called the slope of the tangent line. So, the derivative of a function at a certain point is the slope of the tangent line that point.

If we zoom back out again, eventually the graph of $y = x^2$ no longer looks like a line; we can see its curvature. The tangent line tracks the graph for a while, but eventually diverges. The red line shown below is the tangent line to the parabola. The derivative of $x^2$ with respect to x is 2x, so the slope of this tangent line through (2,4) is $2x = 2*2 = 4$. To find the equation for tangent line itself, we choose the line with the specified slope that goes through the point. That would be $y = 4x-4$.

### Circle

Elementary geometry tells us that the tangent to a circle is perpendicular to the radius. Let’s combine this fact with some calculus.

If we have a circle at the origin, the slope to a point (x,y) on the circle is y/x.

The circle is given by $x^2 + y^2 = R^2$. Applying $\textrm{d}$ to both sides gives $2x\textrm{d}x + 2y\textrm{d}y = 0$ (because $\textrm{d}R = 0$). This simplifies to

$\frac{\textrm{d}y}{\textrm{d}x} = -\frac{x}{y}$

Which is the slope of the tangent line.

Since this is perpendicular to a line of slope y/x, we see that perpendicular lines have negative-reciprocal slopes, a fact familiar from algebra.

### Square Roots

If you want to estimate the square root of a number $n$, a good way is take a guess $g$, then average $g$ with $n/g$. For example, to find the square root of 37, guess that it’s 6, then take the average of 6 and 37/6.

$\frac{6 + 37/6}{2} = 6.0833$

The actual answer is about 6.0828. It’s close. To get closer, iterate.

$\frac{6.0833 + 37/6.0833}{2} = 6.08276256$

The actual answer, with more accuracy, is 6.08276253. So we’ve got 7 decimal places of accuracy after two iterations of guessing.

Calculus shows us where this comes from. We are estimating $\sqrt{n}$. That is a zero of $x^2 - n$. So we plot $y = x^2 - n$ (here, $n = 37$).

We don’t know where the zero is, but we know that $x = 6$ is near the zero. So we draw the tangent line to the graph at $x = 6$. This tangent is $y = 12x - 73$.

The tangent line tracks the parabola quite closely for the very short $\textrm{d}x$ from the point $x = 6$ to wherever the zero is. So closely that we can’t even see the difference there. Zoom in near the point (6,-1).

Now we see that the tangent line is a very good approximation to the parabola near the zero, so we can approximate the zero using the zero of the tangent line instead of the zero of the parabola. The zero of the tangent line is given by

$0 = 12x - 73$

$x = 6.0833$

This is our first new guess for the zero of the parabola. It’s off, but only by a tiny bit, as this even-more-zoomed picture shows. We’ve zoomed in so closely that the original point (6,-1) is no longer visible.

From here, we can iterate the process by drawing a new tangent line like this:

We’ve zoomed in even closer. The red line is the tangent that gave us our first improved guess of 6.0833. Next, we drew a new tangent (purple) to the graph (blue) at the location of the improved guess to get a second improved guess, which is again so close we can’t even see the difference on this picture, despite zooming in three times already.

This general idea of estimating the zeroes of a function by guessing, drawing tangents, and finding a zero of the tangent, is called Newton’s method.

### Exercises

1. Graph $y = \sin x$ and find the places where the tangent line slices through the graph, rather than lying completely above or below it near the point of tangency. What is unique about the derivative at these points? (Answer: the derivative is at a local minimum or maximum (i.e. the graph is steepest) when the tangent line slices through)
2. Find the slope of the tangent line to a point (x,y) on the ellipse $(x/a)^2 + (y/b)^2 = 1$ via calculus. Find it again by starting with the unit circle $x'^2 + y'^2 = 1$, for which you already know the slope of the tangent, and making appropriate substitutions for $x'$ and $y'$. (Answer: $\textrm{d}y/\textrm{d}x = -x/y * (b/a)^2$)
3. In this post, we found that $y = 4x - 4$ is tangent to $y = x^2$ at $(2,4)$. Confirm this without calculus by noting that there are many lines through (2,4), all with different slopes. The thing that singles out the tangent line is that it only intersects the parabola once. Any line through (2,4) with a shallower slope than the tanget will intersect the parabola at (2,4), but intersect again somewhere off to the left. Any line with a steeper slope will have a second intersection to the right. Use algebra to write down the equation for a line passing through (2,4) with unknown slope, and set its y-value equal to x^2 to find the intersections with the parabola. What slope does the line need to have so that there is only one such intersection?
4. Do the previous exercise over for a circle (i.e. use algebra to find the tangent line to a circle)
5. For any point outside a circle, there are two tangents to the circle that pass through the point. When are these tangents perpendicular? (Answer: When the point is on a circle with the same center and radius $\sqrt{2}$ as much)
6. Newton’s method of estimating zeroes gave the same numerical answer for the zero of $x^2 - 37$ as the algorithm for estimating square roots gave for $\sqrt{37}$. Show that this is always the case (i.e. perform Newton’s method on $y = x^2 -n$ with a tangent at some point $g$, and show that the new guess generated is the same as that given in the algorithm).
7. Use Newton’s method to estimate $28^{1/3}$ to four decimal places (Answer: 3.0366).

### The Root of the Issue

September 29, 2009

I … regard it as mysterious that an object moving in an inverse square force law traces out a conic section. There are lots of ways to prove it, of course. Newton did it using Euclidean geometry. My homework problems above give two other ways. The one using the Runge-Lenz vector is pretty… but I’m still looking for the truly beautiful way, where you leave the room saying: “Inverse square force law… conic sections… of course! Now the connection is obvious!” – John Baez, Mysteries of The Gravitational 2-Body Problem

I’m not ready to going to give the beautiful proof Baez has been searching for throughout a long career in mathematical physics. I’d like to, but I’m not brilliant enough to be that easy to understand. Instead, I’m going to talk about some middle school math.

I’ve found that in most circumstances, if I’m willing to sit and be confused for long enough, I can normally understand what people are trying to tell me about math. That’s nice. It doesn’t work that way for everyone, and I’m glad I was lucky enough to be able to enjoy it, to the extent I can. But more than knowing the answer to a difficult problem, we humans like to know where the answer comes from.

Suppose, for example, I tell you that the solution to

$x^2 + ax = c$

is

$x = -a/2 + \sqrt{b + a^2/4}$.

It’s easy to verify – just plug the purported solution back into the original equation and you’ll see that it works. But if you have a soul you’ll wonder where in Hell I got that from. (Which is the sort of thinking that, ironically, will cost you your soul due to blasphemy.) Actually where I got it from was my seventh grade math teacher. But I should have gotten it by drawing a picture.

We start with $x^2$. It looks like this:

We'll represent the values on each side of the equation by the area of a figure. This is how we start.

Next is $+ ax$. Where is $ax$ in that picture? $x$ is the side of the square, so if we add on to that with a rectangle of width $a$, we’ll have a region $x^2 + ax$, which is the left hand side of the original equation.

The total area is now x^2 + ax. I know the picture says bx where it should say ax. This is the internet. You get what you pay for.

But that is not really fair to the other side of the square, who didn’t get any region added on. Let’s be symmetric about this, and add $ax/2$ to both sides.

That’s the left hand side of the equation. The right hand side is just $c$.

Here's a picture of the entire equation: x^2 + ax = c.

The thing on the left, though, is so damn close to being tractable. It’s almost a square. Once we’ve drawn this picture, it’s natural to “complete the square” by adding in that little region that’s $a/2 * a/2 = a^2/4$.

We add a little region to both sides, completing the square.

Now let’s do some morphing and stretch that right hand side out into whatever shape we want. Also a square, perhaps?

The equation discusses area, not shape, so we can make the shape on the right into any shape we want, as long as we give it the same area. We'll merge the red and green of the previous image to make purple, and form a square to give each side of the equation the same shape.

Great. Now we have two squares that are the same size. Therefore, the lengths of their edges are the same. And the length of the edge on the right hand side is just the square root of the area $c + a^2/4$. The length of the edge of the square on the left is $x + a/2$, so equating them gives

$x + a/2 = \sqrt{a^2/4 + c}$

or

$x = -a/2 + \sqrt{a^2/4 + c}$.

Cool.

Now let $a=14$ and $b=-23$. Then $x = -7 + \sqrt{72} = -7 + 6\sqrt{2}$.

Aaaaaaaaaaaw PHOOEY! I don’t know what the square root of two is. I am a Pythagorean and lived thousands of years ago. I believe that everything is ratios of integers and that you can’t eat beans because they resemble a fetus! But wait, I do have a little trick to get good rational approximations of root two. The trick is to make a table with two columns, and use a rule to generate new entries as you go down. It looks like this:

 1 1 2 3 5 7 12 17 29 41

The rule is, to put a new entry in the left hand column, add the two entries in the row above it. To put a new entry in the right hand column, again go to the row above, but this time add twice the left hand column to the right hand column. Just try; you’ll see.

The miraculous part comes when you divide the right hand column by the left. Let’s do this again.

 X Y Y/X 1 1 1 2 3 1.5 5 7 1.4 12 17 1.417 29 41 1.4138

It’s getting suspiciously close to root two. It’s not hard to verify that the table isn’t going to make a mistake; it will get closer and closer to root two. First we’ll write down formulas explaining the rule. Call the entry in the left column and $n^{th}$ row $X_n$ and right column $Y_n$. Then the rule is

$X_{n+1} = X_n + Y_n$

$Y_{n+1} = 2X_n + Y_n$.

Because we think the ratio is going towards $\sqrt{2}$, let $Y_n = \sqrt{2}X_n + \epsilon$. Then algebra tells you (on simplification)

$Y_{n+1} = \sqrt{2}X_{n+1} - \epsilon(\sqrt{2} - 1)$

from which we see that the ratio $Y_n/X_n$ converges to root two, oscillating above and below it each iteration.

The method is a general one for extracting square roots. Simply let $Y_n = cX_n + Y_n$ and you’ll extract the square root of $c$. It’s similar to an even-simpler method for finding rational approximations to the golden ratio – take successive terms of the Fibonacci sequence, which converges to the exponential of the golden ratio plus a constant. But I don’t see where it comes from.

I suppose we could write the iteration equations as a matrix, and talk about having $(1, \sqrt{2})$ as an eigenvector, etc. But the only reason I think to do that is that linear algebra and calculus are about the only math I know, so I try to use them for everything. If we start by assuming we’re going to find some rule that lets us make a table to find rational approximations of root two, it’s not hard to believe someone would come upon the rule. But who would get this idea of the table (or some similar equivalent idea) in the first place? I don’t know. But I’m happy people told me about it.

And this is only one of many ways to extract a square root. We could guess-and-check at will, trying first 1.5, then 1.4, then 1.45, then 1.42, then 1.41, then 1.415, etc. That’s a very intuitive rule, although a poor one from an efficiency standpoint. Or we could use some other rule to generate a new guess. For example, first take a guess at root two. Then average your guess $g$ with $2/g$. This generates a new, better guess. Repeating the process creates a sequence of rationals that converges to root two, just like the original method did. This new guess, though, has a wonderfully-intuitive explanation, and is almost obvious. It’s Newton’s method. I’ve seen one or two other methods that were more complicated – enough that I didn’t care to work through them in great detail when, after all, I can tell Wolfram Alpha to do whatever I want. (Well, not quite. Just now I told it to make me a sandwich, and it replied that it was assuming that “sandwich” was a city in Massachusetts).

So sometimes things make a lot of sense. Sometimes they only make a medium amount. Bit by bit, as I learn, the sphere of things that makes sense gradually expands. On the other hand, the sphere of things I heard about but don’t make sense expands even faster, and on top of that, the sphere of things I’ve heard about but understand so poorly I can’t even claim the results don’t make sense to me, since I don’t know what the results are saying, outstrips them all.