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}\]

Error

Bits error versus x

Target

Original32.2
Target0
Herbie0.0
\[\begin{array}{l} \mathbf{if}\;x \lt 0:\\ \;\;\;\;2\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if (log (exp (fma (fabs x) (/ -1 x) 1))) < -1.7800590868057611e-307

    1. Initial program 30.8

      \[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
    2. Applied simplify61.9

      \[\leadsto \color{blue}{(\left(\left|x\right|\right) \cdot \left(\frac{-1}{x}\right) + 1)_*}\]
    3. Using strategy rm
    4. 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)))

    1. Initial program 32.3

      \[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
    2. Applied simplify28.4

      \[\leadsto \color{blue}{(\left(\left|x\right|\right) \cdot \left(\frac{-1}{x}\right) + 1)_*}\]
    3. Using strategy rm
    4. Applied add-log-exp0.0

      \[\leadsto \color{blue}{\log \left(e^{(\left(\left|x\right|\right) \cdot \left(\frac{-1}{x}\right) + 1)_*}\right)}\]
  3. Recombined 2 regimes into one program.

Runtime

Time bar (total: 23.7s)Debug logProfile

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)))))