Average Error: 19.6 → 0.0
Time: 9.0s
Precision: 64
Internal precision: 128
\[\sqrt{x \cdot x + y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.798458072626415 \cdot 10^{+148}:\\ \;\;\;\;-\left(x + \frac{1}{2} \cdot \frac{y}{x}\right)\\ \mathbf{if}\;x \le 3.3156380580081446 \cdot 10^{+107}:\\ \;\;\;\;\sqrt{x \cdot x + y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{1}{2} \cdot \frac{y}{x}\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Target

Original19.6
Comparison0.3
Herbie0.0
\[ \begin{array}{l} \mathbf{if}\;x \lt -1.5097698010472593 \cdot 10^{+153}:\\ \;\;\;\;-\left(\frac{1}{2} \cdot \frac{y}{x} + x\right)\\ \mathbf{if}\;x \lt 5.582399551122541 \cdot 10^{+57}:\\ \;\;\;\;\sqrt{{x}^2 + y}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{y}{x} + x\\ \end{array} \]

Derivation

  1. Split input into 3 regimes.
  2. if x < -1.798458072626415e+148

    1. Initial program 57.9

      \[\sqrt{x \cdot x + y}\]
    2. Applied taylor 0

      \[\leadsto -\left(x + \frac{1}{2} \cdot \frac{y}{x}\right)\]
    3. Taylor expanded around -inf 0

      \[\leadsto \color{blue}{-\left(x + \frac{1}{2} \cdot \frac{y}{x}\right)}\]

    if -1.798458072626415e+148 < x < 3.3156380580081446e+107

    1. Initial program 0.0

      \[\sqrt{x \cdot x + y}\]

    if 3.3156380580081446e+107 < x

    1. Initial program 46.2

      \[\sqrt{x \cdot x + y}\]
    2. Applied taylor 0.0

      \[\leadsto x + \frac{1}{2} \cdot \frac{y}{x}\]
    3. Taylor expanded around inf 0.0

      \[\leadsto \color{blue}{x + \frac{1}{2} \cdot \frac{y}{x}}\]
  3. Recombined 3 regimes into one program.
  4. Removed slow pow expressions

Runtime

Time bar (total: 9.0s) Debug log

Please include this information when filing a bug report:

herbie --seed '#(1213585941 1107528756 3166255956 227454801 1182528254 2608549406)'
(FPCore (x y)
  :name "Linear.Quaternion:$clog from linear-1.19.1.3"

  :target
  (if (< x -1.5097698010472593e+153) (- (+ (* 1/2 (/ y x)) x)) (if (< x 5.582399551122541e+57) (sqrt (+ (sqr x) y)) (+ (* 1/2 (/ y x)) x)))

  (sqrt (+ (* x x) y)))