
(FPCore (a b) :precision binary64 (log (+ (exp a) (exp b))))
double code(double a, double b) {
return log((exp(a) + exp(b)));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = log((exp(a) + exp(b)))
end function
public static double code(double a, double b) {
return Math.log((Math.exp(a) + Math.exp(b)));
}
def code(a, b): return math.log((math.exp(a) + math.exp(b)))
function code(a, b) return log(Float64(exp(a) + exp(b))) end
function tmp = code(a, b) tmp = log((exp(a) + exp(b))); end
code[a_, b_] := N[Log[N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\log \left(e^{a} + e^{b}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b) :precision binary64 (log (+ (exp a) (exp b))))
double code(double a, double b) {
return log((exp(a) + exp(b)));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = log((exp(a) + exp(b)))
end function
public static double code(double a, double b) {
return Math.log((Math.exp(a) + Math.exp(b)));
}
def code(a, b): return math.log((math.exp(a) + math.exp(b)))
function code(a, b) return log(Float64(exp(a) + exp(b))) end
function tmp = code(a, b) tmp = log((exp(a) + exp(b))); end
code[a_, b_] := N[Log[N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\log \left(e^{a} + e^{b}\right)
\end{array}
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (log1p (+ (exp a) (expm1 b))))
assert(a < b);
double code(double a, double b) {
return log1p((exp(a) + expm1(b)));
}
assert a < b;
public static double code(double a, double b) {
return Math.log1p((Math.exp(a) + Math.expm1(b)));
}
[a, b] = sort([a, b]) def code(a, b): return math.log1p((math.exp(a) + math.expm1(b)))
a, b = sort([a, b]) function code(a, b) return log1p(Float64(exp(a) + expm1(b))) end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[Log[1 + N[(N[Exp[a], $MachinePrecision] + N[(Exp[b] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\mathsf{log1p}\left(e^{a} + \mathsf{expm1}\left(b\right)\right)
\end{array}
Initial program 48.8%
*-un-lft-identity48.8%
exp-prod48.8%
expm1-log1p-u45.8%
expm1-undefine45.8%
pow-sub45.8%
Applied egg-rr45.8%
exp-1-e45.8%
log1p-undefine45.8%
rem-exp-log48.8%
unpow148.8%
exp-1-e48.8%
Simplified48.8%
log1p-expm1-u48.8%
expm1-undefine48.8%
add-exp-log48.8%
pow148.8%
pow-div48.8%
add-exp-log45.8%
expm1-undefine45.8%
log1p-define45.8%
expm1-log1p-u48.8%
pow-to-exp48.8%
log-E48.8%
*-un-lft-identity48.8%
Applied egg-rr48.8%
associate--l+49.6%
expm1-undefine74.4%
Simplified74.4%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= (exp a) 1e-91) (/ b (+ (exp a) 1.0)) (log (+ (exp a) (exp b)))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (exp(a) <= 1e-91) {
tmp = b / (exp(a) + 1.0);
} else {
tmp = log((exp(a) + exp(b)));
}
return tmp;
}
NOTE: a and b should be sorted in increasing order before calling this function.
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (exp(a) <= 1d-91) then
tmp = b / (exp(a) + 1.0d0)
else
tmp = log((exp(a) + exp(b)))
end if
code = tmp
end function
assert a < b;
public static double code(double a, double b) {
double tmp;
if (Math.exp(a) <= 1e-91) {
tmp = b / (Math.exp(a) + 1.0);
} else {
tmp = Math.log((Math.exp(a) + Math.exp(b)));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if math.exp(a) <= 1e-91: tmp = b / (math.exp(a) + 1.0) else: tmp = math.log((math.exp(a) + math.exp(b))) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (exp(a) <= 1e-91) tmp = Float64(b / Float64(exp(a) + 1.0)); else tmp = log(Float64(exp(a) + exp(b))); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (exp(a) <= 1e-91)
tmp = b / (exp(a) + 1.0);
else
tmp = log((exp(a) + exp(b)));
end
tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := If[LessEqual[N[Exp[a], $MachinePrecision], 1e-91], N[(b / N[(N[Exp[a], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[Log[N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;e^{a} \leq 10^{-91}:\\
\;\;\;\;\frac{b}{e^{a} + 1}\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{a} + e^{b}\right)\\
\end{array}
\end{array}
if (exp.f64 a) < 1.00000000000000002e-91Initial program 8.8%
Taylor expanded in b around 0 97.4%
log1p-define100.0%
Simplified100.0%
Taylor expanded in b around inf 97.4%
if 1.00000000000000002e-91 < (exp.f64 a) Initial program 64.8%
Final simplification74.1%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= (exp a) 5e-132) (/ b (+ (exp a) 1.0)) (log1p (pow E b))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (exp(a) <= 5e-132) {
tmp = b / (exp(a) + 1.0);
} else {
tmp = log1p(pow(((double) M_E), b));
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (Math.exp(a) <= 5e-132) {
tmp = b / (Math.exp(a) + 1.0);
} else {
tmp = Math.log1p(Math.pow(Math.E, b));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if math.exp(a) <= 5e-132: tmp = b / (math.exp(a) + 1.0) else: tmp = math.log1p(math.pow(math.e, b)) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (exp(a) <= 5e-132) tmp = Float64(b / Float64(exp(a) + 1.0)); else tmp = log1p((exp(1) ^ b)); end return tmp end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := If[LessEqual[N[Exp[a], $MachinePrecision], 5e-132], N[(b / N[(N[Exp[a], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[Log[1 + N[Power[E, b], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;e^{a} \leq 5 \cdot 10^{-132}:\\
\;\;\;\;\frac{b}{e^{a} + 1}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left({e}^{b}\right)\\
\end{array}
\end{array}
if (exp.f64 a) < 4.9999999999999999e-132Initial program 8.8%
Taylor expanded in b around 0 98.7%
log1p-define100.0%
Simplified100.0%
Taylor expanded in b around inf 98.7%
if 4.9999999999999999e-132 < (exp.f64 a) Initial program 64.4%
*-un-lft-identity64.4%
exp-prod64.4%
expm1-log1p-u60.3%
expm1-undefine60.3%
pow-sub60.3%
Applied egg-rr60.3%
exp-1-e60.3%
log1p-undefine60.3%
rem-exp-log64.4%
unpow164.4%
exp-1-e64.4%
Simplified64.4%
Taylor expanded in a around 0 61.6%
log1p-define61.6%
log-E61.6%
distribute-lft-in61.6%
metadata-eval61.6%
metadata-eval61.6%
cancel-sign-sub-inv61.6%
e-exp-161.6%
div-exp61.6%
sub-neg61.6%
neg-mul-161.6%
remove-double-neg61.6%
+-commutative61.6%
Simplified61.6%
*-un-lft-identity61.6%
exp-prod61.6%
associate--l+61.6%
metadata-eval61.6%
+-rgt-identity61.6%
e-exp-161.6%
Applied egg-rr61.6%
Final simplification72.0%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= (exp a) 5e-132) (/ b (+ (exp a) 1.0)) (log1p (exp b))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (exp(a) <= 5e-132) {
tmp = b / (exp(a) + 1.0);
} else {
tmp = log1p(exp(b));
}
return tmp;
}
assert a < b;
public static double code(double a, double b) {
double tmp;
if (Math.exp(a) <= 5e-132) {
tmp = b / (Math.exp(a) + 1.0);
} else {
tmp = Math.log1p(Math.exp(b));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if math.exp(a) <= 5e-132: tmp = b / (math.exp(a) + 1.0) else: tmp = math.log1p(math.exp(b)) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (exp(a) <= 5e-132) tmp = Float64(b / Float64(exp(a) + 1.0)); else tmp = log1p(exp(b)); end return tmp end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := If[LessEqual[N[Exp[a], $MachinePrecision], 5e-132], N[(b / N[(N[Exp[a], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[Log[1 + N[Exp[b], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;e^{a} \leq 5 \cdot 10^{-132}:\\
\;\;\;\;\frac{b}{e^{a} + 1}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(e^{b}\right)\\
\end{array}
\end{array}
if (exp.f64 a) < 4.9999999999999999e-132Initial program 8.8%
Taylor expanded in b around 0 98.7%
log1p-define100.0%
Simplified100.0%
Taylor expanded in b around inf 98.7%
if 4.9999999999999999e-132 < (exp.f64 a) Initial program 64.4%
Taylor expanded in a around 0 61.6%
log1p-define61.6%
Simplified61.6%
Final simplification72.0%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= (exp a) 5e-132) (/ b (+ (exp a) 1.0)) (+ (log 2.0) (* b (+ 0.5 (* b 0.125))))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (exp(a) <= 5e-132) {
tmp = b / (exp(a) + 1.0);
} else {
tmp = log(2.0) + (b * (0.5 + (b * 0.125)));
}
return tmp;
}
NOTE: a and b should be sorted in increasing order before calling this function.
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (exp(a) <= 5d-132) then
tmp = b / (exp(a) + 1.0d0)
else
tmp = log(2.0d0) + (b * (0.5d0 + (b * 0.125d0)))
end if
code = tmp
end function
assert a < b;
public static double code(double a, double b) {
double tmp;
if (Math.exp(a) <= 5e-132) {
tmp = b / (Math.exp(a) + 1.0);
} else {
tmp = Math.log(2.0) + (b * (0.5 + (b * 0.125)));
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if math.exp(a) <= 5e-132: tmp = b / (math.exp(a) + 1.0) else: tmp = math.log(2.0) + (b * (0.5 + (b * 0.125))) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (exp(a) <= 5e-132) tmp = Float64(b / Float64(exp(a) + 1.0)); else tmp = Float64(log(2.0) + Float64(b * Float64(0.5 + Float64(b * 0.125)))); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (exp(a) <= 5e-132)
tmp = b / (exp(a) + 1.0);
else
tmp = log(2.0) + (b * (0.5 + (b * 0.125)));
end
tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := If[LessEqual[N[Exp[a], $MachinePrecision], 5e-132], N[(b / N[(N[Exp[a], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[Log[2.0], $MachinePrecision] + N[(b * N[(0.5 + N[(b * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;e^{a} \leq 5 \cdot 10^{-132}:\\
\;\;\;\;\frac{b}{e^{a} + 1}\\
\mathbf{else}:\\
\;\;\;\;\log 2 + b \cdot \left(0.5 + b \cdot 0.125\right)\\
\end{array}
\end{array}
if (exp.f64 a) < 4.9999999999999999e-132Initial program 8.8%
Taylor expanded in b around 0 98.7%
log1p-define100.0%
Simplified100.0%
Taylor expanded in b around inf 98.7%
if 4.9999999999999999e-132 < (exp.f64 a) Initial program 64.4%
Taylor expanded in a around 0 61.6%
Taylor expanded in b around 0 58.9%
*-commutative58.9%
Simplified58.9%
Final simplification70.1%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= (exp a) 5e-132) (/ b (+ (exp a) 1.0)) (+ (* b 0.5) (log 2.0))))
assert(a < b);
double code(double a, double b) {
double tmp;
if (exp(a) <= 5e-132) {
tmp = b / (exp(a) + 1.0);
} else {
tmp = (b * 0.5) + log(2.0);
}
return tmp;
}
NOTE: a and b should be sorted in increasing order before calling this function.
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (exp(a) <= 5d-132) then
tmp = b / (exp(a) + 1.0d0)
else
tmp = (b * 0.5d0) + log(2.0d0)
end if
code = tmp
end function
assert a < b;
public static double code(double a, double b) {
double tmp;
if (Math.exp(a) <= 5e-132) {
tmp = b / (Math.exp(a) + 1.0);
} else {
tmp = (b * 0.5) + Math.log(2.0);
}
return tmp;
}
[a, b] = sort([a, b]) def code(a, b): tmp = 0 if math.exp(a) <= 5e-132: tmp = b / (math.exp(a) + 1.0) else: tmp = (b * 0.5) + math.log(2.0) return tmp
a, b = sort([a, b]) function code(a, b) tmp = 0.0 if (exp(a) <= 5e-132) tmp = Float64(b / Float64(exp(a) + 1.0)); else tmp = Float64(Float64(b * 0.5) + log(2.0)); end return tmp end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
tmp = 0.0;
if (exp(a) <= 5e-132)
tmp = b / (exp(a) + 1.0);
else
tmp = (b * 0.5) + log(2.0);
end
tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := If[LessEqual[N[Exp[a], $MachinePrecision], 5e-132], N[(b / N[(N[Exp[a], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(b * 0.5), $MachinePrecision] + N[Log[2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;e^{a} \leq 5 \cdot 10^{-132}:\\
\;\;\;\;\frac{b}{e^{a} + 1}\\
\mathbf{else}:\\
\;\;\;\;b \cdot 0.5 + \log 2\\
\end{array}
\end{array}
if (exp.f64 a) < 4.9999999999999999e-132Initial program 8.8%
Taylor expanded in b around 0 98.7%
log1p-define100.0%
Simplified100.0%
Taylor expanded in b around inf 98.7%
if 4.9999999999999999e-132 < (exp.f64 a) Initial program 64.4%
Taylor expanded in b around 0 59.3%
log1p-define59.8%
Simplified59.8%
Taylor expanded in a around 0 58.2%
Final simplification69.6%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (log1p (+ (exp a) (* b (+ 1.0 (* b 0.5))))))
assert(a < b);
double code(double a, double b) {
return log1p((exp(a) + (b * (1.0 + (b * 0.5)))));
}
assert a < b;
public static double code(double a, double b) {
return Math.log1p((Math.exp(a) + (b * (1.0 + (b * 0.5)))));
}
[a, b] = sort([a, b]) def code(a, b): return math.log1p((math.exp(a) + (b * (1.0 + (b * 0.5)))))
a, b = sort([a, b]) function code(a, b) return log1p(Float64(exp(a) + Float64(b * Float64(1.0 + Float64(b * 0.5))))) end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[Log[1 + N[(N[Exp[a], $MachinePrecision] + N[(b * N[(1.0 + N[(b * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\mathsf{log1p}\left(e^{a} + b \cdot \left(1 + b \cdot 0.5\right)\right)
\end{array}
Initial program 48.8%
*-un-lft-identity48.8%
exp-prod48.8%
expm1-log1p-u45.8%
expm1-undefine45.8%
pow-sub45.8%
Applied egg-rr45.8%
exp-1-e45.8%
log1p-undefine45.8%
rem-exp-log48.8%
unpow148.8%
exp-1-e48.8%
Simplified48.8%
log1p-expm1-u48.8%
expm1-undefine48.8%
add-exp-log48.8%
pow148.8%
pow-div48.8%
add-exp-log45.8%
expm1-undefine45.8%
log1p-define45.8%
expm1-log1p-u48.8%
pow-to-exp48.8%
log-E48.8%
*-un-lft-identity48.8%
Applied egg-rr48.8%
associate--l+49.6%
expm1-undefine74.4%
Simplified74.4%
Taylor expanded in b around 0 71.1%
*-commutative71.1%
Simplified71.1%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (+ (* b 0.5) (log 2.0)))
assert(a < b);
double code(double a, double b) {
return (b * 0.5) + log(2.0);
}
NOTE: a and b should be sorted in increasing order before calling this function.
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (b * 0.5d0) + log(2.0d0)
end function
assert a < b;
public static double code(double a, double b) {
return (b * 0.5) + Math.log(2.0);
}
[a, b] = sort([a, b]) def code(a, b): return (b * 0.5) + math.log(2.0)
a, b = sort([a, b]) function code(a, b) return Float64(Float64(b * 0.5) + log(2.0)) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = (b * 0.5) + log(2.0);
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[(N[(b * 0.5), $MachinePrecision] + N[Log[2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
b \cdot 0.5 + \log 2
\end{array}
Initial program 48.8%
Taylor expanded in b around 0 70.4%
log1p-define71.1%
Simplified71.1%
Taylor expanded in a around 0 43.0%
Final simplification43.0%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (log (+ b 2.0)))
assert(a < b);
double code(double a, double b) {
return log((b + 2.0));
}
NOTE: a and b should be sorted in increasing order before calling this function.
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = log((b + 2.0d0))
end function
assert a < b;
public static double code(double a, double b) {
return Math.log((b + 2.0));
}
[a, b] = sort([a, b]) def code(a, b): return math.log((b + 2.0))
a, b = sort([a, b]) function code(a, b) return log(Float64(b + 2.0)) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = log((b + 2.0));
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[Log[N[(b + 2.0), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\log \left(b + 2\right)
\end{array}
Initial program 48.8%
Taylor expanded in a around 0 45.4%
Taylor expanded in b around 0 42.2%
Final simplification42.2%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (log1p 1.0))
assert(a < b);
double code(double a, double b) {
return log1p(1.0);
}
assert a < b;
public static double code(double a, double b) {
return Math.log1p(1.0);
}
[a, b] = sort([a, b]) def code(a, b): return math.log1p(1.0)
a, b = sort([a, b]) function code(a, b) return log1p(1.0) end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[Log[1 + 1.0], $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\mathsf{log1p}\left(1\right)
\end{array}
Initial program 48.8%
Taylor expanded in b around 0 43.9%
log1p-define44.7%
Simplified44.7%
Taylor expanded in a around 0 42.7%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (* a 0.5))
assert(a < b);
double code(double a, double b) {
return a * 0.5;
}
NOTE: a and b should be sorted in increasing order before calling this function.
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = a * 0.5d0
end function
assert a < b;
public static double code(double a, double b) {
return a * 0.5;
}
[a, b] = sort([a, b]) def code(a, b): return a * 0.5
a, b = sort([a, b]) function code(a, b) return Float64(a * 0.5) end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
tmp = a * 0.5;
end
NOTE: a and b should be sorted in increasing order before calling this function. code[a_, b_] := N[(a * 0.5), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
a \cdot 0.5
\end{array}
Initial program 48.8%
Taylor expanded in b around 0 43.9%
log1p-define44.7%
Simplified44.7%
Taylor expanded in a around 0 42.8%
Taylor expanded in a around inf 7.5%
*-commutative7.5%
Simplified7.5%
herbie shell --seed 2024165
(FPCore (a b)
:name "symmetry log of sum of exp"
:precision binary64
(log (+ (exp a) (exp b))))