
(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 17 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.2%
*-lft-identity99.2%
associate-*l/99.2%
associate-/r/99.2%
remove-double-neg99.2%
unsub-neg99.2%
div-sub71.5%
*-lft-identity71.5%
associate-*l/71.5%
lft-mult-inverse99.6%
sub-neg99.6%
distribute-frac-neg99.6%
remove-double-neg99.6%
div-exp100.0%
Simplified100.0%
add-exp-log100.0%
log-rec100.0%
log1p-define100.0%
Applied egg-rr100.0%
(FPCore (a b)
:precision binary64
(if (<= a -4.5e+116)
(/ 1.0 (+ 2.0 (* a (+ (* a (+ 0.5 (* a -0.16666666666666666))) -1.0))))
(if (<= a -3.9e+39)
(/
1.0
(+
2.0
(*
b
(+
1.0
(*
(/ (* b (+ 0.5 (* b 0.16666666666666666))) b)
(* b (+ -1.0 (/ (- (/ (- (* 54.0 (/ -1.0 b)) 18.0) b) 6.0) b))))))))
(/ 1.0 (+ 1.0 (exp b))))))
double code(double a, double b) {
double tmp;
if (a <= -4.5e+116) {
tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * -0.16666666666666666))) + -1.0)));
} else if (a <= -3.9e+39) {
tmp = 1.0 / (2.0 + (b * (1.0 + (((b * (0.5 + (b * 0.16666666666666666))) / b) * (b * (-1.0 + (((((54.0 * (-1.0 / b)) - 18.0) / b) - 6.0) / b)))))));
} 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 <= (-4.5d+116)) then
tmp = 1.0d0 / (2.0d0 + (a * ((a * (0.5d0 + (a * (-0.16666666666666666d0)))) + (-1.0d0))))
else if (a <= (-3.9d+39)) then
tmp = 1.0d0 / (2.0d0 + (b * (1.0d0 + (((b * (0.5d0 + (b * 0.16666666666666666d0))) / b) * (b * ((-1.0d0) + (((((54.0d0 * ((-1.0d0) / b)) - 18.0d0) / b) - 6.0d0) / b)))))))
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 <= -4.5e+116) {
tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * -0.16666666666666666))) + -1.0)));
} else if (a <= -3.9e+39) {
tmp = 1.0 / (2.0 + (b * (1.0 + (((b * (0.5 + (b * 0.16666666666666666))) / b) * (b * (-1.0 + (((((54.0 * (-1.0 / b)) - 18.0) / b) - 6.0) / b)))))));
} else {
tmp = 1.0 / (1.0 + Math.exp(b));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -4.5e+116: tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * -0.16666666666666666))) + -1.0))) elif a <= -3.9e+39: tmp = 1.0 / (2.0 + (b * (1.0 + (((b * (0.5 + (b * 0.16666666666666666))) / b) * (b * (-1.0 + (((((54.0 * (-1.0 / b)) - 18.0) / b) - 6.0) / b))))))) else: tmp = 1.0 / (1.0 + math.exp(b)) return tmp
function code(a, b) tmp = 0.0 if (a <= -4.5e+116) tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(Float64(a * Float64(0.5 + Float64(a * -0.16666666666666666))) + -1.0)))); elseif (a <= -3.9e+39) tmp = Float64(1.0 / Float64(2.0 + Float64(b * Float64(1.0 + Float64(Float64(Float64(b * Float64(0.5 + Float64(b * 0.16666666666666666))) / b) * Float64(b * Float64(-1.0 + Float64(Float64(Float64(Float64(Float64(54.0 * Float64(-1.0 / b)) - 18.0) / b) - 6.0) / b)))))))); 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 <= -4.5e+116) tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * -0.16666666666666666))) + -1.0))); elseif (a <= -3.9e+39) tmp = 1.0 / (2.0 + (b * (1.0 + (((b * (0.5 + (b * 0.16666666666666666))) / b) * (b * (-1.0 + (((((54.0 * (-1.0 / b)) - 18.0) / b) - 6.0) / b))))))); else tmp = 1.0 / (1.0 + exp(b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -4.5e+116], 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], If[LessEqual[a, -3.9e+39], N[(1.0 / N[(2.0 + N[(b * N[(1.0 + N[(N[(N[(b * N[(0.5 + N[(b * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision] * N[(b * N[(-1.0 + N[(N[(N[(N[(N[(54.0 * N[(-1.0 / b), $MachinePrecision]), $MachinePrecision] - 18.0), $MachinePrecision] / b), $MachinePrecision] - 6.0), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 -4.5 \cdot 10^{+116}:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(a \cdot \left(0.5 + a \cdot -0.16666666666666666\right) + -1\right)}\\
\mathbf{elif}\;a \leq -3.9 \cdot 10^{+39}:\\
\;\;\;\;\frac{1}{2 + b \cdot \left(1 + \frac{b \cdot \left(0.5 + b \cdot 0.16666666666666666\right)}{b} \cdot \left(b \cdot \left(-1 + \frac{\frac{54 \cdot \frac{-1}{b} - 18}{b} - 6}{b}\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + e^{b}}\\
\end{array}
\end{array}
if a < -4.50000000000000016e116Initial 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 100.0%
if -4.50000000000000016e116 < a < -3.9000000000000001e39Initial 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 a around 0 22.5%
Taylor expanded in b around 0 22.5%
*-commutative22.5%
Simplified22.5%
distribute-lft-in22.5%
flip-+15.8%
Applied egg-rr15.8%
difference-of-squares15.8%
distribute-lft-out--15.8%
times-frac22.5%
distribute-lft-out22.5%
distribute-lft-out--22.5%
sub-neg22.5%
distribute-rgt-neg-in22.5%
metadata-eval22.5%
sub-neg22.5%
distribute-rgt-neg-in22.5%
metadata-eval22.5%
Applied egg-rr22.5%
metadata-eval22.5%
distribute-rgt-neg-in22.5%
add-sqr-sqrt21.5%
sqrt-unprod22.5%
swap-sqr22.5%
metadata-eval22.5%
metadata-eval22.5%
swap-sqr22.5%
sqrt-unprod1.0%
add-sqr-sqrt22.5%
Applied egg-rr22.5%
Taylor expanded in b around -inf 80.7%
if -3.9000000000000001e39 < a Initial program 98.9%
*-lft-identity98.9%
associate-*l/98.9%
associate-/r/98.9%
remove-double-neg98.9%
unsub-neg98.9%
div-sub93.8%
*-lft-identity93.8%
associate-*l/93.8%
lft-mult-inverse99.5%
sub-neg99.5%
distribute-frac-neg99.5%
remove-double-neg99.5%
div-exp100.0%
Simplified100.0%
Taylor expanded in a around 0 96.6%
Final simplification96.2%
(FPCore (a b) :precision binary64 (if (<= a -6200000.0) (/ 1.0 (+ 1.0 (exp (- a)))) (/ 1.0 (+ 1.0 (exp b)))))
double code(double a, double b) {
double tmp;
if (a <= -6200000.0) {
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 <= (-6200000.0d0)) 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 <= -6200000.0) {
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 <= -6200000.0: 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 <= -6200000.0) 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 <= -6200000.0) 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, -6200000.0], 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 -6200000:\\
\;\;\;\;\frac{1}{1 + e^{-a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + e^{b}}\\
\end{array}
\end{array}
if a < -6.2e6Initial 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%
if -6.2e6 < a Initial program 98.9%
*-lft-identity98.9%
associate-*l/98.9%
associate-/r/98.9%
remove-double-neg98.9%
unsub-neg98.9%
div-sub97.3%
*-lft-identity97.3%
associate-*l/97.3%
lft-mult-inverse99.4%
sub-neg99.4%
distribute-frac-neg99.4%
remove-double-neg99.4%
div-exp100.0%
Simplified100.0%
Taylor expanded in a around 0 99.0%
(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.2%
*-lft-identity99.2%
associate-*l/99.2%
associate-/r/99.2%
remove-double-neg99.2%
unsub-neg99.2%
div-sub71.5%
*-lft-identity71.5%
associate-*l/71.5%
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 9.5e+15)
(/ 1.0 (+ 2.0 (* a (+ (* a (+ 0.5 (* a -0.16666666666666666))) -1.0))))
(/
1.0
(+
2.0
(*
b
(+
1.0
(*
(* b 0.16666666666666666)
(*
b
(+
1.0
(*
b
(+
0.6666666666666666
(* b (+ 0.2222222222222222 (* b 0.07407407407407407))))))))))))))
double code(double a, double b) {
double tmp;
if (b <= 9.5e+15) {
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.16666666666666666) * (b * (1.0 + (b * (0.6666666666666666 + (b * (0.2222222222222222 + (b * 0.07407407407407407)))))))))));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 9.5d+15) 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.16666666666666666d0) * (b * (1.0d0 + (b * (0.6666666666666666d0 + (b * (0.2222222222222222d0 + (b * 0.07407407407407407d0)))))))))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 9.5e+15) {
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.16666666666666666) * (b * (1.0 + (b * (0.6666666666666666 + (b * (0.2222222222222222 + (b * 0.07407407407407407)))))))))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 9.5e+15: 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.16666666666666666) * (b * (1.0 + (b * (0.6666666666666666 + (b * (0.2222222222222222 + (b * 0.07407407407407407))))))))))) return tmp
function code(a, b) tmp = 0.0 if (b <= 9.5e+15) 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(Float64(b * 0.16666666666666666) * Float64(b * Float64(1.0 + Float64(b * Float64(0.6666666666666666 + Float64(b * Float64(0.2222222222222222 + Float64(b * 0.07407407407407407)))))))))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 9.5e+15) 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.16666666666666666) * (b * (1.0 + (b * (0.6666666666666666 + (b * (0.2222222222222222 + (b * 0.07407407407407407))))))))))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 9.5e+15], 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[(N[(b * 0.16666666666666666), $MachinePrecision] * N[(b * N[(1.0 + N[(b * N[(0.6666666666666666 + N[(b * N[(0.2222222222222222 + N[(b * 0.07407407407407407), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 9.5 \cdot 10^{+15}:\\
\;\;\;\;\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 + \left(b \cdot 0.16666666666666666\right) \cdot \left(b \cdot \left(1 + b \cdot \left(0.6666666666666666 + b \cdot \left(0.2222222222222222 + b \cdot 0.07407407407407407\right)\right)\right)\right)\right)}\\
\end{array}
\end{array}
if b < 9.5e15Initial program 99.0%
*-lft-identity99.0%
associate-*l/99.0%
associate-/r/99.0%
remove-double-neg99.0%
unsub-neg99.0%
div-sub72.6%
*-lft-identity72.6%
associate-*l/72.6%
lft-mult-inverse99.5%
sub-neg99.5%
distribute-frac-neg99.5%
remove-double-neg99.5%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 77.3%
Taylor expanded in a around 0 68.6%
if 9.5e15 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub67.8%
*-lft-identity67.8%
associate-*l/67.8%
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 64.7%
*-commutative64.7%
Simplified64.7%
distribute-lft-in64.7%
flip-+38.5%
Applied egg-rr38.5%
difference-of-squares38.5%
distribute-lft-out--38.5%
times-frac64.7%
distribute-lft-out64.7%
distribute-lft-out--64.7%
sub-neg64.7%
distribute-rgt-neg-in64.7%
metadata-eval64.7%
sub-neg64.7%
distribute-rgt-neg-in64.7%
metadata-eval64.7%
Applied egg-rr64.7%
metadata-eval64.7%
distribute-rgt-neg-in64.7%
add-sqr-sqrt64.7%
sqrt-unprod64.7%
swap-sqr64.7%
metadata-eval64.7%
metadata-eval64.7%
swap-sqr64.7%
sqrt-unprod0.0%
add-sqr-sqrt64.7%
Applied egg-rr64.7%
Taylor expanded in b around 0 85.7%
*-commutative85.7%
Simplified85.7%
Taylor expanded in b around inf 85.7%
*-commutative85.7%
Simplified85.7%
Final simplification72.6%
(FPCore (a b)
:precision binary64
(if (<= b 1.65e+21)
(/ 1.0 (+ 2.0 (* a (+ (* a (+ 0.5 (* a -0.16666666666666666))) -1.0))))
(/
1.0
(+
2.0
(*
b
(+
1.0
(*
(* b 0.16666666666666666)
(*
b
(+ 1.0 (* b (+ 0.6666666666666666 (* b 0.2222222222222222))))))))))))
double code(double a, double b) {
double tmp;
if (b <= 1.65e+21) {
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.16666666666666666) * (b * (1.0 + (b * (0.6666666666666666 + (b * 0.2222222222222222)))))))));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 1.65d+21) 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.16666666666666666d0) * (b * (1.0d0 + (b * (0.6666666666666666d0 + (b * 0.2222222222222222d0)))))))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 1.65e+21) {
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.16666666666666666) * (b * (1.0 + (b * (0.6666666666666666 + (b * 0.2222222222222222)))))))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 1.65e+21: 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.16666666666666666) * (b * (1.0 + (b * (0.6666666666666666 + (b * 0.2222222222222222))))))))) return tmp
function code(a, b) tmp = 0.0 if (b <= 1.65e+21) 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(Float64(b * 0.16666666666666666) * Float64(b * Float64(1.0 + Float64(b * Float64(0.6666666666666666 + Float64(b * 0.2222222222222222)))))))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 1.65e+21) 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.16666666666666666) * (b * (1.0 + (b * (0.6666666666666666 + (b * 0.2222222222222222))))))))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 1.65e+21], 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[(N[(b * 0.16666666666666666), $MachinePrecision] * N[(b * N[(1.0 + N[(b * N[(0.6666666666666666 + N[(b * 0.2222222222222222), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.65 \cdot 10^{+21}:\\
\;\;\;\;\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 + \left(b \cdot 0.16666666666666666\right) \cdot \left(b \cdot \left(1 + b \cdot \left(0.6666666666666666 + b \cdot 0.2222222222222222\right)\right)\right)\right)}\\
\end{array}
\end{array}
if b < 1.65e21Initial program 99.0%
*-lft-identity99.0%
associate-*l/99.0%
associate-/r/99.0%
remove-double-neg99.0%
unsub-neg99.0%
div-sub72.2%
*-lft-identity72.2%
associate-*l/72.2%
lft-mult-inverse99.5%
sub-neg99.5%
distribute-frac-neg99.5%
remove-double-neg99.5%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 77.4%
Taylor expanded in a around 0 68.8%
if 1.65e21 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub69.0%
*-lft-identity69.0%
associate-*l/69.0%
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 65.7%
*-commutative65.7%
Simplified65.7%
distribute-lft-in65.7%
flip-+39.1%
Applied egg-rr39.1%
difference-of-squares39.1%
distribute-lft-out--39.1%
times-frac65.7%
distribute-lft-out65.7%
distribute-lft-out--65.7%
sub-neg65.7%
distribute-rgt-neg-in65.7%
metadata-eval65.7%
sub-neg65.7%
distribute-rgt-neg-in65.7%
metadata-eval65.7%
Applied egg-rr65.7%
metadata-eval65.7%
distribute-rgt-neg-in65.7%
add-sqr-sqrt65.7%
sqrt-unprod65.7%
swap-sqr65.7%
metadata-eval65.7%
metadata-eval65.7%
swap-sqr65.7%
sqrt-unprod0.0%
add-sqr-sqrt65.7%
Applied egg-rr65.7%
Taylor expanded in b around 0 77.6%
*-commutative77.6%
Simplified77.6%
Taylor expanded in b around inf 77.6%
*-commutative87.1%
Simplified77.6%
Final simplification70.8%
(FPCore (a b)
:precision binary64
(if (<= b 4e+24)
(/ 1.0 (+ 2.0 (* a (+ (* a (+ 0.5 (* a -0.16666666666666666))) -1.0))))
(/
1.0
(+
2.0
(*
b
(+
1.0
(*
(* b 0.16666666666666666)
(* b (+ 1.0 (* b 0.6666666666666666))))))))))
double code(double a, double b) {
double tmp;
if (b <= 4e+24) {
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.16666666666666666) * (b * (1.0 + (b * 0.6666666666666666)))))));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 4d+24) 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.16666666666666666d0) * (b * (1.0d0 + (b * 0.6666666666666666d0)))))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 4e+24) {
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.16666666666666666) * (b * (1.0 + (b * 0.6666666666666666)))))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 4e+24: 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.16666666666666666) * (b * (1.0 + (b * 0.6666666666666666))))))) return tmp
function code(a, b) tmp = 0.0 if (b <= 4e+24) 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(Float64(b * 0.16666666666666666) * Float64(b * Float64(1.0 + Float64(b * 0.6666666666666666)))))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 4e+24) 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.16666666666666666) * (b * (1.0 + (b * 0.6666666666666666))))))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 4e+24], 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[(N[(b * 0.16666666666666666), $MachinePrecision] * N[(b * N[(1.0 + N[(b * 0.6666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4 \cdot 10^{+24}:\\
\;\;\;\;\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 + \left(b \cdot 0.16666666666666666\right) \cdot \left(b \cdot \left(1 + b \cdot 0.6666666666666666\right)\right)\right)}\\
\end{array}
\end{array}
if b < 3.9999999999999999e24Initial program 99.0%
*-lft-identity99.0%
associate-*l/99.0%
associate-/r/99.0%
remove-double-neg99.0%
unsub-neg99.0%
div-sub72.0%
*-lft-identity72.0%
associate-*l/72.0%
lft-mult-inverse99.5%
sub-neg99.5%
distribute-frac-neg99.5%
remove-double-neg99.5%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 77.1%
Taylor expanded in a around 0 68.6%
if 3.9999999999999999e24 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub69.6%
*-lft-identity69.6%
associate-*l/69.6%
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 67.9%
*-commutative67.9%
Simplified67.9%
distribute-lft-in67.9%
flip-+40.4%
Applied egg-rr40.4%
difference-of-squares40.4%
distribute-lft-out--40.4%
times-frac67.9%
distribute-lft-out67.9%
distribute-lft-out--67.9%
sub-neg67.9%
distribute-rgt-neg-in67.9%
metadata-eval67.9%
sub-neg67.9%
distribute-rgt-neg-in67.9%
metadata-eval67.9%
Applied egg-rr67.9%
metadata-eval67.9%
distribute-rgt-neg-in67.9%
add-sqr-sqrt67.9%
sqrt-unprod67.9%
swap-sqr67.9%
metadata-eval67.9%
metadata-eval67.9%
swap-sqr67.9%
sqrt-unprod0.0%
add-sqr-sqrt67.9%
Applied egg-rr67.9%
Taylor expanded in b around 0 78.1%
*-commutative78.1%
Simplified78.1%
Taylor expanded in b around inf 78.1%
*-commutative90.0%
Simplified78.1%
Final simplification70.7%
(FPCore (a b)
:precision binary64
(if (<= b 6e+35)
(/ 1.0 (+ 2.0 (* a (+ (* a (+ 0.5 (* a -0.16666666666666666))) -1.0))))
(/
1.0
(+ 2.0 (* b (+ 1.0 (* 0.5 (* b (+ 1.0 (* b 0.6666666666666666))))))))))
double code(double a, double b) {
double tmp;
if (b <= 6e+35) {
tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * -0.16666666666666666))) + -1.0)));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (0.5 * (b * (1.0 + (b * 0.6666666666666666)))))));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 6d+35) then
tmp = 1.0d0 / (2.0d0 + (a * ((a * (0.5d0 + (a * (-0.16666666666666666d0)))) + (-1.0d0))))
else
tmp = 1.0d0 / (2.0d0 + (b * (1.0d0 + (0.5d0 * (b * (1.0d0 + (b * 0.6666666666666666d0)))))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 6e+35) {
tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * -0.16666666666666666))) + -1.0)));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (0.5 * (b * (1.0 + (b * 0.6666666666666666)))))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 6e+35: tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * -0.16666666666666666))) + -1.0))) else: tmp = 1.0 / (2.0 + (b * (1.0 + (0.5 * (b * (1.0 + (b * 0.6666666666666666))))))) return tmp
function code(a, b) tmp = 0.0 if (b <= 6e+35) 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(0.5 * Float64(b * Float64(1.0 + Float64(b * 0.6666666666666666)))))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 6e+35) tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * -0.16666666666666666))) + -1.0))); else tmp = 1.0 / (2.0 + (b * (1.0 + (0.5 * (b * (1.0 + (b * 0.6666666666666666))))))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 6e+35], 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[(0.5 * N[(b * N[(1.0 + N[(b * 0.6666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6 \cdot 10^{+35}:\\
\;\;\;\;\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 + 0.5 \cdot \left(b \cdot \left(1 + b \cdot 0.6666666666666666\right)\right)\right)}\\
\end{array}
\end{array}
if b < 5.99999999999999981e35Initial program 99.0%
*-lft-identity99.0%
associate-*l/99.0%
associate-/r/99.0%
remove-double-neg99.0%
unsub-neg99.0%
div-sub71.6%
*-lft-identity71.6%
associate-*l/71.6%
lft-mult-inverse99.5%
sub-neg99.5%
distribute-frac-neg99.5%
remove-double-neg99.5%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 77.2%
Taylor expanded in a around 0 68.8%
if 5.99999999999999981e35 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub70.9%
*-lft-identity70.9%
associate-*l/70.9%
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 69.1%
*-commutative69.1%
Simplified69.1%
distribute-lft-in69.1%
flip-+41.0%
Applied egg-rr41.0%
difference-of-squares41.0%
distribute-lft-out--41.0%
times-frac69.1%
distribute-lft-out69.1%
distribute-lft-out--69.1%
sub-neg69.1%
distribute-rgt-neg-in69.1%
metadata-eval69.1%
sub-neg69.1%
distribute-rgt-neg-in69.1%
metadata-eval69.1%
Applied egg-rr69.1%
metadata-eval69.1%
distribute-rgt-neg-in69.1%
add-sqr-sqrt69.1%
sqrt-unprod69.1%
swap-sqr69.1%
metadata-eval69.1%
metadata-eval69.1%
swap-sqr69.1%
sqrt-unprod0.0%
add-sqr-sqrt69.1%
Applied egg-rr69.1%
Taylor expanded in b around 0 79.5%
*-commutative79.5%
Simplified79.5%
Taylor expanded in b around 0 69.1%
Final simplification68.8%
(FPCore (a b) :precision binary64 (if (<= b 6e+35) (/ 1.0 (+ 2.0 (* a (+ (* a (+ 0.5 (* a -0.16666666666666666))) -1.0)))) (/ 1.0 (+ 2.0 (* b (+ 1.0 (* (* b 0.16666666666666666) (- -6.0 b))))))))
double code(double a, double b) {
double tmp;
if (b <= 6e+35) {
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.16666666666666666) * (-6.0 - b)))));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 6d+35) 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.16666666666666666d0) * ((-6.0d0) - b)))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 6e+35) {
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.16666666666666666) * (-6.0 - b)))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 6e+35: 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.16666666666666666) * (-6.0 - b))))) return tmp
function code(a, b) tmp = 0.0 if (b <= 6e+35) 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(Float64(b * 0.16666666666666666) * Float64(-6.0 - b)))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 6e+35) 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.16666666666666666) * (-6.0 - b))))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 6e+35], 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[(N[(b * 0.16666666666666666), $MachinePrecision] * N[(-6.0 - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6 \cdot 10^{+35}:\\
\;\;\;\;\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 + \left(b \cdot 0.16666666666666666\right) \cdot \left(-6 - b\right)\right)}\\
\end{array}
\end{array}
if b < 5.99999999999999981e35Initial program 99.0%
*-lft-identity99.0%
associate-*l/99.0%
associate-/r/99.0%
remove-double-neg99.0%
unsub-neg99.0%
div-sub71.6%
*-lft-identity71.6%
associate-*l/71.6%
lft-mult-inverse99.5%
sub-neg99.5%
distribute-frac-neg99.5%
remove-double-neg99.5%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 77.2%
Taylor expanded in a around 0 68.8%
if 5.99999999999999981e35 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub70.9%
*-lft-identity70.9%
associate-*l/70.9%
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 69.1%
*-commutative69.1%
Simplified69.1%
distribute-lft-in69.1%
flip-+41.0%
Applied egg-rr41.0%
difference-of-squares41.0%
distribute-lft-out--41.0%
times-frac69.1%
distribute-lft-out69.1%
distribute-lft-out--69.1%
sub-neg69.1%
distribute-rgt-neg-in69.1%
metadata-eval69.1%
sub-neg69.1%
distribute-rgt-neg-in69.1%
metadata-eval69.1%
Applied egg-rr69.1%
metadata-eval69.1%
distribute-rgt-neg-in69.1%
add-sqr-sqrt69.1%
sqrt-unprod69.1%
swap-sqr69.1%
metadata-eval69.1%
metadata-eval69.1%
swap-sqr69.1%
sqrt-unprod0.0%
add-sqr-sqrt69.1%
Applied egg-rr69.1%
Taylor expanded in b around inf 69.1%
associate-*r*69.1%
+-commutative69.1%
distribute-rgt-in69.1%
*-lft-identity69.1%
mul-1-neg69.1%
unsub-neg69.1%
mul-1-neg69.1%
distribute-rgt-neg-in69.1%
associate-*l*69.1%
lft-mult-inverse69.1%
metadata-eval69.1%
metadata-eval69.1%
Simplified69.1%
Taylor expanded in b around inf 69.1%
*-commutative91.6%
Simplified69.1%
Final simplification68.8%
(FPCore (a b) :precision binary64 (if (<= b 6e+35) (/ 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 <= 6e+35) {
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 <= 6d+35) 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 <= 6e+35) {
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 <= 6e+35: 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 <= 6e+35) 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 <= 6e+35) 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, 6e+35], 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 6 \cdot 10^{+35}:\\
\;\;\;\;\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 < 5.99999999999999981e35Initial program 99.0%
*-lft-identity99.0%
associate-*l/99.0%
associate-/r/99.0%
remove-double-neg99.0%
unsub-neg99.0%
div-sub71.6%
*-lft-identity71.6%
associate-*l/71.6%
lft-mult-inverse99.5%
sub-neg99.5%
distribute-frac-neg99.5%
remove-double-neg99.5%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 77.2%
Taylor expanded in a around 0 68.8%
if 5.99999999999999981e35 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub70.9%
*-lft-identity70.9%
associate-*l/70.9%
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 69.1%
*-commutative69.1%
Simplified69.1%
Final simplification68.8%
(FPCore (a b) :precision binary64 (if (<= b 3.3e+47) (/ 1.0 (+ 2.0 (* a (+ (* a (+ 0.5 (* a -0.16666666666666666))) -1.0)))) (/ 2.0 (* b (- b)))))
double code(double a, double b) {
double tmp;
if (b <= 3.3e+47) {
tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * -0.16666666666666666))) + -1.0)));
} else {
tmp = 2.0 / (b * -b);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 3.3d+47) then
tmp = 1.0d0 / (2.0d0 + (a * ((a * (0.5d0 + (a * (-0.16666666666666666d0)))) + (-1.0d0))))
else
tmp = 2.0d0 / (b * -b)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 3.3e+47) {
tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * -0.16666666666666666))) + -1.0)));
} else {
tmp = 2.0 / (b * -b);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 3.3e+47: tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * -0.16666666666666666))) + -1.0))) else: tmp = 2.0 / (b * -b) return tmp
function code(a, b) tmp = 0.0 if (b <= 3.3e+47) tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(Float64(a * Float64(0.5 + Float64(a * -0.16666666666666666))) + -1.0)))); else tmp = Float64(2.0 / Float64(b * Float64(-b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 3.3e+47) tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * -0.16666666666666666))) + -1.0))); else tmp = 2.0 / (b * -b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 3.3e+47], 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[(2.0 / N[(b * (-b)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.3 \cdot 10^{+47}:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(a \cdot \left(0.5 + a \cdot -0.16666666666666666\right) + -1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{b \cdot \left(-b\right)}\\
\end{array}
\end{array}
if b < 3.2999999999999999e47Initial program 99.0%
*-lft-identity99.0%
associate-*l/99.0%
associate-/r/99.0%
remove-double-neg99.0%
unsub-neg99.0%
div-sub71.5%
*-lft-identity71.5%
associate-*l/71.5%
lft-mult-inverse99.5%
sub-neg99.5%
distribute-frac-neg99.5%
remove-double-neg99.5%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 76.6%
Taylor expanded in a around 0 68.3%
if 3.2999999999999999e47 < 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.2%
*-lft-identity71.2%
associate-*l/71.2%
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 4.9%
+-commutative4.9%
Simplified4.9%
Taylor expanded in b around inf 4.9%
associate-*r/4.9%
metadata-eval4.9%
Simplified4.9%
Taylor expanded in b around 0 43.6%
clear-num44.1%
associate-/r/43.6%
Applied egg-rr43.6%
frac-2neg43.6%
metadata-eval43.6%
frac-times44.1%
metadata-eval44.1%
Applied egg-rr44.1%
Final simplification63.4%
(FPCore (a b) :precision binary64 (if (<= b 3.9e+136) (/ 1.0 (+ 2.0 (* a (+ -1.0 (* a 0.5))))) (/ 2.0 (* b (- b)))))
double code(double a, double b) {
double tmp;
if (b <= 3.9e+136) {
tmp = 1.0 / (2.0 + (a * (-1.0 + (a * 0.5))));
} else {
tmp = 2.0 / (b * -b);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 3.9d+136) then
tmp = 1.0d0 / (2.0d0 + (a * ((-1.0d0) + (a * 0.5d0))))
else
tmp = 2.0d0 / (b * -b)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 3.9e+136) {
tmp = 1.0 / (2.0 + (a * (-1.0 + (a * 0.5))));
} else {
tmp = 2.0 / (b * -b);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 3.9e+136: tmp = 1.0 / (2.0 + (a * (-1.0 + (a * 0.5)))) else: tmp = 2.0 / (b * -b) return tmp
function code(a, b) tmp = 0.0 if (b <= 3.9e+136) tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(-1.0 + Float64(a * 0.5))))); else tmp = Float64(2.0 / Float64(b * Float64(-b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 3.9e+136) tmp = 1.0 / (2.0 + (a * (-1.0 + (a * 0.5)))); else tmp = 2.0 / (b * -b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 3.9e+136], N[(1.0 / N[(2.0 + N[(a * N[(-1.0 + N[(a * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(b * (-b)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.9 \cdot 10^{+136}:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(-1 + a \cdot 0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{b \cdot \left(-b\right)}\\
\end{array}
\end{array}
if b < 3.90000000000000019e136Initial program 99.1%
*-lft-identity99.1%
associate-*l/99.1%
associate-/r/99.1%
remove-double-neg99.1%
unsub-neg99.1%
div-sub71.6%
*-lft-identity71.6%
associate-*l/71.6%
lft-mult-inverse99.5%
sub-neg99.5%
distribute-frac-neg99.5%
remove-double-neg99.5%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 71.6%
Taylor expanded in a around 0 58.0%
if 3.90000000000000019e136 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub70.4%
*-lft-identity70.4%
associate-*l/70.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 100.0%
Taylor expanded in b around 0 5.8%
+-commutative5.8%
Simplified5.8%
Taylor expanded in b around inf 5.8%
associate-*r/5.8%
metadata-eval5.8%
Simplified5.8%
Taylor expanded in b around 0 78.8%
clear-num79.8%
associate-/r/78.8%
Applied egg-rr78.8%
frac-2neg78.8%
metadata-eval78.8%
frac-times79.8%
metadata-eval79.8%
Applied egg-rr79.8%
Final simplification60.3%
(FPCore (a b) :precision binary64 (if (<= b 3.4e-16) (/ 1.0 (- 2.0 a)) (/ 1.0 (* b (/ b 2.0)))))
double code(double a, double b) {
double tmp;
if (b <= 3.4e-16) {
tmp = 1.0 / (2.0 - a);
} else {
tmp = 1.0 / (b * (b / 2.0));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 3.4d-16) then
tmp = 1.0d0 / (2.0d0 - a)
else
tmp = 1.0d0 / (b * (b / 2.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 3.4e-16) {
tmp = 1.0 / (2.0 - a);
} else {
tmp = 1.0 / (b * (b / 2.0));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 3.4e-16: tmp = 1.0 / (2.0 - a) else: tmp = 1.0 / (b * (b / 2.0)) return tmp
function code(a, b) tmp = 0.0 if (b <= 3.4e-16) tmp = Float64(1.0 / Float64(2.0 - a)); else tmp = Float64(1.0 / Float64(b * Float64(b / 2.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 3.4e-16) tmp = 1.0 / (2.0 - a); else tmp = 1.0 / (b * (b / 2.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 3.4e-16], N[(1.0 / N[(2.0 - a), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(b * N[(b / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.4 \cdot 10^{-16}:\\
\;\;\;\;\frac{1}{2 - a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{b \cdot \frac{b}{2}}\\
\end{array}
\end{array}
if b < 3.4e-16Initial program 98.9%
*-lft-identity98.9%
associate-*l/98.9%
associate-/r/98.9%
remove-double-neg98.9%
unsub-neg98.9%
div-sub72.9%
*-lft-identity72.9%
associate-*l/72.9%
lft-mult-inverse99.5%
sub-neg99.5%
distribute-frac-neg99.5%
remove-double-neg99.5%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 77.6%
Taylor expanded in a around 0 51.9%
neg-mul-151.9%
unsub-neg51.9%
Simplified51.9%
if 3.4e-16 < b Initial program 99.9%
*-lft-identity99.9%
associate-*l/99.9%
associate-/r/99.9%
remove-double-neg99.9%
unsub-neg99.9%
div-sub67.6%
*-lft-identity67.6%
associate-*l/67.6%
lft-mult-inverse99.9%
sub-neg99.9%
distribute-frac-neg99.9%
remove-double-neg99.9%
div-exp99.9%
Simplified99.9%
Taylor expanded in a around 0 97.1%
Taylor expanded in b around 0 10.2%
+-commutative10.2%
Simplified10.2%
Taylor expanded in b around inf 4.5%
associate-*r/4.5%
metadata-eval4.5%
Simplified4.5%
Taylor expanded in b around 0 34.0%
clear-num34.4%
associate-/r/34.0%
Applied egg-rr34.0%
associate-*l/34.0%
*-un-lft-identity34.0%
clear-num34.4%
Applied egg-rr34.4%
frac-2neg34.4%
add-sqr-sqrt0.0%
associate-/l*0.0%
add-sqr-sqrt0.0%
sqrt-unprod0.0%
sqr-neg0.0%
sqrt-unprod0.0%
add-sqr-sqrt0.0%
add-sqr-sqrt0.0%
sqrt-unprod34.9%
sqr-neg34.9%
sqrt-unprod34.9%
add-sqr-sqrt34.9%
distribute-neg-frac34.9%
metadata-eval34.9%
Applied egg-rr34.9%
associate-*r/34.9%
rem-square-sqrt34.9%
associate-/r/34.9%
Simplified34.9%
Final simplification47.4%
(FPCore (a b) :precision binary64 (if (<= b 2.9) (/ 1.0 (- 2.0 a)) (/ (- 2.0) (* b b))))
double code(double a, double b) {
double tmp;
if (b <= 2.9) {
tmp = 1.0 / (2.0 - a);
} else {
tmp = -2.0 / (b * b);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 2.9d0) then
tmp = 1.0d0 / (2.0d0 - a)
else
tmp = -2.0d0 / (b * b)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 2.9) {
tmp = 1.0 / (2.0 - a);
} else {
tmp = -2.0 / (b * b);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 2.9: tmp = 1.0 / (2.0 - a) else: tmp = -2.0 / (b * b) return tmp
function code(a, b) tmp = 0.0 if (b <= 2.9) tmp = Float64(1.0 / Float64(2.0 - a)); else tmp = Float64(Float64(-2.0) / Float64(b * b)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 2.9) tmp = 1.0 / (2.0 - a); else tmp = -2.0 / (b * b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 2.9], N[(1.0 / N[(2.0 - a), $MachinePrecision]), $MachinePrecision], N[((-2.0) / N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.9:\\
\;\;\;\;\frac{1}{2 - a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2}{b \cdot b}\\
\end{array}
\end{array}
if b < 2.89999999999999991Initial program 98.9%
*-lft-identity98.9%
associate-*l/98.9%
associate-/r/98.9%
remove-double-neg98.9%
unsub-neg98.9%
div-sub73.0%
*-lft-identity73.0%
associate-*l/73.0%
lft-mult-inverse99.5%
sub-neg99.5%
distribute-frac-neg99.5%
remove-double-neg99.5%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 77.8%
Taylor expanded in a around 0 52.3%
neg-mul-152.3%
unsub-neg52.3%
Simplified52.3%
if 2.89999999999999991 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub66.7%
*-lft-identity66.7%
associate-*l/66.7%
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 98.5%
Taylor expanded in b around 0 4.7%
+-commutative4.7%
Simplified4.7%
Taylor expanded in b around inf 4.7%
associate-*r/4.7%
metadata-eval4.7%
Simplified4.7%
Taylor expanded in b around 0 36.5%
clear-num37.0%
associate-/r/36.5%
Applied egg-rr36.5%
frac-2neg36.5%
metadata-eval36.5%
frac-times37.0%
metadata-eval37.0%
Applied egg-rr37.0%
Final simplification48.5%
(FPCore (a b) :precision binary64 (if (<= b 2.1e-15) (/ 1.0 (- 2.0 a)) (/ (/ -2.0 b) b)))
double code(double a, double b) {
double tmp;
if (b <= 2.1e-15) {
tmp = 1.0 / (2.0 - a);
} else {
tmp = (-2.0 / b) / b;
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 2.1d-15) then
tmp = 1.0d0 / (2.0d0 - a)
else
tmp = ((-2.0d0) / b) / b
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 2.1e-15) {
tmp = 1.0 / (2.0 - a);
} else {
tmp = (-2.0 / b) / b;
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 2.1e-15: tmp = 1.0 / (2.0 - a) else: tmp = (-2.0 / b) / b return tmp
function code(a, b) tmp = 0.0 if (b <= 2.1e-15) tmp = Float64(1.0 / Float64(2.0 - a)); else tmp = Float64(Float64(-2.0 / b) / b); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 2.1e-15) tmp = 1.0 / (2.0 - a); else tmp = (-2.0 / b) / b; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 2.1e-15], N[(1.0 / N[(2.0 - a), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 / b), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.1 \cdot 10^{-15}:\\
\;\;\;\;\frac{1}{2 - a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-2}{b}}{b}\\
\end{array}
\end{array}
if b < 2.09999999999999981e-15Initial program 98.9%
*-lft-identity98.9%
associate-*l/98.9%
associate-/r/98.9%
remove-double-neg98.9%
unsub-neg98.9%
div-sub73.0%
*-lft-identity73.0%
associate-*l/73.0%
lft-mult-inverse99.5%
sub-neg99.5%
distribute-frac-neg99.5%
remove-double-neg99.5%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 77.7%
Taylor expanded in a around 0 52.1%
neg-mul-152.1%
unsub-neg52.1%
Simplified52.1%
if 2.09999999999999981e-15 < b Initial program 99.9%
*-lft-identity99.9%
associate-*l/99.9%
associate-/r/99.9%
remove-double-neg99.9%
unsub-neg99.9%
div-sub67.1%
*-lft-identity67.1%
associate-*l/67.1%
lft-mult-inverse99.9%
sub-neg99.9%
distribute-frac-neg99.9%
remove-double-neg99.9%
div-exp99.9%
Simplified99.9%
Taylor expanded in a around 0 97.0%
Taylor expanded in b around 0 8.9%
+-commutative8.9%
Simplified8.9%
Taylor expanded in b around inf 4.5%
associate-*r/4.5%
metadata-eval4.5%
Simplified4.5%
Taylor expanded in b around 0 34.5%
(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.2%
*-lft-identity99.2%
associate-*l/99.2%
associate-/r/99.2%
remove-double-neg99.2%
unsub-neg99.2%
div-sub71.5%
*-lft-identity71.5%
associate-*l/71.5%
lft-mult-inverse99.6%
sub-neg99.6%
distribute-frac-neg99.6%
remove-double-neg99.6%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 67.4%
Taylor expanded in a around 0 40.4%
neg-mul-140.4%
unsub-neg40.4%
Simplified40.4%
(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.2%
*-lft-identity99.2%
associate-*l/99.2%
associate-/r/99.2%
remove-double-neg99.2%
unsub-neg99.2%
div-sub71.5%
*-lft-identity71.5%
associate-*l/71.5%
lft-mult-inverse99.6%
sub-neg99.6%
distribute-frac-neg99.6%
remove-double-neg99.6%
div-exp100.0%
Simplified100.0%
Taylor expanded in a around 0 80.3%
Taylor expanded in b around 0 39.6%
(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 2024107
(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))))