Average Error: 0.2 → 0.2
Time: 2.1s
Precision: binary64
Cost: 7041
\[\frac{x}{1 + \sqrt{x + 1}}\]
\[\begin{array}{l} \mathbf{if}\;x \leq 7.897555139426257 \cdot 10^{-06}:\\ \;\;\;\;\frac{x}{2 + x \cdot 0.5}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x + 1} + -1\\ \end{array}\]
\frac{x}{1 + \sqrt{x + 1}}
\begin{array}{l}
\mathbf{if}\;x \leq 7.897555139426257 \cdot 10^{-06}:\\
\;\;\;\;\frac{x}{2 + x \cdot 0.5}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{x + 1} + -1\\

\end{array}
(FPCore (x) :precision binary64 (/ x (+ 1.0 (sqrt (+ x 1.0)))))
(FPCore (x)
 :precision binary64
 (if (<= x 7.897555139426257e-06)
   (/ x (+ 2.0 (* x 0.5)))
   (+ (sqrt (+ x 1.0)) -1.0)))
double code(double x) {
	return x / (1.0 + sqrt(x + 1.0));
}
double code(double x) {
	double tmp;
	if (x <= 7.897555139426257e-06) {
		tmp = x / (2.0 + (x * 0.5));
	} else {
		tmp = sqrt(x + 1.0) + -1.0;
	}
	return tmp;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Alternatives

Alternative 1
Error0.2
Cost6848
\[\frac{x}{1 + \sqrt{x + 1}}\]
Alternative 2
Error20.2
Cost448
\[\frac{x}{2 + x \cdot 0.5}\]
Alternative 3
Error20.7
Cost192
\[x \cdot 0.5\]
Alternative 4
Error60.9
Cost64
\[1\]

Error

Derivation

  1. Split input into 2 regimes
  2. if x < 7.89755513942625704e-6

    1. Initial program 0.0

      \[\frac{x}{1 + \sqrt{x + 1}}\]
    2. Taylor expanded around 0 0.3

      \[\leadsto \frac{x}{\color{blue}{0.5 \cdot x + 2}}\]
    3. Simplified0.3

      \[\leadsto \frac{x}{\color{blue}{2 + x \cdot 0.5}}\]
    4. Simplified0.3

      \[\leadsto \color{blue}{\frac{x}{2 + x \cdot 0.5}}\]

    if 7.89755513942625704e-6 < x

    1. Initial program 0.5

      \[\frac{x}{1 + \sqrt{x + 1}}\]
    2. Using strategy rm
    3. Applied flip-+_binary64_31210.6

      \[\leadsto \frac{x}{\color{blue}{\frac{1 \cdot 1 - \sqrt{x + 1} \cdot \sqrt{x + 1}}{1 - \sqrt{x + 1}}}}\]
    4. Applied associate-/r/_binary64_30930.7

      \[\leadsto \color{blue}{\frac{x}{1 \cdot 1 - \sqrt{x + 1} \cdot \sqrt{x + 1}} \cdot \left(1 - \sqrt{x + 1}\right)}\]
    5. Simplified0.1

      \[\leadsto \color{blue}{-1} \cdot \left(1 - \sqrt{x + 1}\right)\]
    6. Simplified0.1

      \[\leadsto \color{blue}{\sqrt{x + 1} + -1}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 7.897555139426257 \cdot 10^{-06}:\\ \;\;\;\;\frac{x}{2 + x \cdot 0.5}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x + 1} + -1\\ \end{array}\]

Reproduce

herbie shell --seed 2021044 
(FPCore (x)
  :name "Numeric.Log:$clog1p from log-domain-0.10.2.1, B"
  :precision binary64
  (/ x (+ 1.0 (sqrt (+ x 1.0)))))