\[ \begin{array}{c}[a, b] = \mathsf{sort}([a, b])\\ \end{array} \]
Math FPCore C Fortran Java Python Julia MATLAB Wolfram TeX \[\log \left(e^{a} + e^{b}\right)
\]
↓
\[\begin{array}{l}
\mathbf{if}\;e^{a} \leq 10^{-64}:\\
\;\;\;\;\frac{b}{1 + e^{a}}\\
\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
(if (<= (exp a) 1e-64) (/ b (+ 1.0 (exp a))) (log (+ (exp a) (exp b))))) double code(double a, double b) {
return log((exp(a) + exp(b)));
}
↓
double code(double a, double b) {
double tmp;
if (exp(a) <= 1e-64) {
tmp = b / (1.0 + exp(a));
} else {
tmp = log((exp(a) + exp(b)));
}
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) :: tmp
if (exp(a) <= 1d-64) then
tmp = b / (1.0d0 + exp(a))
else
tmp = log((exp(a) + exp(b)))
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 tmp;
if (Math.exp(a) <= 1e-64) {
tmp = b / (1.0 + Math.exp(a));
} else {
tmp = Math.log((Math.exp(a) + Math.exp(b)));
}
return tmp;
}
def code(a, b):
return math.log((math.exp(a) + math.exp(b)))
↓
def code(a, b):
tmp = 0
if math.exp(a) <= 1e-64:
tmp = b / (1.0 + math.exp(a))
else:
tmp = math.log((math.exp(a) + math.exp(b)))
return tmp
function code(a, b)
return log(Float64(exp(a) + exp(b)))
end
↓
function code(a, b)
tmp = 0.0
if (exp(a) <= 1e-64)
tmp = Float64(b / Float64(1.0 + exp(a)));
else
tmp = log(Float64(exp(a) + exp(b)));
end
return tmp
end
function tmp = code(a, b)
tmp = log((exp(a) + exp(b)));
end
↓
function tmp_2 = code(a, b)
tmp = 0.0;
if (exp(a) <= 1e-64)
tmp = b / (1.0 + exp(a));
else
tmp = log((exp(a) + exp(b)));
end
tmp_2 = tmp;
end
code[a_, b_] := N[Log[N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
↓
code[a_, b_] := If[LessEqual[N[Exp[a], $MachinePrecision], 1e-64], N[(b / N[(1.0 + N[Exp[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Log[N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\log \left(e^{a} + e^{b}\right)
↓
\begin{array}{l}
\mathbf{if}\;e^{a} \leq 10^{-64}:\\
\;\;\;\;\frac{b}{1 + e^{a}}\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{a} + e^{b}\right)\\
\end{array}
Alternatives Alternative 1 Error 1.3 Cost 19776
\[\begin{array}{l}
t_0 := 1 + e^{a}\\
\log t_0 + \frac{b}{t_0}
\end{array}
\]
Alternative 2 Error 1.3 Cost 19652
\[\begin{array}{l}
\mathbf{if}\;e^{a} \leq 10^{-64}:\\
\;\;\;\;\frac{b}{1 + e^{a}}\\
\mathbf{else}:\\
\;\;\;\;\log \left(1 + \left(e^{a} + b\right)\right)\\
\end{array}
\]
Alternative 3 Error 1.7 Cost 19524
\[\begin{array}{l}
t_0 := 1 + e^{a}\\
\mathbf{if}\;e^{a} \leq 10^{-64}:\\
\;\;\;\;\frac{b}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\log t_0\\
\end{array}
\]
Alternative 4 Error 1.7 Cost 19524
\[\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0:\\
\;\;\;\;\frac{b}{1 + e^{a}}\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{b} - -1\right)\\
\end{array}
\]
Alternative 5 Error 1.7 Cost 13764
\[\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0.2:\\
\;\;\;\;\frac{b}{1 + e^{a}}\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot b + \log 2\right) + a \cdot \left(0.5 - b \cdot 0.25\right)\\
\end{array}
\]
Alternative 6 Error 1.7 Cost 13508
\[\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0.2:\\
\;\;\;\;\frac{b}{1 + e^{a}}\\
\mathbf{else}:\\
\;\;\;\;\log \left(2 + a\right) + \frac{b}{2 + a}\\
\end{array}
\]
Alternative 7 Error 2.1 Cost 13252
\[\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0:\\
\;\;\;\;\frac{b}{1 + e^{a}}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot b + \log 2\\
\end{array}
\]
Alternative 8 Error 28.1 Cost 6852
\[\begin{array}{l}
\mathbf{if}\;a \leq -155:\\
\;\;\;\;\frac{b}{2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot b + \log 2\\
\end{array}
\]
Alternative 9 Error 28.2 Cost 6724
\[\begin{array}{l}
\mathbf{if}\;a \leq -1:\\
\;\;\;\;\frac{b}{2}\\
\mathbf{else}:\\
\;\;\;\;\log \left(2 + a\right)\\
\end{array}
\]
Alternative 10 Error 28.1 Cost 6724
\[\begin{array}{l}
\mathbf{if}\;a \leq -150:\\
\;\;\;\;\frac{b}{2}\\
\mathbf{else}:\\
\;\;\;\;\log \left(2 + b\right)\\
\end{array}
\]
Alternative 11 Error 28.5 Cost 6596
\[\begin{array}{l}
\mathbf{if}\;a \leq -150:\\
\;\;\;\;\frac{b}{2}\\
\mathbf{else}:\\
\;\;\;\;\log 2\\
\end{array}
\]
Alternative 12 Error 56.3 Cost 192
\[\frac{b}{2}
\]