TeX

Thursday, August 10, 2017

Lesson 6. Derivative = Slope?

Reminder: Slope at Max / Min

Again, our primary goal is to find maximum / minimum of a certain function $f(x)$ that we meet in our lives. Last time, we have observed that at any $x$-value where $f(x)$ achieves maximum or minimum, the slope is zero! For example, take $f(x) = 1 - x^{2}$. Go to FooPlot and type "1 - x^2" under "Function $y(x)$". You see that at $x = 0$, we achieve maximum and there, we have slope zero. Today, we will study how to find this point where $f(x)$ has slope $0$ without plotting.

Slope of a linear function

linear function in $x$ looks like $x, 2x, (1/2)x + 1, (x - 10) + 1, 100x - \pi, \dots$. In some math class you took in your life, you might remember the form

$y = mx + b$

where $m, b$ are constants. This is a graph of a linear function, which is a non-vertical line in the plane. Take an example where $m = 2$ and $B = 4$. We would have $y = 2x + 4$. Go to FooPlot and type "2x + 4" under "Function $y(x)$".

You are looking at the graph of the linear function $f(x) = 2x + 4$. What is the slope of the line? Slope = Rise/run, so we must have $2$, as the slope of the line. This number $2$ should be what we call the "slope of the linear function" $f(x) = 2x + 4$.

More generally, when $f(x) = mx + b$, the slope of the function $f(x)$ is $m$.

Slope of a non-linear function: derivative

A function $f(x)$ is not a linear function when $y = f(x)$ does not look like a line. For example, we saw $y = 1 - x^{2}$ did not look like a line. Go to FooPlot and type "1 - x^{2}" under "Function $y(x)$". What is the slope of this function $y(x) = 1 - x^{2}$? It's trickier to tell then when $f(x)$ was a linear function. Our "rise/run" trick does not seem to work!

Or does it? Let $\epsilon$ be a small amount of "run", which means the change in $x$. When we start at $x$, we go as far as $x + \epsilon$ in the horizontal direction. What is "rise", the change in $y$? It must be $y(x + \epsilon) - y(x)$. Can you follow? Otherwise, please ask in the comment section!

Continuing, the "rise/run" is

\begin{align*} \dfrac{y(x + \epsilon) - y(x)}{\epsilon} &= \dfrac{1 - (x + \epsilon)^{2} - (1 - x^{2})}{\epsilon} \\ &= \dfrac{x^{2} - (x + \epsilon)^{2}}{\epsilon} \\ &= \dfrac{(x - (x + \epsilon)(x + (x + \epsilon))}{\epsilon} \\ &= \dfrac{-\epsilon(2x + \epsilon)}{\epsilon} \\ &= 2x + \epsilon.\end{align*}

Since we agreed that $\epsilon$ is a small amount, the slope is slightly more than $2x$. Let's look at the picture of $y(x) = 1 - x^{2}$ you drew on FooPlot, we saw that when $x = 0$, the picture tells you that the slope is $0$. We know that when we change a little bit $\epsilon$ from $x$, our slope is $-2x + \epsilon$. This means that when we change a little bit from $x = 0$, our slope is $-2 \cdot 0 + \epsilon = \epsilon$, which is almost zero!

With a bit of more careful thought, you could say that slope of the function $y(x) = 1 - x^{2}$ at $x$ is equal to $-2x$. We write this $y'(x) = -2x$ and call this the derivative of a function $y(x) = 1 - x^{2}$ at $x$.

Try. On the graph of $y(x) = 1 - 2x^{2}$, pick an $x$-value, say $x = -1/2$ and draw the line tangent to the graph. What is the slope of the line? Is it equal to $y'(-1/2) = 1$? Can you see what's going on?

Generalization for polynomials. We can similarly go about other polynomial functions such as $f(x) = 2x^{4} + x^{3} + x + 10$. Can you guess what the derivative $f'(x)$ is? You get

$f'(x) = 8x^{3} + 3x^{2} + 1$.

In general, the rule is that when you have $g(x) = x^{n}$ for some $n \geq 1$, you have

$g'(x) = nx^{n-1}$.

Thursday, August 3, 2017

Lesson 5. Max / Min and Slope Zero

Reminder

Our primary goal at this moment in learning calculus is to find maximum / minimum of certain functions!

Slope at max / min

Last time, we have considered the continuous function $f(x) = -x^{2} + 1$. Using FooPlot, we have observed that the function takes maximum at $x = 0$ with the value $f(0) = 1$. Here, we make an important observation. Again, type "-x^2 + 1" under "Function $y(x)$" on FooPlot. It gives you all the points $(x, y)$ such that $y = -x^{2} + 1$. Pick any point on the curve $y = -x^{2} + 1$. At each point, you can draw a line that meets that curve only at that point but nowhere else. Do you follow? Otherwise, please ask questions using the comment section below!

Such a line is called the tangent line at the point you picked. Now, look at the slope of the tangent line as you move the point along the curve $y = -x^{2} + 1$. What do you see? When does the slope get steep and when does it become flat? You can notice that at $x = 0$, where the function $f(x) = -x^{2} + 1$ has maximum, the slope is completely flat! We call this "slope $0$".

What is going on?

How did you get slope $0$ at the point where the function has maximum? Is this a mystery? No! Notice that maximum means highest point when you think of the graph of the function as a mountain. So when you go to the mountain, you go up before the maximum and go down after the maximum.

Be careful: your maximum may have a sharp cusp!

On FooPlot, type "1 - sqrt(x^2)" under "Function $y(x)$", it gives you the graph $y = 1 - |x|$. Don't be scared. The symbol $|x|$ means the distance between $x$ and $0$. Let's try some numbers, we have

$|0| = 0$,
$|1| = 1$,
$|\pi| = \pi$.

But we also have

$|-1000| = 1000$,
$|-\pi^{10}| = \pi^{10}$.

Do you have some feeling about $|x|$ now? Otherwise, don't forget to ask questions using the comment section below!

Now, go back to the plot $y = 1 - |x|$ you drew. Where is the maximum? The maximum of the function $x \mapsto 1 - |x|$ happens at $x = 0$, and the value of it is $y = 1$. However, what is the slope at $x = 0$? This is impossible to tell! If you look at the left side of $x = 0$, you would say you have slope $1$. However, if you look at the right side of $x = 0$, you would say you have slope $-1$. (Remember, from math classes at school back in the days, slope means rise/run!)

This is somewhat frustrating. For the function $f(x) = 1 - x^2$, we observed that we had slope $0$ at maximum because we go up and then turn back down at the highest point. However, for the function $g(x) = 1 - |x|$, this was not true! We could not even talk about slope at $x = 0$ because there were two different slopes based on whether we come from the left or the right side of $x = 0$.

The reason for this issue is that for $g(x) = 1 - |x|$, when we reach the top of the mountain (or the maximum at $x = 0$), some steep jump in our direction happens. That is, the graph $y = 1 - |x|$ is NOT smooth at $x = 0$. It turns out that as long as your graph is smooth, this issue does not happen.

Moral. When a function $f(x)$ reaches a maximum or a minimum, as long as the function is smooth, it must have slope $0$ at that point.

Wednesday, August 2, 2017

Lesson 4. Continuous functions: what we can optimize

Continuous functions: those that have chance to be optimized

As I have advertised in the last lesson, we will think about functions that can be maximized / minimized. In order to give you an idea of what "continuous" means, it is better to give you some discontinuous functions. On FooPlot, type "1/x" under "Function $y(x)$". Note that the horizontal line has $x$-values while the vertical line has $y$-values. The plot you just made consists of $(x, y)$ such that $y = 1/x$. For exmpale, we have $1 = 1/1$, so the plot, which is a curve, passes $(1, 1)$. Let's try a harder one. You also have $-2 = 1/(-1/2)$, so your plot passes $(-2, -1/2)$ as well.

Now, in the equation $y = 1/x$, put $x = 0.001$. Then what do you get for $y$? You get $y = 1/0.001 = (1/0.001)(1000/1000) = 1000/1 = 1000$. Trying more numbers, you see as $x$ gets closer from the right side to $x = 0$, the values of $y$ gets bigger.

On the other hand, try $x = -0.001$ in your equation $y = 1/x$. You get $y = -1000$, and you see that when $x$ gets closer from the left side to $x = 0$, the magnitude of $y$ is getting bigger, but with a negative sign! You should really see this in your plot on FooPlot. You shall soon notice that you cannot take $x = 0$ in the equation $y = 1/x$. In this case, we say that the function $x \mapsto 1/x$ is discontinuous at $x = 0$, because the value at $x = 0$ is undefined. Here is an important observation in your picture: the function $x \mapsto 1/x$ has NO maximum. This issue of not having maximum happens at $x = 0$, where the function is discontinuous.

If you have read the discussion about $\sqrt{2}$ in Lesson 2, you might ask whether we have some "legitimate cheating" that resolve this issue. Let's try. For example, we can define the function $f(x)$ by saying $f(x) = 1/x$ for all $x \neq 0$, but then force $f(0) = 0$. This is not plugging $x = 0$ in the expression $1/x$. We are merely coloring $(0, 0)$ in the plot you draw on FooPlot. Notice that there is still discontinuity at $x = 0$. You still cannot find maximum of this function because of this discontinuity at $x = 0$.

Now, consider the function $x \mapsto -x^{2} + 1$. Type "-x^2 + 1" under "Function $y(x)$" on FooPlot to draw the plot of the function, namely all the points $(x, y)$ such that $y = -x^{2} + 1$. Notice that this function is continuous everywhere. That is, on a sheet of paper, you can draw this function at once without having to put your pen off the paper. Unlike the function $x \mapsto 1/x$, notice that the function $x \mapsto -x^{2} + 1$ has a maximum! This maximum happens at $x = 0$, and the value of the maximum is $y = -0^{2} + 1 = 1$.

Optimization needs local constraint

Now, we have a very nice continuous function $x \mapsto -x^{2} + 1$, along with the plot $y = -x^{2} + 1$. We have witnessed that at $x = 0$, the function has maximum $y = 1$. However, can you find its minimum? No, as $x$ becomes $100, 1000, 10000, \dots$, your plot shows that the $y$-value will decrease forever. What do we do in this situation? "Legitimate cheating"! We only think about the function from $x = 0$ to $x = 1$ and forget about any other $x$-values in the picture. Then, notice that the function from $x = 0$ to $x = 1$ take minimum at $x = 1$, because we simply cannot take other values such as $x = 2, 3, 4, \dots$. That is, we realized: continuous functions can be locally maximized / minimized.

Subtle remark: end points and Extreme Value Theorem

We noticed that the function $h(x) = -x^{2} + 1$, when restricted to the interval from $x = 0$ to $x = 1$, obtains minimum at $x = 1$, namely $h(1) = -1 + 1 = 0$. (Note that I named this function using the letter $h$ without telling you.) If you are very subtle, you could ask, what if we talk about the interval from $x = 0$ to $x = 1$, but not including endpoints $x = 0$ and $x = 1$? You can see that this is quite annoying, but we have to stick to the truth: without the end point $x = 0$, the function $h(x)$ does not have maximum. The reason is as follows: we have 

$h(0.1) = -0.01 + 1 = 0.99$ and likewise have 
$h(0.01) = 0.9999$, 
$h(0.001) = 0.999999$, 
$h(0.0001) = 0.99999999, \dots$, 

so as $x$ gets closer to $x = 0$ from the right side, the value of $h(x)$ increases toward $1$, but since you cannot take $x = 0$ (because we are not including this point), you can never hit $1$. Since $h(x)$ can increase forever, this means that it does not take maximum when restricted to $0 < x < 1$ (that is, from $x = 0$ to $x = 1$ without including the end points).

It turns out that once we include the end points, we can always maximize and minimize a continuous function. This is what people call 

Extreme Value TheoremAny continuous function on an interval including endpoints can obtain maximum and minimum.


Exercise: what you really need to check whether you are following!

One of my good teachers in college told me that "the best way to learn mathematics by doing exercises." You are serious about learning, and you know you want to understand what is going on. Thus, you want to try this exercise. You don't have to get it right. If you feel like your answer is OK, then you are good to go. Otherwise, feel free to leave any question in the comment section below!

Exercise. Let $f(x) = -x^{2} + 1$ defined for $0 \leq x < 1$. That is, the function is defined from $x = 0$ to $x = 1$, including $x = 0$ but not including $x = 1$. 
  1. Does $f(x)$ takes maximum in the given interval? If so, at which $x$-value does it take maximum. What is the value of the maximum?
  2. Does $f(x)$ takes minimum in the given interval? If not, explain why it does not take the minimum, possibly using the argument I used in the post.

Tuesday, August 1, 2017

Lesson 3. Plotting functions

Optimization: reminder of our goals - maximize / minimize

Let's not forget our goals in studying calculus. Half of our goal is to maximize / minimize functions. A fancy word to describe this is optimization. Before getting into this, we introduce some tools to study with.

Wolramalpha.com: where we can draw

This book is extremely informal, so pictures are essential. However, it takes too much to draw pictures, so we will address this website to use some drawings. To warm up, go to the website and type "plot y = x^2". Do you see a nice parabola? Good!

Plot of a function

Recall that a function is a machine that if you give me something, it gives you something. For example $x \mapsto x^{2}$ is a function. What does it do? If you give it $1$, it gives you $1$. If you give it $2$ it gives you $4$. What if you give it $10$? It gives you $100$. If you give it $-10$ it gives you $100$ as well. The plot of the function is a painting that captures this. On a paper, you mark the points of the form:

(what you give, what the function give you).

In our case, such points are $(1, 1), (2, 4), (10, 100), (-10, 100)$. Are there more? Yes! For example, you have $(\sqrt{2}, 2), (\pi, \pi^{2}), (1.2345, 1.52399025)$... There are infinitely many points on this plot. Go ahead and go to Wolframalpha and type "plot y = x^2" to see them all.

FooPlot: even more accurate

One setback of Wolframalpha is that you cannot enlarge your plot unless you pay them. For this reason, we shall occasionally address this website to plot functions. Go to the website and under "Function $y(x)$", type "x^2". This has the same effect as typing "plot y = x^2" on Wolframalpha. Notice that you can enlarge / shrink the picture by clicking "+" / "-" button.

What will we study with this plotting skill?

In the next lesson, we will describe a special kind of functions that we can optimize, using the plotting skill we have. They are called continuous functions.

Lesson 2. Functions and Real Numbers

Functions: if you give me something, I give you something.

Again, we want to study calculus to maximize / minimize / measure something. For example, you suppose that you know how the price $p$ (in USD) of bread you made fluctuates with respect to the quantity $q$ (in number of loafs) you produce. For example, say when $q = 1$, we have $p = 100$. When $q = 2$, we have $p = 10$. More generally, suppose that 


$p = 100^{1/q}.$

The total revenue you gain is then the product of the price of each loaf and the number of loafs you sold, namely 


$p \cdot q = 100^{1/q}q.$

Notice that when you decide the number $q$ of loafs of bread you sell, the total revenue you gain is determined. That is, when you produce $2$ loafs, you will obtain $10$ dollars by putting $q = 2$ in the right-hand side of above. This is what we call a function. There are many ways to write a function. My favorite way is to write 


$q \mapsto 100^{1/q}q.$

Very often, you would want to name your function, say $R$ for ``revenue'' and write 


$R(q) = 100^{1/q}q.$

You say the revenue function "$R$ is a function in quantity $q$". Notice that the price function $p$ was a function in quantity $q$ as well. More explicitly, we could write 


$p(q) = 100^{1/q}.$ 

Now, here is something nice to tell your parents when they inquire what you learn at school: 


"Mathematics is the study of functions.''


Real numbers: they are real, but you may not write them how you want

For calculus, we use real numbers. That is, we use numbers in our real lives. For example, we use integers 


$\dots, -2, -1, 0, 1, 2, \cdots.$

We use rational numbers (or synonymously, "ratios"), which are written as fractions of integers such as $5/2, 100/3,$ or $-20/999$. We also use irrational numbers, but unlike rational numbers, it is a bit difficult to wrap our heads around irrational numbers, which is probably why we call them "irrational" in the first place. The easiest irrational number can be given as a solution to the equation 


$x^{2} = 2.$

That is, no rational number squares to $2$. This is one of the moments where mathematicians "legally cheat". That is, we imagine such a number that can be a solution to the above equation in $x$, and call it 


$x = \sqrt{2}.$

By our imagination, such a number must satisfy 


$(\sqrt{2})^{2} = 2.$

You might say this seems fishy. You should ask: "How do you construct such a number?" Here is one trick: draw a triangle two of whose edges have length $1$ and require the triangle to have the right angle between the two edges of the same length. Then the length of the hypotenuse of the triangle is the number you want!

We now know that our imagination of such a number $\sqrt{2}$ is actually a reality, but we still feel like we are missing something. How do we write this other than this weird symbol above? Let's do some experiments. We have 


$1.4^{2} = 1.96,$

which is quite close to $2$, so it is tempting to write


"$1.4 = \sqrt{2}$",

but this is NOT true! We wanted something that squares to $2$, NOT $1.96$. No matter how you learn, one of the most important reasons you use mathematics is to be correct. The difference or error you get is $2 - 1.96 = 0.04$, so you might say that's small. However, if $2$ means "$2$ billion dollars", how much is $0.04$? I will let you answer this question.

Still, you can say $1.4$ is an estimation of $\sqrt{2}$, albeit not being equal to it. Unfortunately, it is impossible to write a decimal expression for $\sqrt{2},$ and again, that's why it is called "irrational".


Another example of irrational number is: $\pi.$

What is it? Before the "correct" answer, we should all remember it is NOT equal to $3.14$. What is it then? Well, remember how we constructed $\sqrt{2}?$

We are going to say $\pi$ is the number that is half of the circumference of the circle whose radius is $1$. It turns out that you cannot write $\pi$ as an any decimal expression. This is quite bizarre, isn't it? (Google this if you want!) Our familiar $3.14$ is just an estimation of $\pi$.

To wrap up, we have learned that a function (you give me something, I give you something back) is and what real numbers are. Some of the real numbers such as integers and rational numbers were familiar to us, while irrational numbers were esoteric. This is because we are so used to decimal expressions of numbers! Since you cannot write irrational numbers in a terminating decimal, it just looks more difficult. You do not need to know so much about irrationality unless you need it for a very particular use, so don't worry!

Lesson 1. What is Calculus? Why do we study Calculus?

Scared?

"I study mathematics.'' Being able to say this is the first step to study mathematics. Say "mathematics'' rather than "math'' because that way, it sounds more serious. You are serious about studying the subject. You do not have to be good at it, and no one should expect that when you say this sentence. Don't be scared. This book is created in order to get rid of math-phobia among first year college students or high school seniors, who want to get a feeling of what calculus is. This does not mean that the book will teach you all the essentials that a standard calculus curriculum should teach. Please do NOT rely on this book for your exams.

What is calculus?

Roughly speaking, calculus is the study of slopes and areas. You will make sense of this slowly, so this remark is not too important.

Why do you study calculus?

Why do you study calculus? Even before you start studying calculus, you must ask this yourself, your classmates, and your teachers. Here is one answer, or before I give you an answer, let me ask: if you are a businessperson, is it important to maximize profit? Without some special reasons, you are likely to say "yes". Or, let me ask again, is it important to minimize deficit? Again, you are probably going to say "yes". Hence, here is one reason to study calculus: you study calculus to learn how to maximize or minimize.

Another reason may sound somewhat technical: you study calculus to learn how to measure quantity, area, volume, etc. Undoubtedly, it is important to measure various quantities in life. Now, you should ask then "What do we maximize / minimize / measure?" Roughly, we maximize / minimize / measure what we call functions.