As we talked about in previous article, the derivative of a function is expressed with this thing someone might have seen somewhere and be intimidated by it (it’s me, I’m that one who used to be intimidated by it):
\[{\frac{d}{dx}} [f(x)]\]
For example, if we have the function \(f(x) = x^3\), the definition of its derivative would be expressed like this:
\[{\frac{d}{dx}} [f(x)] = 3x^2\]
Finding the derivative of a function is basically what
differentiation is.
Now, integration is basically looking for an
anti-derivative of a derivative of a function. Or, in short, treating a
function like it’s a derivative of a mystery function, therefore we must
try and figure out what this mystery function is.
Let’s say we have defined a function: \(f(x) = 3x^2\). And no this is not a derived function. It’s just a coincidence that it looks like the function above it. The mystery function can be written in this expression:
\[\int_{}^{} f(x) \; dx\]
This is pretty much the opposite of the power rule we talked about in the previous article about differentiation.
\[\int_{}^{} x^n \; dx = {\frac{x^{n + 1}}{n + 1}} + C\]
Where \(c\) is some constant that we
might need sometime down the road of looking for the mystery function.
As an example, let’s plug in \[f(x) =
{\frac{1}{2}x + 20}\] as a function. What could be the function
that this function was derived from?
Let’s break it down one by
one. We can work on \({\frac{1}{2}}x\)
first:
\[\begin{align*} \int_{}^{} {\frac{1}{2}x} \; dx &= {\frac{0.5x^{1 + 1}}{1 + 1}} \\ &= {\frac{0.5x^2}{2}} \\ \end{align*}\]
Now, we work on \(20\). To apply the power rule, or in this case, the not-power rule to a constant, we can imagine that this constant is multiplied by a variable to the power of \(0\). Something like:
\[\begin{align*} \int_{}^{} {20x^0} \; dx &= {\frac{20x^{0 + 1}}{0 + 1}} \\ &= 20x \\ \end{align*}\]
Now we can string the whole thing together and get the mystery function:
\[\int_{}^{} f(x) \; dx = F(x) = {\frac{0.5x^2}{2}} + 20x\]
This is what is essentially going on behind the mosaicCalc
antiD() function, which is the function you would use to
generate an anti-derivative of a function in R. Let’s say we need to
graph out this function. We can define it first:
f <- makeFun(((1/2) * x) + 20 ~ x)
Now, let’s make the anti-derivative of this function. To do that, we
can use the antiD() function.
F <- antiD(f(x) ~ x)
Just to see if we got the same function which is supposed to be the anti-derivative of \(f()\), let’s plug in a number into the anti-derivative. This is not actually how to use this function, but we’re just making sure.
Let’s see what \(F(100)\) produces:
F(100)
## [1] 4500
To find out if antiD() figured out the correct
anti-derivative based on the answer above, let’s try and simulate what
goes on behind the screen of what goes on when we executed
F(100), a.k.a. evaluate \(F(100)\) manually:
\[ \begin{align*} F(x) &= {\frac{0.5x^2}{2}} + 20x \\ F(100) &= {\frac{0.5(100)^2}{2}} + 20(100) \\ &= {\frac{0.5{\cancel{(10000)}}}{{\cancel{2}}}} + 2000 \\ &= (0.5 * 5000) + 2000 \\ &= 2500 + 2000 \\ &= 4500 \\ \end{align*} \]
So we can confirm that our \(F(x)\)
and R with the F() are the same function.
Kaplan, Daniel. 2022. MOSAIC Calculus. GitHub Pages. https://dtkaplan.github.io/MC2/