Math FPCore C Fortran Java Python Julia MATLAB Wolfram TeX \[\frac{e^{a}}{e^{a} + e^{b}}
\]
↓
\[\begin{array}{l}
t_0 := \frac{e^{a}}{e^{a} + e^{b}}\\
\mathbf{if}\;t_0 \leq 1:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{e^{b} + 1}\\
\end{array}
\]
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b)))) ↓
(FPCore (a b)
:precision binary64
(let* ((t_0 (/ (exp a) (+ (exp a) (exp b)))))
(if (<= t_0 1.0) t_0 (/ 1.0 (+ (exp b) 1.0))))) double code(double a, double b) {
return exp(a) / (exp(a) + exp(b));
}
↓
double code(double a, double b) {
double t_0 = exp(a) / (exp(a) + exp(b));
double tmp;
if (t_0 <= 1.0) {
tmp = t_0;
} else {
tmp = 1.0 / (exp(b) + 1.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(a) / (exp(a) + exp(b))
if (t_0 <= 1.0d0) then
tmp = t_0
else
tmp = 1.0d0 / (exp(b) + 1.0d0)
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(a) / (Math.exp(a) + Math.exp(b));
double tmp;
if (t_0 <= 1.0) {
tmp = t_0;
} else {
tmp = 1.0 / (Math.exp(b) + 1.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(a) / (math.exp(a) + math.exp(b))
tmp = 0
if t_0 <= 1.0:
tmp = t_0
else:
tmp = 1.0 / (math.exp(b) + 1.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(a) / Float64(exp(a) + exp(b)))
tmp = 0.0
if (t_0 <= 1.0)
tmp = t_0;
else
tmp = Float64(1.0 / Float64(exp(b) + 1.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(a) / (exp(a) + exp(b));
tmp = 0.0;
if (t_0 <= 1.0)
tmp = t_0;
else
tmp = 1.0 / (exp(b) + 1.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[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1.0], t$95$0, N[(1.0 / N[(N[Exp[b], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]
\frac{e^{a}}{e^{a} + e^{b}}
↓
\begin{array}{l}
t_0 := \frac{e^{a}}{e^{a} + e^{b}}\\
\mathbf{if}\;t_0 \leq 1:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{e^{b} + 1}\\
\end{array}
Alternatives Alternative 1 Error 11.6 Cost 26185
\[\begin{array}{l}
\mathbf{if}\;e^{b} \leq 1 \lor \neg \left(e^{b} \leq 2\right):\\
\;\;\;\;\frac{1}{e^{b} + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{a}}{e^{a} + 1}\\
\end{array}
\]
Alternative 2 Error 1.0 Cost 6852
\[\begin{array}{l}
\mathbf{if}\;a \leq -8600000:\\
\;\;\;\;\frac{e^{a}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{e^{b} + 1}\\
\end{array}
\]
Alternative 3 Error 11.9 Cost 6724
\[\begin{array}{l}
\mathbf{if}\;b \leq 9 \cdot 10^{+15}:\\
\;\;\;\;\frac{e^{a}}{2}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \frac{1}{b}\right) + -1\\
\end{array}
\]
Alternative 4 Error 21.3 Cost 1604
\[\begin{array}{l}
\mathbf{if}\;a \leq -720:\\
\;\;\;\;\frac{1}{\left(\frac{-4}{b} + \frac{-8}{b \cdot b}\right) - b \cdot \left(\frac{b}{2 - b} + b \cdot -0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \frac{1}{b + 2}\right) + -1\\
\end{array}
\]
Alternative 5 Error 22.7 Cost 708
\[\begin{array}{l}
\mathbf{if}\;b \leq -1.05 \cdot 10^{-183}:\\
\;\;\;\;0.5 + a \cdot 0.25\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \frac{1}{b + 2}\right) + -1\\
\end{array}
\]
Alternative 6 Error 23.4 Cost 580
\[\begin{array}{l}
\mathbf{if}\;b \leq 5.2 \cdot 10^{-28}:\\
\;\;\;\;0.5 + a \cdot 0.25\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \frac{1}{b}\right) + -1\\
\end{array}
\]
Alternative 7 Error 30.5 Cost 452
\[\begin{array}{l}
\mathbf{if}\;b \leq 5.2 \cdot 10^{-28}:\\
\;\;\;\;0.5 + a \cdot 0.25\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{b \cdot b}\\
\end{array}
\]
Alternative 8 Error 38.3 Cost 320
\[0.5 + a \cdot 0.25
\]
Alternative 9 Error 38.4 Cost 64
\[0.5
\]