# if $f(x)=\int_0^x \lfloor{t}\rfloor \,dt$ for $x≥0$, draw the graph of $f$ over the interval [0,4]

if $f(x)=\int_0^x \lfloor{t}\rfloor \,dt$ for $x≥0$, draw the graph of $f$ over the interval [0,4]

This is an exercise from Apostol's Calculus Vol.1.

I quite don't get how to write $\int_0^x \lfloor{t}\rfloor \,dt$ as an algebraic expression without knowing calculus' fundamental theorem and $\lfloor{t}\rfloor$'s derivative, which haven't been introduced yet.

I input the function in a function plotter, and came up with this.

But I need to know why the graph is like this, to do the problem for my self, and understand it.

Could you help me?

If $x \in [0,1)$, $f(x) = \int_0^x \lfloor t \rfloor \, dt= \int_0^x 0\, dt=0$.

If $x \in [1,2)$, $f(x) = \int_0^1 \lfloor t\rfloor \, dt + \int_1^x \lfloor t \rfloor \, dt= \int_0^1 0\, dt + \int_1^x 1\, dt=x-1$.

If $x \in [2, 3)$, $f(x) = \int_0^1 \lfloor t\rfloor \, dt + \int_1^2 \lfloor t\rfloor \, dt + \int_2^x \lfloor t \rfloor \, dt= \int_0^1 0\, dt + \int_1^2 1\, dt + \int_2^x 2\, dt=1+2(x-2)$.

In general, if $x \in [n, n+1), n \in \mathbb{N} \cup \{0\}$,

\begin{align} f(x) &= \sum_{i=0}^{n-1} \int_i^{i+1} \lfloor t \rfloor \, dt + \int_n^x \lfloor t \rfloor \, dt \\ &= \sum_{i=0}^{n-1} \int_i^{i+1} i \, dt + \int_n^x n \, dt \\ &= \left(\sum_{i=0}^{n-1} i \right)+ n(x-n) \end{align}

Try to simplify the last term.

## You have graphed a piecewise linear approximation of a parabola!

### So, why is this the case?


Let's compute the definite integrals of these two functions, to see precisely what it is that makes your graph an "approximate" parabola: \begin{align} F(x) &:= \int_0^x f(t)\,dt = \int_0^x \floor{t}dt = \frac{1}{2}\floor{x}(2x - \floor{x} - 1) \\ G(x) &:= \int_0^x g(t)\,dt = \int_0^x (x-\frac{1}{2})\,dt = \frac{1}{2}x(x-1) \end{align} $$F(x)$$ is the piecewise-linear function that you graphed in your question. $$G(x)$$, meanwhile, is just a parabola, whose expression is just the antiderivative of $$g$$ evaluated from $$0$$ to $$x$$. I won't elaborate just yet on how I arrived at the actual expression for $$F(x)$$, but don't worry - we'll circle back to that. The much bigger question is the why, the deep connection of the Fundamental Theorem of Calculus to your graph.

Try graphing $$F(x)$$ and $$G(x)$$ together - look how closely they coincide! This is actually a really cool perspective from which to illustrate the underlying meaning of the Fundamental Theorem of Calculus.

The Fundamental Theorem of Calculus says that if $$F$$ and $$G$$ are the integrals of $$f$$ and $$g$$, then $$f$$ and $$g$$ are the derivatives of $$F$$ and $$G$$, and vice versa. In other words, it says:

The integral is the antiderivative: $$F'(x) \equiv f(x)$$.

In our example, we've seen that $$f(x)$$ - an approximate line - and $$g(x)$$ - a line - are related by "approximateness". We want to know what kind of object this integral $$F(x)=\int_0^x{f(t)\,dt}$$ will end up being an approximation of. The Fundamental Theorem of Calculus tells us that that object is none other than $$G(x)=\int_0^x{g(t)\,dt}$$ - a parabola! \begin{align} f(x) &\approx g(x) &&\text{from our definition of } g\\ \Rightarrow \int_0^x f(t)\,dt &\approx \int_0^x g(t)\,dt &&\text{integrate both sides} \\ \Rightarrow F(x) - F(0) &\approx G(x) - G(0) &&\text{apply the Fundamental Theorem} \\ \Rightarrow F(x) &\approx G(x) &&\text{because }F(0) = G(0) = 0 \end{align}

### How do you actually get the expression for $$F(x)$$?

OK, time to circle back as promised, and answer your more specific questions about the function $$f(x) = \floor{x}$$.

First, let's touch on the derivative, $$f'(x) = \frac{\mathrm{d}}{\mathrm{d}x}f(x)$$.

The derivative is like the slope of a line, except a line has the same slope everywhere, while a function can be more or less "sloped" at different locations.

However the floor function does not really have a "slope" - it's flat, except for when it jumps to the next integer. It is not continuous. And because is is not continuous, when we try apply the definition of derivative for an integer point $$x$$, we get a different answer, depending on whether we approach $$x$$ from the left or the right: \begin{align} f'_{\uparrow}(x) &= \lim_{h\uparrow 0}\frac{f(x) - f(x-h)}{h} & \text{and}&\; & f'_{\downarrow}(x) &= \lim_{h\downarrow 0}\frac{f(x+h) - f(x)}{h} \\ &= \lim_{h\uparrow 0}\frac{\floor{x} - \floor{x-h}}{h} & &\, & &= \lim_{h\downarrow 0}\frac{\floor{x+h} - \floor{x}}{h} \\ &= \lim_{h\uparrow 0}\frac{x - (x-1)}{h} & &\, & &= \lim_{h\downarrow 0}\frac{x - x}{h} \\ f'_{\uparrow}(x) &= \lim_{h\uparrow 0}\frac{1}{h} = +\infty & \text{and}&\; & f'_{\downarrow}(x) &= \lim_{h\downarrow 0}{0} = 0 \end{align} The visual intuition here is that $$f'_{\uparrow}(x) = +\infty$$ is the "infinite" slope of the cliff at the vertical jump from the left, while $$f'_{\downarrow}(x) = 0$$ is the flat slope on approach from the right.

For $$f'(x)$$ to exist would require the left & right one-sided limits to be equal, but instead we showed $$f'_{\uparrow}(x) = +\infty\neq 0 = f'_{\downarrow}(x)$$. Since the limit does not exist, neither does $$f'(x)$$.

So if $$x$$ is an integer, then $$f'(x)$$ is not well-defined, while if $$x$$ is a non-integer, then $$f'(x)=0$$. Overall, we must say that $$f'(x)$$ is not a well-defined function on $$\mathbb{R}$$, or that $$f$$ is not differentiable, because of its undefined behavior on $$\mathbb{Z}$$.

$$\text{***}$$

Next, let's move on to the integral, $$F(x) = \int_0^x{f(t)\,dt}$$.

The Fundamental Theorem of Calculus states that the integral is the "opposite" of the derivative. Where the derivative shows the rate of change in $$f(x)$$, the integral shows the level of accumulation under $$f(x)$$.

So while a function like the floor function might not have a derivative, it can certainly still have an integral, as your graph shows!

Just for fun, I'll show you two distinct but similar approaches to find the integral of $$\floor{x}$$. ;) You can pick the one you like best.

1. The first approach is to just forget entirely about antiderivatives, and think in terms of geometry.

Go all the way back to the original definition of the integral as a limit of Riemann sums. A Riemann sum is basically a series of rectangles under the graph of $$f(x)$$ that estimates the area under the curve. More rectangles with a narrower width make a more accurate estimate. The integral of $$f(x)$$ is the limit these estimates, where the area becomes exact.

But in the case of $$\floor{x}$$, this is easy - between each pair of integers, the function is already flat! We don't need a limit, because we can just compute the exact value of the rectangles directly (taking care, of course, with values like $$x=2.7$$, to adjust for the last $$0.3$$ between $$2.7$$ and $$3$$). This area will be the integral $$F(x)$$ of the floor function. \begin{align} F(x) &= \int_0^x{\floor{t}\,dt} \\ &= \sum_{n=0}^\floor{x}n\cdot (1) - \floor{x}(\floor{x}+1-x) \\ &= \frac{\floor{x}(\floor{x} + 1)}{2} - \floor{x}(\floor{x}+1-x) \\ &= \frac{1}{2}\floor{x}\left(\floor{x} + 1 - 2\floor{x}-2+2x \right) \\ \Rightarrow F(x) &= \int_0^x{\floor{t}\,dt} = \frac{1}{2}\floor{x}\left(2x - \floor{x} - 1\right) \end{align}

2. The second approach is to decompose the overall integral $$F(x)=\int_0^x{\floor{t}dt}$$ as a sum of separate integrals for each integer-width line segment. Actually, this is not fundamentally any different from what we just did in the first approach. The meanings are the same - the difference is merely that we are approaching the problem with more algebra and less geometry. \begin{align} F(x) &= \int_0^x{\floor{t}dt} \\ &= \int_0^1{0\,dt} + \int_1^2{1\,dt} + \cdots + \int_\floor{x}^{\floor{x}+1}{\floor{x}dt} - \int_x^{\floor{x}+1}{\floor{x}dt} \\ &= \sum_{n=0}^{\floor{x}}{n\int_{n}^{n+1}{dt}} - \floor{x}\int_x^{\floor{x}+1}{dt} \\ &= \sum_{n=0}^{\floor{x}}n(1) - \floor{x}(\floor{x}+1-x) \\ &= \cdots \text{(same as line 2 of approach 1, so skip to the end}) \\ F(x) &= \frac{1}{2}\floor{x}\left(2x - \floor{x} - 1\right) = \int_0^x{\floor{t}\,dt} \end{align} [Note that $$\floor{x}dt$$ is not a mistake in the last 2 terms of the second line. Admittedly this can be confusing, but $$t$$ is just a "dummy variable", used to prevent confusion. The "main" $$x$$ is the argument of $$F(x)$$ which enters into the equation through its appearance in the upper integration limit. The $$\floor{x}$$ in $$\floor{x}dt$$ is actually that $$x$$, to which we separately applied the floor function when we split up the integral, so that we could use it as the upper sum limit.

For example, if $$x=2.7$$ and we want $$F(2.7)=\int_0^{2.7}{\floor{t}dt}$$, then a sum like $$\sum_{n=0}^{2.7}{n\int_{n}^{n+1}{dt}}$$ makes no sense - $$n$$ has to be an integer, so we use $$\sum_{n=0}^{2}{n\int_{n}^{n+1}{dt}}$$ for the segments $$(0, 1), (1, 2), (2, 3)$$ and then subtract the last term to adjust for the interval $$(2.7, 3)$$.]

### Optional addendum: What is the real life significance of $$F(x) \approx G(x)$$?

A final side note: this "approximate parabola" you have generated is not just a useless curiosity! There are many cases in science or engineering where similar "approximated" functions are used as a simplified model of some real-life process.

Not only does this usually make the math easier, it also serves to eliminate the "noise" of real life processes in cases where that noise would only be a distraction from the core theory.

For example, you might see a problem like this in physics:

If a car traveling along a straight road accelerates from a stopping point at $$10 \,\mathrm{m/s}^2$$ for $$4 \,\mathrm{s}$$, then decelerates at $$5 \,\mathrm{m/s}^2$$ for $$2 \,\mathrm{s}$$, how fast will the car be going after $$6 \,\mathrm{s}$$?

You would likely solve this problem by defining the car's acceleration profile with a piecewise function, $$a(t) = \begin{cases} \;10, & 0 \le t \lt 4 \\ -5, & 4 \le t \lt 6 \\ \;\,\; 0, & t \lt 0 \;\text{or}\; t \ge 6, \end{cases}$$ ...and integrating $$v(t) = \int_0^s a(s)\,ds$$ to find the car's velocity at time $$t$$.

This piecewise function is not unlike the above step function, at least conceptually, in that if you really want to get detailed, the function $$a(t)$$ and the problem only give an approximate description of the car's real-life acceleration.

By this, I mean that in "messy" reality, if you watched very closely (say, in slow motion), you would see the driver gradually start to put his foot down on the accelerator. As this happened, the car's acceleration would smoothly increase from $$0 \,\mathrm{m/s}^2$$ to $$10 \,\mathrm{m/s}^2$$, in the ~$$0.1 \,\mathrm{s}$$ it might take for the gas pedal to hit the floor. Something similar would happen after 4 seconds, when the driver stopped accelerating and started braking.

These processes may be quick, but they do not occur literally instantaneously in zero seconds (in fact, in different contexts of the example I just described, they would even be objects of study in their own right). The "real" acceleration of a real car driving in the way described by the problem would look more like a steep (but still smooth) plateau followed by a steep basin.

This "real" acceleration is analogous to the parabola $$G(x)$$ in our example. It has more detail - but the rub is, this detail is unnecessary for understanding the basic relationship between acceleration and velocity, and in fact it would even complicate matters so as to distract from that relationship.

So we abstract away from it, and use a much simpler acceleration profile. As a result the velocity function we end up getting by integration is analogous to $$F(x)$$ from the earlier example!