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.7 Cost 19520
\[\frac{e^{a}}{e^{a} + e^{b}}
\]
Alternative 2 Error 1.3 Cost 13248
\[\frac{e^{a}}{e^{b} + \left(a + 1\right)}
\]
Alternative 3 Error 1.6 Cost 13120
\[\frac{e^{a}}{e^{b} + 1}
\]
Alternative 4 Error 12.8 Cost 6860
\[\begin{array}{l}
\mathbf{if}\;b \leq -0.00034235619640380857:\\
\;\;\;\;e^{a}\\
\mathbf{elif}\;b \leq 0.4563430726744827:\\
\;\;\;\;0.5 + b \cdot -0.25\\
\mathbf{elif}\;b \leq 458428064680208450:\\
\;\;\;\;e^{a}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \frac{1}{b + 2}\right) + -1\\
\end{array}
\]
Alternative 5 Error 2.4 Cost 6856
\[\begin{array}{l}
\mathbf{if}\;b \leq -8.391741647252022:\\
\;\;\;\;e^{a}\\
\mathbf{elif}\;b \leq 15921188690786.355:\\
\;\;\;\;\frac{e^{a}}{2}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \frac{1}{b + 2}\right) + -1\\
\end{array}
\]
Alternative 6 Error 1.0 Cost 6852
\[\begin{array}{l}
\mathbf{if}\;a \leq -380525397.76365477:\\
\;\;\;\;e^{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{e^{b} + 1}\\
\end{array}
\]
Alternative 7 Error 22.4 Cost 708
\[\begin{array}{l}
\mathbf{if}\;b \leq -0.00034235619640380857:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \frac{1}{b + 2}\right) + -1\\
\end{array}
\]
Alternative 8 Error 38.4 Cost 64
\[0.5
\]