| Alternative 1 | |
|---|---|
| Accuracy | 98.7% |
| Cost | 25924 |
\[\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0:\\
\;\;\;\;\frac{b}{2 + \mathsf{expm1}\left(a\right)}\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{a} + e^{b}\right)\\
\end{array}
\]
(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)
Results
Initial program 54.7%
Applied egg-rr53.9%
Simplified97.8%
[Start]53.9 | \[ \log \left(\sqrt{e^{a} + e^{b}}\right) + \log \left(\sqrt{e^{a} + e^{b}}\right)
\] |
|---|---|
log-prod [<=]53.5 | \[ \color{blue}{\log \left(\sqrt{e^{a} + e^{b}} \cdot \sqrt{e^{a} + e^{b}}\right)}
\] |
rem-square-sqrt [=>]54.7 | \[ \log \color{blue}{\left(e^{a} + e^{b}\right)}
\] |
log1p-expm1 [<=]54.6 | \[ \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\log \left(e^{a} + e^{b}\right)\right)\right)}
\] |
expm1-def [<=]54.6 | \[ \mathsf{log1p}\left(\color{blue}{e^{\log \left(e^{a} + e^{b}\right)} - 1}\right)
\] |
rem-exp-log [=>]54.6 | \[ \mathsf{log1p}\left(\color{blue}{\left(e^{a} + e^{b}\right)} - 1\right)
\] |
associate--l+ [=>]54.8 | \[ \mathsf{log1p}\left(\color{blue}{e^{a} + \left(e^{b} - 1\right)}\right)
\] |
expm1-def [=>]97.8 | \[ \mathsf{log1p}\left(e^{a} + \color{blue}{\mathsf{expm1}\left(b\right)}\right)
\] |
Final simplification97.8%
| Alternative 1 | |
|---|---|
| Accuracy | 98.7% |
| Cost | 25924 |
| Alternative 2 | |
|---|---|
| Accuracy | 98.2% |
| Cost | 20036 |
| Alternative 3 | |
|---|---|
| Accuracy | 98.1% |
| Cost | 19652 |
| Alternative 4 | |
|---|---|
| Accuracy | 97.7% |
| Cost | 19396 |
| Alternative 5 | |
|---|---|
| Accuracy | 97.6% |
| Cost | 7236 |
| Alternative 6 | |
|---|---|
| Accuracy | 97.6% |
| Cost | 6980 |
| Alternative 7 | |
|---|---|
| Accuracy | 58.2% |
| Cost | 6852 |
| Alternative 8 | |
|---|---|
| Accuracy | 58.2% |
| Cost | 6852 |
| Alternative 9 | |
|---|---|
| Accuracy | 97.5% |
| Cost | 6852 |
| Alternative 10 | |
|---|---|
| Accuracy | 57.7% |
| Cost | 6724 |
| Alternative 11 | |
|---|---|
| Accuracy | 57.7% |
| Cost | 6724 |
| Alternative 12 | |
|---|---|
| Accuracy | 57.3% |
| Cost | 6596 |
| Alternative 13 | |
|---|---|
| Accuracy | 11.8% |
| Cost | 192 |
herbie shell --seed 2023122
(FPCore (a b)
:name "symmetry log of sum of exp"
:precision binary64
(log (+ (exp a) (exp b))))