Average Error: 0.4 → 0.5
Time: 5.5m
Precision: 64
Internal Precision: 128
\[\log \left(1 + e^{x}\right) - x \cdot y\]
\[\left(\log \left(\sqrt{{\left(e^{x}\right)}^{3} + 1}\right) + \left(\log \left(\sqrt{\sqrt{{\left(e^{x}\right)}^{3} + 1}}\right) + \log \left(\frac{\sqrt{\sqrt{{\left(e^{x}\right)}^{3} + 1}}}{\left(e^{x} \cdot e^{x} - e^{x}\right) + 1}\right)\right)\right) - y \cdot x\]

Error

Bits error versus x

Bits error versus y

Target

Original0.4
Target0.1
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. Initial program 0.4

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

    \[\leadsto \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\]
  4. Using strategy rm
  5. Applied *-un-lft-identity0.5

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

    \[\leadsto \log \left(\frac{{1}^{3} + {\left(e^{x}\right)}^{3}}{1 \cdot 1 + \left(\color{blue}{1 \cdot \left(e^{x} \cdot e^{x}\right)} - 1 \cdot e^{x}\right)}\right) - x \cdot y\]
  7. Applied distribute-lft-out--0.5

    \[\leadsto \log \left(\frac{{1}^{3} + {\left(e^{x}\right)}^{3}}{1 \cdot 1 + \color{blue}{1 \cdot \left(e^{x} \cdot e^{x} - e^{x}\right)}}\right) - x \cdot y\]
  8. Applied distribute-lft-out0.5

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

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

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

    \[\leadsto \color{blue}{\left(\log \left(\frac{\sqrt{{1}^{3} + {\left(e^{x}\right)}^{3}}}{1}\right) + \log \left(\frac{\sqrt{{1}^{3} + {\left(e^{x}\right)}^{3}}}{1 + \left(e^{x} \cdot e^{x} - e^{x}\right)}\right)\right)} - x \cdot y\]
  12. Using strategy rm
  13. Applied *-un-lft-identity1.0

    \[\leadsto \left(\log \left(\frac{\sqrt{{1}^{3} + {\left(e^{x}\right)}^{3}}}{1}\right) + \log \left(\frac{\sqrt{{1}^{3} + {\left(e^{x}\right)}^{3}}}{1 + \color{blue}{1 \cdot \left(e^{x} \cdot e^{x} - e^{x}\right)}}\right)\right) - x \cdot y\]
  14. Applied *-un-lft-identity1.0

    \[\leadsto \left(\log \left(\frac{\sqrt{{1}^{3} + {\left(e^{x}\right)}^{3}}}{1}\right) + \log \left(\frac{\sqrt{{1}^{3} + {\left(e^{x}\right)}^{3}}}{\color{blue}{1 \cdot 1} + 1 \cdot \left(e^{x} \cdot e^{x} - e^{x}\right)}\right)\right) - x \cdot y\]
  15. Applied distribute-lft-out1.0

    \[\leadsto \left(\log \left(\frac{\sqrt{{1}^{3} + {\left(e^{x}\right)}^{3}}}{1}\right) + \log \left(\frac{\sqrt{{1}^{3} + {\left(e^{x}\right)}^{3}}}{\color{blue}{1 \cdot \left(1 + \left(e^{x} \cdot e^{x} - e^{x}\right)\right)}}\right)\right) - x \cdot y\]
  16. Applied add-sqr-sqrt0.5

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

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

    \[\leadsto \left(\log \left(\frac{\sqrt{{1}^{3} + {\left(e^{x}\right)}^{3}}}{1}\right) + \color{blue}{\left(\log \left(\frac{\sqrt{\sqrt{{1}^{3} + {\left(e^{x}\right)}^{3}}}}{1}\right) + \log \left(\frac{\sqrt{\sqrt{{1}^{3} + {\left(e^{x}\right)}^{3}}}}{1 + \left(e^{x} \cdot e^{x} - e^{x}\right)}\right)\right)}\right) - x \cdot y\]
  19. Final simplification0.5

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

Reproduce

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