\[ \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}\\
\frac{b}{t_0} + \left(\log t_0 + 0.5 \cdot \left(\left(\frac{1}{t_0} - \frac{1}{{t_0}^{2}}\right) \cdot {b}^{2}\right)\right)
\end{array}
\]
(FPCore (a b) :precision binary64 (log (+ (exp a) (exp b))))
↓
(FPCore (a b)
:precision binary64
(let* ((t_0 (+ 1.0 (exp a))))
(+
(/ b t_0)
(+
(log t_0)
(* 0.5 (* (- (/ 1.0 t_0) (/ 1.0 (pow t_0 2.0))) (pow b 2.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 (b / t_0) + (log(t_0) + (0.5 * (((1.0 / t_0) - (1.0 / pow(t_0, 2.0))) * pow(b, 2.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 = (b / t_0) + (log(t_0) + (0.5d0 * (((1.0d0 / t_0) - (1.0d0 / (t_0 ** 2.0d0))) * (b ** 2.0d0))))
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 (b / t_0) + (Math.log(t_0) + (0.5 * (((1.0 / t_0) - (1.0 / Math.pow(t_0, 2.0))) * Math.pow(b, 2.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 (b / t_0) + (math.log(t_0) + (0.5 * (((1.0 / t_0) - (1.0 / math.pow(t_0, 2.0))) * math.pow(b, 2.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(Float64(b / t_0) + Float64(log(t_0) + Float64(0.5 * Float64(Float64(Float64(1.0 / t_0) - Float64(1.0 / (t_0 ^ 2.0))) * (b ^ 2.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 = (b / t_0) + (log(t_0) + (0.5 * (((1.0 / t_0) - (1.0 / (t_0 ^ 2.0))) * (b ^ 2.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[(b / t$95$0), $MachinePrecision] + N[(N[Log[t$95$0], $MachinePrecision] + N[(0.5 * N[(N[(N[(1.0 / t$95$0), $MachinePrecision] - N[(1.0 / N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\log \left(e^{a} + e^{b}\right)
↓
\begin{array}{l}
t_0 := 1 + e^{a}\\
\frac{b}{t_0} + \left(\log t_0 + 0.5 \cdot \left(\left(\frac{1}{t_0} - \frac{1}{{t_0}^{2}}\right) \cdot {b}^{2}\right)\right)
\end{array}
Alternatives
| Alternative 1 |
|---|
| Error | 26.3 |
|---|
| Cost | 32452 |
|---|
\[\begin{array}{l}
t_0 := e^{a} + e^{b}\\
\mathbf{if}\;t_0 \leq 1:\\
\;\;\;\;0.5 \cdot b\\
\mathbf{else}:\\
\;\;\;\;\log t_0\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 1.3 |
|---|
| Cost | 19776 |
|---|
\[\begin{array}{l}
t_0 := 1 + e^{a}\\
\log t_0 + \frac{b}{t_0}
\end{array}
\]
| Alternative 3 |
|---|
| Error | 27.5 |
|---|
| Cost | 19524 |
|---|
\[\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0:\\
\;\;\;\;0.5 \cdot b + 0.125 \cdot {b}^{2}\\
\mathbf{else}:\\
\;\;\;\;\log \left(1 + e^{a}\right)\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 27.6 |
|---|
| Cost | 19524 |
|---|
\[\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0:\\
\;\;\;\;0.5 \cdot b + 0.125 \cdot {b}^{2}\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{b} - -1\right)\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 28.0 |
|---|
| Cost | 7044 |
|---|
\[\begin{array}{l}
\mathbf{if}\;a \leq -125:\\
\;\;\;\;0.5 \cdot b + 0.125 \cdot {b}^{2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot b + \log 2\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 27.9 |
|---|
| Cost | 6852 |
|---|
\[\begin{array}{l}
\mathbf{if}\;a \leq -78:\\
\;\;\;\;0.5 \cdot b\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot b + \log 2\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 28.0 |
|---|
| Cost | 6724 |
|---|
\[\begin{array}{l}
\mathbf{if}\;a \leq -90:\\
\;\;\;\;0.5 \cdot b\\
\mathbf{else}:\\
\;\;\;\;\log \left(2 + b\right)\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 28.3 |
|---|
| Cost | 6596 |
|---|
\[\begin{array}{l}
\mathbf{if}\;a \leq -108:\\
\;\;\;\;0.5 \cdot b\\
\mathbf{else}:\\
\;\;\;\;\log 2\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 56.3 |
|---|
| Cost | 192 |
|---|
\[0.5 \cdot b
\]