April 2023

You are currently browsing the monthly archive for April 2023.

The following function has come up twice in my research

$$f(a,b)=\frac{\ln(b)-\ln(a)}{b-a}$$ where $0<a<b.$

Now, I had known that if $a$ and $b$ are close, then $$f(a,b)\approx\frac{1}{\mathrm{mean}(a,b)}$$ and $$\frac{1}{b}<f(a,b)<\frac1{a}.$$ But last week, with a little help from GPT, I got some better approximations and bounds on $f(a,b)$.

Let $m=(a+b)/2$ and $\Delta = (b-a)/2$.

Below GPT and I derive the following

  • $$1/b < f(a,b) < 1/a,$$
  • $$1/m <  f(a,b) < 1/m + \frac{\Delta^2}{3m}\left(\frac{1}{m^2-\Delta^2 }\right),$$
  • $$ -\frac{2\Delta^4}{15a^5}< f(a,b)\; – \frac{1}{6}\left(\frac{1}{a}+\frac{4}{m}+\frac{1}{b}\right) < -\frac{2\Delta^4}{15b^5},\mathrm{\ and}$$
  • $$\begin{aligned} f(a,b) &= \frac{ \tanh^{-1}(\Delta/m)}{\Delta} = \frac1{m} \frac{ \tanh^{-1}(\Delta/m)}{\Delta/m}\\&= \frac{1}{\Delta} \left(\frac{\Delta}{m} + \frac{\Delta^3}{3m^3}+ \frac{\Delta^5}{5m^5} + \cdots\right)\\  &= \frac{1}{m} \left(1 + \frac{\Delta^2}{3m^2}+ \frac{\Delta^4}{5m^4} + \cdots\right) \end{aligned}$$

where  $$ \tanh^{-1}(y) = x$$ if and only if $$\tanh(x) := \frac{ e^x-e^{-x}}{e^x + e^{-x}} =y$$ for any $x\in\mathbb{R}$ and $y\in(-1,1)$.

(Alternatively, $$\tanh^{-1}(x) = \frac{1}{2} \ln (x+1)-\frac{1}{2} \ln (1-x)$$ where $\ln(x)$ is the natural log and $|x|<1$.)

The derivation

At first I tried to use Taylor Series to bound $f(a,b)$, but it was a bit convoluted so I asked GPT. GPT created a much nicer, simpler proof. (See this PDF). GPT’s key observation was that $$f(a,b)= \frac{\ln(b)-\ln(a)}{b-a} = \frac{1}{b-a}\int_a^b \frac{dx}{x}$$ is the mean value of $1/x$ over the interval $[a,b]$. (In truth, I felt a bit dumb for not having noticed this. Lol.)

GPT’s observation inspires a bit more analysis.

Let $$z= \frac{x}{m} -1,\mathrm{\ so\ \ } m(z+1)=x.$$ If $x=a$, then
$$z= \frac{a}{m} -1= \frac{m-\Delta}{m} – 1= -\frac{\Delta}{m}.$$
Similarly, if $x=b$,
$$z= \frac{b}{m} -1= \frac{m+\Delta}{m} – 1= \frac{\Delta}{m}.$$
Applying these substitutions to the integral yields
$$\begin{aligned}
\int_{x=a}^{x=b} \frac{dx}{x} &=\int_{z=-\Delta/m}^{z=\Delta/m}\frac{m\;dz}{m(z+1)} \\
&=\int_{z=-\Delta/m}^{z=\Delta/m}\frac{dz}{z+1} \\
&=\int_{z=-\Delta/m}^{z=\Delta/m} (1-z+z^2-z^3+\cdots)dz\\
&=\int_{z=-\Delta/m}^{z=\Delta/m} (1+z^2+z^4+\cdots)dz\\
&=\int_{z=-\Delta/m}^{z=\Delta/m} \frac{dz}{1-z^2}\\
&=\left.\tanh^{-1}(z)\right|_{z=-\Delta/m}^{z=\Delta/m} \\
&= \tanh^{-1}(\Delta/m) – \tanh^{-1}(-\Delta/m)\\
&= 2 \tanh^{-1}(\Delta/m).
\end{aligned}$$
(Above we twice applied the wonderful thumb rule $$\frac{1}{1-x} = 1+ x + x^2 +x^3+\dots$$ if $|x|<1$. See idea #87 from the top 100 math ideas.)

So,
$$\frac{\ln(b) – \ln(a)}{b-a} =\frac{ 2 \tanh^{-1}(\Delta/m)}{b-a}=\frac{ \tanh^{-1}(\Delta/m)}{\Delta}.$$

Furthermore,
$$
\tanh^{-1}(x) = x + x^3/3 + x^5/5 + \cdots,
$$
so
$$\begin{aligned}
f(a,b) = \frac{\ln(b) – \ln(a)}{b-a} &= \frac{1}{\Delta} \left(\frac{\Delta}{m} + \frac{\Delta^3}{3m^3}+ \frac{\Delta^5}{5m^5} + \cdots\right) \\
&=\frac{1}{m} + \frac{\Delta^2}{3m^3}+ \frac{\Delta^4}{5m^5} + \frac{\Delta^6}{7m^7} + \cdots
\end{aligned}$$
This series gives us some nice approximations of $f(a,b)$ when $\Delta/m<1/2$. We can also bound the error of the approximation $$f(a,b)\approx 1/m$$ as follows $$\begin{aligned}
\frac{1}{m} <\frac{\ln(b) – \ln(a)}{b-a}&=\frac{1}{m} + \frac{\Delta^2}{3m^3}+ \frac{\Delta^4}{5m^5} + \frac{\Delta^6}{7m^7} + \cdots \\
&<\frac{1}{m} + \frac{\Delta^2}{3m^3}+ \frac{\Delta^4}{3m^5} + \frac{\Delta^6}{3m^7} + \cdots \\
&=\frac{1}{m} + \frac{\Delta^2}{3m^3}(1 + \frac{\Delta^2}{m^2} + \frac{\Delta^4}{m^4} + \cdots )\\
&=\frac{1}{m} + \frac{\Delta^2}{3m^3}\left(\frac{1}{1-\frac{\Delta^2}{m^2} }\right)\\
&=\frac{1}{m} + \frac{\Delta^2}{3m}\left(\frac{1}{m^2-\Delta^2 }\right).\\
\end{aligned} $$

Example.

Let $a= 6/100$ and $b=7/100$. Then $m=13/200$, $\Delta = 1/200$,

  • $$\frac{\ln(b)-\ln(a)}{b-a}= \tanh^{-1}(\Delta/m)/\Delta \approx 15.415067982725830429,$$
  • $$1/m \approx 15.3846,$$
  • $$1/m + \Delta^2/(3 m^3)\approx 15.41496,\ \mathrm{and}$$
  • $$1/m + \Delta^2/(3 m^3) + \Delta^4/(5 m^5)\approx 15.4150675.$$
  • $$1/m+ \frac{\Delta^2}{3m}\left(\frac{1}{m^2-\Delta^2 }\right)\approx 15.41514$$

 

Applying Simpson’s Rule

We can also use Simpson’s rule to approximate $\ln(b)-\ln(a)$.  The error formula for Simpson’s rule is

$$\begin{align}\int_{a}^{b}g(x)\,dx&=\frac{\Delta}{3}[g(a)+4g(m)+g(b)]-\frac{\Delta^5}{90}g^{(4)}(\xi)\end{align}$$

for some $\xi$ in the interval $(a,b)$. Setting $g(x)=1/x$, $$I=\ln(b)-\ln(a),\quad\mathrm{ and }\quad h(a,b)= \frac{\Delta}{3}\left(\frac{1}{a}+\frac{4}{m}+\frac{1}{b}\right)$$ with $m=(a+b)/2$ and $\Delta=(b-a)/2$ gives

$$\begin{align} \ln(b) – \ln(a) &=\frac{\Delta}{3}\left(\frac{1}{a}+\frac{4}{m}+\frac{1}{b}\right)-\frac{\Delta^5}{90}\frac{24}{\xi^5} \\ I&=h(a,b)-\frac{4\Delta^5}{15\xi^5}\\I-h(a,b) &= -\frac{4\Delta^5}{15\xi^5}\\-\frac{4\Delta^5}{15a^5}&< I-h(a,b) < -\frac{4\Delta^5}{15b^5}.\end{align}$$

Now we divide by $2\Delta = b-a$ to conclude that
$$\begin{aligned}\frac{\ln(b) – \ln(a)}{b-a}&= \frac{1}{6}\left(\frac{1}{a}+\frac{8}{a+b}+\frac{1}{b}\right) + error \\&= \frac{1}{6}\left(\frac{1}{a}+\frac{4}{m}+\frac{1}{b}\right) + error \\&\approx \frac{1}{6}\left(\frac{1}{a}+\frac{4}{m}+\frac{1}{b}\right) -\frac{2\Delta^4}{15m^5}\end{aligned}$$
where
$$ -\frac{2\Delta^4}{15a^5}< error < -\frac{2\Delta^4}{15b^5}.$$

 

(Thanks to GPT and StackEdit(https://stackedit.io/).)