Solve this definite integral involving greatest integer function$?$

calculusdefinite integralsintegrationreal-analysis

Find the value of the integral $$\int_0^2[x^2-x+1]\:\:dx$$ where $[\cdot]$ denotes the greatest integer function.

My work:

I calculated this integral normally and I got the answer as $\frac83$ and then rounding it off to the greatest integer, the answer came out to be $2$.

But this answer is wrong and the correct answer is $1$. The solution involved graph of the quadratic and then by the help of graph and diving the integral into three parts, he got the answer.

I want to know that is there any other method $($not involving graphs$)$ by which we can solve this as I'm not so well versed in graphs. Maybe there is a trick or two which we can apply here.

Any help is greatly appreciated.

Best Answer

For each $x\in[0,2]$,$$\lfloor x^2-x+1\rfloor=\left\{\begin{array}{l}0&\text{ if }x\in(0,1)\\1&\text{ if }x=0\text{ or }x\in\left[1,\frac{1+\sqrt5}2\right)\\2&\text{ if }x\in\left[\frac{1+\sqrt5}2,2\right)\\3&\text{ if }x=2.\end{array}\right.$$Therefore\begin{align}\int_0^2\lfloor x^2-x+1\rfloor\,\mathrm dx&=\frac{1+\sqrt5}2-1+2\left(2-\frac{1+\sqrt5}2\right)\\&=\frac{5-\sqrt5}2.\end{align}