A Mathematical Allegory

We have defined function y = \arcsin(x) as a set:

\{(x, y) | \sin(y) =x, \frac{-\pi}{2} \le y \le \frac{\pi}{2}\}.

By definition,

\arcsin(-1) = \frac{-\pi}{2}, \arcsin(0)=0, \arcsin(1) = \frac{\pi}{2}


\frac{d}{dx} \arcsin(x) = \frac{1}{\sqrt{1-x^2}}.

It means that \arcsin(x) is the unique solution of

\frac{dy}{dx} = \frac{1}{\sqrt{1-x^2}}\quad\quad\quad(\star)

where y(-1)=-\frac{\pi}{2}, y(0)=0 and y(1)=\frac{\pi}{2}.

To compute \arcsin(x), we solve (\star) for y(x) as follows:

Integrate \frac{dy}{dx} = \frac{1}{\sqrt{1-x^2}} from -1 to x gives

\displaystyle\int\limits_{-1}^{x}\frac{dy}{dx} \,dx=\displaystyle\int\limits_{-1}^{x}\frac{1}{\sqrt{1-\xi^2}}\; d\xi\overset{\textbf{FTC}}{\implies}y(x) - y(-1) = \displaystyle\int\limits_{-1}^{x} \frac{1}{\sqrt{1-\xi^2}}\, d\xi.


y(x) = \displaystyle\int\limits_{-1}^{x}\frac{1}{\sqrt(1-\xi^2}\,d\xi + y(-1) \overset{y(-1)=\frac{-\pi}{2}}{=} \displaystyle\int\limits_{-1}^{x}\frac{1}{\sqrt{1-\xi^2}}\,d\xi - \frac{\pi}{2}.

That is,

\arcsin(x) = \displaystyle\int\limits_{-1}^{x} \frac{1}{\sqrt{1-\xi^2}}\;d\xi - \frac{\pi}{2}.

To obtain \arcsin(x), -1 < x < 1, we numerically evaluate \int\limits_{-1}^{x}\frac{1}{\sqrt{1-\xi^2}}\,d\xi, using function ‘quad_qags’.

Fig. 1

The result is visually validated in Fig. 2.

Fig. 2

Note: ‘romberg’, another function that computes the numerical integration by Romberg’s method will not work since it evaluates \frac{1}{\sqrt{1-x^2}} at x=-1.

Fig. 3

An alternate approach is to solve \frac{dy}{dx} = \frac{1}{\sqrt{1-x^2}}, y(0)=0 as an initial-value problem of ODE using ‘rk’ , the function that implements the classic Runge-Kutta algorithm.

Fig. 4 for 0 < x < 1

Fig. 5 -1<x<0

Putting the results together, we have

Fig. 6 -1<x<1

However, we cannot solve \frac{dy}{dx} = \frac{1}{\sqrt{1-x^2}}, y(-1)=\frac{-\pi}{2} using ‘rk’:

Fig. 7

Exercise-1 Compute \arccos(x) for x \in (-1, 1).

Exercise-2 Explain why ‘rk’ cannot solve \frac{dy}{dx} = \frac{1}{\sqrt{1-x^2}}, y(-1)=\frac{-\pi}{2}.

Finding Derivative the “Hard” Way

In “Instrumental Flying“, we defined \cosh^{-1}(x), \sinh^{-1}(x) as the inverse of \cosh(x) and \sinh(x) repectively.

To find the derivative of \cosh^{-1}(x), let

y = \cosh^{-1}(x).

We have

x = \cosh(y).

Differentiate it,

\frac{d}{dx} x = \frac{d}{dx} \cosh(y) \implies 1=\frac{d}{dy} \cosh(y)\cdot \frac{dy}{dx},


1 = \sinh(y) \frac{dy}{dx}\implies \frac{dy}{dx} = \frac{1}{\sinh(y)}.

By \cosh(y)^2-\sinh(y)^2=1 (see Exercise-1) and \cosh(y) \ge 1 (see Exrecise-2),

\sinh(y)^2 = \cosh(y)^2-1 \implies |\sinh(y)| = \sqrt{x^2-1} \overset{ (\star) }{\implies} \sinh(y) = \sqrt{x^2-1}.

And so,

\frac{dy}{dx} = \frac{1}{\sqrt{x^2-1}} \implies \boxed{\frac{d}{dx}\cosh^{-1}(x) = \frac{1}{\sqrt{x^2-1}}}.

Similarly, to find \frac{d}{dx}\sinh^{-1}(x), let

y = \sinh^{-1}(x)\implies x=\sinh(y).

Differentiate it,

\frac{d}{dx} x = \frac{d}{dx}\sinh(y) = \frac{d}{dy}\sinh(y)\frac{dy}{dx}\implies 1 = \cosh(y)\cdot\frac{dy}{dx}.

By \cosh(x)^2-\sinh(x)^2=1, \cosh(y) \ge 1 and \cosh(y) \ge 1,

\cosh(y) = \textbf{+}\sqrt{\sinh(y)^2+1} = \sqrt{x^2+1}.


1 = \sqrt{x^2+1}\frac{dy}{dx} \implies \boxed{\frac{d}{dx}\sinh^{-1}(x) = \frac{1}{\sqrt{x^2+1}}}.


\forall x \ge 0, \sinh(x) \ge 0.\quad\quad\quad(\star)

By definition,

\sinh(x) = \frac{e^x-e^{-x}}{2} = \frac{e^{2x}-1}{2 e^{x}} \ge 0, since \forall x>0, e^{x},e^{2x} \ge 1 (see Exercise-3).

Exercise-1 Show that \forall x \in R, \cosh(x)^2 - \sinh(x)^2 =1.

Exercise-2 Show that \forall x \in R, \cosh(x) \ge 1.

Exercise-3 Show that \forall x \ge 0, e^{x} \ge 1.

Exercise-4 Differentiate \cos^{-1}(x), \sinh^{-1}(x) directly (hint: see”Deriving Two Inverse Functions“).

Polar plot

The polar coordinates r and \theta can be converted to the Cartesian coordinates x and y using the trigonometry functions:

\begin{cases} x=r\cdot\cos(\theta) \\ y=r\cdot\sin(\theta)\end{cases}

It follows that a figure specified in (r, \theta) can be plotted by ‘plot2d’ as a parametric curve:

Fig. 1 r = \cos(5\theta)

It is possible to plot two or more parametric curves together:

Fig. 2 r=\theta and r=\cos(5\theta)

An alternate is the ‘draw2d’ function, it draws graphic objects created by the ‘polar’ function:

Fig. 3 r=\theta and r=\cos(5\theta)

Fig. 4 shows a graceful geometric curve that resembles a butterfly. Its equation is expressed in polar coordinates by

r = e^{\sin(\theta)} - 2\cos(4\theta)+\sin(\frac{\theta}{12})^5

Fig. 4

Let’s combine them!

It is possible to combine two or more plots into one picture.

For example, we solve the following initial-value problem

\begin{cases} \frac{dy}{dx} = (x-y)/2 \\ y(0)=1 \end{cases}\quad\quad\quad(\star)

and plot the analytic solution in Fig. 1.

Fig. 1

We can also solve (\star) numerically and plot the discrete data points:

Fig. 2

Fig. 3 is the result of combining Fig.1 and Fig. 2.


It validates the numerical solution obtained by ‘rk’: the two figures clearly overlapped.

An Alternate Solver of ODEs

Besides ‘ode2’, ‘contrib_ode’ also solves differential equations.

For example,

\frac{d^2y}{dx^2} - \frac{1+x}{x} \cdot \frac{dy}{dx}+ \frac{1}{x}\cdot y=0.

While ‘ode2’ fails:

‘contrib_ode’ succeeds:

This is an example taking from page 4 of Bender and Orszag’s “Advanced Mathematical Methods for Scientists and Engineers“. On the same page, there is another good example:

\frac{dy}{dx} = \frac{A^2}{x^4}-y^2, \quad\quad A is a constant.

Using ‘contrib_ode’, we have

It seems that ‘contrib_ode’ is a better differential equation solver than ‘ode2’:

Even though it is not perfect:

From the examples, we see the usage of ‘contrib_ode’ is the same as ‘ode2’. However, unlike ‘ode2’, ‘contrib_ode’ always return a list of solution(s). It means to solve either initial-value or boundary-value problem, the solution of the differential equation is often lifted out of this list first:

Exercise Solve the following differential equations without using a CAS:

  1. \frac{dy}{dx}= \frac{A^2}{x^4} - y^2 (hint: Riccati Equation)
  2. \frac{d^2 y}{dx^2} = \frac{y \frac{dy}{dx}} {x}


As far as I know, ‘bc2’, Maxima’s built-in function for solving two-point boundary value problem only handles the type:

\begin{cases} y'' = f(x, y, y')\\ y(a)=\alpha, y'(b) = \beta \end{cases}\quad\quad\quad(*)

For example, solving \begin{cases} y'' + y (y')^3=0 \\y(0) = 1, y(1)=3 \end{cases}:

But ‘bc2’ can not be applied to

\begin{cases} -y'' + 9 y =12 \sin(t)\\ y(0)=y(2\pi), y'(0) = y'(2\pi) \end{cases}

since it is not the type of (*). However, you can roll your own:

An error occurs on the line where the second boundary condition is specified. It attempts to differentiate the solution with respect to t under the context that t=0. i.e.,

diff(rhs(sol), 0);

which is absurd.

The correct way is to express the boundary conditions using ‘at’ instead of ‘ev’:

The following works too as the derivative is obtained before using ‘ev’:

Nonetheless, I still think using ’at’ is a better way:

“Instrumental Flying”

Consider the following set

S_1 = \{(x,y) | x=\frac{e^y-e^{-y}}{2}\}.\quad\quad\quad(1-1)

For all (x, y_1), (x, y_2) \in S_1, we have

\frac{e^{y_1}-e^{-y_1}}{2}=x, \frac{e^{y_2}-e^{-y_2}}{2}=x.

That is,

(x, y_1), (x, y_2) \in S_1 \implies \frac{e^{y_1}-e^{-y_1}}{2}- \frac{e^{y_2}-e^{-y_2}}{2}= 0.\quad\quad\quad(1-2)

Since \frac{e^{y_1}-e^{-y_1}}{2}- \frac{e^{y_2}-e^{-y_2}}{2}= 0 if and only if y_1 = y_2 (Exercise-1),

\frac{e^{y_1}-e^{-y_1}}{2}-\frac{e^{y_2}-e^{-y_2}}{2}=0 \implies y_1 = y_2.\quad\quad\quad(1-3)

From (1-2) and (1-3), we conclude:

\forall (x, y_1), (x, y_2) \in S_1 \implies y_1 = y_2.

i.e., S_1 defines a function.

Alternatively, (1-1) can be expressed as

S_1 = \{(x, y) | x = \sinh(y)\}.

It shows that S_1 is the inverse of \sinh(x). Therefore, we name the function defined by (1-1) \sinh^{-1} and write it as

y = \sinh^{-1}(x).

Let’s look at another set:

S_2 = \{(x,y)|x=\frac{e^y+e^{-y}}{2}\}.\quad\quad\quad(2-1)

For a pair (x, y_1>0) \in S_2, we have


For another pair (x, y_2=-y_1),

\frac{e^{y_2} + e^{-y_2}}{2} = \frac{e^{-y_1}+e^{-(-y_1)}}{2} = \frac{e^{-y_1} + e^{y_1}}{2} \overset{(2-2)}{=} x\implies (x, y_2=-y_1) \in S_2.

Since y_1>0, y_2 = -y_1 \neq y_1, (x, y_1), (x, y_2) \in S_1 does not implie y_1 = y_2. It means S_2 does not define a function.

However, modification of S_2 gives

S_3 = \{(x, y) | x=\frac{e^y+e^{-y}}{2}, y \ge 0\}.\quad\quad\quad(2-3)

It defines a function.

Rewrite (2-3) as

S_3 = \{(x, y) | x = \cosh(y), y \ge 0\}.\quad\quad\quad(2-4)

Then \forall (x, y_1), (x, y_2) \in S_3, we have

x=\cosh(y_1), x=\cosh(y_2)\implies \cosh(y_1) = \cosh(y_2).\quad\quad\quad(2-5)

Notice that by (2-3), y_1, y_2 \ge 0.

Cleary, (2-5) is true if and only if y_1 =y_2. For if y_1 \ne y_2, by (\star), \cosh(y_1) \ne \cosh(y_2).


(x, y_1), (x, y_2) \in S_3 \implies y_1 = y_2.

We name the function defined by (2-3) \cosh^{-1} as (2-4) shows that it is the inverse of \cosh(x).

See “Deriving Two Inverse Functions” for the explicit expressions of \sinh^{-1} and \cosh^{-1}.


t_1 \ge 0, t_2 \ge 0, t_1 \ne t_2 \implies \cosh(t_1) \ne \cosh(t_2).\quad\quad\quad(\star)

Without loss of generality, we assume that t_2 > t_1. By Lagrange’s mean-value theorem (see “A Sprint to FTC“),

\cosh(t_2) -\cos(t_1) =\cosh'(\xi) (t_2-t_1)

where \xi \in (t_1, t_2).

We have

t_2 > t_1 \implies t_2 - t_1 >0


\forall t > 0, (\cosh(t))' = (\frac{e^t+e^{-t}}{2})' = \frac{e^t-e^{-t}}{2}  \overset{t>0\implies t >-t \implies e^t  >e^{-t}}{>} 0.


\cosh(t_2) - \cosh(t_1) = \cosh'(\xi) (t_2-t_1) > 0.


\cosh(t_2) \ne \cosh(t_1).

Exercise-1 Show that \frac{e^{y_1}-e^{-y_1}}{2}- \frac{e^{y_2}-e^{-y_2}}{2}= 0 if and only if y_1 = y_2.

Deriving Two Inverse Functions

In “Instrumental Flying“, we defined function y=\sinh^{-1}(x) as

\{(x, y) | x = \frac{e^y-e^{-y}}{2}\}.\quad\quad\quad(1)

From x = \frac{e^y-e^{-y}}{2}, we obtain

(e^y)^2-2x\cdot e^y-1=0.

It means either e^y = x-\sqrt{x^2+1} or e^y = x+\sqrt{x^2+1}.

But e^y = x-\sqrt{x^2+1} suggests e^y < 0 (see Exercise-1), contradicts the fact that \forall t \in R, e^t > 0 (see “Two Peas in a Pod, Part 2“).


e^y = x+\sqrt{x^2+1} \implies y = \log(x + \sqrt{x^2+1}).


\sinh^{-1}(x) = \log(x + \sqrt{x^2+1}), \;\;x \in (-\infty, +\infty).

We also defined a non-negative valued function y = \cosh^{-1}(x):

\{(x, y) | x = \frac{e^y + e^{-y}}{2}, y \ge 0\}.\quad\quad\quad(2)

Simplifying x=\frac{e^y+e^{-y}}{2} yields

(e^y)^2-2x\cdot e^y+1=0.

It follows that either e^y = x-\sqrt{x^2-1} or e^y=x+\sqrt{x^2-1}.

For both expressions’ right-hand side to be valid requires that x \ge 1. However, when x = 2,

e^y = x-\sqrt{x^2-1} = 2 - \sqrt{3} < 1

suggests that y < 0 (see Exercise-2,3), contradicts (2).


e^y = x+\sqrt{x^2-1} \implies y = \log(x+\sqrt{x^2-1}).


\cosh^{-1}(x) = \log(x+\sqrt{x^2-1}), \;\;x \in [1, +\infty).

See also “A Relentless Pursuit“.

Exercise-1 Show that \forall x \in R, x-\sqrt{x^2+1} < 0.

Exercise-2 Without calculator or CAS, show that 2-\sqrt{3} < 1.

Exercise-3 Prove \forall t \ge 0. e^t \ge 1 (hint: see “Two Peas in a Pod, Part 2“)