Average Error: 0.5 → 0.5
Time: 23.0s
Precision: 64
Internal Precision: 896
\[\log \left(1 + e^{x}\right) - x \cdot y\]
\[\begin{array}{l} \mathbf{if}\;\log \left(1 + e^{x}\right) - x \cdot y \le -0.23813016894602648:\\ \;\;\;\;(\left(\sqrt[3]{\log_* (1 + e^{x})} \cdot \sqrt[3]{\log_* (1 + e^{x})}\right) \cdot \left(\sqrt[3]{\log_* (1 + e^{x})}\right) + \left(-y \cdot x\right))_*\\ \mathbf{if}\;\log \left(1 + e^{x}\right) - x \cdot y \le 244079.7035616162:\\ \;\;\;\;(e^{\log_* (1 + \left(\log_* (1 + e^{x}) - y \cdot x\right))} - 1)^*\\ \mathbf{else}:\\ \;\;\;\;(\left(\sqrt[3]{\log_* (1 + e^{x})} \cdot \sqrt[3]{\log_* (1 + e^{x})}\right) \cdot \left(\sqrt[3]{\log_* (1 + e^{x})}\right) + \left(-y \cdot x\right))_*\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Target

Original0.5
Target0.0
Herbie0.5
\[\begin{array}{l} \mathbf{if}\;x \le 0:\\ \;\;\;\;\log \left(1 + e^{x}\right) - x \cdot y\\ \mathbf{else}:\\ \;\;\;\;\log \left(1 + e^{-x}\right) - \left(-x\right) \cdot \left(1 - y\right)\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if (- (log (+ 1 (exp x))) (* x y)) < -0.23813016894602648 or 244079.7035616162 < (- (log (+ 1 (exp x))) (* x y))

    1. Initial program 1.3

      \[\log \left(1 + e^{x}\right) - x \cdot y\]
    2. Applied simplify1.3

      \[\leadsto \color{blue}{\log_* (1 + e^{x}) - y \cdot x}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt1.3

      \[\leadsto \color{blue}{\left(\sqrt[3]{\log_* (1 + e^{x})} \cdot \sqrt[3]{\log_* (1 + e^{x})}\right) \cdot \sqrt[3]{\log_* (1 + e^{x})}} - y \cdot x\]
    5. Applied fma-neg1.3

      \[\leadsto \color{blue}{(\left(\sqrt[3]{\log_* (1 + e^{x})} \cdot \sqrt[3]{\log_* (1 + e^{x})}\right) \cdot \left(\sqrt[3]{\log_* (1 + e^{x})}\right) + \left(-y \cdot x\right))_*}\]

    if -0.23813016894602648 < (- (log (+ 1 (exp x))) (* x y)) < 244079.7035616162

    1. Initial program 0.1

      \[\log \left(1 + e^{x}\right) - x \cdot y\]
    2. Applied simplify0.0

      \[\leadsto \color{blue}{\log_* (1 + e^{x}) - y \cdot x}\]
    3. Using strategy rm
    4. Applied expm1-log1p-u0.0

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

Runtime

Time bar (total: 23.0s)Debug logProfile

herbie shell --seed '#(1070833653 108281690 3330367898 3632331308 3494323072 43156186)' +o rules:numerics
(FPCore (x y)
  :name "Logistic regression 2"

  :herbie-target
  (if (<= x 0) (- (log (+ 1 (exp x))) (* x y)) (- (log (+ 1 (exp (- x)))) (* (- x) (- 1 y))))

  (- (log (+ 1 (exp x))) (* x y)))