Tuesday, August 19, 2014

Basic Physics: Part 0, Section 4: Derivatives

Previously in this series, we covered algebra, trigonometry, vectors and vector multiplication. Now (after more delay than I would have liked) it's time to tackle the elephant in the room--calculus.

No, please don't close this tab! I swear, it's not as scary as you've been told. If you made it through trig and vectors (which, if you are reading this I assume you have) you've really made it through more mind bending stuff than we will need to cover here.

Why cover calculus at all? Aren't there algebra-based physics courses at every university? Yes, yes there are. And anyone who has taught physics with only algebra, trig and vectors will tell you it's actually harder to teach physics without reference to derivatives and integrals. Newton invented/discovered calculus so he could describe his theory of gravity and motion (his notation was abysmal, though). Calculus is the mathematics of change. Algebra is the mathematics of stability. And physics is really boring if nothing ever moves.

Now, depending on when you went to school, learning calculus may have been reserved for the students who were good at math, or who hadn't been told that "math wasn't for them". I am here to tell you this is like telling students who are going to live in another country that they don't need to learn the past or future tense, they can get along just fine with the present tense. Technically, this is true in a lot of cases, but it limits their ability to get everything out of their trip. Try to think of calculus in this way--not as some strange new kind of math, but just a different tense in this language.

We'll begin where most calculus textbooks begin with derivatives. Calculus has a very intuitive explanation of derivatives: they are the slopes of lines. That's it. What makes derivatives interesting is that they give you the slope at any point along a line*. You will generally hear the included caveat that the line must be smooth and continuous, but this isn't a calc class and I'm not going to show you any equations which are not differentiable (capable of having their derivative taken), so we aren't going to worry about that here.

Let's start with the simplest case, a straight line going through the origin of our coordinate system:

In this case, the slope of the line is going to be the same everywhere, and we can find the slope using the tried and true "rise over run" method. In moving 4 units to the right, the line has moved 3 units up, so our slope \(a\) is $$ a = 3/4 = .75 $$ So far so good. Nothing scary or uncomfortable  to date. A little algebra, that's all, and a little reading off a plot. Now, what if we were just given the equation for this line, in the slope-intercept form encountered in algebra class: $$ y = ax$$ $$y = .75 x$$
Still not too bad. And if I had presented this to your first, you probably could have told me the slope of this line just from this--the coefficient of \(x\) gives the slope, so \(.75\). Congratulations, you just took your first derivative without knowing it!

So, if derivatives are that easy, you ask your computer suspiciously, why is there an entire semester of calculus dedicated to it, hmm? Well, two reasons. First of all, because there are way more complicated kinds of lines than straight lines, and second of all, no one dedicates an entire semester to derivatives. They usually also teach limits (proto-derivatives) and numerical integration (proto-integrals) in the same semester. Derivatives are usually 4-5 weeks of the semester, a lot of that learning special cases.

What if I gave you the line with the equation $$ y = x^2 + 3, $$ would you know what it's slope is? It looks similar to the linear equation in slope-intercept form, but you probably have a feeling that the \(x\) being squared complicates things. And it does, since \(x^2\) is a parabola.


Parabola!

Now, you could draw tangent lines at a sampling of points along the parabola, and find the slope of those tangent lines, plot those slope values and approximate the slope of \(y = x^2 + 3\) and you would find that it came close to \(2x\). I can't speak for everyone here, but I find doing that unbelievably boring. Some algebra teacher once made me do that once and  it was tiresome to say the least.

But calculus and the tool of differentiation gives us a much better way.  Remember, mathematicians do not "invent" new kinds of math to torture students and non-mathematicians. They develop new techniques because the old way was inefficient or tedious or just didn't work all that well. Calculus is  a great example of this. Rather than calculating a bunch of individual slope points and extrapolating what we think the slope is, we can find the exact slope with a few simple rules, and a little new notation.

Let's look at our parabola again. So we have the equation $$y = x^2 +3$$ which describes the line itself. If we want to say that we are looking at the equation for the slope of that line we can write it in Leibniz notation as $$ \frac{dy}{dx}$$ which is nice and concise (there is also Lagrange notation and Newton notation). But Leibniz is nice for beginning with because it has a nice math to english translation: the change in \(y\) over the change in \(x\). This is the more formal way to say "rise over run" and is more generally applicable. Also, now that we are finding the slope of the parabola everywhere we call it a "derivative", and we find it by the process of "differentiation".

To find this, we need two rules. The first rule is formally known as the "elementary power rule" but I just learned it as "this is how you do it". For a function \(f(x)\) that has the form (i.e., it looks like or follows the pattern of) $$ f(x) = c x^n $$ where \(c\) is a constant, \(x\) is the variable and \(n\) is a real number (usually integer, but not necessarily) the derivative can always be found in the following manner: $$\frac{df}{dx} = c*n*x^{n-1} $$ If you are wondering what that \(f(x)\) is doing here, since I kinda just started using it, think of it as a way to label a generic equation. You could keep saying \(y=\) such and such, but then it's not always clear which \(y\) you're talking about. If you instead use the notation of Letter(variable) it lets you label both the equation uniquely (function f, function g, function h) and specify which letter is acting as your variable (x, y, z). Neat, huh?

That's it. That is the most basic rule and definition of the derivative. For the special case where there is no variable, just a constant, the derivative of a constant is \(0\). So, to summarize,

  1. Given a function \( f(x) = c x^n\), the derivative is \(\frac{df}{dx} = c*n*x^{n-1}\).
  2. Given a constant function \(f(x) = c\), the derivative is \( \frac{df}{dx} = 0 \)

So, let's apply these rules to the equation for our parabola.
$$y = x^2 + 3$$
$$\frac{dy}{dx} = (2) x^{(2-1)} + 0$$
$$\frac{dy}{dx} = 2x^1 = 2x$$

And so we find in three lines of calculus the  same answer that a bunch of line drawing and measuring and plotting got you. Let's try another one, that's a little longer.
And really funky looking on a graph.
$$f(x) = 3 x^{5} - 2 x^{2} + x^{-3} $$
$$\frac{df}{dx} = 3*5 x^{(5-1)} - 2*2 x^{(2-1)} + -3 x^{(-3-1)} $$
$$\frac{df}{dx} = 15 x^{4} -4 x - 3 x^{-4} $$

Longer, but still not too bad, right? See, I told you calculus wasn't the terror it was made out to be. One more rule and we've knocked out all the differential calculus we'll need for both physics 1 and physics 2. This rule is called the "chain rule" and it covers almost every other situation we could face outside of a calculus book or more advanced physics. What it is, really, is a short cut when your variable of interest is buried inside a parenthetical expression, instead of having to bother to separate it out by algebra (if it can be separated by algebra at all).

Let's start with something that we could mess around with algebra and get it into a form that our first two rules apply. Let's begin with the equation $$g(x) = (x+2)^2$$ By using the FOIL method, we  find that this could also be stated as $$g(x) = x^2 + 4 x + 4$$ Using the two rules laid out above, we find that it's derivative is $$\frac{dg}{dx}= 2x + 4$$ Now we have something to check the chain rule against.
Displaced parabola!

The chain rule is a way to approach these things methodically, working from the outside in. You start by treating everything inside the parentheses as a block. It does not matter how complicated it is inside the parentheses, or how simple. Treat it all as though it were just the variable. So step one of the chain rule gives us $$\text{ Step 1: } \frac{dg}{dx} = 2 (x+2)^{2-1}$$
Now you take the derivative of what's inside the parentheses, and multiply that result by the result of Step 1. $$\text{Step 2: } \frac{dg}{dx} = 2(x+2)^{1} (1+0) = 2x+4$$
Lo and behold, it's the same result. Now for something this simple is using the chain rule worth it? Maybe, maybe not. But what about something that I don't know how to FOIL, like $$h(x)= (x+2)^{-1/2} =\frac{1}{\sqrt{x+2}} $$
How do you FOIL a square root?! Tell me!
Let's try the chain rule on this and see if it doesn't save us having to look that one up in an obscure algebra text.
Step 1: Ignore what's inside parentheses, take the derivative as if (blah blah) = variable.
$$\frac{dh}{dx} = (-.5)(x+2)^{(-.5 - 1)} $$
Step 2: Take the derivative of what's inside the parentheses, multiply it by Step 1.
$$ \frac{dh}{dx} = -.5(x+2)^{-1.5} (1)$$
Step 3: Simplify if necessary
$$\frac{dh}{dx} = -.5 (x+2) ^(\frac{-3}{2}) = \frac{-1}{2 (x+2)^{\frac{3}{2}}}$$

I can guarantee that that was easier than trying to FOIL a square root. But what about something really nasty, like THIS
Honestly had no idea what this would look like before I graphed it
Behold, the rollercoaster that is $$ k(x) = (x^3 + 2)^{-.5}$$ Surely my nasty, terrifying calculuses gets horrifying and complicated now, heh? Stupid physicistses.

Um, nope. Not really. Let's take a look, shall we?
Step 1: Ignore what's inside parentheses, take the derivative as if (blah blah) = variable.
$$\frac{dk}{dx} = (-\frac{1}{2})(x^3+2)^{(-.5 - 1)} $$
Step 2: Take the derivative of what's inside the parentheses, multiply it by Step 1.
$$ \frac{dk}{dx} = (-\frac{1}{2})(x^3+2)^{-1.5} (3x^2)$$
Step 3: Simplify if necessary
$$\frac{dh}{dx} = (\frac{-3x^2}{2})(x^3+2)^{-1.5}  = \frac{-3x^2}{2 (x^3+2)^{\frac{3}{2}}}$$

Still just 3 bite sized steps.

Ah ha, you say, but what if there are parentheses inside the parentheses? What if I have a russian nesting doll of a problem?

You just repeat step 2 until you run out of parentheses inside parentheses. But I honestly can't say that I've ever seen that happen.

And that's nearly all you really need to know about differential calculus to conquer introductory physics! Hopefully you can see, at least a little bit, why physicists and mathematicians love it. It's like upgrading from a hand drill to a power drill. Or a sheet of sandpaper to a power sander. It might take a little getting used to, but it is a very powerful tool in our toolbox and one that will open up the rules of the physical universe to us in a way that algebra just can't. Because as I said in the beginning, the physical world is dynamic and changing, and algebra is the math of the static and stable.

There are two "special cases" that aren't really special cases that we will need, and they are very easy to use, but a bit lengthy to explain, so I'll cover them in a separate section, partly because they are both really cool, and partly because this post is already pretty long.

If anything is still unclear, or even a little foggy, let me know in the comments and I'll do my best to explain! And I hope to see you next time for integration!

* there are a few significant exceptions to this, which we don't have to be concerned with here. If you are interested in knowing more about these exceptions, brownian motion is a particularly interesting case being continuous everywhere and differentiable nowhere.