# `int x^2/sqrt(2x-x^2) dx` Complete the square and find the indefinite integral

Recall that indefinite integral follows `int f(x) dx = F(x) +C`

where:

`f(x)` as the integrand function

`F(x)` as the antiderivative of `f(x)`

`C` as the constant of integration..

To evaluate the given integral problem: `int x^2/sqrt(2x-x^2) dx` , we apply completing the square on the expression: `2x-x^2` .

Completing the square:

Factor out `(-1)`  from `2x-x^2` to get `(-1)(x^2-2x)`

The `x^2-2x` or `x^2-2x+0` resembles` ax^2+bx+c` where:

`a= 1` and `b =-2` that we can plug-into `(-b/(2a))^2` .

`(-b/(2a))^2= (-(-2)/(2*1))^2`

`= (2/2)^2`

` = 1^2`

` =1`

To complete the square, we add and subtract `1` inside the ():

`(-1)(x^2-2x) =(-1)(x^2-2x+1 -1)`

Distribute `(-1)` in "`-1` "to move it outside the () .

`(-1)(x^2-2x+1 -1)= (-1)(x^2-2x+1)+ (-1)(-1)`

`= (-1)(x^2-2x+1)+ 1`

Apply factoring for the perfect square trinomial: `x^2-2x+1= (x-1)^2`

`(-1)(x^2-2x+1)+ 1=-(x-1)^2 + 1`

`= 1-(x-1)^2`

Apply  `2x-x^2=1-(x-2)^2`  to the integral, we get: `int x^2/sqrt(1-(x-1)^2) dx`

Apply u-substitution by letting `u =x-1` then `x = u+1` and `du =dx` . The integral becomes:

`int x^2/sqrt(1-(x-1)^2) dx=int (u+1)^2/sqrt(1-u^2) du`

Apply FOIL method on `(u+1)^2` , we get:

`(u+1)^2 = (u+1) *(u+1)`

`= u*u +u*1 + 1*u +1*1`

`= u^2 +u+u+1`

`= u^2+2u +1`

Plug-in `(u+1)^2= u^2+2u +1` on the integral, we get:

`int (u+1)^2/sqrt(1-u^2) dx =int (u^2+2u +1)/sqrt(1-u^2) du`

Apply the basic integration property: `int (u+v+w) dx = int (u) dx + int (v) dx+int (w) dx` .

`int (u^2+2u +1)/sqrt(1-u^2) du=int u^2/sqrt(1-u^2) du +int (2u)/sqrt(1-u^2) du+int 1/sqrt(1-u^2) du`

Each integral resembles formula from integration table for rational function with roots. For the first integral, we follow: `int (x^2 dx)/sqrt(a^2-x^2) =-(xsqrt(a^2-x^2))/2 +(a^2arcsin(x/a))/2 +C` .

Then,

`int u^2/sqrt(1-u^2) du =-(usqrt(1-u^2))/2 +(1arcsin(u/1))/2`

` =-(usqrt(1-u^2))/2 +arcsin(u)/2`

For second integral,  we follow:  `int x/sqrt(a^2-x^2)dx= -sqrt(a^2-x^2)+C` .

`int (2u)/sqrt(1-u^2) du =2int u/sqrt(1-u^2) du`

`=2 *[-sqrt(1-u^2)]`

`=-2sqrt(1-u^2)`

For the third integral, we follow:  `int dx/(a^2-x^2)dx=arcsin(x/a)+C` .

`int 1/sqrt(1-u^2) du = arcsin(u/1) or arcsin(u)`

Combining the results, we get:

`int (u^2+2u +1)/sqrt(1-u^2) du=-(usqrt(1-u^2))/2 +arcsin(u)/2-2sqrt(1-u^2)+arcsin(u) +C`

Plug-in `u = x-1` , we get the indefinite integral as:

`int x^2/sqrt(2x-x^2) dx`

`=-((x-1)sqrt(1-(x-1)^2))/2 +arcsin(x-1)/2-2sqrt(1-(x-1)^2)+arcsin(x-1) +C`

Recall `1-(x-1)^2 = 2x-x^2` then  the integral becomes:

`int x^2/sqrt(2x-x^2)dx`

`= (( -x+1)sqrt(2x-x^2))/2 +arcsin(x-1)/2-(4sqrt(2x-x^2))/2+(2arcsin(x-1))/2 +C`

`= [arcsin(x-1) + 2arcsin(x-1)]/2 + [( -x+1)sqrt(2x-x^2)-4sqrt(2x-x^2)]/2+C`

`=(3arcsin(x-1))/2 + ((-x-3)sqrt(2x-x^2))/2 +C`

`=(3arcsin(x-1))/2 +((-1)(x+3)sqrt(2x-x^2))/2 +C`

`=(3arcsin(x-1))/2-((x+3)sqrt(2x-x^2))/2 +C`

or  `(3arcsin(x-1))/2-(xsqrt(2x-x^2))/2 -(3sqrt(2x-x^2))/2+C`