
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b))))
double code(double a, double b) {
return exp(a) / (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
public static double code(double a, double b) {
return Math.exp(a) / (Math.exp(a) + Math.exp(b));
}
def code(a, b): return math.exp(a) / (math.exp(a) + math.exp(b))
function code(a, b) return Float64(exp(a) / Float64(exp(a) + exp(b))) end
function tmp = code(a, b) tmp = exp(a) / (exp(a) + exp(b)); end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{a}}{e^{a} + e^{b}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b))))
double code(double a, double b) {
return exp(a) / (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
public static double code(double a, double b) {
return Math.exp(a) / (Math.exp(a) + Math.exp(b));
}
def code(a, b): return math.exp(a) / (math.exp(a) + math.exp(b))
function code(a, b) return Float64(exp(a) / Float64(exp(a) + exp(b))) end
function tmp = code(a, b) tmp = exp(a) / (exp(a) + exp(b)); end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{a}}{e^{a} + e^{b}}
\end{array}
(FPCore (a b) :precision binary64 (exp (- (log1p (exp (- b a))))))
double code(double a, double b) {
return exp(-log1p(exp((b - a))));
}
public static double code(double a, double b) {
return Math.exp(-Math.log1p(Math.exp((b - a))));
}
def code(a, b): return math.exp(-math.log1p(math.exp((b - a))))
function code(a, b) return exp(Float64(-log1p(exp(Float64(b - a))))) end
code[a_, b_] := N[Exp[(-N[Log[1 + N[Exp[N[(b - a), $MachinePrecision]], $MachinePrecision]], $MachinePrecision])], $MachinePrecision]
\begin{array}{l}
\\
e^{-\mathsf{log1p}\left(e^{b - a}\right)}
\end{array}
Initial program 98.8%
*-lft-identity98.8%
associate-*l/98.8%
associate-/r/98.8%
remove-double-neg98.8%
unsub-neg98.8%
div-sub71.1%
*-lft-identity71.1%
associate-*l/71.1%
lft-mult-inverse99.6%
sub-neg99.6%
distribute-frac-neg99.6%
remove-double-neg99.6%
div-exp100.0%
Simplified100.0%
div-exp99.6%
+-commutative99.6%
metadata-eval99.6%
sub-neg99.6%
add-exp-log99.6%
rec-exp99.6%
sub-neg99.6%
metadata-eval99.6%
+-commutative99.6%
log1p-define99.6%
div-exp100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (a b)
:precision binary64
(if (<= b -860.0)
(+ 1.0 (exp b))
(if (<= b 1.95e+96)
(/
1.0
(- (+ 1.0 (* a (+ -1.0 (* a (+ 0.5 (* a -0.16666666666666666)))))) -1.0))
(/ 6.0 (pow b 3.0)))))
double code(double a, double b) {
double tmp;
if (b <= -860.0) {
tmp = 1.0 + exp(b);
} else if (b <= 1.95e+96) {
tmp = 1.0 / ((1.0 + (a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666)))))) - -1.0);
} else {
tmp = 6.0 / pow(b, 3.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= (-860.0d0)) then
tmp = 1.0d0 + exp(b)
else if (b <= 1.95d+96) then
tmp = 1.0d0 / ((1.0d0 + (a * ((-1.0d0) + (a * (0.5d0 + (a * (-0.16666666666666666d0))))))) - (-1.0d0))
else
tmp = 6.0d0 / (b ** 3.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= -860.0) {
tmp = 1.0 + Math.exp(b);
} else if (b <= 1.95e+96) {
tmp = 1.0 / ((1.0 + (a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666)))))) - -1.0);
} else {
tmp = 6.0 / Math.pow(b, 3.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -860.0: tmp = 1.0 + math.exp(b) elif b <= 1.95e+96: tmp = 1.0 / ((1.0 + (a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666)))))) - -1.0) else: tmp = 6.0 / math.pow(b, 3.0) return tmp
function code(a, b) tmp = 0.0 if (b <= -860.0) tmp = Float64(1.0 + exp(b)); elseif (b <= 1.95e+96) tmp = Float64(1.0 / Float64(Float64(1.0 + Float64(a * Float64(-1.0 + Float64(a * Float64(0.5 + Float64(a * -0.16666666666666666)))))) - -1.0)); else tmp = Float64(6.0 / (b ^ 3.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= -860.0) tmp = 1.0 + exp(b); elseif (b <= 1.95e+96) tmp = 1.0 / ((1.0 + (a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666)))))) - -1.0); else tmp = 6.0 / (b ^ 3.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -860.0], N[(1.0 + N[Exp[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.95e+96], N[(1.0 / N[(N[(1.0 + N[(a * N[(-1.0 + N[(a * N[(0.5 + N[(a * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(6.0 / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -860:\\
\;\;\;\;1 + e^{b}\\
\mathbf{elif}\;b \leq 1.95 \cdot 10^{+96}:\\
\;\;\;\;\frac{1}{\left(1 + a \cdot \left(-1 + a \cdot \left(0.5 + a \cdot -0.16666666666666666\right)\right)\right) - -1}\\
\mathbf{else}:\\
\;\;\;\;\frac{6}{{b}^{3}}\\
\end{array}
\end{array}
if b < -860Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub100.0%
*-lft-identity100.0%
associate-*l/100.0%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
div-exp100.0%
+-commutative100.0%
metadata-eval100.0%
sub-neg100.0%
add-exp-log100.0%
rec-exp100.0%
sub-neg100.0%
metadata-eval100.0%
+-commutative100.0%
log1p-define100.0%
div-exp100.0%
Applied egg-rr100.0%
Taylor expanded in a around 0 100.0%
log1p-define100.0%
Simplified100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
sqr-neg100.0%
sqrt-unprod100.0%
add-sqr-sqrt100.0%
log1p-undefine100.0%
rem-exp-log100.0%
+-commutative100.0%
Applied egg-rr100.0%
if -860 < b < 1.95e96Initial program 98.1%
*-lft-identity98.1%
associate-*l/98.1%
associate-/r/98.1%
+-commutative98.1%
remove-double-neg98.1%
sub-neg98.1%
div-sub63.5%
neg-mul-163.5%
*-commutative63.5%
associate-*r/63.5%
metadata-eval63.5%
distribute-neg-frac63.5%
exp-neg63.5%
distribute-rgt-neg-out63.5%
exp-neg63.5%
rgt-mult-inverse99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in b around 0 89.9%
Taylor expanded in a around 0 75.6%
if 1.95e96 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
div-sub64.3%
neg-mul-164.3%
*-commutative64.3%
associate-*r/64.3%
metadata-eval64.3%
distribute-neg-frac64.3%
exp-neg64.3%
distribute-rgt-neg-out64.3%
exp-neg64.3%
rgt-mult-inverse100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 97.9%
*-commutative97.9%
Simplified97.9%
Taylor expanded in b around inf 97.9%
Final simplification84.2%
(FPCore (a b) :precision binary64 (if (<= a -114.0) (/ 1.0 (- (exp (- a)) -1.0)) (/ 1.0 (- (exp b) -1.0))))
double code(double a, double b) {
double tmp;
if (a <= -114.0) {
tmp = 1.0 / (exp(-a) - -1.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
real(8) :: tmp
if (a <= (-114.0d0)) then
tmp = 1.0d0 / (exp(-a) - (-1.0d0))
else
tmp = 1.0d0 / (exp(b) - (-1.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -114.0) {
tmp = 1.0 / (Math.exp(-a) - -1.0);
} else {
tmp = 1.0 / (Math.exp(b) - -1.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -114.0: tmp = 1.0 / (math.exp(-a) - -1.0) else: tmp = 1.0 / (math.exp(b) - -1.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -114.0) tmp = Float64(1.0 / Float64(exp(Float64(-a)) - -1.0)); else tmp = Float64(1.0 / Float64(exp(b) - -1.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -114.0) tmp = 1.0 / (exp(-a) - -1.0); else tmp = 1.0 / (exp(b) - -1.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -114.0], N[(1.0 / N[(N[Exp[(-a)], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Exp[b], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -114:\\
\;\;\;\;\frac{1}{e^{-a} - -1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{e^{b} - -1}\\
\end{array}
\end{array}
if a < -114Initial program 98.6%
*-lft-identity98.6%
associate-*l/98.6%
associate-/r/98.6%
+-commutative98.6%
remove-double-neg98.6%
sub-neg98.6%
div-sub2.7%
neg-mul-12.7%
*-commutative2.7%
associate-*r/2.7%
metadata-eval2.7%
distribute-neg-frac2.7%
exp-neg2.7%
distribute-rgt-neg-out2.7%
exp-neg2.7%
rgt-mult-inverse98.6%
metadata-eval98.6%
Simplified98.6%
Taylor expanded in b around 0 100.0%
rec-exp100.0%
Simplified100.0%
if -114 < a Initial program 98.8%
*-lft-identity98.8%
associate-*l/98.8%
associate-/r/98.8%
+-commutative98.8%
remove-double-neg98.8%
sub-neg98.8%
div-sub98.8%
neg-mul-198.8%
*-commutative98.8%
associate-*r/98.8%
metadata-eval98.8%
distribute-neg-frac98.8%
exp-neg98.8%
distribute-rgt-neg-out98.8%
exp-neg98.8%
rgt-mult-inverse99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in a around 0 97.9%
Final simplification98.5%
(FPCore (a b) :precision binary64 (if (<= a -475000000.0) (/ (exp a) a) (/ 1.0 (- (exp b) -1.0))))
double code(double a, double b) {
double tmp;
if (a <= -475000000.0) {
tmp = exp(a) / a;
} 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
real(8) :: tmp
if (a <= (-475000000.0d0)) then
tmp = exp(a) / a
else
tmp = 1.0d0 / (exp(b) - (-1.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -475000000.0) {
tmp = Math.exp(a) / a;
} else {
tmp = 1.0 / (Math.exp(b) - -1.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -475000000.0: tmp = math.exp(a) / a else: tmp = 1.0 / (math.exp(b) - -1.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -475000000.0) tmp = Float64(exp(a) / a); else tmp = Float64(1.0 / Float64(exp(b) - -1.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -475000000.0) tmp = exp(a) / a; else tmp = 1.0 / (exp(b) - -1.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -475000000.0], N[(N[Exp[a], $MachinePrecision] / a), $MachinePrecision], N[(1.0 / N[(N[Exp[b], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -475000000:\\
\;\;\;\;\frac{e^{a}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{e^{b} - -1}\\
\end{array}
\end{array}
if a < -4.75e8Initial program 98.6%
Taylor expanded in b around 0 100.0%
Taylor expanded in a around 0 100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in a around inf 100.0%
if -4.75e8 < a Initial program 98.9%
*-lft-identity98.9%
associate-*l/98.9%
associate-/r/98.9%
+-commutative98.9%
remove-double-neg98.9%
sub-neg98.9%
div-sub98.3%
neg-mul-198.3%
*-commutative98.3%
associate-*r/98.3%
metadata-eval98.3%
distribute-neg-frac98.3%
exp-neg98.3%
distribute-rgt-neg-out98.3%
exp-neg98.3%
rgt-mult-inverse99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in a around 0 96.9%
Final simplification97.8%
(FPCore (a b)
:precision binary64
(if (<= b -860.0)
(+ 1.0 (exp b))
(if (<= b 1.3e+98)
(/
1.0
(- (+ 1.0 (* a (+ -1.0 (* a (+ 0.5 (* a -0.16666666666666666)))))) -1.0))
(/ 1.0 (+ 2.0 (* b (+ 1.0 (* b (+ 0.5 (* b 0.16666666666666666))))))))))
double code(double a, double b) {
double tmp;
if (b <= -860.0) {
tmp = 1.0 + exp(b);
} else if (b <= 1.3e+98) {
tmp = 1.0 / ((1.0 + (a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666)))))) - -1.0);
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666))))));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= (-860.0d0)) then
tmp = 1.0d0 + exp(b)
else if (b <= 1.3d+98) then
tmp = 1.0d0 / ((1.0d0 + (a * ((-1.0d0) + (a * (0.5d0 + (a * (-0.16666666666666666d0))))))) - (-1.0d0))
else
tmp = 1.0d0 / (2.0d0 + (b * (1.0d0 + (b * (0.5d0 + (b * 0.16666666666666666d0))))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= -860.0) {
tmp = 1.0 + Math.exp(b);
} else if (b <= 1.3e+98) {
tmp = 1.0 / ((1.0 + (a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666)))))) - -1.0);
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666))))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -860.0: tmp = 1.0 + math.exp(b) elif b <= 1.3e+98: tmp = 1.0 / ((1.0 + (a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666)))))) - -1.0) else: tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666)))))) return tmp
function code(a, b) tmp = 0.0 if (b <= -860.0) tmp = Float64(1.0 + exp(b)); elseif (b <= 1.3e+98) tmp = Float64(1.0 / Float64(Float64(1.0 + Float64(a * Float64(-1.0 + Float64(a * Float64(0.5 + Float64(a * -0.16666666666666666)))))) - -1.0)); else tmp = Float64(1.0 / Float64(2.0 + Float64(b * Float64(1.0 + Float64(b * Float64(0.5 + Float64(b * 0.16666666666666666))))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= -860.0) tmp = 1.0 + exp(b); elseif (b <= 1.3e+98) tmp = 1.0 / ((1.0 + (a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666)))))) - -1.0); else tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -860.0], N[(1.0 + N[Exp[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.3e+98], N[(1.0 / N[(N[(1.0 + N[(a * N[(-1.0 + N[(a * N[(0.5 + N[(a * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(2.0 + N[(b * N[(1.0 + N[(b * N[(0.5 + N[(b * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -860:\\
\;\;\;\;1 + e^{b}\\
\mathbf{elif}\;b \leq 1.3 \cdot 10^{+98}:\\
\;\;\;\;\frac{1}{\left(1 + a \cdot \left(-1 + a \cdot \left(0.5 + a \cdot -0.16666666666666666\right)\right)\right) - -1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + b \cdot \left(1 + b \cdot \left(0.5 + b \cdot 0.16666666666666666\right)\right)}\\
\end{array}
\end{array}
if b < -860Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub100.0%
*-lft-identity100.0%
associate-*l/100.0%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
div-exp100.0%
+-commutative100.0%
metadata-eval100.0%
sub-neg100.0%
add-exp-log100.0%
rec-exp100.0%
sub-neg100.0%
metadata-eval100.0%
+-commutative100.0%
log1p-define100.0%
div-exp100.0%
Applied egg-rr100.0%
Taylor expanded in a around 0 100.0%
log1p-define100.0%
Simplified100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
sqr-neg100.0%
sqrt-unprod100.0%
add-sqr-sqrt100.0%
log1p-undefine100.0%
rem-exp-log100.0%
+-commutative100.0%
Applied egg-rr100.0%
if -860 < b < 1.3e98Initial program 98.1%
*-lft-identity98.1%
associate-*l/98.1%
associate-/r/98.1%
+-commutative98.1%
remove-double-neg98.1%
sub-neg98.1%
div-sub63.5%
neg-mul-163.5%
*-commutative63.5%
associate-*r/63.5%
metadata-eval63.5%
distribute-neg-frac63.5%
exp-neg63.5%
distribute-rgt-neg-out63.5%
exp-neg63.5%
rgt-mult-inverse99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in b around 0 89.9%
Taylor expanded in a around 0 75.6%
if 1.3e98 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
div-sub64.3%
neg-mul-164.3%
*-commutative64.3%
associate-*r/64.3%
metadata-eval64.3%
distribute-neg-frac64.3%
exp-neg64.3%
distribute-rgt-neg-out64.3%
exp-neg64.3%
rgt-mult-inverse100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 97.9%
*-commutative97.9%
Simplified97.9%
Final simplification84.2%
(FPCore (a b) :precision binary64 (/ 1.0 (+ (exp (- b a)) 1.0)))
double code(double a, double b) {
return 1.0 / (exp((b - a)) + 1.0);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 1.0d0 / (exp((b - a)) + 1.0d0)
end function
public static double code(double a, double b) {
return 1.0 / (Math.exp((b - a)) + 1.0);
}
def code(a, b): return 1.0 / (math.exp((b - a)) + 1.0)
function code(a, b) return Float64(1.0 / Float64(exp(Float64(b - a)) + 1.0)) end
function tmp = code(a, b) tmp = 1.0 / (exp((b - a)) + 1.0); end
code[a_, b_] := N[(1.0 / N[(N[Exp[N[(b - a), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{e^{b - a} + 1}
\end{array}
Initial program 98.8%
*-lft-identity98.8%
associate-*l/98.8%
associate-/r/98.8%
remove-double-neg98.8%
unsub-neg98.8%
div-sub71.1%
*-lft-identity71.1%
associate-*l/71.1%
lft-mult-inverse99.6%
sub-neg99.6%
distribute-frac-neg99.6%
remove-double-neg99.6%
div-exp100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (a b)
:precision binary64
(if (<= b 6.5e+99)
(/
1.0
(- (+ 1.0 (* a (+ -1.0 (* a (+ 0.5 (* a -0.16666666666666666)))))) -1.0))
(/ 1.0 (+ 2.0 (* b (+ 1.0 (* b (+ 0.5 (* b 0.16666666666666666)))))))))
double code(double a, double b) {
double tmp;
if (b <= 6.5e+99) {
tmp = 1.0 / ((1.0 + (a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666)))))) - -1.0);
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666))))));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 6.5d+99) then
tmp = 1.0d0 / ((1.0d0 + (a * ((-1.0d0) + (a * (0.5d0 + (a * (-0.16666666666666666d0))))))) - (-1.0d0))
else
tmp = 1.0d0 / (2.0d0 + (b * (1.0d0 + (b * (0.5d0 + (b * 0.16666666666666666d0))))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 6.5e+99) {
tmp = 1.0 / ((1.0 + (a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666)))))) - -1.0);
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666))))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 6.5e+99: tmp = 1.0 / ((1.0 + (a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666)))))) - -1.0) else: tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666)))))) return tmp
function code(a, b) tmp = 0.0 if (b <= 6.5e+99) tmp = Float64(1.0 / Float64(Float64(1.0 + Float64(a * Float64(-1.0 + Float64(a * Float64(0.5 + Float64(a * -0.16666666666666666)))))) - -1.0)); else tmp = Float64(1.0 / Float64(2.0 + Float64(b * Float64(1.0 + Float64(b * Float64(0.5 + Float64(b * 0.16666666666666666))))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 6.5e+99) tmp = 1.0 / ((1.0 + (a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666)))))) - -1.0); else tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 6.5e+99], N[(1.0 / N[(N[(1.0 + N[(a * N[(-1.0 + N[(a * N[(0.5 + N[(a * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(2.0 + N[(b * N[(1.0 + N[(b * N[(0.5 + N[(b * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.5 \cdot 10^{+99}:\\
\;\;\;\;\frac{1}{\left(1 + a \cdot \left(-1 + a \cdot \left(0.5 + a \cdot -0.16666666666666666\right)\right)\right) - -1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + b \cdot \left(1 + b \cdot \left(0.5 + b \cdot 0.16666666666666666\right)\right)}\\
\end{array}
\end{array}
if b < 6.5000000000000004e99Initial program 98.6%
*-lft-identity98.6%
associate-*l/98.5%
associate-/r/98.5%
+-commutative98.5%
remove-double-neg98.5%
sub-neg98.5%
div-sub72.4%
neg-mul-172.4%
*-commutative72.4%
associate-*r/72.4%
metadata-eval72.4%
distribute-neg-frac72.4%
exp-neg72.4%
distribute-rgt-neg-out72.4%
exp-neg72.4%
rgt-mult-inverse99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in b around 0 72.6%
Taylor expanded in a around 0 61.8%
if 6.5000000000000004e99 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
div-sub64.3%
neg-mul-164.3%
*-commutative64.3%
associate-*r/64.3%
metadata-eval64.3%
distribute-neg-frac64.3%
exp-neg64.3%
distribute-rgt-neg-out64.3%
exp-neg64.3%
rgt-mult-inverse100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 97.9%
*-commutative97.9%
Simplified97.9%
Final simplification67.7%
(FPCore (a b) :precision binary64 (if (<= b 6.5e+145) (/ 1.0 (+ (* a (+ -1.0 (* a (+ 0.5 (* a -0.16666666666666666))))) 2.0)) (/ 1.0 (+ 2.0 (* b (+ 1.0 (* b 0.5)))))))
double code(double a, double b) {
double tmp;
if (b <= 6.5e+145) {
tmp = 1.0 / ((a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666))))) + 2.0);
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * 0.5))));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 6.5d+145) then
tmp = 1.0d0 / ((a * ((-1.0d0) + (a * (0.5d0 + (a * (-0.16666666666666666d0)))))) + 2.0d0)
else
tmp = 1.0d0 / (2.0d0 + (b * (1.0d0 + (b * 0.5d0))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 6.5e+145) {
tmp = 1.0 / ((a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666))))) + 2.0);
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * 0.5))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 6.5e+145: tmp = 1.0 / ((a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666))))) + 2.0) else: tmp = 1.0 / (2.0 + (b * (1.0 + (b * 0.5)))) return tmp
function code(a, b) tmp = 0.0 if (b <= 6.5e+145) tmp = Float64(1.0 / Float64(Float64(a * Float64(-1.0 + Float64(a * Float64(0.5 + Float64(a * -0.16666666666666666))))) + 2.0)); else tmp = Float64(1.0 / Float64(2.0 + Float64(b * Float64(1.0 + Float64(b * 0.5))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 6.5e+145) tmp = 1.0 / ((a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666))))) + 2.0); else tmp = 1.0 / (2.0 + (b * (1.0 + (b * 0.5)))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 6.5e+145], N[(1.0 / N[(N[(a * N[(-1.0 + N[(a * N[(0.5 + N[(a * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(2.0 + N[(b * N[(1.0 + N[(b * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.5 \cdot 10^{+145}:\\
\;\;\;\;\frac{1}{a \cdot \left(-1 + a \cdot \left(0.5 + a \cdot -0.16666666666666666\right)\right) + 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + b \cdot \left(1 + b \cdot 0.5\right)}\\
\end{array}
\end{array}
if b < 6.50000000000000034e145Initial program 98.6%
*-lft-identity98.6%
associate-*l/98.6%
associate-/r/98.6%
+-commutative98.6%
remove-double-neg98.6%
sub-neg98.6%
div-sub72.2%
neg-mul-172.2%
*-commutative72.2%
associate-*r/72.1%
metadata-eval72.1%
distribute-neg-frac72.1%
exp-neg72.1%
distribute-rgt-neg-out72.1%
exp-neg72.1%
rgt-mult-inverse99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in b around 0 71.1%
rec-exp71.1%
Simplified71.1%
Taylor expanded in a around 0 60.7%
if 6.50000000000000034e145 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
div-sub63.6%
neg-mul-163.6%
*-commutative63.6%
associate-*r/63.6%
metadata-eval63.6%
distribute-neg-frac63.6%
exp-neg63.6%
distribute-rgt-neg-out63.6%
exp-neg63.6%
rgt-mult-inverse100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 91.8%
*-commutative91.8%
Simplified91.8%
Final simplification64.7%
(FPCore (a b) :precision binary64 (if (<= b 2.5e+96) (/ 1.0 (+ (* a (+ -1.0 (* a (+ 0.5 (* a -0.16666666666666666))))) 2.0)) (/ 1.0 (+ 2.0 (* b (+ 1.0 (* b (+ 0.5 (* b 0.16666666666666666)))))))))
double code(double a, double b) {
double tmp;
if (b <= 2.5e+96) {
tmp = 1.0 / ((a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666))))) + 2.0);
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666))))));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 2.5d+96) then
tmp = 1.0d0 / ((a * ((-1.0d0) + (a * (0.5d0 + (a * (-0.16666666666666666d0)))))) + 2.0d0)
else
tmp = 1.0d0 / (2.0d0 + (b * (1.0d0 + (b * (0.5d0 + (b * 0.16666666666666666d0))))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 2.5e+96) {
tmp = 1.0 / ((a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666))))) + 2.0);
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666))))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 2.5e+96: tmp = 1.0 / ((a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666))))) + 2.0) else: tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666)))))) return tmp
function code(a, b) tmp = 0.0 if (b <= 2.5e+96) tmp = Float64(1.0 / Float64(Float64(a * Float64(-1.0 + Float64(a * Float64(0.5 + Float64(a * -0.16666666666666666))))) + 2.0)); else tmp = Float64(1.0 / Float64(2.0 + Float64(b * Float64(1.0 + Float64(b * Float64(0.5 + Float64(b * 0.16666666666666666))))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 2.5e+96) tmp = 1.0 / ((a * (-1.0 + (a * (0.5 + (a * -0.16666666666666666))))) + 2.0); else tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 2.5e+96], N[(1.0 / N[(N[(a * N[(-1.0 + N[(a * N[(0.5 + N[(a * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(2.0 + N[(b * N[(1.0 + N[(b * N[(0.5 + N[(b * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.5 \cdot 10^{+96}:\\
\;\;\;\;\frac{1}{a \cdot \left(-1 + a \cdot \left(0.5 + a \cdot -0.16666666666666666\right)\right) + 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + b \cdot \left(1 + b \cdot \left(0.5 + b \cdot 0.16666666666666666\right)\right)}\\
\end{array}
\end{array}
if b < 2.5000000000000002e96Initial program 98.6%
*-lft-identity98.6%
associate-*l/98.5%
associate-/r/98.5%
+-commutative98.5%
remove-double-neg98.5%
sub-neg98.5%
div-sub72.4%
neg-mul-172.4%
*-commutative72.4%
associate-*r/72.4%
metadata-eval72.4%
distribute-neg-frac72.4%
exp-neg72.4%
distribute-rgt-neg-out72.4%
exp-neg72.4%
rgt-mult-inverse99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in b around 0 72.6%
rec-exp72.6%
Simplified72.6%
Taylor expanded in a around 0 61.8%
if 2.5000000000000002e96 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
div-sub64.3%
neg-mul-164.3%
*-commutative64.3%
associate-*r/64.3%
metadata-eval64.3%
distribute-neg-frac64.3%
exp-neg64.3%
distribute-rgt-neg-out64.3%
exp-neg64.3%
rgt-mult-inverse100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 97.9%
*-commutative97.9%
Simplified97.9%
Final simplification67.7%
(FPCore (a b) :precision binary64 (if (<= b 1.35e+129) (/ 1.0 (+ 2.0 (* a (+ -1.0 (* a 0.5))))) (/ 1.0 (+ 2.0 (* b (+ 1.0 (* b 0.5)))))))
double code(double a, double b) {
double tmp;
if (b <= 1.35e+129) {
tmp = 1.0 / (2.0 + (a * (-1.0 + (a * 0.5))));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * 0.5))));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 1.35d+129) then
tmp = 1.0d0 / (2.0d0 + (a * ((-1.0d0) + (a * 0.5d0))))
else
tmp = 1.0d0 / (2.0d0 + (b * (1.0d0 + (b * 0.5d0))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 1.35e+129) {
tmp = 1.0 / (2.0 + (a * (-1.0 + (a * 0.5))));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * 0.5))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 1.35e+129: tmp = 1.0 / (2.0 + (a * (-1.0 + (a * 0.5)))) else: tmp = 1.0 / (2.0 + (b * (1.0 + (b * 0.5)))) return tmp
function code(a, b) tmp = 0.0 if (b <= 1.35e+129) tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(-1.0 + Float64(a * 0.5))))); else tmp = Float64(1.0 / Float64(2.0 + Float64(b * Float64(1.0 + Float64(b * 0.5))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 1.35e+129) tmp = 1.0 / (2.0 + (a * (-1.0 + (a * 0.5)))); else tmp = 1.0 / (2.0 + (b * (1.0 + (b * 0.5)))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 1.35e+129], N[(1.0 / N[(2.0 + N[(a * N[(-1.0 + N[(a * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(2.0 + N[(b * N[(1.0 + N[(b * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.35 \cdot 10^{+129}:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(-1 + a \cdot 0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + b \cdot \left(1 + b \cdot 0.5\right)}\\
\end{array}
\end{array}
if b < 1.35e129Initial program 98.6%
*-lft-identity98.6%
associate-*l/98.6%
associate-/r/98.6%
+-commutative98.6%
remove-double-neg98.6%
sub-neg98.6%
div-sub72.0%
neg-mul-172.0%
*-commutative72.0%
associate-*r/72.0%
metadata-eval72.0%
distribute-neg-frac72.0%
exp-neg72.0%
distribute-rgt-neg-out72.0%
exp-neg72.0%
rgt-mult-inverse99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in b around 0 72.2%
rec-exp72.2%
Simplified72.2%
Taylor expanded in a around 0 57.8%
if 1.35e129 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
+-commutative100.0%
remove-double-neg100.0%
sub-neg100.0%
div-sub65.8%
neg-mul-165.8%
*-commutative65.8%
associate-*r/65.8%
metadata-eval65.8%
distribute-neg-frac65.8%
exp-neg65.8%
distribute-rgt-neg-out65.8%
exp-neg65.8%
rgt-mult-inverse100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 80.8%
*-commutative80.8%
Simplified80.8%
Final simplification61.2%
(FPCore (a b) :precision binary64 (/ 1.0 (+ 2.0 (* a (+ -1.0 (* a 0.5))))))
double code(double a, double b) {
return 1.0 / (2.0 + (a * (-1.0 + (a * 0.5))));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 1.0d0 / (2.0d0 + (a * ((-1.0d0) + (a * 0.5d0))))
end function
public static double code(double a, double b) {
return 1.0 / (2.0 + (a * (-1.0 + (a * 0.5))));
}
def code(a, b): return 1.0 / (2.0 + (a * (-1.0 + (a * 0.5))))
function code(a, b) return Float64(1.0 / Float64(2.0 + Float64(a * Float64(-1.0 + Float64(a * 0.5))))) end
function tmp = code(a, b) tmp = 1.0 / (2.0 + (a * (-1.0 + (a * 0.5)))); end
code[a_, b_] := N[(1.0 / N[(2.0 + N[(a * N[(-1.0 + N[(a * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{2 + a \cdot \left(-1 + a \cdot 0.5\right)}
\end{array}
Initial program 98.8%
*-lft-identity98.8%
associate-*l/98.8%
associate-/r/98.8%
+-commutative98.8%
remove-double-neg98.8%
sub-neg98.8%
div-sub71.1%
neg-mul-171.1%
*-commutative71.1%
associate-*r/71.1%
metadata-eval71.1%
distribute-neg-frac71.1%
exp-neg71.0%
distribute-rgt-neg-out71.0%
exp-neg71.1%
rgt-mult-inverse99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in b around 0 66.9%
rec-exp66.9%
Simplified66.9%
Taylor expanded in a around 0 52.4%
Final simplification52.4%
(FPCore (a b) :precision binary64 (/ 1.0 (- 2.0 a)))
double code(double a, double b) {
return 1.0 / (2.0 - a);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 1.0d0 / (2.0d0 - a)
end function
public static double code(double a, double b) {
return 1.0 / (2.0 - a);
}
def code(a, b): return 1.0 / (2.0 - a)
function code(a, b) return Float64(1.0 / Float64(2.0 - a)) end
function tmp = code(a, b) tmp = 1.0 / (2.0 - a); end
code[a_, b_] := N[(1.0 / N[(2.0 - a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{2 - a}
\end{array}
Initial program 98.8%
*-lft-identity98.8%
associate-*l/98.8%
associate-/r/98.8%
+-commutative98.8%
remove-double-neg98.8%
sub-neg98.8%
div-sub71.1%
neg-mul-171.1%
*-commutative71.1%
associate-*r/71.1%
metadata-eval71.1%
distribute-neg-frac71.1%
exp-neg71.0%
distribute-rgt-neg-out71.0%
exp-neg71.1%
rgt-mult-inverse99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in b around 0 66.9%
rec-exp66.9%
Simplified66.9%
Taylor expanded in a around 0 38.1%
neg-mul-138.1%
unsub-neg38.1%
Simplified38.1%
Final simplification38.1%
(FPCore (a b) :precision binary64 0.5)
double code(double a, double b) {
return 0.5;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 0.5d0
end function
public static double code(double a, double b) {
return 0.5;
}
def code(a, b): return 0.5
function code(a, b) return 0.5 end
function tmp = code(a, b) tmp = 0.5; end
code[a_, b_] := 0.5
\begin{array}{l}
\\
0.5
\end{array}
Initial program 98.8%
*-lft-identity98.8%
associate-*l/98.8%
associate-/r/98.8%
+-commutative98.8%
remove-double-neg98.8%
sub-neg98.8%
div-sub71.1%
neg-mul-171.1%
*-commutative71.1%
associate-*r/71.1%
metadata-eval71.1%
distribute-neg-frac71.1%
exp-neg71.0%
distribute-rgt-neg-out71.0%
exp-neg71.1%
rgt-mult-inverse99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in a around 0 81.1%
Taylor expanded in b around 0 37.4%
Final simplification37.4%
(FPCore (a b) :precision binary64 (/ 1.0 (+ 1.0 (exp (- b a)))))
double code(double a, double b) {
return 1.0 / (1.0 + exp((b - a)));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 1.0d0 / (1.0d0 + exp((b - a)))
end function
public static double code(double a, double b) {
return 1.0 / (1.0 + Math.exp((b - a)));
}
def code(a, b): return 1.0 / (1.0 + math.exp((b - a)))
function code(a, b) return Float64(1.0 / Float64(1.0 + exp(Float64(b - a)))) end
function tmp = code(a, b) tmp = 1.0 / (1.0 + exp((b - a))); end
code[a_, b_] := N[(1.0 / N[(1.0 + N[Exp[N[(b - a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{1 + e^{b - a}}
\end{array}
herbie shell --seed 2024077
(FPCore (a b)
:name "Quotient of sum of exps"
:precision binary64
:alt
(/ 1.0 (+ 1.0 (exp (- b a))))
(/ (exp a) (+ (exp a) (exp b))))