Average Error: 0.5 → 0.5
Time: 1.3m
Precision: 64
Internal Precision: 640
\[\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.6921301683303508:\\ \;\;\;\;\left(\sqrt[3]{\log \left(1 + e^{x}\right)} \cdot \sqrt[3]{\log \left(1 + e^{x}\right)}\right) \cdot \sqrt[3]{\log \left(1 + {\left(e^{x}\right)}^{3}\right) - \log \left(\left(1 - e^{x}\right) + e^{x + x}\right)} - x \cdot y\\ \mathbf{if}\;\log \left(1 + e^{x}\right) - x \cdot y \le 141.36163919317698:\\ \;\;\;\;\log \left(\frac{1 + e^{x}}{e^{x \cdot y}}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt[3]{\log \left(1 + e^{x}\right)} \cdot \sqrt[3]{\log \left(1 + e^{x}\right)}\right) \cdot \sqrt[3]{\log \left(1 + {\left(e^{x}\right)}^{3}\right) - \log \left(\left(1 - e^{x}\right) + e^{x + x}\right)} - x \cdot y\\ \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.6921301683303508 or 141.36163919317698 < (- (log (+ 1 (exp x))) (* x y))

    1. Initial program 1.0

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

      \[\leadsto \color{blue}{\left(\sqrt[3]{\log \left(1 + e^{x}\right)} \cdot \sqrt[3]{\log \left(1 + e^{x}\right)}\right) \cdot \sqrt[3]{\log \left(1 + e^{x}\right)}} - x \cdot y\]
    4. Using strategy rm
    5. Applied flip3-+1.1

      \[\leadsto \left(\sqrt[3]{\log \left(1 + e^{x}\right)} \cdot \sqrt[3]{\log \left(1 + e^{x}\right)}\right) \cdot \sqrt[3]{\log \color{blue}{\left(\frac{{1}^{3} + {\left(e^{x}\right)}^{3}}{1 \cdot 1 + \left(e^{x} \cdot e^{x} - 1 \cdot e^{x}\right)}\right)}} - x \cdot y\]
    6. Applied log-div1.1

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

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

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

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

    if 0.6921301683303508 < (- (log (+ 1 (exp x))) (* x y)) < 141.36163919317698

    1. Initial program 0.0

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

      \[\leadsto \log \left(1 + e^{x}\right) - \color{blue}{\log \left(e^{x \cdot y}\right)}\]
    4. Applied diff-log0.0

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

Runtime

Time bar (total: 1.3m)Debug log

herbie shell --seed '#(1567391828 2030694642 2833800258 828025724 3004380912 3532991858)' +o setup:early-exit +o reduce:binary-search
(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)))