Average Error: 32.2 → 0.0
Time: 23.7s
Precision: 64
Internal Precision: 1408
\[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
↓
\[\begin{array}{l}
\mathbf{if}\;\log \left(e^{(\left(\left|x\right|\right) \cdot \left(\frac{-1}{x}\right) + 1)_*}\right) \le -1.7800590868057611 \cdot 10^{-307}:\\
\;\;\;\;\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.2 |
|---|
| 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 (log (exp (fma (fabs x) (/ -1 x) 1))) < -1.7800590868057611e-307
Initial program 30.8
\[\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.1
\[\leadsto \color{blue}{\left|x\right| \cdot \frac{-1}{x} + 1}\]
if -1.7800590868057611e-307 < (log (exp (fma (fabs x) (/ -1 x) 1)))
Initial program 32.3
\[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
Applied simplify28.4
\[\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 '#(1070991898 1055468627 4280279443 640792587 928206309 3646738750)' +o rules:numerics
(FPCore (x)
:name "sqrt sqr"
:herbie-target
(if (< x 0) 2 0)
(- (/ x x) (* (/ 1 x) (sqrt (* x x)))))