Average Error: 29.8 → 1.3
Time: 13.6s
Precision: binary64
Cost: 19392
\[ \begin{array}{c}[a, b] = \mathsf{sort}([a, b])\\ \end{array} \]
\[\log \left(e^{a} + e^{b}\right) \]
\[\mathsf{log1p}\left(e^{a} + \mathsf{expm1}\left(b\right)\right) \]
(FPCore (a b) :precision binary64 (log (+ (exp a) (exp b))))
(FPCore (a b) :precision binary64 (log1p (+ (exp a) (expm1 b))))
double code(double a, double b) {
	return log((exp(a) + exp(b)));
}
double code(double a, double b) {
	return log1p((exp(a) + expm1(b)));
}
public static double code(double a, double b) {
	return Math.log((Math.exp(a) + Math.exp(b)));
}
public static double code(double a, double b) {
	return Math.log1p((Math.exp(a) + Math.expm1(b)));
}
def code(a, b):
	return math.log((math.exp(a) + math.exp(b)))
def code(a, b):
	return math.log1p((math.exp(a) + math.expm1(b)))
function code(a, b)
	return log(Float64(exp(a) + exp(b)))
end
function code(a, b)
	return log1p(Float64(exp(a) + expm1(b)))
end
code[a_, b_] := N[Log[N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
code[a_, b_] := N[Log[1 + N[(N[Exp[a], $MachinePrecision] + N[(Exp[b] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\log \left(e^{a} + e^{b}\right)
\mathsf{log1p}\left(e^{a} + \mathsf{expm1}\left(b\right)\right)

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 29.8

    \[\log \left(e^{a} + e^{b}\right) \]
  2. Applied egg-rr30.0

    \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\log \left(e^{a} + e^{b}\right)\right)\right)} \]
  3. Applied egg-rr29.9

    \[\leadsto \color{blue}{\mathsf{log1p}\left(\left(e^{a} + e^{b}\right) - 1\right)} \]
  4. Simplified1.3

    \[\leadsto \color{blue}{\mathsf{log1p}\left(e^{a} + \mathsf{expm1}\left(b\right)\right)} \]
    Proof
    (log1p.f64 (+.f64 (exp.f64 a) (expm1.f64 b))): 0 points increase in error, 0 points decrease in error
    (log1p.f64 (+.f64 (exp.f64 a) (Rewrite<= expm1-def_binary64 (-.f64 (exp.f64 b) 1)))): 119 points increase in error, 0 points decrease in error
    (log1p.f64 (Rewrite<= associate--l+_binary64 (-.f64 (+.f64 (exp.f64 a) (exp.f64 b)) 1))): 5 points increase in error, 1 points decrease in error
  5. Final simplification1.3

    \[\leadsto \mathsf{log1p}\left(e^{a} + \mathsf{expm1}\left(b\right)\right) \]

Alternatives

Alternative 1
Error29.8
Cost19392
\[\log \left(e^{a} + e^{b}\right) \]

Error

Reproduce

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