\[ \begin{array}{c}[a, b] = \mathsf{sort}([a, b])\\ \end{array} \]
\[\log \left(e^{a} + e^{b}\right)
\]
↓
\[\begin{array}{l}
t_0 := e^{a} + e^{b}\\
t_1 := 1 + e^{a}\\
t_2 := \log t_1 + \frac{b}{t_1}\\
\mathbf{if}\;t_0 \leq 1.5:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+102}:\\
\;\;\;\;\log \left(e^{b} \cdot 1.5 - \left(\left(e^{b} - e^{a}\right) + \frac{e^{b}}{-2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\]
(FPCore (a b) :precision binary64 (log (+ (exp a) (exp b))))
↓
(FPCore (a b)
:precision binary64
(let* ((t_0 (+ (exp a) (exp b)))
(t_1 (+ 1.0 (exp a)))
(t_2 (+ (log t_1) (/ b t_1))))
(if (<= t_0 1.5)
t_2
(if (<= t_0 5e+102)
(log (- (* (exp b) 1.5) (+ (- (exp b) (exp a)) (/ (exp b) -2.0))))
t_2))))double code(double a, double b) {
return log((exp(a) + exp(b)));
}
↓
double code(double a, double b) {
double t_0 = exp(a) + exp(b);
double t_1 = 1.0 + exp(a);
double t_2 = log(t_1) + (b / t_1);
double tmp;
if (t_0 <= 1.5) {
tmp = t_2;
} else if (t_0 <= 5e+102) {
tmp = log(((exp(b) * 1.5) - ((exp(b) - exp(a)) + (exp(b) / -2.0))));
} else {
tmp = t_2;
}
return tmp;
}
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
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = exp(a) + exp(b)
t_1 = 1.0d0 + exp(a)
t_2 = log(t_1) + (b / t_1)
if (t_0 <= 1.5d0) then
tmp = t_2
else if (t_0 <= 5d+102) then
tmp = log(((exp(b) * 1.5d0) - ((exp(b) - exp(a)) + (exp(b) / (-2.0d0)))))
else
tmp = t_2
end if
code = tmp
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 = Math.exp(a) + Math.exp(b);
double t_1 = 1.0 + Math.exp(a);
double t_2 = Math.log(t_1) + (b / t_1);
double tmp;
if (t_0 <= 1.5) {
tmp = t_2;
} else if (t_0 <= 5e+102) {
tmp = Math.log(((Math.exp(b) * 1.5) - ((Math.exp(b) - Math.exp(a)) + (Math.exp(b) / -2.0))));
} else {
tmp = t_2;
}
return tmp;
}
def code(a, b):
return math.log((math.exp(a) + math.exp(b)))
↓
def code(a, b):
t_0 = math.exp(a) + math.exp(b)
t_1 = 1.0 + math.exp(a)
t_2 = math.log(t_1) + (b / t_1)
tmp = 0
if t_0 <= 1.5:
tmp = t_2
elif t_0 <= 5e+102:
tmp = math.log(((math.exp(b) * 1.5) - ((math.exp(b) - math.exp(a)) + (math.exp(b) / -2.0))))
else:
tmp = t_2
return tmp
function code(a, b)
return log(Float64(exp(a) + exp(b)))
end
↓
function code(a, b)
t_0 = Float64(exp(a) + exp(b))
t_1 = Float64(1.0 + exp(a))
t_2 = Float64(log(t_1) + Float64(b / t_1))
tmp = 0.0
if (t_0 <= 1.5)
tmp = t_2;
elseif (t_0 <= 5e+102)
tmp = log(Float64(Float64(exp(b) * 1.5) - Float64(Float64(exp(b) - exp(a)) + Float64(exp(b) / -2.0))));
else
tmp = t_2;
end
return tmp
end
function tmp = code(a, b)
tmp = log((exp(a) + exp(b)));
end
↓
function tmp_2 = code(a, b)
t_0 = exp(a) + exp(b);
t_1 = 1.0 + exp(a);
t_2 = log(t_1) + (b / t_1);
tmp = 0.0;
if (t_0 <= 1.5)
tmp = t_2;
elseif (t_0 <= 5e+102)
tmp = log(((exp(b) * 1.5) - ((exp(b) - exp(a)) + (exp(b) / -2.0))));
else
tmp = t_2;
end
tmp_2 = tmp;
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[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[Exp[a], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Log[t$95$1], $MachinePrecision] + N[(b / t$95$1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1.5], t$95$2, If[LessEqual[t$95$0, 5e+102], N[Log[N[(N[(N[Exp[b], $MachinePrecision] * 1.5), $MachinePrecision] - N[(N[(N[Exp[b], $MachinePrecision] - N[Exp[a], $MachinePrecision]), $MachinePrecision] + N[(N[Exp[b], $MachinePrecision] / -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]]
\log \left(e^{a} + e^{b}\right)
↓
\begin{array}{l}
t_0 := e^{a} + e^{b}\\
t_1 := 1 + e^{a}\\
t_2 := \log t_1 + \frac{b}{t_1}\\
\mathbf{if}\;t_0 \leq 1.5:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+102}:\\
\;\;\;\;\log \left(e^{b} \cdot 1.5 - \left(\left(e^{b} - e^{a}\right) + \frac{e^{b}}{-2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
Alternatives
| Alternative 1 |
|---|
| Error | 0.9 |
|---|
| Cost | 46528 |
|---|
\[\begin{array}{l}
t_0 := 1 + e^{a}\\
\left(\log t_0 + \frac{b}{t_0}\right) + 0.5 \cdot \left(\left(\frac{1}{t_0} - \frac{1}{{t_0}^{2}}\right) \cdot {b}^{2}\right)
\end{array}
\]
| Alternative 2 |
|---|
| Error | 0.7 |
|---|
| Cost | 45896 |
|---|
\[\begin{array}{l}
t_0 := e^{a} + e^{b}\\
t_1 := 1 + e^{a}\\
t_2 := \log t_1 + \frac{b}{t_1}\\
\mathbf{if}\;t_0 \leq 2:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+102}:\\
\;\;\;\;\log \left(e^{b} \cdot 1.5 - \left(-1 + 0.5 \cdot e^{b}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 1.9 |
|---|
| Cost | 32452 |
|---|
\[\begin{array}{l}
t_0 := e^{a} + e^{b}\\
\mathbf{if}\;t_0 \leq 1.0000002:\\
\;\;\;\;\frac{b}{1 + e^{a}} + 0.125 \cdot {b}^{2}\\
\mathbf{else}:\\
\;\;\;\;\log t_0\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 3.0 |
|---|
| Cost | 19972 |
|---|
\[\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0:\\
\;\;\;\;\frac{b}{1 + e^{a}} + 0.125 \cdot {b}^{2}\\
\mathbf{else}:\\
\;\;\;\;\log \left(1 + e^{b}\right)\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 26.9 |
|---|
| Cost | 19780 |
|---|
\[\begin{array}{l}
\mathbf{if}\;e^{b} \leq 1.00004:\\
\;\;\;\;\log \left(1 + e^{a}\right) + \frac{b}{2}\\
\mathbf{else}:\\
\;\;\;\;\log \left(1 + e^{b}\right)\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 30.6 |
|---|
| Cost | 13252 |
|---|
\[\begin{array}{l}
\mathbf{if}\;b \leq 4.2 \cdot 10^{-5}:\\
\;\;\;\;\log \left(e^{a} + \left(1 + b\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(1 + e^{b}\right)\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 31.1 |
|---|
| Cost | 13124 |
|---|
\[\begin{array}{l}
\mathbf{if}\;b \leq 4.8 \cdot 10^{-25}:\\
\;\;\;\;\log \left(1 + e^{a}\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(1 + e^{b}\right)\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 32.1 |
|---|
| Cost | 12992 |
|---|
\[\log \left(1 + e^{a}\right)
\]
| Alternative 9 |
|---|
| Error | 31.9 |
|---|
| Cost | 7496 |
|---|
\[\begin{array}{l}
\mathbf{if}\;a \leq -1.4:\\
\;\;\;\;0.125 \cdot {b}^{2}\\
\mathbf{elif}\;a \leq -8.4 \cdot 10^{-16}:\\
\;\;\;\;\left(\frac{a}{8} - \left(a \cdot -0.25 - \log 2\right)\right) + \frac{a}{8}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot b + \log 2\\
\end{array}
\]
| Alternative 10 |
|---|
| Error | 31.9 |
|---|
| Cost | 6984 |
|---|
\[\begin{array}{l}
\mathbf{if}\;a \leq -1.4:\\
\;\;\;\;0.125 \cdot {b}^{2}\\
\mathbf{elif}\;a \leq -8.4 \cdot 10^{-16}:\\
\;\;\;\;0.5 \cdot a + \log 2\\
\mathbf{else}:\\
\;\;\;\;\log \left(2 + b\right)\\
\end{array}
\]
| Alternative 11 |
|---|
| Error | 31.9 |
|---|
| Cost | 6984 |
|---|
\[\begin{array}{l}
\mathbf{if}\;a \leq -1.4:\\
\;\;\;\;0.125 \cdot {b}^{2}\\
\mathbf{elif}\;a \leq -2 \cdot 10^{-16}:\\
\;\;\;\;0.5 \cdot a + \log 2\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot b + \log 2\\
\end{array}
\]
| Alternative 12 |
|---|
| Error | 31.9 |
|---|
| Cost | 6856 |
|---|
\[\begin{array}{l}
\mathbf{if}\;a \leq -1:\\
\;\;\;\;0.125 \cdot {b}^{2}\\
\mathbf{elif}\;a \leq -3.8 \cdot 10^{-16}:\\
\;\;\;\;\log \left(2 + a\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(2 + b\right)\\
\end{array}
\]
| Alternative 13 |
|---|
| Error | 32.9 |
|---|
| Cost | 6592 |
|---|
\[\log \left(2 + b\right)
\]
| Alternative 14 |
|---|
| Error | 33.2 |
|---|
| Cost | 6464 |
|---|
\[\log 2
\]
| Alternative 15 |
|---|
| Error | 62.3 |
|---|
| Cost | 192 |
|---|
\[0.5 \cdot a
\]