Math FPCore C Fortran Java Python Julia MATLAB Wolfram TeX \[\frac{e^{a}}{e^{a} + e^{b}}
\]
↓
\[e^{a - \log \left(e^{a} + e^{b}\right)}
\]
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b)))) ↓
(FPCore (a b) :precision binary64 (exp (- a (log (+ (exp a) (exp b)))))) double code(double a, double b) {
return exp(a) / (exp(a) + exp(b));
}
↓
double code(double a, double b) {
return exp((a - log((exp(a) + exp(b)))));
}
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
code = exp((a - log((exp(a) + exp(b)))))
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) {
return Math.exp((a - Math.log((Math.exp(a) + Math.exp(b)))));
}
def code(a, b):
return math.exp(a) / (math.exp(a) + math.exp(b))
↓
def code(a, b):
return math.exp((a - math.log((math.exp(a) + math.exp(b)))))
function code(a, b)
return Float64(exp(a) / Float64(exp(a) + exp(b)))
end
↓
function code(a, b)
return exp(Float64(a - log(Float64(exp(a) + exp(b)))))
end
function tmp = code(a, b)
tmp = exp(a) / (exp(a) + exp(b));
end
↓
function tmp = code(a, b)
tmp = exp((a - log((exp(a) + exp(b)))));
end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
↓
code[a_, b_] := N[Exp[N[(a - N[Log[N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\frac{e^{a}}{e^{a} + e^{b}}
↓
e^{a - \log \left(e^{a} + e^{b}\right)}
Alternatives Alternative 1 Error 0.8 Cost 26312
\[\begin{array}{l}
\mathbf{if}\;e^{b} \leq 0:\\
\;\;\;\;\frac{1}{e^{b} + 1}\\
\mathbf{elif}\;e^{b} \leq 1.002:\\
\;\;\;\;\frac{e^{a}}{e^{a} + \left(b + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\]
Alternative 2 Error 0.6 Cost 19520
\[\frac{e^{a}}{e^{a} + e^{b}}
\]
Alternative 3 Error 1.0 Cost 13384
\[\begin{array}{l}
\mathbf{if}\;b \leq -4400:\\
\;\;\;\;\frac{1}{e^{b} + 1}\\
\mathbf{elif}\;b \leq 0.0029:\\
\;\;\;\;\frac{e^{a}}{e^{a} + 1}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\]
Alternative 4 Error 0.8 Cost 13252
\[\begin{array}{l}
\mathbf{if}\;e^{a} \leq 0:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{e^{b} + 1}\\
\end{array}
\]
Alternative 5 Error 12.6 Cost 6596
\[\begin{array}{l}
\mathbf{if}\;b \leq -1.45 \cdot 10^{-15}:\\
\;\;\;\;e^{a}\\
\mathbf{elif}\;b \leq 0.0025:\\
\;\;\;\;0.5 + a \cdot 0.25\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\]
Alternative 6 Error 13.1 Cost 1732
\[\begin{array}{l}
t_0 := \frac{1}{b + 2}\\
t_1 := 1 + t_0\\
\mathbf{if}\;a \leq -0.00056:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{t_1}{\frac{t_1}{-1 + t_0}}\\
\end{array}
\]
Alternative 7 Error 13.1 Cost 708
\[\begin{array}{l}
\mathbf{if}\;a \leq -0.00056:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;1 + \left(-1 + \frac{1}{b + 2}\right)\\
\end{array}
\]
Alternative 8 Error 21.9 Cost 452
\[\begin{array}{l}
\mathbf{if}\;a \leq -0.6:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;0.5 + a \cdot 0.25\\
\end{array}
\]
Alternative 9 Error 22.6 Cost 196
\[\begin{array}{l}
\mathbf{if}\;a \leq -1.55 \cdot 10^{-30}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\]
Alternative 10 Error 39.0 Cost 64
\[0.5
\]