Approximating function $f(x)=\sqrt{\sqrt{e^{x}}}$

211 Views Asked by At

I've been tryng to find a good (accurate) low order (2-3) approximation for functions $e^x$ and $2^x$. Found out that taking square root of the function improves accuracy a bit ... and taking multiple square roots even more. So, approximating improves accuracy as seen in example plots:

  1. $f(x)=\sqrt{\sqrt{e^{x}}}$

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

I've noticed that in case of approximation of $2^x$, $f(x)=\sqrt{\sqrt{\sqrt{2^{x}}}}$ (i.e. $2^\frac x{2^3}$ ) produces almost straight line to approximate (sollya code for 3rd order approximation)

f=sqrt(sqrt(sqrt(sqrt(2^x))))
p=remez(f,3,dom_log);
accurateinfnorm((((p^2)^2)^2)^2-2^x,[-0.5;0.5],20); 2.538871513024787418544292449951171875e-8
dirtyinfnorm((((p^2)^2)^2)^2-2^x,[-0.5;0.5]); 2.53887148348479669618870887598400206143150554903096e-8

enter image description here

Errors compared to $2^x$ :

enter image description here enter image description here remez(2^x,3,[-0.5;0.5]);

...

enter image description here remez(sqrt(sqrt(sqrt(2^x))),3,[-0.5;0.5]);

... which sure could help to find a good approximation but,... are there drawbacks in doing it this way?

Edit: My intention is to use this approximation in an implementation the way as like done here.

1

There are 1 best solutions below

0
On

Since, for any positive number, you can write $$a^x=e^{x\log(a)}$$ and that $$\sqrt{a^x}=e^{\frac 12 x\log(a)}\qquad \sqrt{\sqrt{a^x}}=e^{\frac 14 x\log(a)}\qquad\sqrt{\sqrt{\sqrt{a^x}}}=e^{\frac 18 x\log(a)}$$ and so on we can build the $[n,n]$ Padé approximants $$e^{kx}=\frac{1+\frac{k }{2}x+\frac{k^2 }{12}x^2 } {1-\frac{k }{2}x+\frac{k^2 }{12}x^2 }\tag 1$$ $$e^{kx}=\frac{1+\frac{k}{2}x+\frac{k^2 }{10}x^2+\frac{k^3 }{120}x^3 } {1-\frac{k}{2}x+\frac{k^2 }{10}x^2-\frac{k^3 }{120}x^3 }\tag 2$$

For the case of $$\sqrt{\sqrt{\sqrt{2^x}}}$$ using $(2)$ for the range $-\frac 12 \leq x \leq \frac 12$, the maximum absolute error is (at the bound) $3.06 \times 10^{-12}$