## [Math][Calculus] What is derivative?

### Square

You draw two squares, one has side=10 (units), another has side=11, and can you compare their areas?

In Wolfram Mathematica:

In[]:= square10 = Tuples[Range[0, 10], 2];

In[]:= square11 = Tuples[Range[0, 11], 2];

In[]:= new = Complement[square11, square10];

In[]:= ListPlot[{square11, new}, PlotStyle -> Evaluate[{PointSize[0.04], #} & /@ {Blue, Red}]]


Red dots are the dots been "added" during growth of the square from 10 to 11. There are ~2x of them (or ~22 if x=11), and this is exactly the first derivative of $x^2$:

In[]:= D[x^2, x]
Out[]= 2x


Now to get amount of "new dots" that will be "added" if the square growed from 100 to 101, you just calculate 2*101-1.

### Cube

Now let's see what's with cube.

When it grows, 3 "planes" are added at 3 sides after each "iteration". Each plane is essentially a square with side of x. Hence, $\approx 3x^2$ "dots" are "added" at each iteration.

And this is indeed the derivative of $x^3$:

In[]:= D[x^3, x]
Out[]= 3*x^2


And what is with tesseract? 4 3D-cubes are "added" at each "iteration":

In[]:= D[x^4, x]
Out[]= 4*x^3


### Line

What if your figurine is just a one-dimensional line? It grows by 1 at each iteration:

In[]:= D[x, x]
Out[]= 1


### Circle

Here I'm generating dots inside of two circles, using Pythagorean theorem. There are circles we have with r=15 and r=16:

In[]:= coords = Tuples[Range[-20, 20], 2];

In[]:= incircle15[coord_] := Abs[coord[[1]]]^2 + Abs[coord[[2]]]^2 <= 15^2

In[]:= circle15 = Select[coords, incircle15];

In[]:= incircle16[coord_] := Abs[coord[[1]]]^2 + Abs[coord[[2]]]^2 <= 16^2

In[]:= circle16 = Select[coords, incircle16];


How many dots are added when a circle grows from r=15 to r=16?

In[]:= new = Complement[circle16, circle15];

In[]:= Length[circle15]
Out[]= 709

In[]:= Length[new]
Out[]= 88

In[]:= ListPlot[{circle15, new}, AspectRatio -> 1,
PlotStyle -> Evaluate[{PointSize[0.02], #} & /@ {Blue, Red}]]


You see, these new dots are like circle circumference in fact.

Indeed, the first derivative of the circle area function is actually its circumference:

In[]:= D[Pi*r^2, r]
Out[]= 2*Pi*r


Let's check:

In[]:= Pi*15^2 // N
Out[]= 706.858

In[]:= 2*Pi*15 // N
Out[]= 94.2478


Almost equal to amount of dots we generated.

### Cylinder

Cylinder is easy. You can say that at each iteration, a new circle is just added at top (or bottom) of it. Indeed, the derivative of cylinder's volume function is just an area of circle with the same radius:

In[]:= D[Pi*r^2*h, h]
Out[]= Pi * r^2


### Sphere

When a 3D-sphere grows, you can say that 4 disks with the "new" radius are added into it:

In[]:= D[4/3 (Pi*r^3), r]
Out[]= 4 * Pi * r^2


I can show this graphically. Imagine you have a ball and you want to make it bigger. Naive approach is to cut it using knife in 3 planes and insert 3 disks (with "new" radius) in between, like:

( I got this screenshot from this demonstration )

But each disk must have thickness of 4/3 of one "unit". Because $\frac{4}{3}3=4$.

Sure, new "dots" when added during "growth" are distributed across the whole sphere, but most of them can be placed into these "new" 3 planes.

### Conclusion

In other words, derivative is a function that can determine what is added to a function's result, when its input gets incremented by 1.