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

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.6
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 x < -4.160058015293506e-06

    1. Initial program 0.1

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

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

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

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

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

    if -4.160058015293506e-06 < x

    1. Initial program 0.8

      \[\log \left(1 + e^{x}\right) - x \cdot y\]
    2. Initial simplification0.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -4.160058015293506 \cdot 10^{-06}:\\ \;\;\;\;\log \left(\sqrt{1 + e^{x}}\right) + \left(\log \left(\sqrt{1 + e^{x}}\right) - x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\left(\frac{1}{2} \cdot {x}^{2} + 2\right) + x\right) - x \cdot y\\ \end{array}\]

Runtime

Time bar (total: 23.3s)Debug logProfile

herbie shell --seed 2018349 
(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)))