Average Error: 32.7 → 0.0
Time: 15.1s
Precision: 64
Internal Precision: 1344
\[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
↓
\[\begin{array}{l}
\mathbf{if}\;\left|x\right| \cdot \frac{-1}{x} + 1 \le 0.0:\\
\;\;\;\;\left|x\right| \cdot \frac{-1}{x} + 1\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{(\left(\left|x\right|\right) \cdot \left(\frac{-1}{x}\right) + 1)_*}\right)\\
\end{array}\]
Target
| Original | 32.7 |
|---|
| Target | 0 |
|---|
| Herbie | 0.0 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \lt 0:\\
\;\;\;\;2\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}\]
Derivation
- Split input into 2 regimes
if (+ (* (fabs x) (/ -1 x)) 1) < 0.0
Initial program 32.2
\[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
Applied simplify61.9
\[\leadsto \color{blue}{(\left(\left|x\right|\right) \cdot \left(\frac{-1}{x}\right) + 1)_*}\]
- Using strategy
rm Applied fma-udef0.0
\[\leadsto \color{blue}{\left|x\right| \cdot \frac{-1}{x} + 1}\]
if 0.0 < (+ (* (fabs x) (/ -1 x)) 1)
Initial program 33.0
\[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
Applied simplify8.3
\[\leadsto \color{blue}{(\left(\left|x\right|\right) \cdot \left(\frac{-1}{x}\right) + 1)_*}\]
- Using strategy
rm Applied add-log-exp0.0
\[\leadsto \color{blue}{\log \left(e^{(\left(\left|x\right|\right) \cdot \left(\frac{-1}{x}\right) + 1)_*}\right)}\]
- Recombined 2 regimes into one program.
Runtime
herbie shell --seed '#(1071373924 2949776965 1885069702 3247780810 90874544 2263903749)' +o rules:numerics
(FPCore (x)
:name "sqrt sqr"
:herbie-target
(if (< x 0) 2 0)
(- (/ x x) (* (/ 1 x) (sqrt (* x x)))))