Average Error: 19.5 → 0.3
Time: 12.1s
Precision: binary64
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
\[\begin{array}{l} t_0 := \frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right)}\\ t_0 \cdot \frac{t_0}{\frac{1}{\sqrt{x}} + \sqrt{\frac{1}{1 + x}}} \end{array} \]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right)}\\
t_0 \cdot \frac{t_0}{\frac{1}{\sqrt{x}} + \sqrt{\frac{1}{1 + x}}}
\end{array}
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
(FPCore (x)
 :precision binary64
 (let* ((t_0 (/ 1.0 (hypot x (sqrt x)))))
   (* t_0 (/ t_0 (+ (/ 1.0 (sqrt x)) (sqrt (/ 1.0 (+ 1.0 x))))))))
double code(double x) {
	return (1.0 / sqrt(x)) - (1.0 / sqrt(x + 1.0));
}
double code(double x) {
	double t_0 = 1.0 / hypot(x, sqrt(x));
	return t_0 * (t_0 / ((1.0 / sqrt(x)) + sqrt(1.0 / (1.0 + x))));
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original19.5
Target0.7
Herbie0.3
\[\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}} \]

Derivation

  1. Initial program 19.5

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Applied flip--_binary6419.6

    \[\leadsto \color{blue}{\frac{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}} \]
  3. Simplified19.6

    \[\leadsto \frac{\color{blue}{\frac{1}{x} - \frac{1}{1 + x}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}} \]
  4. Simplified19.6

    \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{\color{blue}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{1 + x}}}} \]
  5. Applied frac-sub_binary6418.8

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

    \[\leadsto \frac{\frac{\color{blue}{1}}{x \cdot \left(1 + x\right)}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{1 + x}}} \]
  7. Simplified5.3

    \[\leadsto \frac{\frac{1}{\color{blue}{\mathsf{fma}\left(x, x, x\right)}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{1 + x}}} \]
  8. Applied *-un-lft-identity_binary645.3

    \[\leadsto \frac{\frac{1}{\mathsf{fma}\left(x, x, x\right)}}{\color{blue}{1 \cdot \left(\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{1 + x}}\right)}} \]
  9. Applied add-sqr-sqrt_binary645.4

    \[\leadsto \frac{\frac{1}{\color{blue}{\sqrt{\mathsf{fma}\left(x, x, x\right)} \cdot \sqrt{\mathsf{fma}\left(x, x, x\right)}}}}{1 \cdot \left(\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{1 + x}}\right)} \]
  10. Applied add-cube-cbrt_binary645.4

    \[\leadsto \frac{\frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\sqrt{\mathsf{fma}\left(x, x, x\right)} \cdot \sqrt{\mathsf{fma}\left(x, x, x\right)}}}{1 \cdot \left(\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{1 + x}}\right)} \]
  11. Applied times-frac_binary645.3

    \[\leadsto \frac{\color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\sqrt{\mathsf{fma}\left(x, x, x\right)}} \cdot \frac{\sqrt[3]{1}}{\sqrt{\mathsf{fma}\left(x, x, x\right)}}}}{1 \cdot \left(\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{1 + x}}\right)} \]
  12. Applied times-frac_binary645.3

    \[\leadsto \color{blue}{\frac{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\sqrt{\mathsf{fma}\left(x, x, x\right)}}}{1} \cdot \frac{\frac{\sqrt[3]{1}}{\sqrt{\mathsf{fma}\left(x, x, x\right)}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{1 + x}}}} \]
  13. Simplified5.3

    \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right)}} \cdot \frac{\frac{\sqrt[3]{1}}{\sqrt{\mathsf{fma}\left(x, x, x\right)}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{1 + x}}} \]
  14. Simplified0.3

    \[\leadsto \frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right)} \cdot \color{blue}{\frac{\frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right)}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{1 + x}}}} \]
  15. Applied *-un-lft-identity_binary640.3

    \[\leadsto \frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right)} \cdot \frac{\frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right)}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{\color{blue}{1 \cdot \left(1 + x\right)}}}} \]
  16. Applied sqrt-prod_binary640.3

    \[\leadsto \frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right)} \cdot \frac{\frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right)}}{\frac{1}{\sqrt{x}} + \frac{1}{\color{blue}{\sqrt{1} \cdot \sqrt{1 + x}}}} \]
  17. Applied add-cube-cbrt_binary640.3

    \[\leadsto \frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right)} \cdot \frac{\frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right)}}{\frac{1}{\sqrt{x}} + \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\sqrt{1} \cdot \sqrt{1 + x}}} \]
  18. Applied times-frac_binary640.3

    \[\leadsto \frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right)} \cdot \frac{\frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right)}}{\frac{1}{\sqrt{x}} + \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\sqrt{1}} \cdot \frac{\sqrt[3]{1}}{\sqrt{1 + x}}}} \]
  19. Simplified0.3

    \[\leadsto \frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right)} \cdot \frac{\frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right)}}{\frac{1}{\sqrt{x}} + \color{blue}{1} \cdot \frac{\sqrt[3]{1}}{\sqrt{1 + x}}} \]
  20. Simplified0.3

    \[\leadsto \frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right)} \cdot \frac{\frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right)}}{\frac{1}{\sqrt{x}} + 1 \cdot \color{blue}{\sqrt{\frac{1}{1 + x}}}} \]
  21. Final simplification0.3

    \[\leadsto \frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right)} \cdot \frac{\frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right)}}{\frac{1}{\sqrt{x}} + \sqrt{\frac{1}{1 + x}}} \]

Reproduce

herbie shell --seed 2022100 
(FPCore (x)
  :name "2isqrt (example 3.6)"
  :precision binary64

  :herbie-target
  (/ 1.0 (+ (* (+ x 1.0) (sqrt x)) (* x (sqrt (+ x 1.0)))))

  (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))