Math FPCore C Fortran Java Python Julia MATLAB Wolfram TeX \[\frac{e^{a}}{e^{a} + e^{b}}
\]
↓
\[\begin{array}{l}
t_0 := \frac{1}{1 + e^{b}}\\
\mathbf{if}\;e^{b} \leq 2 \cdot 10^{-5}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;e^{b} \leq 1.00002:\\
\;\;\;\;\frac{e^{a}}{e^{a} + \left(1 + b\right)}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b)))) ↓
(FPCore (a b)
:precision binary64
(let* ((t_0 (/ 1.0 (+ 1.0 (exp b)))))
(if (<= (exp b) 2e-5)
t_0
(if (<= (exp b) 1.00002) (/ (exp a) (+ (exp a) (+ 1.0 b))) t_0)))) double code(double a, double b) {
return exp(a) / (exp(a) + exp(b));
}
↓
double code(double a, double b) {
double t_0 = 1.0 / (1.0 + exp(b));
double tmp;
if (exp(b) <= 2e-5) {
tmp = t_0;
} else if (exp(b) <= 1.00002) {
tmp = exp(a) / (exp(a) + (1.0 + b));
} else {
tmp = 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 = 1.0d0 / (1.0d0 + exp(b))
if (exp(b) <= 2d-5) then
tmp = t_0
else if (exp(b) <= 1.00002d0) then
tmp = exp(a) / (exp(a) + (1.0d0 + b))
else
tmp = 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 = 1.0 / (1.0 + Math.exp(b));
double tmp;
if (Math.exp(b) <= 2e-5) {
tmp = t_0;
} else if (Math.exp(b) <= 1.00002) {
tmp = Math.exp(a) / (Math.exp(a) + (1.0 + b));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b):
return math.exp(a) / (math.exp(a) + math.exp(b))
↓
def code(a, b):
t_0 = 1.0 / (1.0 + math.exp(b))
tmp = 0
if math.exp(b) <= 2e-5:
tmp = t_0
elif math.exp(b) <= 1.00002:
tmp = math.exp(a) / (math.exp(a) + (1.0 + b))
else:
tmp = 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(1.0 / Float64(1.0 + exp(b)))
tmp = 0.0
if (exp(b) <= 2e-5)
tmp = t_0;
elseif (exp(b) <= 1.00002)
tmp = Float64(exp(a) / Float64(exp(a) + Float64(1.0 + b)));
else
tmp = 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 = 1.0 / (1.0 + exp(b));
tmp = 0.0;
if (exp(b) <= 2e-5)
tmp = t_0;
elseif (exp(b) <= 1.00002)
tmp = exp(a) / (exp(a) + (1.0 + b));
else
tmp = 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[(1.0 / N[(1.0 + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Exp[b], $MachinePrecision], 2e-5], t$95$0, If[LessEqual[N[Exp[b], $MachinePrecision], 1.00002], N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[(1.0 + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\frac{e^{a}}{e^{a} + e^{b}}
↓
\begin{array}{l}
t_0 := \frac{1}{1 + e^{b}}\\
\mathbf{if}\;e^{b} \leq 2 \cdot 10^{-5}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;e^{b} \leq 1.00002:\\
\;\;\;\;\frac{e^{a}}{e^{a} + \left(1 + b\right)}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}