Average Error: 30.9 → 0.3
Time: 8.2s
Precision: 64
$\sqrt{x \cdot x + 1} - 1$
$\begin{array}{l} \mathbf{if}\;x \le -1.165295338898229005053508444689214229584:\\ \;\;\;\;-\left(1 + \left(x + \frac{0.5}{x}\right)\right)\\ \mathbf{elif}\;x \le 1.148825357502678556897990347351878881454:\\ \;\;\;\;\left(\frac{{x}^{6}}{{\left(\sqrt{1} + 1\right)}^{3} \cdot 1} \cdot \frac{1}{4} + \left(\frac{1}{8} \cdot \frac{{x}^{6}}{{\left(\sqrt{1} + 1\right)}^{2} \cdot {\left(\sqrt{1}\right)}^{3}} + \frac{{x}^{2}}{\sqrt{1} + 1}\right)\right) + \frac{-1}{2} \cdot \frac{{x}^{4}}{{\left(\sqrt{1} + 1\right)}^{2} \cdot \sqrt{1}}\\ \mathbf{else}:\\ \;\;\;\;x + \left(\frac{0.5}{x} - 1\right)\\ \end{array}$
\sqrt{x \cdot x + 1} - 1
\begin{array}{l}
\mathbf{if}\;x \le -1.165295338898229005053508444689214229584:\\
\;\;\;\;-\left(1 + \left(x + \frac{0.5}{x}\right)\right)\\

\mathbf{elif}\;x \le 1.148825357502678556897990347351878881454:\\
\;\;\;\;\left(\frac{{x}^{6}}{{\left(\sqrt{1} + 1\right)}^{3} \cdot 1} \cdot \frac{1}{4} + \left(\frac{1}{8} \cdot \frac{{x}^{6}}{{\left(\sqrt{1} + 1\right)}^{2} \cdot {\left(\sqrt{1}\right)}^{3}} + \frac{{x}^{2}}{\sqrt{1} + 1}\right)\right) + \frac{-1}{2} \cdot \frac{{x}^{4}}{{\left(\sqrt{1} + 1\right)}^{2} \cdot \sqrt{1}}\\

\mathbf{else}:\\
\;\;\;\;x + \left(\frac{0.5}{x} - 1\right)\\

\end{array}
double f(double x) {
double r1738762 = x;
double r1738763 = r1738762 * r1738762;
double r1738764 = 1.0;
double r1738765 = r1738763 + r1738764;
double r1738766 = sqrt(r1738765);
double r1738767 = r1738766 - r1738764;
return r1738767;
}

double f(double x) {
double r1738768 = x;
double r1738769 = -1.165295338898229;
bool r1738770 = r1738768 <= r1738769;
double r1738771 = 1.0;
double r1738772 = 0.5;
double r1738773 = r1738772 / r1738768;
double r1738774 = r1738768 + r1738773;
double r1738775 = r1738771 + r1738774;
double r1738776 = -r1738775;
double r1738777 = 1.1488253575026786;
bool r1738778 = r1738768 <= r1738777;
double r1738779 = 6.0;
double r1738780 = pow(r1738768, r1738779);
double r1738781 = sqrt(r1738771);
double r1738782 = r1738781 + r1738771;
double r1738783 = 3.0;
double r1738784 = pow(r1738782, r1738783);
double r1738785 = r1738784 * r1738771;
double r1738786 = r1738780 / r1738785;
double r1738787 = 0.25;
double r1738788 = r1738786 * r1738787;
double r1738789 = 0.125;
double r1738790 = 2.0;
double r1738791 = pow(r1738782, r1738790);
double r1738792 = pow(r1738781, r1738783);
double r1738793 = r1738791 * r1738792;
double r1738794 = r1738780 / r1738793;
double r1738795 = r1738789 * r1738794;
double r1738796 = pow(r1738768, r1738790);
double r1738797 = r1738796 / r1738782;
double r1738798 = r1738795 + r1738797;
double r1738799 = r1738788 + r1738798;
double r1738800 = -0.5;
double r1738801 = 4.0;
double r1738802 = pow(r1738768, r1738801);
double r1738803 = r1738791 * r1738781;
double r1738804 = r1738802 / r1738803;
double r1738805 = r1738800 * r1738804;
double r1738806 = r1738799 + r1738805;
double r1738807 = r1738773 - r1738771;
double r1738808 = r1738768 + r1738807;
double r1738809 = r1738778 ? r1738806 : r1738808;
double r1738810 = r1738770 ? r1738776 : r1738809;
return r1738810;
}

# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 3 regimes
2. ## if x < -1.165295338898229

1. Initial program 32.2

$\sqrt{x \cdot x + 1} - 1$
2. Taylor expanded around -inf 0.3

$\leadsto \color{blue}{-\left(x + \left(0.5 \cdot \frac{1}{x} + 1\right)\right)}$
3. Simplified0.3

$\leadsto \color{blue}{-\left(1 + \left(x + \frac{0.5}{x}\right)\right)}$

## if -1.165295338898229 < x < 1.1488253575026786

1. Initial program 30.0

$\sqrt{x \cdot x + 1} - 1$
2. Using strategy rm
3. Applied flip--30.0

$\leadsto \color{blue}{\frac{\sqrt{x \cdot x + 1} \cdot \sqrt{x \cdot x + 1} - 1 \cdot 1}{\sqrt{x \cdot x + 1} + 1}}$
4. Simplified29.9

$\leadsto \frac{\color{blue}{\left(x \cdot x + 1\right) - 1 \cdot 1}}{\sqrt{x \cdot x + 1} + 1}$
5. Taylor expanded around 0 0.3

$\leadsto \color{blue}{\left(\frac{1}{8} \cdot \frac{{x}^{6}}{{\left(\sqrt{1} + 1\right)}^{2} \cdot {\left(\sqrt{1}\right)}^{3}} + \left(\frac{{x}^{2}}{\sqrt{1} + 1} + \frac{1}{4} \cdot \frac{{x}^{6}}{{\left(\sqrt{1} + 1\right)}^{3} \cdot {\left(\sqrt{1}\right)}^{2}}\right)\right) - \frac{1}{2} \cdot \frac{{x}^{4}}{{\left(\sqrt{1} + 1\right)}^{2} \cdot \sqrt{1}}}$
6. Simplified0.3

$\leadsto \color{blue}{\left(\frac{{x}^{6}}{{\left(\sqrt{1} + 1\right)}^{3} \cdot 1} \cdot \frac{1}{4} + \left(\frac{1}{8} \cdot \frac{{x}^{6}}{{\left(\sqrt{1} + 1\right)}^{2} \cdot {\left(\sqrt{1}\right)}^{3}} + \frac{{x}^{2}}{\sqrt{1} + 1}\right)\right) + \frac{-1}{2} \cdot \frac{{x}^{4}}{{\left(\sqrt{1} + 1\right)}^{2} \cdot \sqrt{1}}}$

## if 1.1488253575026786 < x

1. Initial program 31.6

$\sqrt{x \cdot x + 1} - 1$
2. Using strategy rm
3. Applied flip--31.7

$\leadsto \color{blue}{\frac{\sqrt{x \cdot x + 1} \cdot \sqrt{x \cdot x + 1} - 1 \cdot 1}{\sqrt{x \cdot x + 1} + 1}}$
4. Simplified31.7

$\leadsto \frac{\color{blue}{\left(x \cdot x + 1\right) - 1 \cdot 1}}{\sqrt{x \cdot x + 1} + 1}$
5. Taylor expanded around inf 0.3

$\leadsto \color{blue}{\left(x + 0.5 \cdot \frac{1}{x}\right) - 1}$
6. Simplified0.3

$\leadsto \color{blue}{x + \left(\frac{0.5}{x} - 1\right)}$
3. Recombined 3 regimes into one program.
4. Final simplification0.3

$\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.165295338898229005053508444689214229584:\\ \;\;\;\;-\left(1 + \left(x + \frac{0.5}{x}\right)\right)\\ \mathbf{elif}\;x \le 1.148825357502678556897990347351878881454:\\ \;\;\;\;\left(\frac{{x}^{6}}{{\left(\sqrt{1} + 1\right)}^{3} \cdot 1} \cdot \frac{1}{4} + \left(\frac{1}{8} \cdot \frac{{x}^{6}}{{\left(\sqrt{1} + 1\right)}^{2} \cdot {\left(\sqrt{1}\right)}^{3}} + \frac{{x}^{2}}{\sqrt{1} + 1}\right)\right) + \frac{-1}{2} \cdot \frac{{x}^{4}}{{\left(\sqrt{1} + 1\right)}^{2} \cdot \sqrt{1}}\\ \mathbf{else}:\\ \;\;\;\;x + \left(\frac{0.5}{x} - 1\right)\\ \end{array}$

# Reproduce

herbie shell --seed 1
(FPCore (x)
:name "sqrt(x*x + 1) - 1"
:precision binary64
(- (sqrt (+ (* x x) 1)) 1))