Average Error: 32.9 → 16.4
Time: 2.0m
Precision: 64
Internal Precision: 3392
$\sqrt{1 - 0.5 \cdot \left(1 + \frac{x - y}{\sqrt{p + {\left(x - y\right)}^{2}}}\right)}$
$\begin{array}{l} \mathbf{if}\;x - y \le -2.50943054587483 \cdot 10^{+155}:\\ \;\;\;\;\sqrt{1 - 0.5 \cdot \left(1 + \frac{x - y}{y - x}\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\left(1 - 0.5\right) - 0.5 \cdot \frac{x - y}{\sqrt{p + {\left(x - y\right)}^{2}}}}\\ \end{array}$

# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 2 regimes
2. ## if (- x y) < -2.50943054587483e+155

1. Initial program 51.2

$\sqrt{1 - 0.5 \cdot \left(1 + \frac{x - y}{\sqrt{p + {\left(x - y\right)}^{2}}}\right)}$
2. Taylor expanded around 0 0

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

## if -2.50943054587483e+155 < (- x y)

1. Initial program 24.2

$\sqrt{1 - 0.5 \cdot \left(1 + \frac{x - y}{\sqrt{p + {\left(x - y\right)}^{2}}}\right)}$
2. Using strategy rm
3. Applied distribute-lft-in24.2

$\leadsto \sqrt{1 - \color{blue}{\left(0.5 \cdot 1 + 0.5 \cdot \frac{x - y}{\sqrt{p + {\left(x - y\right)}^{2}}}\right)}}$
4. Applied associate--r+24.2

$\leadsto \sqrt{\color{blue}{\left(1 - 0.5 \cdot 1\right) - 0.5 \cdot \frac{x - y}{\sqrt{p + {\left(x - y\right)}^{2}}}}}$
5. Applied simplify24.2

$\leadsto \sqrt{\color{blue}{\left(1 - 0.5\right)} - 0.5 \cdot \frac{x - y}{\sqrt{p + {\left(x - y\right)}^{2}}}}$
3. Recombined 2 regimes into one program.

# Runtime

Time bar (total: 2.0m)Debug log

herbie shell --seed '#(2775764126 3555076145 3898259844 1891440260 2599947619 1948460636)'
(FPCore (x y p)
:name "sqrt(1 - .5*( 1 +(x-y)/(sqrt(p + (x-y)^2))))"
(sqrt (- 1 (* 0.5 (+ 1 (/ (- x y) (sqrt (+ p (pow (- x y) 2)))))))))