Average Error: 15.2 → 0.2
Time: 12.8s
Precision: 64
Internal precision: 128
\[\frac{\left(x \cdot 2.0\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -4.28061768498452 \cdot 10^{-40}:\\ \;\;\;\;\frac{x \cdot 2.0}{\frac{x - y}{y}}\\ \mathbf{if}\;y \le 2.945079413730394 \cdot 10^{-59}:\\ \;\;\;\;\frac{x \cdot 2.0}{x - y} \cdot y\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2.0}{\frac{x - y}{y}}\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Target

Original15.2
Comparison0.4
Herbie0.2
\[ \begin{array}{l} \mathbf{if}\;x \lt -1.7210442634149447 \cdot 10^{+81}:\\ \;\;\;\;\frac{2.0 \cdot x}{x - y} \cdot y\\ \mathbf{if}\;x \lt 8.364504563556443 \cdot 10^{+16}:\\ \;\;\;\;\frac{x \cdot 2.0}{\frac{x - y}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2.0 \cdot x}{x - y} \cdot y\\ \end{array} \]

Derivation

  1. Split input into 2 regimes.
  2. if y < -4.28061768498452e-40 or 2.945079413730394e-59 < y

    1. Initial program 13.6

      \[\frac{\left(x \cdot 2.0\right) \cdot y}{x - y}\]
    2. Using strategy rm
    3. Applied associate-/l* 0.3

      \[\leadsto \color{blue}{\frac{x \cdot 2.0}{\frac{x - y}{y}}}\]

    if -4.28061768498452e-40 < y < 2.945079413730394e-59

    1. Initial program 17.3

      \[\frac{\left(x \cdot 2.0\right) \cdot y}{x - y}\]
    2. Using strategy rm
    3. Applied associate-/l* 16.9

      \[\leadsto \color{blue}{\frac{x \cdot 2.0}{\frac{x - y}{y}}}\]
    4. Using strategy rm
    5. Applied associate-/r/ 0.1

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

Runtime

Time bar (total: 12.8s) Debug log

Please include this information when filing a bug report:

herbie --seed '#(3465518169 3568117505 2285758749 1438489002 4254384245 849122935)'
(FPCore (x y)
  :name "Linear.Projection:perspective from linear-1.19.1.3, B"

  :target
  (if (< x -1.7210442634149447e+81) (* (/ (* 2.0 x) (- x y)) y) (if (< x 8.364504563556443e+16) (/ (* x 2.0) (/ (- x y) y)) (* (/ (* 2.0 x) (- x y)) y)))

  (/ (* (* x 2.0) y) (- x y)))