
(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 18 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 99.6%
*-lft-identity99.6%
associate-*l/99.6%
associate-/r/99.6%
remove-double-neg99.6%
unsub-neg99.6%
div-sub76.1%
*-lft-identity76.1%
associate-*l/76.1%
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%
(FPCore (a b) :precision binary64 (if (<= a -4e-11) (/ 1.0 (+ 1.0 (exp (- a)))) (/ 1.0 (+ 1.0 (exp b)))))
double code(double a, double b) {
double tmp;
if (a <= -4e-11) {
tmp = 1.0 / (1.0 + exp(-a));
} else {
tmp = 1.0 / (1.0 + exp(b));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-4d-11)) then
tmp = 1.0d0 / (1.0d0 + exp(-a))
else
tmp = 1.0d0 / (1.0d0 + exp(b))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -4e-11) {
tmp = 1.0 / (1.0 + Math.exp(-a));
} else {
tmp = 1.0 / (1.0 + Math.exp(b));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -4e-11: tmp = 1.0 / (1.0 + math.exp(-a)) else: tmp = 1.0 / (1.0 + math.exp(b)) return tmp
function code(a, b) tmp = 0.0 if (a <= -4e-11) tmp = Float64(1.0 / Float64(1.0 + exp(Float64(-a)))); else tmp = Float64(1.0 / Float64(1.0 + exp(b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -4e-11) tmp = 1.0 / (1.0 + exp(-a)); else tmp = 1.0 / (1.0 + exp(b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -4e-11], N[(1.0 / N[(1.0 + N[Exp[(-a)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4 \cdot 10^{-11}:\\
\;\;\;\;\frac{1}{1 + e^{-a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + e^{b}}\\
\end{array}
\end{array}
if a < -3.99999999999999976e-11Initial program 100.0%
*-lft-identity100.0%
associate-*l/99.9%
associate-/r/99.9%
remove-double-neg99.9%
unsub-neg99.9%
div-sub10.4%
*-lft-identity10.4%
associate-*l/10.4%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp99.9%
Simplified99.9%
Taylor expanded in b around 0 97.4%
if -3.99999999999999976e-11 < a Initial program 99.4%
*-lft-identity99.4%
associate-*l/99.4%
associate-/r/99.4%
remove-double-neg99.4%
unsub-neg99.4%
div-sub99.4%
*-lft-identity99.4%
associate-*l/99.4%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in a around 0 99.0%
(FPCore (a b) :precision binary64 (if (<= a -5.5e+90) (/ 1.0 (+ 2.0 (* a (+ (* a (* a -0.16666666666666666)) -1.0)))) (/ 1.0 (+ 1.0 (exp b)))))
double code(double a, double b) {
double tmp;
if (a <= -5.5e+90) {
tmp = 1.0 / (2.0 + (a * ((a * (a * -0.16666666666666666)) + -1.0)));
} else {
tmp = 1.0 / (1.0 + exp(b));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-5.5d+90)) then
tmp = 1.0d0 / (2.0d0 + (a * ((a * (a * (-0.16666666666666666d0))) + (-1.0d0))))
else
tmp = 1.0d0 / (1.0d0 + exp(b))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -5.5e+90) {
tmp = 1.0 / (2.0 + (a * ((a * (a * -0.16666666666666666)) + -1.0)));
} else {
tmp = 1.0 / (1.0 + Math.exp(b));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -5.5e+90: tmp = 1.0 / (2.0 + (a * ((a * (a * -0.16666666666666666)) + -1.0))) else: tmp = 1.0 / (1.0 + math.exp(b)) return tmp
function code(a, b) tmp = 0.0 if (a <= -5.5e+90) tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(Float64(a * Float64(a * -0.16666666666666666)) + -1.0)))); else tmp = Float64(1.0 / Float64(1.0 + exp(b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -5.5e+90) tmp = 1.0 / (2.0 + (a * ((a * (a * -0.16666666666666666)) + -1.0))); else tmp = 1.0 / (1.0 + exp(b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -5.5e+90], N[(1.0 / N[(2.0 + N[(a * N[(N[(a * N[(a * -0.16666666666666666), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5.5 \cdot 10^{+90}:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(a \cdot \left(a \cdot -0.16666666666666666\right) + -1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + e^{b}}\\
\end{array}
\end{array}
if a < -5.49999999999999999e90Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub0.0%
*-lft-identity0.0%
associate-*l/0.0%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 100.0%
Taylor expanded in a around 0 98.0%
Taylor expanded in a around inf 98.0%
*-commutative98.0%
Simplified98.0%
if -5.49999999999999999e90 < a Initial program 99.5%
*-lft-identity99.5%
associate-*l/99.5%
associate-/r/99.5%
remove-double-neg99.5%
unsub-neg99.5%
div-sub92.4%
*-lft-identity92.4%
associate-*l/92.4%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp99.9%
Simplified99.9%
Taylor expanded in a around 0 92.2%
Final simplification93.2%
(FPCore (a b) :precision binary64 (/ 1.0 (+ 1.0 (/ 1.0 (exp (- a b))))))
double code(double a, double b) {
return 1.0 / (1.0 + (1.0 / exp((a - b))));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 1.0d0 / (1.0d0 + (1.0d0 / exp((a - b))))
end function
public static double code(double a, double b) {
return 1.0 / (1.0 + (1.0 / Math.exp((a - b))));
}
def code(a, b): return 1.0 / (1.0 + (1.0 / math.exp((a - b))))
function code(a, b) return Float64(1.0 / Float64(1.0 + Float64(1.0 / exp(Float64(a - b))))) end
function tmp = code(a, b) tmp = 1.0 / (1.0 + (1.0 / exp((a - b)))); end
code[a_, b_] := N[(1.0 / N[(1.0 + N[(1.0 / N[Exp[N[(a - b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{1 + \frac{1}{e^{a - b}}}
\end{array}
Initial program 99.6%
*-lft-identity99.6%
associate-*l/99.6%
associate-/r/99.6%
remove-double-neg99.6%
unsub-neg99.6%
div-sub76.1%
*-lft-identity76.1%
associate-*l/76.1%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
div-exp100.0%
clear-num100.0%
div-exp100.0%
Applied egg-rr100.0%
(FPCore (a b)
:precision binary64
(if (<= b -16.5)
(+ 1.0 (exp b))
(if (<= b 2e+99)
(/ 1.0 (+ 2.0 (* a (+ (* 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 <= -16.5) {
tmp = 1.0 + exp(b);
} else if (b <= 2e+99) {
tmp = 1.0 / (2.0 + (a * ((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 <= (-16.5d0)) then
tmp = 1.0d0 + exp(b)
else if (b <= 2d+99) then
tmp = 1.0d0 / (2.0d0 + (a * ((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 <= -16.5) {
tmp = 1.0 + Math.exp(b);
} else if (b <= 2e+99) {
tmp = 1.0 / (2.0 + (a * ((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 <= -16.5: tmp = 1.0 + math.exp(b) elif b <= 2e+99: tmp = 1.0 / (2.0 + (a * ((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 <= -16.5) tmp = Float64(1.0 + exp(b)); elseif (b <= 2e+99) tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(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 <= -16.5) tmp = 1.0 + exp(b); elseif (b <= 2e+99) tmp = 1.0 / (2.0 + (a * ((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, -16.5], N[(1.0 + N[Exp[b], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2e+99], N[(1.0 / N[(2.0 + N[(a * N[(N[(a * N[(0.5 + N[(a * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $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 -16.5:\\
\;\;\;\;1 + e^{b}\\
\mathbf{elif}\;b \leq 2 \cdot 10^{+99}:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(a \cdot \left(0.5 + a \cdot -0.16666666666666666\right) + -1\right)}\\
\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 < -16.5Initial 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%
Applied egg-rr100.0%
if -16.5 < b < 1.9999999999999999e99Initial program 99.4%
*-lft-identity99.4%
associate-*l/99.4%
associate-/r/99.4%
remove-double-neg99.4%
unsub-neg99.4%
div-sub71.2%
*-lft-identity71.2%
associate-*l/71.2%
lft-mult-inverse99.9%
sub-neg99.9%
distribute-frac-neg99.9%
remove-double-neg99.9%
div-exp99.9%
Simplified99.9%
Taylor expanded in b around 0 88.8%
Taylor expanded in a around 0 80.1%
if 1.9999999999999999e99 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub71.1%
*-lft-identity71.1%
associate-*l/71.1%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 97.7%
*-commutative97.7%
Simplified97.7%
Final simplification86.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 99.6%
*-lft-identity99.6%
associate-*l/99.6%
associate-/r/99.6%
remove-double-neg99.6%
unsub-neg99.6%
div-sub76.1%
*-lft-identity76.1%
associate-*l/76.1%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (a b)
:precision binary64
(if (<= b -170.0)
(/
1.0
(+
1.0
(/ 1.0 (+ 1.0 (* b (+ (* b (+ 0.5 (* b -0.16666666666666666))) -1.0))))))
(if (<= b 2e+98)
(/ 1.0 (+ 2.0 (* a (+ (* 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 <= -170.0) {
tmp = 1.0 / (1.0 + (1.0 / (1.0 + (b * ((b * (0.5 + (b * -0.16666666666666666))) + -1.0)))));
} else if (b <= 2e+98) {
tmp = 1.0 / (2.0 + (a * ((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 <= (-170.0d0)) then
tmp = 1.0d0 / (1.0d0 + (1.0d0 / (1.0d0 + (b * ((b * (0.5d0 + (b * (-0.16666666666666666d0)))) + (-1.0d0))))))
else if (b <= 2d+98) then
tmp = 1.0d0 / (2.0d0 + (a * ((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 <= -170.0) {
tmp = 1.0 / (1.0 + (1.0 / (1.0 + (b * ((b * (0.5 + (b * -0.16666666666666666))) + -1.0)))));
} else if (b <= 2e+98) {
tmp = 1.0 / (2.0 + (a * ((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 <= -170.0: tmp = 1.0 / (1.0 + (1.0 / (1.0 + (b * ((b * (0.5 + (b * -0.16666666666666666))) + -1.0))))) elif b <= 2e+98: tmp = 1.0 / (2.0 + (a * ((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 <= -170.0) tmp = Float64(1.0 / Float64(1.0 + Float64(1.0 / Float64(1.0 + Float64(b * Float64(Float64(b * Float64(0.5 + Float64(b * -0.16666666666666666))) + -1.0)))))); elseif (b <= 2e+98) tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(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 <= -170.0) tmp = 1.0 / (1.0 + (1.0 / (1.0 + (b * ((b * (0.5 + (b * -0.16666666666666666))) + -1.0))))); elseif (b <= 2e+98) tmp = 1.0 / (2.0 + (a * ((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, -170.0], N[(1.0 / N[(1.0 + N[(1.0 / N[(1.0 + N[(b * N[(N[(b * N[(0.5 + N[(b * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2e+98], N[(1.0 / N[(2.0 + N[(a * N[(N[(a * N[(0.5 + N[(a * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $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 -170:\\
\;\;\;\;\frac{1}{1 + \frac{1}{1 + b \cdot \left(b \cdot \left(0.5 + b \cdot -0.16666666666666666\right) + -1\right)}}\\
\mathbf{elif}\;b \leq 2 \cdot 10^{+98}:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(a \cdot \left(0.5 + a \cdot -0.16666666666666666\right) + -1\right)}\\
\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 < -170Initial 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%
clear-num100.0%
div-exp100.0%
Applied egg-rr100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 99.4%
if -170 < b < 2e98Initial program 99.4%
*-lft-identity99.4%
associate-*l/99.4%
associate-/r/99.4%
remove-double-neg99.4%
unsub-neg99.4%
div-sub71.2%
*-lft-identity71.2%
associate-*l/71.2%
lft-mult-inverse99.9%
sub-neg99.9%
distribute-frac-neg99.9%
remove-double-neg99.9%
div-exp99.9%
Simplified99.9%
Taylor expanded in b around 0 88.8%
Taylor expanded in a around 0 80.1%
if 2e98 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub71.1%
*-lft-identity71.1%
associate-*l/71.1%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 97.7%
*-commutative97.7%
Simplified97.7%
Final simplification86.1%
(FPCore (a b)
:precision binary64
(if (<= b -28.0)
(/ 1.0 (+ 1.0 (/ 1.0 (+ 1.0 (* b (+ (* b 0.5) -1.0))))))
(if (<= b 6.6e+96)
(/ 1.0 (+ 2.0 (* a (+ (* 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 <= -28.0) {
tmp = 1.0 / (1.0 + (1.0 / (1.0 + (b * ((b * 0.5) + -1.0)))));
} else if (b <= 6.6e+96) {
tmp = 1.0 / (2.0 + (a * ((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 <= (-28.0d0)) then
tmp = 1.0d0 / (1.0d0 + (1.0d0 / (1.0d0 + (b * ((b * 0.5d0) + (-1.0d0))))))
else if (b <= 6.6d+96) then
tmp = 1.0d0 / (2.0d0 + (a * ((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 <= -28.0) {
tmp = 1.0 / (1.0 + (1.0 / (1.0 + (b * ((b * 0.5) + -1.0)))));
} else if (b <= 6.6e+96) {
tmp = 1.0 / (2.0 + (a * ((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 <= -28.0: tmp = 1.0 / (1.0 + (1.0 / (1.0 + (b * ((b * 0.5) + -1.0))))) elif b <= 6.6e+96: tmp = 1.0 / (2.0 + (a * ((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 <= -28.0) tmp = Float64(1.0 / Float64(1.0 + Float64(1.0 / Float64(1.0 + Float64(b * Float64(Float64(b * 0.5) + -1.0)))))); elseif (b <= 6.6e+96) tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(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 <= -28.0) tmp = 1.0 / (1.0 + (1.0 / (1.0 + (b * ((b * 0.5) + -1.0))))); elseif (b <= 6.6e+96) tmp = 1.0 / (2.0 + (a * ((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, -28.0], N[(1.0 / N[(1.0 + N[(1.0 / N[(1.0 + N[(b * N[(N[(b * 0.5), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.6e+96], N[(1.0 / N[(2.0 + N[(a * N[(N[(a * N[(0.5 + N[(a * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $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 -28:\\
\;\;\;\;\frac{1}{1 + \frac{1}{1 + b \cdot \left(b \cdot 0.5 + -1\right)}}\\
\mathbf{elif}\;b \leq 6.6 \cdot 10^{+96}:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(a \cdot \left(0.5 + a \cdot -0.16666666666666666\right) + -1\right)}\\
\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 < -28Initial 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%
clear-num100.0%
div-exp100.0%
Applied egg-rr100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 99.0%
if -28 < b < 6.59999999999999969e96Initial program 99.4%
*-lft-identity99.4%
associate-*l/99.4%
associate-/r/99.4%
remove-double-neg99.4%
unsub-neg99.4%
div-sub71.2%
*-lft-identity71.2%
associate-*l/71.2%
lft-mult-inverse99.9%
sub-neg99.9%
distribute-frac-neg99.9%
remove-double-neg99.9%
div-exp99.9%
Simplified99.9%
Taylor expanded in b around 0 88.8%
Taylor expanded in a around 0 80.1%
if 6.59999999999999969e96 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub71.1%
*-lft-identity71.1%
associate-*l/71.1%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 97.7%
*-commutative97.7%
Simplified97.7%
Final simplification86.0%
(FPCore (a b)
:precision binary64
(if (<= b -62.0)
(/ 1.0 (+ 1.0 (/ 1.0 (+ 1.0 (* b (+ (* b 0.5) -1.0))))))
(if (<= b 1.15e+127)
(/ 1.0 (+ 2.0 (* a (+ (* a (+ 0.5 (* a -0.16666666666666666))) -1.0))))
(/ 1.0 (+ 2.0 (* b (+ 1.0 (* b 0.5))))))))
double code(double a, double b) {
double tmp;
if (b <= -62.0) {
tmp = 1.0 / (1.0 + (1.0 / (1.0 + (b * ((b * 0.5) + -1.0)))));
} else if (b <= 1.15e+127) {
tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * -0.16666666666666666))) + -1.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 <= (-62.0d0)) then
tmp = 1.0d0 / (1.0d0 + (1.0d0 / (1.0d0 + (b * ((b * 0.5d0) + (-1.0d0))))))
else if (b <= 1.15d+127) then
tmp = 1.0d0 / (2.0d0 + (a * ((a * (0.5d0 + (a * (-0.16666666666666666d0)))) + (-1.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 <= -62.0) {
tmp = 1.0 / (1.0 + (1.0 / (1.0 + (b * ((b * 0.5) + -1.0)))));
} else if (b <= 1.15e+127) {
tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * -0.16666666666666666))) + -1.0)));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * 0.5))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -62.0: tmp = 1.0 / (1.0 + (1.0 / (1.0 + (b * ((b * 0.5) + -1.0))))) elif b <= 1.15e+127: tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * -0.16666666666666666))) + -1.0))) else: tmp = 1.0 / (2.0 + (b * (1.0 + (b * 0.5)))) return tmp
function code(a, b) tmp = 0.0 if (b <= -62.0) tmp = Float64(1.0 / Float64(1.0 + Float64(1.0 / Float64(1.0 + Float64(b * Float64(Float64(b * 0.5) + -1.0)))))); elseif (b <= 1.15e+127) tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(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 * 0.5))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= -62.0) tmp = 1.0 / (1.0 + (1.0 / (1.0 + (b * ((b * 0.5) + -1.0))))); elseif (b <= 1.15e+127) tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * -0.16666666666666666))) + -1.0))); else tmp = 1.0 / (2.0 + (b * (1.0 + (b * 0.5)))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -62.0], N[(1.0 / N[(1.0 + N[(1.0 / N[(1.0 + N[(b * N[(N[(b * 0.5), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.15e+127], N[(1.0 / N[(2.0 + N[(a * N[(N[(a * N[(0.5 + N[(a * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $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 -62:\\
\;\;\;\;\frac{1}{1 + \frac{1}{1 + b \cdot \left(b \cdot 0.5 + -1\right)}}\\
\mathbf{elif}\;b \leq 1.15 \cdot 10^{+127}:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(a \cdot \left(0.5 + a \cdot -0.16666666666666666\right) + -1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + b \cdot \left(1 + b \cdot 0.5\right)}\\
\end{array}
\end{array}
if b < -62Initial 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%
clear-num100.0%
div-exp100.0%
Applied egg-rr100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 99.0%
if -62 < b < 1.1500000000000001e127Initial program 99.4%
*-lft-identity99.4%
associate-*l/99.4%
associate-/r/99.4%
remove-double-neg99.4%
unsub-neg99.4%
div-sub70.6%
*-lft-identity70.6%
associate-*l/70.6%
lft-mult-inverse99.9%
sub-neg99.9%
distribute-frac-neg99.9%
remove-double-neg99.9%
div-exp99.9%
Simplified99.9%
Taylor expanded in b around 0 88.5%
Taylor expanded in a around 0 79.9%
if 1.1500000000000001e127 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub74.3%
*-lft-identity74.3%
associate-*l/74.3%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 92.2%
*-commutative92.2%
Simplified92.2%
Final simplification84.9%
(FPCore (a b)
:precision binary64
(if (<= b -46.0)
(/ 1.0 (+ 1.0 (/ 1.0 (+ 1.0 (* b (+ (* b 0.5) -1.0))))))
(if (<= b 1.25e+127)
(/ 1.0 (+ 2.0 (* a (+ (* a (* a -0.16666666666666666)) -1.0))))
(/ 1.0 (+ 2.0 (* b (+ 1.0 (* b 0.5))))))))
double code(double a, double b) {
double tmp;
if (b <= -46.0) {
tmp = 1.0 / (1.0 + (1.0 / (1.0 + (b * ((b * 0.5) + -1.0)))));
} else if (b <= 1.25e+127) {
tmp = 1.0 / (2.0 + (a * ((a * (a * -0.16666666666666666)) + -1.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 <= (-46.0d0)) then
tmp = 1.0d0 / (1.0d0 + (1.0d0 / (1.0d0 + (b * ((b * 0.5d0) + (-1.0d0))))))
else if (b <= 1.25d+127) then
tmp = 1.0d0 / (2.0d0 + (a * ((a * (a * (-0.16666666666666666d0))) + (-1.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 <= -46.0) {
tmp = 1.0 / (1.0 + (1.0 / (1.0 + (b * ((b * 0.5) + -1.0)))));
} else if (b <= 1.25e+127) {
tmp = 1.0 / (2.0 + (a * ((a * (a * -0.16666666666666666)) + -1.0)));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * 0.5))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -46.0: tmp = 1.0 / (1.0 + (1.0 / (1.0 + (b * ((b * 0.5) + -1.0))))) elif b <= 1.25e+127: tmp = 1.0 / (2.0 + (a * ((a * (a * -0.16666666666666666)) + -1.0))) else: tmp = 1.0 / (2.0 + (b * (1.0 + (b * 0.5)))) return tmp
function code(a, b) tmp = 0.0 if (b <= -46.0) tmp = Float64(1.0 / Float64(1.0 + Float64(1.0 / Float64(1.0 + Float64(b * Float64(Float64(b * 0.5) + -1.0)))))); elseif (b <= 1.25e+127) tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(Float64(a * Float64(a * -0.16666666666666666)) + -1.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 <= -46.0) tmp = 1.0 / (1.0 + (1.0 / (1.0 + (b * ((b * 0.5) + -1.0))))); elseif (b <= 1.25e+127) tmp = 1.0 / (2.0 + (a * ((a * (a * -0.16666666666666666)) + -1.0))); else tmp = 1.0 / (2.0 + (b * (1.0 + (b * 0.5)))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -46.0], N[(1.0 / N[(1.0 + N[(1.0 / N[(1.0 + N[(b * N[(N[(b * 0.5), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.25e+127], N[(1.0 / N[(2.0 + N[(a * N[(N[(a * N[(a * -0.16666666666666666), $MachinePrecision]), $MachinePrecision] + -1.0), $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 -46:\\
\;\;\;\;\frac{1}{1 + \frac{1}{1 + b \cdot \left(b \cdot 0.5 + -1\right)}}\\
\mathbf{elif}\;b \leq 1.25 \cdot 10^{+127}:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(a \cdot \left(a \cdot -0.16666666666666666\right) + -1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + b \cdot \left(1 + b \cdot 0.5\right)}\\
\end{array}
\end{array}
if b < -46Initial 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%
clear-num100.0%
div-exp100.0%
Applied egg-rr100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 99.0%
if -46 < b < 1.2500000000000001e127Initial program 99.4%
*-lft-identity99.4%
associate-*l/99.4%
associate-/r/99.4%
remove-double-neg99.4%
unsub-neg99.4%
div-sub70.6%
*-lft-identity70.6%
associate-*l/70.6%
lft-mult-inverse99.9%
sub-neg99.9%
distribute-frac-neg99.9%
remove-double-neg99.9%
div-exp99.9%
Simplified99.9%
Taylor expanded in b around 0 88.5%
Taylor expanded in a around 0 79.9%
Taylor expanded in a around inf 79.5%
*-commutative79.5%
Simplified79.5%
if 1.2500000000000001e127 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub74.3%
*-lft-identity74.3%
associate-*l/74.3%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 92.2%
*-commutative92.2%
Simplified92.2%
Final simplification84.6%
(FPCore (a b)
:precision binary64
(if (<= b -3900.0)
(/ 1.0 (+ 1.0 (/ 1.0 (- 1.0 b))))
(if (<= b 7.6e+120)
(/ 1.0 (+ 2.0 (* a (+ (* a (* a -0.16666666666666666)) -1.0))))
(/ 1.0 (+ 2.0 (* b (+ 1.0 (* b 0.5))))))))
double code(double a, double b) {
double tmp;
if (b <= -3900.0) {
tmp = 1.0 / (1.0 + (1.0 / (1.0 - b)));
} else if (b <= 7.6e+120) {
tmp = 1.0 / (2.0 + (a * ((a * (a * -0.16666666666666666)) + -1.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 <= (-3900.0d0)) then
tmp = 1.0d0 / (1.0d0 + (1.0d0 / (1.0d0 - b)))
else if (b <= 7.6d+120) then
tmp = 1.0d0 / (2.0d0 + (a * ((a * (a * (-0.16666666666666666d0))) + (-1.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 <= -3900.0) {
tmp = 1.0 / (1.0 + (1.0 / (1.0 - b)));
} else if (b <= 7.6e+120) {
tmp = 1.0 / (2.0 + (a * ((a * (a * -0.16666666666666666)) + -1.0)));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * 0.5))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -3900.0: tmp = 1.0 / (1.0 + (1.0 / (1.0 - b))) elif b <= 7.6e+120: tmp = 1.0 / (2.0 + (a * ((a * (a * -0.16666666666666666)) + -1.0))) else: tmp = 1.0 / (2.0 + (b * (1.0 + (b * 0.5)))) return tmp
function code(a, b) tmp = 0.0 if (b <= -3900.0) tmp = Float64(1.0 / Float64(1.0 + Float64(1.0 / Float64(1.0 - b)))); elseif (b <= 7.6e+120) tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(Float64(a * Float64(a * -0.16666666666666666)) + -1.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 <= -3900.0) tmp = 1.0 / (1.0 + (1.0 / (1.0 - b))); elseif (b <= 7.6e+120) tmp = 1.0 / (2.0 + (a * ((a * (a * -0.16666666666666666)) + -1.0))); else tmp = 1.0 / (2.0 + (b * (1.0 + (b * 0.5)))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -3900.0], N[(1.0 / N[(1.0 + N[(1.0 / N[(1.0 - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.6e+120], N[(1.0 / N[(2.0 + N[(a * N[(N[(a * N[(a * -0.16666666666666666), $MachinePrecision]), $MachinePrecision] + -1.0), $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 -3900:\\
\;\;\;\;\frac{1}{1 + \frac{1}{1 - b}}\\
\mathbf{elif}\;b \leq 7.6 \cdot 10^{+120}:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(a \cdot \left(a \cdot -0.16666666666666666\right) + -1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + b \cdot \left(1 + b \cdot 0.5\right)}\\
\end{array}
\end{array}
if b < -3900Initial 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%
clear-num100.0%
div-exp100.0%
Applied egg-rr100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 98.6%
mul-1-neg98.6%
unsub-neg98.6%
Simplified98.6%
if -3900 < b < 7.5999999999999995e120Initial program 99.4%
*-lft-identity99.4%
associate-*l/99.4%
associate-/r/99.4%
remove-double-neg99.4%
unsub-neg99.4%
div-sub70.6%
*-lft-identity70.6%
associate-*l/70.6%
lft-mult-inverse99.9%
sub-neg99.9%
distribute-frac-neg99.9%
remove-double-neg99.9%
div-exp99.9%
Simplified99.9%
Taylor expanded in b around 0 88.5%
Taylor expanded in a around 0 79.9%
Taylor expanded in a around inf 79.5%
*-commutative79.5%
Simplified79.5%
if 7.5999999999999995e120 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub74.3%
*-lft-identity74.3%
associate-*l/74.3%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 92.2%
*-commutative92.2%
Simplified92.2%
Final simplification84.5%
(FPCore (a b)
:precision binary64
(if (<= b -62.0)
(/ 1.0 (+ 1.0 (/ 1.0 (- 1.0 b))))
(if (<= b 8e+126)
(/ 1.0 (+ 2.0 (* a (+ (* a 0.5) -1.0))))
(/ 1.0 (+ 2.0 (* b (+ 1.0 (* b 0.5))))))))
double code(double a, double b) {
double tmp;
if (b <= -62.0) {
tmp = 1.0 / (1.0 + (1.0 / (1.0 - b)));
} else if (b <= 8e+126) {
tmp = 1.0 / (2.0 + (a * ((a * 0.5) + -1.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 <= (-62.0d0)) then
tmp = 1.0d0 / (1.0d0 + (1.0d0 / (1.0d0 - b)))
else if (b <= 8d+126) then
tmp = 1.0d0 / (2.0d0 + (a * ((a * 0.5d0) + (-1.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 <= -62.0) {
tmp = 1.0 / (1.0 + (1.0 / (1.0 - b)));
} else if (b <= 8e+126) {
tmp = 1.0 / (2.0 + (a * ((a * 0.5) + -1.0)));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * 0.5))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -62.0: tmp = 1.0 / (1.0 + (1.0 / (1.0 - b))) elif b <= 8e+126: tmp = 1.0 / (2.0 + (a * ((a * 0.5) + -1.0))) else: tmp = 1.0 / (2.0 + (b * (1.0 + (b * 0.5)))) return tmp
function code(a, b) tmp = 0.0 if (b <= -62.0) tmp = Float64(1.0 / Float64(1.0 + Float64(1.0 / Float64(1.0 - b)))); elseif (b <= 8e+126) tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(Float64(a * 0.5) + -1.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 <= -62.0) tmp = 1.0 / (1.0 + (1.0 / (1.0 - b))); elseif (b <= 8e+126) tmp = 1.0 / (2.0 + (a * ((a * 0.5) + -1.0))); else tmp = 1.0 / (2.0 + (b * (1.0 + (b * 0.5)))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -62.0], N[(1.0 / N[(1.0 + N[(1.0 / N[(1.0 - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8e+126], N[(1.0 / N[(2.0 + N[(a * N[(N[(a * 0.5), $MachinePrecision] + -1.0), $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 -62:\\
\;\;\;\;\frac{1}{1 + \frac{1}{1 - b}}\\
\mathbf{elif}\;b \leq 8 \cdot 10^{+126}:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(a \cdot 0.5 + -1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + b \cdot \left(1 + b \cdot 0.5\right)}\\
\end{array}
\end{array}
if b < -62Initial 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%
clear-num100.0%
div-exp100.0%
Applied egg-rr100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 98.6%
mul-1-neg98.6%
unsub-neg98.6%
Simplified98.6%
if -62 < b < 7.9999999999999994e126Initial program 99.4%
*-lft-identity99.4%
associate-*l/99.4%
associate-/r/99.4%
remove-double-neg99.4%
unsub-neg99.4%
div-sub70.6%
*-lft-identity70.6%
associate-*l/70.6%
lft-mult-inverse99.9%
sub-neg99.9%
distribute-frac-neg99.9%
remove-double-neg99.9%
div-exp99.9%
Simplified99.9%
Taylor expanded in b around 0 88.5%
Taylor expanded in a around 0 74.0%
if 7.9999999999999994e126 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub74.3%
*-lft-identity74.3%
associate-*l/74.3%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 92.2%
*-commutative92.2%
Simplified92.2%
Final simplification80.8%
(FPCore (a b) :precision binary64 (if (<= b -2600.0) (/ 1.0 (+ 1.0 (/ 1.0 (- 1.0 b)))) (/ 1.0 (+ 2.0 (* a (+ (* a 0.5) -1.0))))))
double code(double a, double b) {
double tmp;
if (b <= -2600.0) {
tmp = 1.0 / (1.0 + (1.0 / (1.0 - b)));
} else {
tmp = 1.0 / (2.0 + (a * ((a * 0.5) + -1.0)));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= (-2600.0d0)) then
tmp = 1.0d0 / (1.0d0 + (1.0d0 / (1.0d0 - b)))
else
tmp = 1.0d0 / (2.0d0 + (a * ((a * 0.5d0) + (-1.0d0))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= -2600.0) {
tmp = 1.0 / (1.0 + (1.0 / (1.0 - b)));
} else {
tmp = 1.0 / (2.0 + (a * ((a * 0.5) + -1.0)));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -2600.0: tmp = 1.0 / (1.0 + (1.0 / (1.0 - b))) else: tmp = 1.0 / (2.0 + (a * ((a * 0.5) + -1.0))) return tmp
function code(a, b) tmp = 0.0 if (b <= -2600.0) tmp = Float64(1.0 / Float64(1.0 + Float64(1.0 / Float64(1.0 - b)))); else tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(Float64(a * 0.5) + -1.0)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= -2600.0) tmp = 1.0 / (1.0 + (1.0 / (1.0 - b))); else tmp = 1.0 / (2.0 + (a * ((a * 0.5) + -1.0))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -2600.0], N[(1.0 / N[(1.0 + N[(1.0 / N[(1.0 - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(2.0 + N[(a * N[(N[(a * 0.5), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2600:\\
\;\;\;\;\frac{1}{1 + \frac{1}{1 - b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(a \cdot 0.5 + -1\right)}\\
\end{array}
\end{array}
if b < -2600Initial 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%
clear-num100.0%
div-exp100.0%
Applied egg-rr100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 98.6%
mul-1-neg98.6%
unsub-neg98.6%
Simplified98.6%
if -2600 < b Initial program 99.5%
*-lft-identity99.5%
associate-*l/99.5%
associate-/r/99.5%
remove-double-neg99.5%
unsub-neg99.5%
div-sub71.2%
*-lft-identity71.2%
associate-*l/71.2%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp99.9%
Simplified99.9%
Taylor expanded in b around 0 78.5%
Taylor expanded in a around 0 63.8%
Final simplification69.8%
(FPCore (a b) :precision binary64 (if (<= a -2050.0) (/ (/ -2.0 a) a) (/ 1.0 (+ 1.0 (/ 1.0 (- 1.0 b))))))
double code(double a, double b) {
double tmp;
if (a <= -2050.0) {
tmp = (-2.0 / a) / a;
} else {
tmp = 1.0 / (1.0 + (1.0 / (1.0 - b)));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-2050.0d0)) then
tmp = ((-2.0d0) / a) / a
else
tmp = 1.0d0 / (1.0d0 + (1.0d0 / (1.0d0 - b)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -2050.0) {
tmp = (-2.0 / a) / a;
} else {
tmp = 1.0 / (1.0 + (1.0 / (1.0 - b)));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -2050.0: tmp = (-2.0 / a) / a else: tmp = 1.0 / (1.0 + (1.0 / (1.0 - b))) return tmp
function code(a, b) tmp = 0.0 if (a <= -2050.0) tmp = Float64(Float64(-2.0 / a) / a); else tmp = Float64(1.0 / Float64(1.0 + Float64(1.0 / Float64(1.0 - b)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -2050.0) tmp = (-2.0 / a) / a; else tmp = 1.0 / (1.0 + (1.0 / (1.0 - b))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -2050.0], N[(N[(-2.0 / a), $MachinePrecision] / a), $MachinePrecision], N[(1.0 / N[(1.0 + N[(1.0 / N[(1.0 - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2050:\\
\;\;\;\;\frac{\frac{-2}{a}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + \frac{1}{1 - b}}\\
\end{array}
\end{array}
if a < -2050Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub0.0%
*-lft-identity0.0%
associate-*l/0.0%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 100.0%
Taylor expanded in a around 0 5.7%
neg-mul-15.7%
unsub-neg5.7%
Simplified5.7%
Taylor expanded in a around inf 5.7%
associate-*r/5.7%
neg-mul-15.7%
distribute-neg-in5.7%
metadata-eval5.7%
associate-*r/5.7%
metadata-eval5.7%
distribute-neg-frac5.7%
metadata-eval5.7%
Simplified5.7%
Taylor expanded in a around 0 48.9%
if -2050 < a Initial program 99.4%
*-lft-identity99.4%
associate-*l/99.4%
associate-/r/99.4%
remove-double-neg99.4%
unsub-neg99.4%
div-sub99.4%
*-lft-identity99.4%
associate-*l/99.4%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp99.9%
Simplified99.9%
div-exp100.0%
clear-num99.9%
div-exp100.0%
Applied egg-rr100.0%
Taylor expanded in a around 0 97.5%
Taylor expanded in b around 0 74.4%
mul-1-neg74.4%
unsub-neg74.4%
Simplified74.4%
(FPCore (a b) :precision binary64 (if (<= a -2.9) (/ (/ -2.0 a) a) (+ 0.5 (* a 0.25))))
double code(double a, double b) {
double tmp;
if (a <= -2.9) {
tmp = (-2.0 / a) / a;
} else {
tmp = 0.5 + (a * 0.25);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-2.9d0)) then
tmp = ((-2.0d0) / a) / a
else
tmp = 0.5d0 + (a * 0.25d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -2.9) {
tmp = (-2.0 / a) / a;
} else {
tmp = 0.5 + (a * 0.25);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -2.9: tmp = (-2.0 / a) / a else: tmp = 0.5 + (a * 0.25) return tmp
function code(a, b) tmp = 0.0 if (a <= -2.9) tmp = Float64(Float64(-2.0 / a) / a); else tmp = Float64(0.5 + Float64(a * 0.25)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -2.9) tmp = (-2.0 / a) / a; else tmp = 0.5 + (a * 0.25); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -2.9], N[(N[(-2.0 / a), $MachinePrecision] / a), $MachinePrecision], N[(0.5 + N[(a * 0.25), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.9:\\
\;\;\;\;\frac{\frac{-2}{a}}{a}\\
\mathbf{else}:\\
\;\;\;\;0.5 + a \cdot 0.25\\
\end{array}
\end{array}
if a < -2.89999999999999991Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub3.2%
*-lft-identity3.2%
associate-*l/3.2%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 98.5%
Taylor expanded in a around 0 5.9%
neg-mul-15.9%
unsub-neg5.9%
Simplified5.9%
Taylor expanded in a around inf 5.9%
associate-*r/5.9%
neg-mul-15.9%
distribute-neg-in5.9%
metadata-eval5.9%
associate-*r/5.9%
metadata-eval5.9%
distribute-neg-frac5.9%
metadata-eval5.9%
Simplified5.9%
Taylor expanded in a around 0 47.4%
if -2.89999999999999991 < a Initial program 99.4%
*-lft-identity99.4%
associate-*l/99.4%
associate-/r/99.4%
remove-double-neg99.4%
unsub-neg99.4%
div-sub99.4%
*-lft-identity99.4%
associate-*l/99.4%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 58.5%
Taylor expanded in a around 0 58.0%
*-commutative58.0%
Simplified58.0%
(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 99.6%
*-lft-identity99.6%
associate-*l/99.6%
associate-/r/99.6%
remove-double-neg99.6%
unsub-neg99.6%
div-sub76.1%
*-lft-identity76.1%
associate-*l/76.1%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 68.2%
Taylor expanded in a around 0 45.1%
neg-mul-145.1%
unsub-neg45.1%
Simplified45.1%
(FPCore (a b) :precision binary64 (+ 0.5 (* a 0.25)))
double code(double a, double b) {
return 0.5 + (a * 0.25);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 0.5d0 + (a * 0.25d0)
end function
public static double code(double a, double b) {
return 0.5 + (a * 0.25);
}
def code(a, b): return 0.5 + (a * 0.25)
function code(a, b) return Float64(0.5 + Float64(a * 0.25)) end
function tmp = code(a, b) tmp = 0.5 + (a * 0.25); end
code[a_, b_] := N[(0.5 + N[(a * 0.25), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 + a \cdot 0.25
\end{array}
Initial program 99.6%
*-lft-identity99.6%
associate-*l/99.6%
associate-/r/99.6%
remove-double-neg99.6%
unsub-neg99.6%
div-sub76.1%
*-lft-identity76.1%
associate-*l/76.1%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 68.2%
Taylor expanded in a around 0 44.5%
*-commutative44.5%
Simplified44.5%
(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 99.6%
*-lft-identity99.6%
associate-*l/99.6%
associate-/r/99.6%
remove-double-neg99.6%
unsub-neg99.6%
div-sub76.1%
*-lft-identity76.1%
associate-*l/76.1%
lft-mult-inverse100.0%
sub-neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in a around 0 83.0%
Taylor expanded in b around 0 43.7%
(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 2024112
(FPCore (a b)
:name "Quotient of sum of exps"
:precision binary64
:alt
(! :herbie-platform default (/ 1 (+ 1 (exp (- b a)))))
(/ (exp a) (+ (exp a) (exp b))))