\[ \begin{array}{c}[a, b] = \mathsf{sort}([a, b])\\ \end{array} \]
\[\log \left(e^{a} + e^{b}\right)
\]
↓
\[\begin{array}{l}
t_0 := 1 + e^{a}\\
\log t_0 + \frac{b}{t_0}
\end{array}
\]
(FPCore (a b) :precision binary64 (log (+ (exp a) (exp b))))
↓
(FPCore (a b)
:precision binary64
(let* ((t_0 (+ 1.0 (exp a)))) (+ (log t_0) (/ b t_0))))
double code(double a, double b) {
return log((exp(a) + exp(b)));
}
↓
double code(double a, double b) {
double t_0 = 1.0 + exp(a);
return log(t_0) + (b / t_0);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = log((exp(a) + exp(b)))
end function
↓
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_0
t_0 = 1.0d0 + exp(a)
code = log(t_0) + (b / t_0)
end function
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) {
double t_0 = 1.0 + Math.exp(a);
return Math.log(t_0) + (b / t_0);
}
def code(a, b):
return math.log((math.exp(a) + math.exp(b)))
↓
def code(a, b):
t_0 = 1.0 + math.exp(a)
return math.log(t_0) + (b / t_0)
function code(a, b)
return log(Float64(exp(a) + exp(b)))
end
↓
function code(a, b)
t_0 = Float64(1.0 + exp(a))
return Float64(log(t_0) + Float64(b / t_0))
end
function tmp = code(a, b)
tmp = log((exp(a) + exp(b)));
end
↓
function tmp = code(a, b)
t_0 = 1.0 + exp(a);
tmp = log(t_0) + (b / t_0);
end
code[a_, b_] := N[Log[N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
↓
code[a_, b_] := Block[{t$95$0 = N[(1.0 + N[Exp[a], $MachinePrecision]), $MachinePrecision]}, N[(N[Log[t$95$0], $MachinePrecision] + N[(b / t$95$0), $MachinePrecision]), $MachinePrecision]]
\log \left(e^{a} + e^{b}\right)
↓
\begin{array}{l}
t_0 := 1 + e^{a}\\
\log t_0 + \frac{b}{t_0}
\end{array}
Alternatives
| Alternative 1 |
|---|
| Error | 1.6 |
|---|
| Cost | 19524 |
|---|
\[\begin{array}{l}
t_0 := 1 + e^{a}\\
\mathbf{if}\;e^{a} \leq 0:\\
\;\;\;\;\frac{b}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\log t_0\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 1.2 |
|---|
| Cost | 13252 |
|---|
\[\begin{array}{l}
\mathbf{if}\;a \leq -37:\\
\;\;\;\;\frac{b}{1 + e^{a}}\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{a} + \left(b - -1\right)\right)\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 27.4 |
|---|
| Cost | 6852 |
|---|
\[\begin{array}{l}
\mathbf{if}\;a \leq -118:\\
\;\;\;\;\frac{b}{2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot b + \log 2\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 1.9 |
|---|
| Cost | 6852 |
|---|
\[\begin{array}{l}
\mathbf{if}\;a \leq -37:\\
\;\;\;\;\frac{b}{1 + e^{a}}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot b + \log 2\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 27.5 |
|---|
| Cost | 6724 |
|---|
\[\begin{array}{l}
\mathbf{if}\;a \leq -1:\\
\;\;\;\;\frac{b}{2}\\
\mathbf{else}:\\
\;\;\;\;\log \left(2 + a\right)\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 27.5 |
|---|
| Cost | 6724 |
|---|
\[\begin{array}{l}
\mathbf{if}\;a \leq -145:\\
\;\;\;\;\frac{b}{2}\\
\mathbf{else}:\\
\;\;\;\;\log \left(2 + b\right)\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 27.8 |
|---|
| Cost | 6596 |
|---|
\[\begin{array}{l}
\mathbf{if}\;a \leq -160:\\
\;\;\;\;\frac{b}{2}\\
\mathbf{else}:\\
\;\;\;\;\log 2\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 56.4 |
|---|
| Cost | 192 |
|---|
\[\frac{b}{2}
\]