Average Error: 0.5 → 0.4
Time: 42.2s
Precision: 64
Internal Precision: 640
\[\log \left(1 + e^{x}\right) - x \cdot y\]
\[\begin{array}{l} \mathbf{if}\;x \le -4.466556916356668 \cdot 10^{-05}:\\ \;\;\;\;\sqrt{\log \left(1 + e^{x}\right)} \cdot \sqrt{\log \left(1 + e^{x}\right)} - x \cdot y\\ \mathbf{else}:\\ \;\;\;\;\log \left(\frac{1}{2} \cdot {x}^{2} + \left(2 + x\right)\right) - x \cdot y\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Target

Original0.5
Target0.1
Herbie0.4
\[\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 x < -4.466556916356668e-05

    1. Initial program 0.2

      \[\log \left(1 + e^{x}\right) - x \cdot y\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt0.2

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

    if -4.466556916356668e-05 < x

    1. Initial program 0.6

      \[\log \left(1 + e^{x}\right) - x \cdot y\]
    2. Taylor expanded around 0 0.5

      \[\leadsto \log \color{blue}{\left(\frac{1}{2} \cdot {x}^{2} + \left(2 + x\right)\right)} - x \cdot y\]
  3. Recombined 2 regimes into one program.
  4. Removed slow pow expressions.

Runtime

Time bar (total: 42.2s)Debug logProfile

herbie shell --seed '#(1063282112 2455465480 4141627379 3773598652 1647277307 776739644)' 
(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)))