Average Error: 34.4 → 5.1
Time: 44.6s
Precision: 64
Internal Precision: 384
\[\frac{x \cdot x - \left(y \cdot 4.0\right) \cdot y}{x \cdot x + \left(y \cdot 4.0\right) \cdot y}\]
↓
\[\begin{array}{l}
\mathbf{if}\;y \le -7.802168173177268 \cdot 10^{+153}:\\
\;\;\;\;-1.0\\
\mathbf{if}\;y \le -5.836330729285146 \cdot 10^{-79}:\\
\;\;\;\;\frac{x \cdot x}{x \cdot x + \left(y \cdot 4.0\right) \cdot y} - \frac{\left(y \cdot 4.0\right) \cdot y}{x \cdot x + \left(y \cdot 4.0\right) \cdot y}\\
\mathbf{if}\;y \le 3.452373824601348 \cdot 10^{-136}:\\
\;\;\;\;1\\
\mathbf{if}\;y \le 2.424870889256943 \cdot 10^{+28}:\\
\;\;\;\;\frac{x \cdot x}{x \cdot x + \left(y \cdot 4.0\right) \cdot y} - \frac{\left(y \cdot 4.0\right) \cdot y}{x \cdot x + \left(y \cdot 4.0\right) \cdot y}\\
\mathbf{if}\;y \le 5.208440760297056 \cdot 10^{+55}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1.0\\
\end{array}\]
Target
| Original | 34.4 |
|---|
| Target | 34.4 |
|---|
| Herbie | 5.1 |
|---|
\[\begin{array}{l}
\mathbf{if}\;\frac{x \cdot x - \left(y \cdot 4.0\right) \cdot y}{x \cdot x + \left(y \cdot 4.0\right) \cdot y} \lt 0.9743233849626781:\\
\;\;\;\;\frac{x \cdot x}{x \cdot x + \left(y \cdot y\right) \cdot 4.0} - \frac{\left(y \cdot y\right) \cdot 4.0}{x \cdot x + \left(y \cdot y\right) \cdot 4.0}\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{x}{\sqrt{x \cdot x + \left(y \cdot y\right) \cdot 4.0}}\right)}^{2} - \frac{\left(y \cdot y\right) \cdot 4.0}{x \cdot x + \left(y \cdot y\right) \cdot 4.0}\\
\end{array}\]
Derivation
- Split input into 3 regimes
if y < -7.802168173177268e+153 or 5.208440760297056e+55 < y
Initial program 53.8
\[\frac{x \cdot x - \left(y \cdot 4.0\right) \cdot y}{x \cdot x + \left(y \cdot 4.0\right) \cdot y}\]
Taylor expanded around 0 0
\[\leadsto \color{blue}{-1.0}\]
if -7.802168173177268e+153 < y < -5.836330729285146e-79 or 3.452373824601348e-136 < y < 2.424870889256943e+28
Initial program 15.9
\[\frac{x \cdot x - \left(y \cdot 4.0\right) \cdot y}{x \cdot x + \left(y \cdot 4.0\right) \cdot y}\]
- Using strategy
rm Applied div-sub15.9
\[\leadsto \color{blue}{\frac{x \cdot x}{x \cdot x + \left(y \cdot 4.0\right) \cdot y} - \frac{\left(y \cdot 4.0\right) \cdot y}{x \cdot x + \left(y \cdot 4.0\right) \cdot y}}\]
if -5.836330729285146e-79 < y < 3.452373824601348e-136 or 2.424870889256943e+28 < y < 5.208440760297056e+55
Initial program 32.2
\[\frac{x \cdot x - \left(y \cdot 4.0\right) \cdot y}{x \cdot x + \left(y \cdot 4.0\right) \cdot y}\]
Taylor expanded around inf 0
\[\leadsto \color{blue}{1}\]
- Recombined 3 regimes into one program.
- Removed slow
pow expressions.
Runtime
herbie shell --seed '#(1567391828 2030694642 2833800258 828025724 3004380912 3532991858)' +o setup:early-exit +o reduce:binary-search
(FPCore (x y)
:name "Diagrams.TwoD.Arc:arcBetween from diagrams-lib-1.3.0.3"
:herbie-target
(if (< (/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))) 0.9743233849626781) (- (/ (* x x) (+ (* x x) (* (* y y) 4.0))) (/ (* (* y y) 4.0) (+ (* x x) (* (* y y) 4.0)))) (- (pow (/ x (sqrt (+ (* x x) (* (* y y) 4.0)))) 2) (/ (* (* y y) 4.0) (+ (* x x) (* (* y y) 4.0)))))
(/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))))