# Getting started on Apache Ignite

Setup Apache Ignite

[2] Install Ignite

unzip apache-ignite-2.9.1-bin.zip

[3] Add Ignite to the PATH environment variable

export PATH=$PATH:$JAVA_HOME/bin:$IGNITE_HOME/bin [3] Start Ignite by executing the following command ignite.sh You should see: (^c to stop Ignite) [4] Enable Ignite restful interface copy the folder$IGNITE_HOME/libs/optional/ignite-rest-http to $IGNITE_HOME/libs Setup Apache Maven [1] Download Maven from https://maven.apache.org/download.cgi : [2] install Maven unzip apache-maven-3.8.1-bin.zip [3] Add Maven to the PATH environment variable export PATH=$PATH:$JAVA_HOME/bin:$IGNITE_HOME/bin:\$MAVEN_HOME/bin

[4] Test Maven, run

mvn -v

You should see:

Rest Client communicates with Ignite

[1] Create Ignite cache

Open your web-browser and enter the following URL:

http://localhost:8080/ignite?cmd=getorcreate&cacheName=testCache

It should return :

Cache is created.

[2] Put data into Ignite cache:

http://localhost:8080/ignite?cmd=put&key=pi&val=3.1415926&cacheName=testCache

[3] Get data from Ignite cache:

http://localhost:8080/ignite?cmd=get&key=pi&cacheName=testCache

You should see:

You can also use ignitevisorcmd to view your cache:

ignitevisorcmd.sh

You should see:

First Ignite Application

[1] Write your first Ignite application

[2] Build your first Ignite application

mvn clean install

You should see:

[3] Run your first Ignite application

java -jar target/HelloIgnite-runnable.jar

[4] Verify cache entries using ignitevisorcmd:

cache -scan

# Deriving Generalized Leibniz’s Integral Rule

The general form of Leibniz’s Integral Rule with variable limits states:

Suppose $f(x, t)$ satisfies the condition stated previously for the basic form of Leibniz’s Rule (LR-1, see “A Semi-Rigorous Derivation of Leibniz’s Rule“) . In addition, $a(t), b(t)$ are defined and have continuous derivatives for $t_1\le t\le t_2.$ Then for $t_1\le t \le t_2,$

$\frac{d}{d t}\int\limits_{a(t)}^{b(t)}f(x, t)\;dx = f(b(t),t)\cdot b'(t) -f(a(t),t)\cdot a'(t)+ \int\limits_{a(t)}^{b(t)}\frac{\partial}{\partial t}f(x, t)\;dx.\quad\quad\quad(1)$

(1) can be derived as a consequence of LR-1, the Multivariable Chain Rule, and the Fundamental Theorem of Calculus (FTC):

Clearly,

$\int\limits_{a(t)}^{b(t)}f(x, t)\;dx\quad\quad\quad(2)$

on the left side of (1) is a function of $t$.

Let

$u = a(t),\quad\quad\quad(3)$

$v = b(t),\quad\quad\quad(4)$

$w = t,\quad\quad\quad(5)$

(2) can be expressed as

$G(u,v,w) = \int\limits_{u}^{v}f(x,w)\;dx.$

Hence, by the chain rule,

$\frac{d}{d t}\int\limits_{u}^{v}f(x, w)\;dx = \frac{\partial}{\partial u}G(u,v,w)\cdot \frac{du}{dt} + \frac{\partial}{\partial v} G(u,v,w)\cdot \frac{dv}{dt} + \frac{\partial}{\partial w}G(u,v,w)\cdot \frac{dw}{dt}$

where

$\frac{\partial}{\partial u}G(u,v,w)=\frac{\partial}{\partial u}\int\limits_{u}^{v}f(x, w)\;dx$

$= \frac{\partial}{\partial u}\left(-\int\limits_{v}^{u}f(x, w)\;dx\right)$

$= -\frac{\partial}{\partial u}\int\limits_{v}^{u}f(x, w) \;dx$

$\overset{\textbf{FTC}}{=} -f(u, w)$

$\overset{(3), (5)}{=} -f(a(t), t),$

$\frac{\partial}{\partial v}G(u,v,w)=\frac{\partial}{\partial v}\int\limits_{u}^{v}f(x, w)\;dx \overset{\textbf{FTC}}{=}f(v, w) \overset{(4), (5)}{=} f(b(t), t)$

and,

$\frac{\partial}{\partial w}G(u,v,w)=\frac{\partial}{\partial w}\int\limits_{u}^{v}f(x, w)\;dx \overset{\textbf{LR-1}}{=} \int\limits_{u}^{v}\frac{\partial}{\partial w}f(x, w)\;dx\overset{(3), (4), (5)}{=} \int\limits_{a(t)}^{b(t)}\frac{\partial}{\partial t}f(x, t)\;dx.$

It follows that

$\frac{d}{d t}\int\limits_{a(t)}^{b(t)}f(x, t)\;dx =-f(a(t),t)\cdot a'(t) + f(b(t),t)\cdot b'(t) + \int\limits_{a(t)}^{b(t)}\frac{\partial}{\partial t}f(x, t)\;dx,$

i.e.,

$\frac{d}{d t}\int\limits_{a(t)}^{b(t)}f(x, t)\;dx = f(b(t),t)\cdot b'(t) -f(a(t),t)\cdot a'(t)+ \int\limits_{a(t)}^{b(t)}\frac{\partial}{\partial t}f(x, t)\;dx.$

# A Semi-Rigorous Derivation of Leibniz’s Rule

Leibniz’s rule (LR-1) states:

Let $f(x, \beta)$ be continuous and have a continuous derivative $\frac{\partial}{\partial \beta}$ in a domain of $x\beta-$plane that includes the rectangle $a \le x \le b, \beta_1 \le \beta \le \beta_2,$

$\frac{d}{d\beta}\int\limits_{a}^{b}f(x, \beta)\;dx =\int\limits_{a}^{b}\frac{\partial}{\partial \beta}f(x, \beta)\;dx.$

I will derive LR-1 semi-rigorously as follows:

Let

$g(t) = \int\limits_{a}^{b} \frac{\partial}{\partial t}f(x, t)\;dx.\quad\quad\quad(1-1)$

Integrate (1-1) with respect to $t$ from a constant $\alpha$ to a variable $\beta$, we have

$\int\limits_{\alpha}^{\beta} g(t)\;dt = \int\limits_{\alpha}^{\beta}\left(\int\limits_{a}^{b} \frac{\partial}{\partial t}f(x, t)\;dx\right)\;dt$

$\overset{(\star)}{=}\int\limits_{a}^{b}\left(\int\limits_{\alpha}^{\beta} \frac{\partial}{\partial t}f(x, t)\;dt\right)\;dx$

$=\int\limits_{a}^{b}f(x, \beta) - f(x, \alpha)\; dx$

$=\int\limits_{a}^{b}f(x, \beta)\;dx - \int\limits_{a}^{b}f(x,\alpha)\; dx.$

That is,

$\int\limits_{\alpha}^{\beta} g(t)\;dt = \int\limits_{a}^{b}f(x, \beta)\;dx - \int\limits_{a}^{b}f(x,\alpha)\; dx.\quad\quad\quad(1-2)$

While $\int\limits_{\alpha}^{\beta}g(t)\;dt$ and $\int\limits_{a}^{b}f(x,\beta)\;dx$ are functions of $\beta$, $\int\limits_{a}^{b}f(x,\alpha)\;dx$ is a constant.

Since

$\frac{d}{d\beta}\int\limits_{\alpha}^{\beta} g(t)\;dt \overset{\textbf{FTC}}{= }g(\beta), \quad\frac{d}{d\beta}\left(\int\limits_{a}^{b}f(x, \beta)\;dx - \int\limits_{a}^{b}f(x,\alpha)\; dx\right)=\frac{d}{d\beta}\int\limits_{a}^{b}f(x, \beta)\;dx,$

differentiate (1-2) with respect to $\beta$ gives

$g(\beta) = \frac{d}{d\beta}\int\limits_{a}^{b}f(x, \beta)\;dx\overset{(1-1)}{\implies} \int\limits_{a}^{b} \frac{\partial}{\partial \beta}f(x, \beta)\;dx= \frac{d}{d\beta}\int\limits_{a}^{b}f(x, \beta)\;dx;$

i.e.,

$\frac{d}{d\beta}\int\limits_{a}^{b}f(x, \beta)\;dx = \int\limits_{a}^{b} \frac{\partial}{\partial \beta}f(x, \beta)\;dx.$

In the three-dimensional $x, y, z$-space, the double integral of a continuous function with two independent variables, $V=\iint_{R} f(x, y) dx dy$, may be interpreted as a volume between the surface $z=f(x, y)$ and the $x, y$-plane:

Fig. 1 $V = \iint_R f(x,y) dx dy$

We see from Fig. 1 that on one hand,

$V=\int\limits_{c}^{d}\int\limits_{a}^{b}f(x,y)\;dx dy,\quad\quad\quad(2-1)$

but on the other hand,

$V=\int\limits_{a}^{b}\int\limits_{c}^{d}f(x,y)\;dy dx.\quad\quad\quad(2-2)$

Since (2-1) and (2-2) amounts to the same thing, it must be true that

$\int\limits_{c}^{d}\int\limits_{a}^{b}f(x,y)\;dx dy=\int\limits_{a}^{b}\int\limits_{c}^{d}f(x,y)\;dy dx.\quad\quad\quad(\star)$

In other words, the order of integration can be interchanged.

# The beat of a different drum

“I had learned to do integrals by various methods shown in a book that my high school physics teacher Mr. Bader had given me. [It] showed how to differentiate parameters under the integral sign — it’s a certain operation. It turns out that’s not taught very much in the universities; they don’t emphasize it. But I caught on how to use that method, and I used that one damn tool again and again. [If] guys at MIT or Princeton had trouble doing a certain integral, [then] I come along and try differentiating under the integral sign, and often it worked. So I got a great reputation for doing integrals, only because my box of tools was different from everybody else’s, and they had tried all their tools on it before giving the problem to me.” (Richard P. Feynman, “Surely You’re Joking, Mr. Feynman!”, Bantam Book, 1985)

“Feynman’s Trick” is a powerful technique for evaluating nontrivial definite integrals. It is based on Leibniz’s rule (LR-1) which states:

Let $f(x, \beta)$ be a differentiable function in$\beta$ with $\frac{\partial}{\partial \beta}f(x, \beta)$ continuous. Then

$\frac{d}{d\beta}\int\limits_{a}^{b}f(x, \beta)\;dx = \int\limits_{a}^{b}\frac{\partial}{\partial \beta}f(x, \beta)\;dx.$

This is how it works in practice:

To evaluate definite integral

$\int\limits_{a}^{b} f(x)\;dx,$

we introduce into integrand $f(x)$ a parameter $\beta$ such that

$f(x) = f(x, \beta)$ when $\beta = \beta_0\quad\quad\quad(1)$

and

$\int\limits_{a}^{b}f(x,\beta)\;dx = f_*$ when $\beta = \beta_*.\quad\quad\quad(2)$

Suppose

$\int\limits_{a}^{b}\frac{\partial}{\partial \beta}f(x,\beta)\; dx=g(\beta).\quad\quad\quad(3)$

By Leibniz’s rule,

$\frac{d}{d\beta}\int\limits_{a}^{b}f(x, \beta)=\int\limits_{a}^{b}\frac{\partial}{\partial \beta}f(x,\beta)\; dx\overset{(3)}{=}g(\beta).\quad\quad\quad(4)$

Integrate (4) with respect to $\beta$:

$\int \left(\frac{d}{d\beta}\int\limits_{a}^{b}f(x, \beta)\;dx\right) \; d\beta = \int g(\beta)\;d\beta\implies \int\limits_{a}^{b}f(x,\beta)\;dx = G(\beta)+ C\quad(5)$

where $G'(\beta)=g(\beta).$

Let $\beta=\beta_*,$

$\int\limits_{a}^{b}f(x, \beta_*)\;dx \overset{(2)}{=} f_* \overset{(5)}{=} G(\beta_*) + C\implies C=f_*-G(\beta_*).$

Let $\beta = \beta_0,$

$\int\limits_{a}^{b}f(x) \;dx \overset{(1)}{=} \int\limits_{a}^{b}f(x, \beta_0)\;dx\overset{(5)}{=} G(\beta_0) + C.$

And so,

$\int\limits_{a}^{b}f(x) \;dx = G(\beta_0) + f_*-G(\beta_*).$

Now, let’s play “Feynman’s Trick” on definite integral $\int\limits_{0}^{1} \frac{x-1}{\log(x)}\;dx:$

Differentiate $\int\limits_{0}^{1}\frac{x^{\beta}-1}{\log(x)}\;dx$ with respect to $\beta,$ we have

$\frac{d}{d\beta}\int\limits_{0}^{1}\frac{x^\beta-1}{\log(x)}\;dx =\int\limits_{0}^{1}\frac{\partial}{\partial \beta}\frac{x^{\beta-1}}{\log(x)}\;dx=\int\limits_{0}^{1}\frac{x^{\beta}\log(x)}{\log(x)}\;dx=\int\limits_{0}^{1}x^{\beta}\;dx=\frac{x^{\beta+1}}{\beta+1}\bigg|_{0}^{1}=\frac{1}{\beta+1}.$

It means

$\int\limits_{0}^{1}\frac{x^{\beta}-1}{\log(x)}\;dx=\int\frac{1}{\beta+1}\;d\beta = \log(\beta+1)+C\overset{\beta=0}{\implies} 0=\log(0+1) +C \implies C=0.$

Hence,

$\int\limits_{0}^{1}\frac{x^{\beta}-1}{\log(x)}\;dx = \log(\beta+1).$

Let $\beta=1$,

$\int\limits_{0}^{1}\frac{x-1}{\log(x)}\;dx = \log(2).$

Exercise-1 Given $\int\limits_{-\infty}^{\infty}\frac{e^{2x}}{ae^{3x}+b}\;dx = \frac{2\pi}{3\sqrt{3}a^{2/3}b^{1/3}}$ where $a, b >0.$ Show that

$\int\limits_{-\infty}^{\infty}\frac{e^{2x}}{(e^{3x}+1)^2}\;dx = \frac{2\pi}{9\sqrt{3}}.$

# Playing “Feynman’s Trick” on Indefinite Integrals – Tongue in Cheek

“Differentiation under the integral sign”, a.k.a., “Feynman’s trick” is a clever application of Leibniz’s rule (LR-1):

Let $f(x, \beta)$ be continuous and have a continuous derivative $\frac{\partial}{\partial \beta}$ in a domain of $x\beta-$plane that includes the rectangle $a \le x \le b, \beta_1 \le \beta \le \beta_2,$

$\frac{d}{d\beta}\int\limits_{a}^{b}f(x, \beta)\;dx =\int\limits_{a}^{b}\frac{\partial}{\partial \beta}f(x, \beta)\;dx.$

“Feynman’s trick” is known to be an effective technique for evaluating difficult definite integral such as $\int\limits_{0}^{1}\frac{x-1}{\log(x)}\;dx.$

Is Feynman’s “trick” applicable to indefinite integrals too?

In other words, is it also true that

$\frac{\partial}{\partial \beta}\int f(x, \beta)\;dx + C = \int \frac{\partial}{\partial \beta}f(x, \beta)\;dx?\quad\quad\quad(\star)$

Let’s apply$(\star)$ to indefinite integral $\int \log(x)\;dx:$

$\frac{\partial}{\partial \beta}\int x^{\beta}\;dx+C = \int \frac{\partial}{\partial \beta}x^{\beta}\;dx = \int x^{\beta}\log(x)\;dx;$

i.e.,

$\int x^{\beta}\log(x)\;dx =\frac{\partial}{\partial \beta}\int x^{\beta}\;dx+C.\quad\quad\quad(1)$

Since $\int x^{\beta}\; dx = \frac{x^{\beta+1}}{\beta+1} + C_1$, the right-hand side of (1) is

$\frac{\partial}{\partial \beta}\left(\frac{x^{\beta+1}}{\beta+1}+C_1\right) + C= \frac{x^{\beta+1}\log(x)\cdot (\beta+1) - x^{\beta+1}}{(\beta+1)^2}+C.$

It means

$\int x^{\beta}\log(x)\;dx = \frac{x^{\beta+1}\log(x)\cdot (\beta+1) - x^{\beta+1}}{(\beta+1)^2}+C.$

For $\beta = 0$, we have

$\int \log(x)\;dx = x\log(x)-x+C.$

It checks out:

$\frac{d}{dx}(x\log(x)-x+C) = \log(x)+x \cdot \frac{1}{x}-1 = \log(x).$

Let’s also evaluate $\int x e^{x}\;dx:$

By $(\star),$

$\frac{\partial}{\partial \beta}\int e^{\beta x}\;dx + C = \int\frac{\partial}{\partial \beta} e^{\beta x}\;dx=\int x e^{\beta x}\;dx$.

That is,

$\int x e^{\beta x}\;dx = \frac{\partial}{\partial \beta}\int e^{\beta x}\; dx+C= \frac{\partial}{\partial \beta}\left(\frac{1}{\beta}e^{\beta x} + C_1\right)+C=\frac{e^{\beta x}\beta x - e^{\beta x}}{\beta^2}+C.\quad\quad(2)$

Let $\beta = 1$, (2) yields

$\int x e^{x} \;dx= e^x (x-1)+C.$

It checks out too:

$\frac{d}{dx} (e^x (x-1)+C) = e^x(x-1) + e^x = x e^x$.

Now that we have gained confidence in the validity of $(\star),$ let’s prove it.

Given

$G_1(x) = \int g(x)\;dx, G_2(x) = \int\limits_{a}^{x} g(x)\; dx$

where $g(x)$ is a function of $x$, we have,

$(G_1(x)-G_2(x))' = (\int g(x)\;dx)' - (\int\limits_{a}^{x} g(x) \;dx)'= g(x)-g(x) = 0$.

It means

$G_1(x)-G_2(x)=C\implies \int g(x)\;dx= \int\limits_{a}^{x}g(x)\;dx + C.$

When $x=b$,

$\int g(x)\;dx = \int\limits_{a}^{b}g(x)\;dx+C;$

i.e., for $f(x,\beta)$, a function of both $x$ and $\beta,$

$\int f(x,\beta)\;dx = \int\limits_{a}^{b} f(x, \beta)\;dx+C\quad\quad\quad(3)$

and,

$\int \frac{\partial}{\partial t} f(x,\beta)\;dx = \int\limits_{a}^{b} \frac{\partial}{\partial \beta}f(x, \beta)\;dx+C.\quad\quad\quad(4)$

It follows that

$\frac{\partial}{\partial \beta}\int f(x,\beta)\;dx \overset{(3)}{=} \frac{\partial}{\partial \beta}\left(\int\limits_{a}^{b}f(x,\beta)\;dx+C\right)$

$=\frac{\partial}{\partial \beta}\int\limits_{a}^{b}f(x,\beta)\;dx$

$\overset{\textbf{LR-1}}{=} \int\limits_{a}^{b}\frac{\partial}{\partial \beta}f(x,\beta)\;dt$

$\overset{(4)}{=} \int\frac{\partial }{\partial \beta}f(x,\beta)\;dx -C.$

And so,

$\frac{\partial}{\partial \beta}\int f(x,\beta)\;dx +C= \int \frac{\partial}{\partial \beta} f(x,\beta)\;dx.$

Exercise-1 Evaluate $\int x^2 e^x\;dx$.

hint: $\frac{\partial}{\partial \beta}\int x e^{\beta x}\;dx = \int x^2 e^{\beta x}\; dx.$

# Jump!

Problem Given

$f(x) = e^x + \int\limits_{0}^{x} (t-x)f(t)\;dt\quad\quad\quad(\star)$

where $f(x)$ is a continuous function, find $f(x).$

Solution

From $(\star)$, we see that

$f(0) = 1;$

$f(x) = e^x + \int\limits_{0}^{x} t\cdot f(t) - x\cdot f(t) \;dt = e^x + \int\limits_{0}^{x} t\cdot f(t)\;dt-x\cdot \int\limits_{0}^{x}f(t)\;dt$.

And so,

$\frac{df(x)}{dx}=\frac{de^x}{dx} + \frac{d}{dx}\int\limits_{0}^{x}tf(t)\;dt - \frac{d}{dx}\left(x\cdot \int\limits_{0}^{x}f(t)\;dt\right)$

$=e^x+\frac{d}{dx}\int\limits_{0}^{x}tf(t)\;dt-\left(\int\limits_{0}^{x}f(t)\;dt + x\frac{d}{dx}\int\limits_{0}^{x}f(t)\;dt\right)$

$\overset{\textbf{FTC}}{=}e^x + xf(x) -\int\limits_{0}^{x} f(t)\;dt - xf(x)$

$= e^x - \int\limits_{0}^{x}f(t)\;dt$

That is,

$\frac{d}{dx}f(x)= e^x - \int\limits_{0}^{x}f(t)\;dt\implies f'(0) = 1.$

It follows that

$\frac{d^2f(x)}{dx^2}=\frac{d}{dx}\left(e^x-\int\limits_{0}^{x}f(t)\;dt\right)=e^x-\frac{d}{dx}\left(\int\limits_{0}^{x}f(t)\;dt\right)\overset{\textbf{FTC}}{=}e^x-f(x).$

Solving

$\begin{cases} f''(x)=e^x-f(x) \\f(0)=1\\f'(0)=1 \end{cases}\quad\quad\quad(\star\star)$

gives

$f(x) = \frac{1}{2}(\sin(x)+\cos(x)+e^x).$

Fig. 1

Notice the derivation of $(\star\star)$ can be simplified if Leibniz’s Rule (LR-1, see “A Missing Piece from Popular Textbooks”) is applied:

$\frac{df(x)}{dx} = e^x + \underline{\frac{d}{dx}\int\limits_{0}^{x}(t-x)f(t)\;dt}$

$\overset{\textbf{LR-1}}{=} e^x + \underline{\int\limits_{0}^{x}\frac{\partial}{\partial x}(t-x)f(t)\;dt}$

$=e^x+\int\limits_{0}^{x}-1\cdot f(t)\;dt$

$= e^x-\int\limits_{0}^{x}f(t)\;dt$

$\implies \frac{d^2f(x)}{dx}=e^x-\frac{d}{dx}\int\limits_{0}^{x}f(t)\;dt\overset{\textbf{FTC}}{=}e^x-f(x).$

Fig.2 shows that Omega CAS explorer‘s Maxima engine is both FTC and LR-1 aware:

Fig. 2

Exercise-1 Given:

$f(x) = \int\limits_{0}^{x}t\cdot f(x-t)\;dt+\sin(x)$

where $f(x)$ is a continuous function, find $f(x).$

hint: Let $u=x-t, t = x-u; t=0\implies u=x; t=x\implies u=0; \frac{du}{dt}=-1$;

$f(x) = \int\limits_{x}^{0}(x-u)\cdot f(u)\cdot (-1)\;du + \sin(x)=\int\limits_{0}^{x}(x-u)f(u)\;du+\sin(x).$

# FTC saves the day!

Problem-1 Given

$f(x) = \int\limits_{0}^{2x}f(\frac{t}{2})\;dt +\log(2)\quad\quad\quad(\star)$

where $f(x)$ is a continuous function, find $f(x).$

Solution

Let

$p=2x \implies \frac{dp}{dx} = 2.\quad\quad\quad(1-1)$

By $(\star)$,

$\frac{df(x)}{dx} =\frac{d}{dx} \int\limits_{0}^{p} f(\frac{t}{2})\;dt + \frac{d\log(2)}{dx} = \underline{\frac{d}{dp}\left(\int\limits_{0}^{p} f(\frac{t}{2})\;dt\right)} \cdot \frac{dp}{dx}\overset{\textbf{FTC}}{=}\underline{f(\frac{p}{2})}\cdot \frac{dp}{dx}\overset{(1-1)}{=}2f(x),$

i.e.,

$\frac{df(x)}{dx} = 2f(x).\quad\quad\quad(1-2)$

Moreover, we see from $(\star)$ that

$f(0) = \int\limits_{0}^{0}f(\frac{t}{2})\;dt + \log(2) = 0 + \log(2) = \log(2).\quad\quad\quad(1-3)$

Solving initial-value problem

$\begin{cases} \frac{df(x)}{dx} = 2f(x)\\ f(0)=\log(2)\end{cases}$

gives

$f(x) = \log(2)\cdot e^{2x}.$

We use Omega CAS Explorer to verify:

Fig. 1-1

Problem-2 Given

$\int\limits_{0}^{1}f(u\cdot x) \;du = \frac{1}{2} f(x) +1\quad\quad\quad(\star\star)$

where $f(x)$ is a continuous function, find $f(x).$

Solution

Let $p=u\cdot x,$

$u=\frac{p}{x} \implies \frac{du}{dp} = \frac{1}{x}\quad\quad\quad(2-1)$

$u=0\implies p=0; u=1\implies p=x.\quad\quad\quad(2-2)$

$\int\limits_{0}^{1}f(u\cdot x)\;du\overset{(2)}{=} \int\limits_{0}^{x}f(p)\cdot\frac{du}{dp}\cdot dp\overset{(1)}{=}\int\limits_{0}^{x}f(p)\frac{1}{x}\;dp=\frac{1}{x}\int\limits_{0}^{x}f(p)\;dp.\quad\quad\quad(2-3)$

By (2-3), we express $(\star\star)$ as

$\frac{1}{x}\int\limits_{0}^{x}f(p)\;dp = \frac{1}{2}f(x)+1,$

i.e.,

$\int\limits_{0}^{x} f(p)\;dp = \frac{x}{2}f(x)+x.$

It follows that

$\underline{\frac{d}{dx}\left(\int\limits_{0}^{x}f(p)\;dp\right)}=\frac{d}{dx}\left(\frac{x}{2}f(x)+x\right)\overset{\textbf{FTC}}{\implies}\underline{f(x)}=\frac{1}{2}\left(f(x) + x\frac{d f(x)}{dx}\right)+1.\;(2-4)$

Solving differential equation (2-4) (see Fig. 2-1) gives

$f(x) = c x + 2.$

Fig. 2-1

The solution is verified by Omega CAS Explorer:

Fig. 2-2

Exercise-1 Solving $\begin{cases} \frac{df(x)}{dx} = 2f(x)\\ f(0)=\log(2)\end{cases}$ using a CAS.

Exercise-2 Solving (2-4) without using a CAS.

# An Epilogue to “Truth vs. Intellect”

This post illustrates an alternative of compute the approximate value of $\pi$.

We begin with a circle whose radius is $r$, and let $L_{n}, L_{n+1}$ denotes the side’s length of regular polygon inscribed in the circle with $2^n$ and $2^{n+1}$ sides respectively, $n=2, 4, ....$

Fig. 1

On one hand, we see the area of $\Delta ABC$ as

$\frac{1}{2}\cdot AB\cdot BC = \frac{1}{2}\cdot AB\cdot L_{n+1}$.

On the other hand, it is also

$\frac{1}{2}\cdot AC\cdot BE = \frac{1}{2}\cdot 2r\cdot \frac{L_n}{2}=\frac{1}{2}\cdot r\cdot L_n.$

Therefore,

$\frac{1}{2}AB\cdot L_{n+1}= \frac{1}{2}r\cdot L_n.$

Or,

$AB^2\cdot L_{n+1}^2 = r^2\cdot L_n^2\quad\quad\quad(1)$

where by Pythagorean theorem,

$AB^2= (2r)^2 - L_{n+1}^2.\quad\quad\quad(2)$

Substituting (2) into (1) gives

$(4r^2-L_{n+1}^2)L_{n+1}^2 = L_n^2\implies 4r^2L_{n+1}^2 - L_{n+1}^4 = r^2 L_n^2.$

That is,

$L_{n+1}^4-4r^2L_{n+1}^2+r^2 L_n^2 = 0.$

Let $p = L_{n+1}^2$, we have

$p^2-4r^2 p + r^2 L_n^2=0.\quad\quad\quad(3)$

Solving (3) for $p$ yields

$p = 2r^2 \pm r \sqrt{4 r^2-L_n^2}.$

Since $L_n^2$ must be greater than $L_{n+1}^2$ (see Exercise 1), it must be true (see Exercise 2) that

$L_{n+1}^2=2r^2 - r \sqrt{4r^2-L_n^2}.\quad\quad\quad(4)$

Notice when $r=\frac{1}{2}$, we obtain (5) in “Truth vs. Intellect“.

With increasing $n$,

$L_n\cdot 2^n \approx \pi\cdot 2r \implies \pi \approx \frac{L_n 2^n}{2r}.\quad\quad\quad$

We can now compute the approximate value of $\pi$ from any circle with radius $r$:

Fig. 2 $r=2$

Fig. 3 $r=\frac{1}{8}$

Exercise 1 Explain $L_{n}^2 > L_{n+1}^2$ geometrically.

Exercise 2 Show it is $2r^2-r\sqrt{4r^2-L_n^2}$ that represents $L_{n+1}^2.$

# Truth vs. Intellect

It was known long ago that $\pi$, the ratio of the circumference to the diameter of a circle, is a constant. Nearly all people of the ancient world used number $3$ for $\pi$. As an approximation obtained through physical measurements with limited accuracy, it is sufficient for everyday needs.

An ancient Chinese text (周髀算经,100 BC) stated that for a circle with unit diameter, the ratio is $3$.

In the Bible, we find the following description of a large vessel in the courtyard of King Solomon’s temple:

He made the Sea of cast metal, circular in shape, measuring ten cubits from rim to rim and five cubits high, It took a line of thirty cubits to measure around it. (1 Kings 7:23, New International Version)

This infers a value of $\pi = \frac{30}{10} = 3$.

It is fairly obvious that a regular polygon with many sides is approximately a circle. Its perimeter is approximately the circumference of the circle. The more sides the polygon has, the more accurate the approximation.

To find an accurate approximation for $\pi$, we inscribe regular polygons in a circle of diameter $1$. Let $L_{n}, L_{n+1}$ denotes the side’s length of regular polygon with $2^n$ and $2^{n+1}$ sides respectively, $n=2, 4, ....$

Fig. 1

From Fig. 1, we have

$\begin{cases} L_{n+1}^2 = x^2 + (\frac{1}{2} L_n)^2\quad\quad\quad(1) \\ (\frac{1}{2})^2 = (\frac{1}{2}L_n)^2 + y^2\quad\quad\;\quad(2)\\ x+y = \frac{1}{2}\;\quad\quad\quad\quad\quad\quad(3) \end{cases}$

It follows that

$y\overset{(2)}{=}\sqrt{(\frac{1}{2})^2-(\frac{1}{2} L_n)^2} \overset{(3)}{ \implies} x=\frac{1}{2}-\sqrt{(\frac{1}{2})^2-(\frac{1}{2}L_n)^2}.\quad\quad\quad(4)$

Substituting (4) into (1) yields

$L_{n+1}^2 = \left(\frac{1}{2}-\sqrt{(\frac{1}{2})^2-(\frac{1}{2}L_n)^2}\right)^2+(\frac{1}{2}L_n)^2$

That is,

$L_{n+1}^2 = \frac{1}{4}\left(L_n^2 + \left(1-\sqrt{1-L_n^2}\right)^2\right).$

Further simplification gives

$L_{n+1}^2 = \frac{1}{2}\left(1-\sqrt{1-L_n^2}\right),\quad\quad\quad(5)$

Starting with an inscribed square $(L_2^2 =\frac{1}{2})$, we compute $L_{n+1}^2$ from $L_{n}^2$ (see Fig. 2). The perimeter of the polygon with $2^{n+1}$ sides is $2^{n+1} \cdot L_{n+1}$.

Fig. 2

Clearly,

$\lim\limits_{n \rightarrow \infty} 2^n \cdot L_{n} = \pi$.

Exercise-1 Explain, and then make the appropriate changes:

Hint: (5) is equivalent to $L_{n+1}^2 = \frac{L_n^2}{2\left(1+\sqrt{1-L_{n}^2}\right)}.$

# We all bleed the same color

In “Mathematical Models in Biology”, Leah Edelstein-Keshet presents a model describing the number of circulating red blood cells (RBC’s). It assumes that the spleen filters out and destroys a fraction of the cells daily while the bone marrow produces a amount proportional to the number lost on the previous day:

$\begin{cases} R_{n+1} = (1-f)R_n+M_n\\ M_{n+1} = \gamma f R_n\end{cases}(1)$

where

$R_n -$ number of RBC’s in circulation on day $n$,

$M_n -$ number of RBC’s produced by marrow on day $n$,

$f -$ fraction of RBC’s removed by the spleen,

$\gamma -$ numer of RBC’s produced per number lost.

What would be the cell count on the $n^{th}$ day?

Observe first that (1) is equivalent to

$R_{n+2} = (1-f)R_{n+1}+M_{n+1}\quad\quad\quad(2)$

where

$M_{n+1} = \gamma f R_n.\quad\quad\quad(3)$

Let $n = -1$,

$M_0=\gamma f R_{-1} \implies R_{-1} = \frac{M_0}{\gamma f}.\quad\quad\quad(4)$

Substituting (3) into (2) yields

$R_{n+2} = (1-f)R_{n+1}+\gamma f R_{n}.$

We proceed to solve the following initial-value problem using ‘solve_rec‘ (see “Solving Difference Equations using Omega CAS Explorer“):

$\begin{cases} R_{n+2}=(1-f)R_{n+1}+\gamma f R_{n}\\ R_{0}=1, R_{-1} = \frac{1}{\gamma f}\end{cases}$

Evaluate the solution with $f=\frac{1}{2}, g=1$, we have

$R_n = \frac{4}{3} + \frac{(-1)^{n+1}2^{-n}}{3}.\quad\quad\quad(5)$

Plotting (5) by ‘plot2d(4/3 + (-1)^(n+1)*2^(-n)/3, [n, 0, 10], WEB_PLOT)’ fails (see Fig. 1) since plot2d treats (5) as a continuous function whose domain includes number such as $\frac{1}{2}$.

Fig. 1

Instead, a discrete plot is needed:

Fig. 2

From Fig. 2 we see that $R_{n}$ converges to a value between $1.3$ and $1.35$. In fact,

$\lim\limits_{n \rightarrow \infty} \frac{4}{3} + \frac{(-1)^{n+1}2^{-n}}{3} = \frac{4}{3}\approx 1.3333....$