Posts Tagged ‘visualization’

Integration by parts

April 19, 2013

How did loving the ground-up toenails of bisexuals get an interior designer to take up geology? Simple, he went from noting decor to what the core denotes by being into grated bi-parts.

I don’t really get why this XKCD is funny.

But here is a picture explaining integration by parts:

The area of the entire rectangle is uv, and it is made of two parts we integrate, so

 

uv = \int \!u\, \text{d}v + \int\! v\,\text{d}u

 

and therefore

 

\int \! u \,\text{d}v = uv - \int\! v \,\text{d}u

 

Also, take \text{d}(uv) = \text{d}(\int \!u \,\text{d}v + \int \!v\,\text{d}u) and you find

 

\text{d}(uv) = u \,\text{d}v + v\,\text{d}u,

 

which is the product rule.

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.

This series
I – Introduction
II – Trigonometry
III – Differentiation Rules 1
IV – Graphs, Tangents, Derivatives


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).

Visualizing Elementary Calculus: Trigonometry

March 26, 2011

Here we’ll find the derivatives of trigonometric functions. The goal is to reinforce the idea of \textrm{d} as a thing that means “a little bit of” and grant some new insight into why these derivatives are what they are. The first argument is based on the preface of Tristan Needham’s Visual Complex Analysis. I haven’t read the bulk of it, but the preface is good.

This series
I – Introduction
II – Trigonometry


The Sine Function

Let’s find \textrm{d}(\sin\theta) / \textrm{d}\theta. The sine function is the height of a right triangle in the unit circle. We’ll draw it, and add a little change in \theta. This induces a change in \sin\theta. The change in \theta is called \textrm{d}\theta and the change in \sin\theta is called \textrm{d}(\sin\theta).

We show the sine of an angle as the dark blue line. The change in the sine when we change the angle slightly is the light blue line.

The interesting part is \textrm{d}\sin\theta, so we’ll zoom in there in the next picture. Before we do, remember that the arc length along a piece of the unit circle is equal to the angle it subtends. This will tell us the length of the little piece of the circumference near \textrm{d}\sin\theta. Also remember that we’re imagining \textrm{d}\theta to get smaller and smaller, until the two radii in the picture are parallel. We get this:

The interesting region is blown up to large size. The black line d(theta) is part of the edge of the circle. The angles marked are congruent to theta.

The section of the circle is \textrm{d}\theta long. It looks like a straight line because we are zoomed in close, like the horizon at the beach. You can use some geometry to show that the angles marked are congruent to \theta.

Looking at the right triangle formed, we can use the definition of the cosine function to read off

\frac{\textrm{d}(\sin\theta)}{\textrm{d}\theta} = \cos\theta

which is the derivative of the sine function.

Motion on the Unit Circle

Another way to view these derivatives is to imagine a point moving around the outside edge of the unit circle with speed one. Its location as a function of time is (\cos t, \sin t).

Its velocity is tangent to the circle and length one. Let’s draw the velocity vector right at the point, and then also translate it to the origin.

The position of the point is the red vector r. Its velocity is the green tangent v, which has also been copied to the origin.

We want to know the coordinates of \vec{v}. That’s not too hard; \vec{v} is a quarter-circle rotation of \vec{r}. Draw in the components of \vec{r}, and rotate those components to get \vec{v}. The x-component of the position becomes the y-component of the velocity, and the y-component of the position becomes minus one times the x-component of the velocity.

The components of the position get rotated a quarter turn to make the components of the velocity.

The derivative of position is velocity, and so comparing components between the position and velocity vectors, we get

\frac{\textrm{d}(\cos\theta)}{\textrm{d}\theta} = -\sin\theta

\frac{\textrm{d}(\sin\theta)}{\textrm{d}\theta} = \cos\theta

Exercises

  • Look back at the first derivation we gave that \textrm{d}(\sin\theta)/\textrm{d}\theta = \cos\theta. Rework it to find derivatives of the other five trig functions. You might want to note that one way to interpret \tan\theta and \sec\theta is

The tangent and secant of an angle are side lengths of a right triangle with "adjacent" side length one.


(Answers)

  • Look back at the argument about a dot moving around a circle. Consider a larger circle to find the derivative of 5\sin\theta with respect to \theta. (Answer: 5\cos\theta)
  • Suppose the dot moving around the edge of the circle is going three times as fast. What does this mean for the derivative of \sin(3 t) and \cos(3 t) with respect to t? Remember that the velocity must still be perpendicular to the position, but not necessarily unit length and more. (Answer: the derivative of \sin(3 t) with respect to t is 3\cos(3 t).
  • Suppose the dot is moving at a variable speed v(t) = t, so that it keeps getting faster. Then the y-coordinate of the position is \sin(\frac{1}{2}t^2). Again, the velocity is perpendicular to position, but its length is changing. What is the derivative of \sin(\frac{1}{2}t^2) with respect to t? (Answer: t\cos(\frac{1}{2}t^2)