Math FPCore C Fortran Java Python Julia MATLAB Wolfram TeX \[\frac{e^{a}}{e^{a} + e^{b}}
\]
↓
\[\begin{array}{l}
t_0 := e^{b} + 1\\
\mathbf{if}\;e^{b} \leq 0.98:\\
\;\;\;\;\frac{1}{t_0}\\
\mathbf{elif}\;e^{b} \leq 1:\\
\;\;\;\;\frac{e^{a}}{e^{a} + 1}\\
\mathbf{else}:\\
\;\;\;\;e^{-\log t_0}\\
\end{array}
\]
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b)))) ↓
(FPCore (a b)
:precision binary64
(let* ((t_0 (+ (exp b) 1.0)))
(if (<= (exp b) 0.98)
(/ 1.0 t_0)
(if (<= (exp b) 1.0) (/ (exp a) (+ (exp a) 1.0)) (exp (- (log t_0))))))) double code(double a, double b) {
return exp(a) / (exp(a) + exp(b));
}
↓
double code(double a, double b) {
double t_0 = exp(b) + 1.0;
double tmp;
if (exp(b) <= 0.98) {
tmp = 1.0 / t_0;
} else if (exp(b) <= 1.0) {
tmp = exp(a) / (exp(a) + 1.0);
} else {
tmp = exp(-log(t_0));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = exp(a) / (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) :: tmp
t_0 = exp(b) + 1.0d0
if (exp(b) <= 0.98d0) then
tmp = 1.0d0 / t_0
else if (exp(b) <= 1.0d0) then
tmp = exp(a) / (exp(a) + 1.0d0)
else
tmp = exp(-log(t_0))
end if
code = tmp
end function
public static double code(double a, double b) {
return Math.exp(a) / (Math.exp(a) + Math.exp(b));
}
↓
public static double code(double a, double b) {
double t_0 = Math.exp(b) + 1.0;
double tmp;
if (Math.exp(b) <= 0.98) {
tmp = 1.0 / t_0;
} else if (Math.exp(b) <= 1.0) {
tmp = Math.exp(a) / (Math.exp(a) + 1.0);
} else {
tmp = Math.exp(-Math.log(t_0));
}
return tmp;
}
def code(a, b):
return math.exp(a) / (math.exp(a) + math.exp(b))
↓
def code(a, b):
t_0 = math.exp(b) + 1.0
tmp = 0
if math.exp(b) <= 0.98:
tmp = 1.0 / t_0
elif math.exp(b) <= 1.0:
tmp = math.exp(a) / (math.exp(a) + 1.0)
else:
tmp = math.exp(-math.log(t_0))
return tmp
function code(a, b)
return Float64(exp(a) / Float64(exp(a) + exp(b)))
end
↓
function code(a, b)
t_0 = Float64(exp(b) + 1.0)
tmp = 0.0
if (exp(b) <= 0.98)
tmp = Float64(1.0 / t_0);
elseif (exp(b) <= 1.0)
tmp = Float64(exp(a) / Float64(exp(a) + 1.0));
else
tmp = exp(Float64(-log(t_0)));
end
return tmp
end
function tmp = code(a, b)
tmp = exp(a) / (exp(a) + exp(b));
end
↓
function tmp_2 = code(a, b)
t_0 = exp(b) + 1.0;
tmp = 0.0;
if (exp(b) <= 0.98)
tmp = 1.0 / t_0;
elseif (exp(b) <= 1.0)
tmp = exp(a) / (exp(a) + 1.0);
else
tmp = exp(-log(t_0));
end
tmp_2 = tmp;
end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
↓
code[a_, b_] := Block[{t$95$0 = N[(N[Exp[b], $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[N[Exp[b], $MachinePrecision], 0.98], N[(1.0 / t$95$0), $MachinePrecision], If[LessEqual[N[Exp[b], $MachinePrecision], 1.0], N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[Exp[(-N[Log[t$95$0], $MachinePrecision])], $MachinePrecision]]]]
\frac{e^{a}}{e^{a} + e^{b}}
↓
\begin{array}{l}
t_0 := e^{b} + 1\\
\mathbf{if}\;e^{b} \leq 0.98:\\
\;\;\;\;\frac{1}{t_0}\\
\mathbf{elif}\;e^{b} \leq 1:\\
\;\;\;\;\frac{e^{a}}{e^{a} + 1}\\
\mathbf{else}:\\
\;\;\;\;e^{-\log t_0}\\
\end{array}
Alternatives Alternative 1 Error 1.1 Cost 26184
\[\begin{array}{l}
t_0 := \frac{1}{e^{b} + 1}\\
\mathbf{if}\;e^{b} \leq 0.98:\\
\;\;\;\;t_0\\
\mathbf{elif}\;e^{b} \leq 1:\\
\;\;\;\;\frac{e^{a}}{e^{a} + 1}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
Alternative 2 Error 0.7 Cost 19520
\[\frac{e^{a}}{e^{a} + e^{b}}
\]
Alternative 3 Error 1.0 Cost 13508
\[\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0.0001:\\
\;\;\;\;e^{a}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \frac{1}{e^{b} + 1}\right) + -1\\
\end{array}
\]
Alternative 4 Error 1.0 Cost 13252
\[\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0.0001:\\
\;\;\;\;e^{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{e^{b} + 1}\\
\end{array}
\]
Alternative 5 Error 15.3 Cost 7124
\[\begin{array}{l}
\mathbf{if}\;b \leq -1474655.4947532765:\\
\;\;\;\;e^{b} + 1\\
\mathbf{elif}\;b \leq -9.390390219898622 \cdot 10^{-30}:\\
\;\;\;\;\left(1.5 + b \cdot -0.25\right) + -1\\
\mathbf{elif}\;b \leq -8.073838721941194 \cdot 10^{-73}:\\
\;\;\;\;e^{a}\\
\mathbf{elif}\;b \leq -3.458280205294541 \cdot 10^{-94}:\\
\;\;\;\;0.5\\
\mathbf{elif}\;b \leq -2.38 \cdot 10^{-243}:\\
\;\;\;\;e^{a}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \frac{1}{b + 2}\right) + -1\\
\end{array}
\]
Alternative 6 Error 15.9 Cost 6860
\[\begin{array}{l}
\mathbf{if}\;b \leq -8.073838721941194 \cdot 10^{-73}:\\
\;\;\;\;e^{a}\\
\mathbf{elif}\;b \leq -3.458280205294541 \cdot 10^{-94}:\\
\;\;\;\;0.5\\
\mathbf{elif}\;b \leq -2.38 \cdot 10^{-243}:\\
\;\;\;\;e^{a}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \frac{1}{b + 2}\right) + -1\\
\end{array}
\]
Alternative 7 Error 23.3 Cost 716
\[\begin{array}{l}
\mathbf{if}\;b \leq -3.458280205294541 \cdot 10^{-94}:\\
\;\;\;\;0.5\\
\mathbf{elif}\;b \leq -4.727176996354683 \cdot 10^{-191}:\\
\;\;\;\;0\\
\mathbf{elif}\;b \leq 0.0336326306206187:\\
\;\;\;\;b \cdot -0.25 + 0.5\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\]
Alternative 8 Error 23.3 Cost 716
\[\begin{array}{l}
\mathbf{if}\;b \leq -3.458280205294541 \cdot 10^{-94}:\\
\;\;\;\;0.5 + a \cdot 0.25\\
\mathbf{elif}\;b \leq -4.727176996354683 \cdot 10^{-191}:\\
\;\;\;\;0\\
\mathbf{elif}\;b \leq 0.0336326306206187:\\
\;\;\;\;b \cdot -0.25 + 0.5\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\]
Alternative 9 Error 13.8 Cost 708
\[\begin{array}{l}
\mathbf{if}\;a \leq -1 \cdot 10^{+30}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \frac{1}{b + 2}\right) + -1\\
\end{array}
\]
Alternative 10 Error 23.4 Cost 460
\[\begin{array}{l}
\mathbf{if}\;b \leq -3.458280205294541 \cdot 10^{-94}:\\
\;\;\;\;0.5\\
\mathbf{elif}\;b \leq -4.727176996354683 \cdot 10^{-191}:\\
\;\;\;\;0\\
\mathbf{elif}\;b \leq 0.0336326306206187:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\]
Alternative 11 Error 38.8 Cost 64
\[0.5
\]