Integral: The CAS & I

Evaluate \displaystyle\int \frac{1}{\sqrt{-(x-\alpha_1)(x-\alpha_2)}}\;dx, \alpha_2 \ne \alpha_1.

\displaystyle\int \frac{1}{\sqrt{-(x-\alpha_1)(x-\alpha_2)}}\;dx

= \displaystyle\int \frac{1}{\sqrt{-(x^2-(\alpha_1+\alpha_2)x+\alpha_1 \alpha_2)}}\;dx

= \displaystyle\int \frac{1}{\sqrt{-x^2+(\alpha_1+\alpha_2)x-\alpha_1 \alpha_2}}\;dx

= \displaystyle\int \frac{1}{\sqrt{-x^2+(\alpha_1+\alpha_2)x-\left(\frac{\alpha_1+\alpha_2}{2}\right)^2 + \left(\frac{\alpha_1+\alpha_2}{2}\right)^2-\alpha_1 \alpha_2}}\;dx

= \displaystyle\int \frac{1}{\sqrt{\left(\frac{\alpha_1+\alpha_2}{2}\right)^2-\alpha_1 \alpha_2-x^2+(\alpha_1+\alpha_2)x-\left(\frac{\alpha_1+\alpha_2}{2}\right)^2}}\;dx

= \displaystyle\int \frac{1}{\sqrt{\left(\frac{\alpha_1+\alpha_2}{2}\right)^2-\alpha_1 \alpha_2-\left(x^2-(\alpha_1+\alpha_2)x+\left(\frac{\alpha_1+\alpha_2}{2}\right)^2\right)}}\;dx

= \displaystyle\int \frac{1}{\sqrt{\frac{\alpha_1^2+\alpha_2^2+2\alpha_1\alpha_2-4\alpha_1\alpha_2}{4}-\left(x^2-(\alpha_1+\alpha_2)x+\left(\frac{\alpha_1+\alpha_2}{2}\right)^2\right)}}\;dx

= \displaystyle\int \frac{1}{\sqrt{\frac{\alpha_1^2+\alpha_2^2-2\alpha_1\alpha_2}{4}-\left(x^2-(\alpha_1+\alpha_2)x+\left(\frac{\alpha_1+\alpha_2}{2}\right)^2\right)}}\;dx

= \displaystyle\int \frac{1}{\sqrt{\frac{\left(\alpha_1-\alpha_2\right)^2}{4} - \frac{4x^2-4x(\alpha_1+\alpha_2)+(\alpha_1+\alpha_2)^2}{4}}}\;dx

= \displaystyle\int \frac{2}{\sqrt{\left(\alpha_2-\alpha_1\right)^2-\left(2x-(\alpha_1+\alpha_2)\right)^2}}\;dx

For a \ne 0, \int\frac{1}{\sqrt{a^2-x^2}}\;dx = \arcsin(\frac{x}{|a|}) (see Exercise-1)


Exercise-1 Show that for a \ne 0, \int\frac{1}{\sqrt{a^2-x^2}}\;dx = \arcsin(\frac{x}{|a|}).


A Computer Algebra Aided Proof in Plane Geometry

Given \Delta ABC and two squares ABEF, ACGH in Fig. 1. The squares are sitting on the two sides of \Delta ABC, AB and AC, respectively. Both squares are oriented away from the interior of \Delta ABC. \Delta BCP is an isosceles right triangle. P is on the same side of A. Prove that points E, P and G lie on the same line.

Fig. 1

Introducing rectangular coordinates show in Fig. 2:

Fig. 2

We observe that


x_1 < -a\quad\quad(2)

x_3 > a\quad\quad\quad(3)

CG=CA\implies (x-a)^2+y_3^2 = (x-a)^2 +y^2\quad\quad(4)

AB=AE\implies (x+a)^2+y^2=(x_1+a)^2+y_1^2\quad\quad(5)

CG\perp CA \implies y_3 y = -(x-a)(x_3-a)\quad\quad\quad(6)

BE\perp AB \implies y_1y = -(x_1+a)(x+a)\quad\quad\quad(7)

Fig. 3

Solving system of equations (4), (5), (6), (7), we obtain four set of solutions:

x_1=-y-a, y_1=x+a, x_3=y+a, y_3=a-x\quad\quad(8)

x_1=y-a, y_1=-x-a, x_3=y+a, y_3=a-x\quad\quad(9)

x_1=-y-a, y_1=x+a, x_3=a-y, y_3=x-a\quad\quad(10)

x_1=y-a, y_1=-x-a, x_3=a-y, y_3=x-a\quad\quad(11)

Among them, only (10) truly represents the coordinates in Fig. 2.

Fig. 4

By Heron’s formula (see “Had Heron Known Analytic Geometry…“), the area of triangle with vortex (-y-a, x+a), (0, a), (y+a, a-x) is

\frac{1}{2}\begin{vmatrix} -y-a & x+a & 1 \\ 0 & a &1 \\ y+a & a-x & 1\end{vmatrix}.

From Fig. 4, we see that it is zero.


E, P, G lie on the same line.

The reason we do not consider (9), (10), (11) is due to the fact that

(9) contradicts (2) since y>0, a>0 \implies x_1=y-a=-a+y>-a.


by (1), (10) and (11) indicate x_3=a-y <a which contradicts (3).

Exercise-1 Prove “E, P, G lie on the same line” with complex numbers (hint: see “Treasure Hunt with Complex Numbers“).

A Proof without Trigonometric Function

Problem: A and B are squares. Without invoking trigonometric functions, show that the area of triangle C equals that of D.

Solution: Introducing a rectangular coordinate system and complex number V_1, V_2, P, W_1, W_2, Q:

Let A_1, A_2 denote the area of triangle C and D respectively.

We have

P = V_2-V_1.\quad\quad\quad(1)

Let s_1 = \frac{|V_1| + |V_2| + |P|}{2} \overset{(1)}{=} \frac{|V_1| + |V_2| + |V_2 - V_1|}{2}.

By Heron’s formula derived without invoking trigonometric function (see “An Algebraic Proof of Heron’s Formula“),

A_1 = \sqrt{s_1(s_1-|V_1|)(s_1-|V_2|)(s_1-|P|)}\overset{(1)}=\sqrt{s_1(s_1-|V_1|)(s_1-|V_2|)(s_1-|V_2-V_1|)}.\quad(*)

We also have

W_1 = \bold{i}V_1, \quad W_2 = -\bold{i}V_2\quad\quad\quad(2)

(see “Treasure Hunt with Complex Numbers“) and,

Q = W_2-W_1\overset{(2)}{=}-\bold{i}V_2-\bold{i}V_1.\quad\quad\quad(3)


Let s_2 = \frac{|W_1| + |W_2| + |Q|}{2} \overset{(2), (3)}{=} \frac{|iV_1| + |-\bold{i}V_2| +|-\bold{i}V_2-\bold{i}V_1|}{2}=\frac{|V_1| + |V_2| +|V_2+V_1|}{2}.

A_2 = \sqrt{s_2(s_2-|W_1|)(s_2-|W_2|)(s_2- |Q|)}

\overset{(2), (3)}{=}\sqrt{s_2(s_2-|\bold{i}V_1|)(s_2-|-\bold{i}V_2|)(s_2- |-\bold{i}V_2-\bold{i}V_1|)}.

That is,

A_2=\sqrt{s_2(s_2-|V_1|)(s_2-|V_2|)(s_2- |V_2+V_1|)}\quad\quad\quad(**)

It is shown by Omega CAS Explorer that the expression under the square root of A_1 is the same as that of A_2:


A_1 = A_2.

Exercise-1 The two squares with area 25 and 36 ( see figure below) are positioned so that AB=7. Find the area of triangle TSC.

My Pi

Besides “Wallis’ Pi“, there is another remarkable expression for the number \pi as an infinite product. We derive it as follows:

From the trigonometric identity

\sin(2x) = 2\sin(x)\cos(x),

we have

\sin(x) = 2\sin(\frac{x}{2})\cos(\frac{x}{2})

= 2\cdot 2\sin(\frac{x}{4})\cos(\frac{x}{4}) \cdot\cos(\frac{x}{2})

= 2\cdot 2\cdot 2\sin(\frac{x}{8})\cos(\frac{x}{8})\cdot \cos(\frac{x}{4})\cdot \cos(\frac{x}{2})


= 2^n\sin(\frac{x}{2^n})\cdot \prod\limits_{i=1}^{n}\cos(\frac{x}{2^i}).

That is,

\sin(x) = 2^n\sin(\frac{x}{2^n})\cdot \prod\limits_{i=1}^{n}\cos(\frac{x}{2^i}).

Dividing both sides by x yields

\frac{\sin(x)}{x} = \frac{2^n\sin(\frac{x}{2^n})}{x}\cdot \prod\limits_{i=1}^{n}\cos(\frac{x}{2^i})=\frac{\sin(\frac{x}{2^n})}{\frac{x}{2^n}}\cdot \prod\limits_{i=1}^{n}\cos(\frac{x}{2^i})


\prod\limits_{i=1}^{n} \cos(\frac{x}{2^i})=\frac{\sin(x)}{x} /\frac{\sin(\frac{x}{2^n})}{\frac{x}{2^n}}.

It follows that since \lim\limits_{n \rightarrow \infty}\frac{\sin(\frac{x}{2^n})}{\frac{x}{2^n}}=1,

\lim\limits_{n \rightarrow \infty}\prod\limits_{i=1}^{n} \cos(\frac{x}{2^i})=\lim\limits_{n \rightarrow \infty}\frac{\sin(x)}{x}/\lim\limits_{n \rightarrow \infty}\frac{\sin(\frac{x}{2^n})}{\frac{x}{2^n}}=\frac{\sin(x)}{x};


\frac{\sin(x)}{x}=\lim\limits_{n \rightarrow \infty}\prod\limits_{i=1}^{n} \cos(\frac{x}{2^i}).\quad\quad\quad(1)


x = \frac{\pi}{2},

(1) becomes

\frac{2}{\pi} =\lim\limits_{n\rightarrow \infty}\prod\limits_{i=1}^{n}\cos(\frac{\pi}{2\cdot2^i})=\lim\limits_{n\rightarrow \infty}\cos(\frac{\pi}{4})\cos(\frac{\pi}{8})\cdots\cos(\frac{\pi}{2\cdot 2^n}).\quad\quad\quad(2)

We know

\cos(\frac{\pi}{4}) = \frac{\sqrt{2}}{2}.

Applying the half-angle formula

\cos(\frac{x}{2}) = \pm \sqrt{\frac{1+\cos(x)}{2}}


\cos(\frac{\pi}{8}) = \sqrt{\frac{1+\cos(\frac{\pi}{4})}{2}} = \frac{\sqrt{2+\sqrt{2}}}{2};

\cos(\frac{\pi}{16}) = \sqrt{\frac{1+\cos(\frac{\pi}{8})}{2}} = \frac{\sqrt{2+\sqrt{2+\sqrt{2}}}}{2};



\frac{2}{\pi} = \frac{\sqrt{2}}{2} \cdot\frac{\sqrt{2+\sqrt{2}}}{2}\cdot \frac{\sqrt{2+\sqrt{2+\sqrt{2}}}}{2}\cdots\quad\quad\quad(3)

We compute the value of \pi according to (3):

Fig. 1

Exercise-1 Compute \pi from (1) by letting x = \frac{\pi}{6}.

Gotta Catch ‘Em All !

Solving \frac{d^2y}{dx^2} = \frac{y}{x}\cdot\frac{dy}{dx}.

Even though ‘contrib_ode’, Maxima’s ODE solver choked on this equation (see “An Alternate Solver of ODEs“), it still can be solved as demonstrated below:

multiplied by x,

x\frac{d^2y}{dx^2} = y\frac{dy}{dx},


x\frac{d}{dx}\left(\frac{dy}{dx}\right) = y\frac{dy}{dx}.

Integrate it, we have

\int x\frac{d}{dx}\left(\frac{dy}{dx}\right)\;dx = \int y \frac{dy}{dx} \;dx \implies \int \left(\frac{dy}{dx}\right)'\cdot x\;dx = \frac{1}{2}y^2+c.\quad\quad\quad(1-1)

By \int u'\cdot v\;dx = u\cdot v - \int u\cdot v'\;dx (see “Integration by Parts Done Right“),

\int \left(\frac{dy}{dx}\right)'\cdot x\;dx = \frac{dy}{dx}\cdot x-\int\frac{dy}{dx}\cdot x'\;dx \overset{x'=1}{=}  x\frac{dy}{dx}-\int \frac{dy}{dx}\;dx = x\frac{dy}{dx}-y.

As a result, (1-1) yields a new ODE

x\frac{dy}{dx} -y = \frac{1}{2}y^2 + c\quad\quad\quad(1-2)


2x\frac{dy}{dx}=2y+y^2+c_1,\quad c_1=2c.\quad\quad\quad(1-3)

Upon submitting (1-3) to Omega CAS Explorer in non-expert mode, the CAS asks for the range of c_1.

Fig. 1

Depending on the range provided, ‘ode2’ gives three different solutions (see Fig. 2, 3 and 4).

Fig. 2 c_1>1

Fig. 3 c_1<1

Fig. 4 c_1=1

Let’s also solve (1-3) manually:

If y^2+2y+c_1=0, (1-3) has a constant solution


In fact, this solution can be observed from \frac{d^2y}{dx^2} = \frac{y}{x}\cdot\frac{dy}{dx} right away.

Otherwise (y^2+2y+c_1 \ne 0),


That is,




For c_1-1>0, let k=\sqrt{c_1-1}, we have


Divide both numerator and denominator on the left side by k^2,


Write it as


Multiply both sides by k,


Integrate it,

\int\frac{1}{k}\cdot\frac{1}{(\frac{y+1}{k})^2+1}\cdot\frac{dy}{dx}\;dx=\int k\cdot\frac{1}{2x}\;dx,

we obtain

\arctan(\frac{y+1}{k}) = \frac{k}{2}\log(|x|)+c_2.


\arctan(\frac{y+1}{\sqrt{c_1-1}}) = \frac{\sqrt{c_1-1}}{2}\log(|x|)+c_2


y = 2k_1\tan(k_1\log|x| +k_2) -1\quad\quad\quad(2-2)

where k_1=\frac{\sqrt{c_1-1}}{2}, k_2=c_2.

For c_1-1<0, let k=\sqrt{1-c_1},



\frac{1}{2k}\left(\frac{1}{y+1-k} - \frac{1}{y+1+k}\right)\cdot\frac{dy}{dx}= \frac{1}{2x}

\int \left(\frac{1}{y+1-k} - \frac{1}{y+1+k}\right)\cdot\frac{dy}{dx}\;dx= \int\frac{k}{x}\;dx

\log|y+1-k| - \log|y+1+k| = k\cdot\log|x| + c_2

\log\bigg|\frac{y+1-k}{y+1+k}\bigg| = k\cdot\log|x| + c_2

\log\bigg|\frac{y+1-\sqrt{1-c_1}}{y+1+\sqrt{1-c_1}}\bigg| = \sqrt{1-c_1}\cdot\log|x| + c_2

y= -\frac{k_2(1+k_1)|x|^{k_1}+k_1-1}{k_2|x|^{k_1}-1}, \quad k_1=\sqrt{1-c_1}, k_2=e^{c_2}.\quad\quad\quad(2-3)

For c_1-1=0 \quad(c_1=1),


\int \frac{1}{(y+1)^2}\cdot\frac{dy}{dx}\;dx=\int \frac{1}{2x}\;dx

-\frac{1}{y+1} = \frac{1}{2}\log|x| +c_2

y+1 = \frac{-1}{\frac{1}{2}\log|x|+c_2}

y = -1 - \frac{1}{\frac{1}{2}\log|x|+c_2}.\quad\quad\quad(2-4)

Notice when c_1 = 0, c=0. (1-2) becomes

\frac{dy}{dx} - \frac{1}{x}y = \frac{1}{2x}y^2.

This is a Bernoulli’s Equation \frac{dy}{dx}+f(x)y=g(x)y^{\alpha} with f(x)=\frac{1}{x}, g(x)=\frac{1}{2x} and \alpha=2. Solving it (see “Meeting Mr. Bernoulli“),

y^{1-2} = e^{(2-1)\int -\frac{1}{x}\;dx}\cdot\left((1-2)\int e^{-(2-1)\int-\frac{1}{x}\;dx} \cdot \frac{1}{2x}\;dx+c\right)

= e^{-\log|x|}\cdot\left(-\int e^{\log|x|} \frac{1}{2x}\;dx +c\right)

= \frac{1}{|x|}\cdot\left(-\int |x|\cdot\frac{1}{2x}\;dx + c\right)

= \frac{1}{|x|}\cdot\left(-\int (\pm x)\cdot\frac{1}{2x}\;dx+c\right)

= \frac{1}{|x|}\cdot\left(-(\pm)\int \frac{1}{2}\;dx + c\right)

= \frac{1}{|x|}\cdot\left(-\frac{1}{2}(\pm x) + c\right)

= \frac{1}{|x|}\cdot\left(-\frac{1}{2}|x|+c\right)

= -\frac{1}{2} + \frac{c}{|x|}

\frac{1}{y} = -\frac{1}{2} + \frac{c}{|x|}\implies y = \frac{-2|x|}{|x|-2c}.\quad\quad\quad(3-1)

Since c_1 =0 \implies c_1-1=0-1 = -1 <0, we can verify (3-1) as follows:

substitute c_1=0 into (2-3),

y = -\frac{k2(1+\sqrt{1-0})|x|^{\sqrt{1-0}}+\sqrt{1-0}-1}{k_2|x|-1}=-\frac{2k_2|x|}{k_2|x|-1}\overset{k_2=\frac{1}{2c}}{=}\frac{-2|x|}{|x|-2c}.

Unsurprisingly, this is the same as (3-1).

Exercise-1 Mathematica solves \frac{d^2y}{dx^2} = \frac{y}{x}\cdot\frac{dy}{dx}:

But it only return one solution. Show that it is equivalent to (2-2).

Exercise-2 Solving (1-2) using ‘contrib_ode’.

Exercise-3 Show that (2-2), (2-3) and (2-4) are equivalent to results shown in Fig. 2, 3 and 4 respectively.