Average Error: 30.0 → 1.1
Time: 4.6s
Precision: binary64
\[[a, b]=\mathsf{sort}([a, b])\]
\[\log \left(e^{a} + e^{b}\right)\]
\[\log \log \left(e \cdot e^{e^{a}}\right) + \frac{b}{1 + e^{a}}\]
\log \left(e^{a} + e^{b}\right)
\log \log \left(e \cdot e^{e^{a}}\right) + \frac{b}{1 + e^{a}}
(FPCore (a b) :precision binary64 (log (+ (exp a) (exp b))))
(FPCore (a b)
 :precision binary64
 (+ (log (log (* E (exp (exp a))))) (/ b (+ 1.0 (exp a)))))
double code(double a, double b) {
	return log(exp(a) + exp(b));
}
double code(double a, double b) {
	return log(log(((double) M_E) * exp(exp(a)))) + (b / (1.0 + exp(a)));
}

Error

Bits error versus a

Bits error versus b

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 30.0

    \[\log \left(e^{a} + e^{b}\right)\]
  2. Taylor expanded around 0 1.1

    \[\leadsto \color{blue}{\log \left(e^{a} + 1\right) + \frac{b}{e^{a} + 1}}\]
  3. Simplified1.1

    \[\leadsto \color{blue}{\log \left(1 + e^{a}\right) + \frac{b}{1 + e^{a}}}\]
  4. Using strategy rm
  5. Applied add-log-exp_binary641.1

    \[\leadsto \log \left(1 + \color{blue}{\log \left(e^{e^{a}}\right)}\right) + \frac{b}{1 + e^{a}}\]
  6. Applied add-log-exp_binary641.1

    \[\leadsto \log \left(\color{blue}{\log \left(e^{1}\right)} + \log \left(e^{e^{a}}\right)\right) + \frac{b}{1 + e^{a}}\]
  7. Applied sum-log_binary641.1

    \[\leadsto \log \color{blue}{\log \left(e^{1} \cdot e^{e^{a}}\right)} + \frac{b}{1 + e^{a}}\]
  8. Final simplification1.1

    \[\leadsto \log \log \left(e \cdot e^{e^{a}}\right) + \frac{b}{1 + e^{a}}\]

Alternatives

Reproduce

herbie shell --seed 2021110 
(FPCore (a b)
  :name "symmetry log of sum of exp"
  :precision binary64
  (log (+ (exp a) (exp b))))