Introduction
Integrals are found in many different applications.
A very common one is finding the distance traveled while moving with a varying velocity, which can also be described as finding the length of some path that you moved on. You might unknowingly encounter this in many games. If a camera in a cutscene or an NPC patrolling an area need to move at a certain speed along a designer specified path, you need to calculate the length of it first.
You can find the area of complicated shapes with integrals, which uses the classic notion of area under a graph.
Probability theory uses integrals for defining various kinds of events and combinations of events.
In computer graphics we can define the interaction of light and surfaces with integrals.
Many applications go farther than the basic notation and examples we will see in the following sections, but are fundamentally the same.
We won't do any overly formal or perfect proofs in this document, there are other documents for that and I highly encourage you to check those out if you really want to understand everything on a fundamental level. Instead we will try to find some kind of understanding of the notation and words commonly used, hopefully striking a balance between accuracy and understandability for someone not fully into math formalism. Feel free to tell me if there is something actually really wrong though, I would like to not convey misinformation!
Area under a curve
The first time you will encounter integrals is probably when trying to find the area under a graph defined by some function . We will also use this approach, as it is pretty intuitive.
Basic idea
Let's start with a very simple function: , which is a horizontal line, that looks as follows:
Now, how would we calculate the area under that graph between and ? That area looks like a rectangle, so why not use that. The area of a rectangle is just width times height. Height is given by , in this case just . The width is the -range of the regions, so , giving us an area of .
Now let's look at a slightly more complicated function in the same region.
We can of course again use a rectangle, but this won't give us the exact area in this case due to the non horizontal line. We can still try to approximate the area. But how to choose the height? Well, there are infinite choices. Let's stick with two simple choices: Use the function value at the left or right side, so and .
Obviously, the left rectangle has an area of , since , so it shows up as just a line. The right rectangle then has an area of . Now we can actually compute the area ourselves, since the shape is just right-angled triangle! For that, the formula is just half the height times the base, so . This of course makes sense, as it is exactly half of the right rectangle. but we can also see, that the solutions lies between our two approximations.
How to do better? Well, how about we keep using rectangles, since they are really easy to calculate, but we use more of them. Let's start by using two rectangles, one for each half of the region. The following will show the left and right rectangles on a plot left and right respectively. Each rectangle will display its area in the middle.
Both values are already closer to the correct value than they were before! But why stop there? We could also use, segments (or many more). Let's have a look at .
This got us even close to the actual value! We also see that the left rectangles, which are too small, slowly go up in total size, while the right angles, which are too large, slowly go down.
Let's do it one last time, but without the individual areas and see how this works out with a lot more subrectangles.
Nice! Very very close to the actual value!
We will continue in the next section to write this notion down with some math.
Defining what the integral is
In the last sections, we have seen how we can approach computing the area under a curve by just drawing a bunch of easy to calculate rectangles along the function.
In this section we will write it down nicely and cover the notation you might come across when you look up integrals, which might seem intimidating.
We start by defining an interval in which we want to find the area of the function, denoted by . is the lower starting -value, is the upper ending -value. Since we are planning to make a bunch of rectangles, let's use a name for the number of those rectangles: .
Since we try to keep it easy, each rectangle will have the same width. The length of the total interval is . Thus, the width of one rectangle is just . We should also give this value a name:
This might be a first stumbling block, but don't worry! That symbol is a Greek letter and you pronounce it "delta", so is pronounced "delta x". This symbol is commonly used in math and physics to denote some kind of difference (Delta, Difference). Here we also have a difference, though scaled a bit.
We will also need -values, where we evaluate the function at to get the height of our rectangles. As we only use -values at the beginning or the end of our rectangles, we should just find some expression for those. The easiest ones are the first and last one, those are just (first) and (last). The subscript will become clearer in the next step. Now, what is the second value? It should be one rectangle width away from the first. We already defined the rectangle width as !. So the second value is . The third one then is one width further than the second one. . We can also just put in the definition of into that last one: .
You can probably guess the pattern from that. will be and so on. If we use that subscript as a nice index for which point we are talking about, then we get this very simple formula:
This is consistent with the start of this. If we plug in , we get . If we plug in (and remember that ), we get .
We can now define the area of one of our rectangles. Let's start with the first one again. We have to decide, whether to use the left or right rectangle. If we use the left, then we evaluate the function , that we want to integrate, at the left point. So the area will be . The second rectangle will then use the second -value, and its area is . This will go on until the -th rectangle. If you keep in mind, that we started counting at for our subscripts, the last rectangle will be . In the following, let's skip the symbol, as it clutters up the notation, so we write instead of . Let us now add up all our areas to find the total area !
As you can see, all the terms in the sum look basically the same. Each term looks like , where is some index. We basically just write down a list of values for and then add the corresponding term to the total. The values that takes are . With this we introduce the next math notation you will come across very often. The summation symbol (Sigma). With that symbol, the above sum can be written compactly as:
Below the , we write the name of the index variable, here , and what its start index is, here . On top of the we write what the final value of will be, here . This then just means: Write down all integer values of between the starting and endvalue (inclusive), plug that value into the formula right of and add all the different values that are produced that way. Which is exactly what we have written down before. You can remember the connection of the symbol and sums as: Sigma, Sum.
We can also see how nice this notation is, when we now consider the right rectangles. They only differ, in that we start with not the first -value, but the second one, namely . We still have the same number of rectangles. As a consequence, the last rectangle will use the last -value , whereas the left rectangles used the second to last. As an exercise, you can verify the following, by writing it down for some , for example . The total area for the right rectangles can be written as:
Looks basically the same, just shifted by one!
Only one last step is missing to arrive at what the integral will be!
As we have seen in the last section, increasing will make our two sums become closer to the correct solution. What we want is for both of them to agree on the result. For that, we have to make it so small, that it won't matter anymore, if we choose the left or right side as the height. The higher the number of rectangles , the smaller the width . The idea is now to not just use a finite number of rectangles, but infinite ones. This is probably a bit hard to think about. From a practical point of view, think about how the will become smaller and smaller for very large numbers of . Now if you had a really good microscope to look at the graph, at some point you probably couldn't differentiate between different rectangles anymore, as they were too small. If your function is not some incredibly weird one, it shouldn't change that much in value anymore inside of that super small rectangular region, at least your microscope wouldn't be able to see anything. At that point, you wouldn't care about left or right rectangle, you would measure the same value for both.
In math, we have a tool to describe this process of "make a value go towards infinity and see what happens". It is called the "limit". We write the limit of an expresion as goes to infinity as . Basically we check, if the expression will result in a nice value when considering an infinite value. Writing this down for our area (right rectangles), we have:
If that expression does make sense, we introduce a nice new formulation for that whole thing:
The basically becomes , the symbol students are always reminded about not to forget. The part her signals the process of going from the discrete fixed number of rectangles to infinite ones, each with a width that isn't really a number anymore. We often call this thing a "differential" value. Still, the holds this concept of the width that we used before, while the part holds the concept of height, so we can't forget about either of them when writing down an integral.
Similarly to the analogy with the microscope, you can think about subdividing that symbol in smaller and smaller regions. At the beginning, it's just four lines. But if you keep refining it with more and more lines and smooth them out a bit, your symbol might look something like . It is basically just a smooth S, just as in Sum and Sigma. You can think about the as the symbol that incapsulates the whole processing of splitting up the area in incredibly small parts and adding them.
Now, with those last few paragraphs you might be asking: What? How would we even compute an integral with infinities flying around? And you wouldn't be wrong. You can actually find results with that definition, but it is tedious and probably won't be getting you anywhere for anything non-trivial. These kinds of constructions are very important for creating certain formulations and proving properties though.
Which is why in the next section we will go over the "common" way to compute an integral.
Computing integrals
This section will cover actually computing integrals. First we will just give a brief overview of numerical methods, no details, just some keywords. Then we will go to antiderivatives and how they work.
Numerical computation
From the previous sections, we basically already have one method of computing an integral, albeit not exactly in most cases. If we take the right hand side of the integral and remove the limit, but exchange the equality with an approximate equality, we have out first method:
We have to choose a number of segments and then just calculate the summation terms, as we did in the beginning. This is annoying to do by hand, so in most cases we will use a computer, which can calculate far higher number of segments in very short amounts of time. It is also straightforward, just requiring basic arithmetic and a loop.
Still, we might want to keep the number of segments as low as possible, for example if the function is very costly to evaluate. Other schemes exist to find better approximations, such as the trapezoidal or Simpson's rule.
A very different approach is to use stochastics. As mentioned in the introduction, integrals play a huge part in probability theory. The definition of the expected value of a function actually allows us to compute an approximation of an integral with random numbers!
Antiderivatives
While not always possible, antiderivatives provide a very powerful way to compute integrals. The following will cover the basic idea on the second fundamental theorem of calculus, which allows us to directly write down integrals, that we know are derivatives of some other function.
For now we will not cover other techniques, such as substitution.
The fundamental theorem of calculus
The fundamental theorem of calculus relates antiderivatives with integrals. As stated before, this is not a math textbook, so please consult one for the rigorous definitions of this all, such as the correct intervals which we technically need to be careful about.
First of, what is an antiderivative? Usually, it is just written with the upper case letter of the function to be considered.
If the following statement is true, then is an antiderivative for .
And antiderivative means:
Now one cause of confusion might be the different variable name in the first statement, where we used . This is basically just to distinguish different variables. The and are basically placeholder names and stand for the different terms in our integral sum (just that the sum isn't discrete anymore). We could call them by any way we want. The in the first statement is the parameter of . It effects the upper bound of the integral. That basically just means: Only calculate the sum, until your value reaches . In the second statement, we use the same variable since we actually mean the same position. In words: The rate of change at is just the value of at .
We want to see why that is true. But we can already think about why it intuitively makes sense:
The derivative measures the rate of change of a function. describes the area of the curve up until . Now, what exactly causes to change? The function of course. Similarly to when we walk. Let's say you have walked up until time . Now you walk with a speed of . If someone asked you what the rate of change was between time and . You would just check how far you have gotten in that time. After a second of movement, you have moved . And the rate of change was thus , your speed.
Continuing from our discussion from before, we can do a very non-rigorous "proof" to check how this works out. This should be roughly correct, but it is not in the details, please be aware of that.
So for simplicity, we will just use values located at one of our segment endpoints (inbetween is just a constant rectangle anyways). We might not have an exact expression for , but we have approximated the integral in the last section!
We will evaluate at some segment point , where is just some value between and .
So to get the integral up to the value we just don't use all the terms until , but stop at instead for the left rectangles. The is due to the same reason as before: We use the value left of our segment as height.
Now we try to differentiate , which might sound scarier than it is.
You may recall the secant approximation for the derivative, called the difference quotient:
We look a bit ahead of the point , calculate the change from our current position and divide by the distance traveled between the two points, to obtain the slope. As a further simplification, we use the same distance that we use in our rectangles .
Now let's plug in our expression for !
As we used as our distance, our approximation for can just walk one step farther than , as you can see in the sum.
Now when you look at the two sums in the numerator, they are equal aside from the on the top of the first . So aside from the term for , all other terms appear on the left and the right side. And since the right side is subtracted from the left, we are left with:
And with that we have arrived at what the fundamental theorem of calculus says: The derivative of the antiderivative is the function inside of the integral!
The important consequence is: If we know the derivative of a function, then that function is an antiderivative of the derivative!
Derivatives are generally much easier than antiderivatives. With this property, we can find a lot of base antiderivatives with wich more complex ones can be constructed with other means. Neat!
One last thing to note here is another one of those parts, that you easily get points deducted for in tests!
Let's say you know an antiderivative . Now we add some constant value to it: . What happens, if we differentiate that?
As constants vanish under differentiation, there are actually infinitely many antiderivatives, each differing by some constant factor to all the others. Which is why you should write down the , when writing down antiderivatives.
Now how do we solve the problem, that our solution is not unique? Well, we actually know one correct value of , namely . This means, that the area from to , a zero length interval is . We can use that to nail down :
And we can then compute the integral as
The second fundamental theorem of calculus, which states, that if is an antiderivative of , then we have:
results in the same expression, but starts from a general antiderivative.
We also use another shorthand notation:
Examples
Here are a few examples, that you will usually get taught alongside antiderivatives. Basically we calculate some derivatives and from that get some antiderivatives.
One of the first types of functions you will encounter are polynomials, which are luckily easy to differentiate. The derivative of is just . From this we try to go the other way around. Can we find a polynomial, that works just like this rule and results in ? Well, yes! . We can check the rule:
This checks out and so we have:
Another common example is , which is especially nice, since . So we also have:
And as the last example, we have the sine and cosine functions, which derive into each other. We have:
This results in the following two integrals: