
(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 15 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-sub77.3%
*-lft-identity77.3%
associate-*l/77.3%
lft-mult-inverse99.2%
sub-neg99.2%
distribute-frac-neg99.2%
remove-double-neg99.2%
div-exp100.0%
Simplified100.0%
add-exp-log100.0%
log-rec100.0%
log1p-define100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (a b) :precision binary64 (if (<= a -54000000.0) (/ 1.0 (+ 1.0 (exp (- a)))) (/ 1.0 (+ 1.0 (exp b)))))
double code(double a, double b) {
double tmp;
if (a <= -54000000.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 <= (-54000000.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 <= -54000000.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 <= -54000000.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 <= -54000000.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 <= -54000000.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, -54000000.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 -54000000:\\
\;\;\;\;\frac{1}{1 + e^{-a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + e^{b}}\\
\end{array}
\end{array}
if a < -5.4e7Initial 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 -5.4e7 < a Initial program 99.0%
*-lft-identity99.0%
associate-*l/99.0%
associate-/r/99.0%
remove-double-neg99.0%
unsub-neg99.0%
div-sub98.5%
*-lft-identity98.5%
associate-*l/98.5%
lft-mult-inverse99.0%
sub-neg99.0%
distribute-frac-neg99.0%
remove-double-neg99.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in a around 0 98.9%
Final simplification99.1%
(FPCore (a b)
:precision binary64
(if (<= a -2.5e+77)
(/
1.0
(+
2.0
(*
a
(+
(* a (+ 0.5 (* a (- (* a 0.041666666666666664) 0.16666666666666666))))
-1.0))))
(/ 1.0 (+ 1.0 (exp b)))))
double code(double a, double b) {
double tmp;
if (a <= -2.5e+77) {
tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * ((a * 0.041666666666666664) - 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 <= (-2.5d+77)) then
tmp = 1.0d0 / (2.0d0 + (a * ((a * (0.5d0 + (a * ((a * 0.041666666666666664d0) - 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 <= -2.5e+77) {
tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * ((a * 0.041666666666666664) - 0.16666666666666666)))) + -1.0)));
} else {
tmp = 1.0 / (1.0 + Math.exp(b));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -2.5e+77: tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * ((a * 0.041666666666666664) - 0.16666666666666666)))) + -1.0))) else: tmp = 1.0 / (1.0 + math.exp(b)) return tmp
function code(a, b) tmp = 0.0 if (a <= -2.5e+77) tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(Float64(a * Float64(0.5 + Float64(a * Float64(Float64(a * 0.041666666666666664) - 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 <= -2.5e+77) tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * ((a * 0.041666666666666664) - 0.16666666666666666)))) + -1.0))); else tmp = 1.0 / (1.0 + exp(b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -2.5e+77], N[(1.0 / N[(2.0 + N[(a * N[(N[(a * N[(0.5 + N[(a * N[(N[(a * 0.041666666666666664), $MachinePrecision] - 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $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 -2.5 \cdot 10^{+77}:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(a \cdot \left(0.5 + a \cdot \left(a \cdot 0.041666666666666664 - 0.16666666666666666\right)\right) + -1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + e^{b}}\\
\end{array}
\end{array}
if a < -2.50000000000000002e77Initial 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 -2.50000000000000002e77 < a Initial program 99.0%
*-lft-identity99.0%
associate-*l/99.0%
associate-/r/99.1%
remove-double-neg99.1%
unsub-neg99.1%
div-sub92.1%
*-lft-identity92.1%
associate-*l/92.1%
lft-mult-inverse99.1%
sub-neg99.1%
distribute-frac-neg99.1%
remove-double-neg99.1%
div-exp100.0%
Simplified100.0%
Taylor expanded in a around 0 96.7%
Final simplification97.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.2%
*-lft-identity99.2%
associate-*l/99.2%
associate-/r/99.2%
remove-double-neg99.2%
unsub-neg99.2%
div-sub77.3%
*-lft-identity77.3%
associate-*l/77.3%
lft-mult-inverse99.2%
sub-neg99.2%
distribute-frac-neg99.2%
remove-double-neg99.2%
div-exp100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (a b)
:precision binary64
(if (<= b 4e+67)
(/
1.0
(+
2.0
(*
a
(+
(*
a
(+
0.5
(*
a
(-
(* a (+ 0.041666666666666664 (* a -0.008333333333333333)))
0.16666666666666666))))
-1.0))))
(/
1.0
(+
2.0
(*
b
(+
1.0
(*
b
(+ 0.5 (* b (+ 0.16666666666666666 (* b 0.041666666666666664)))))))))))
double code(double a, double b) {
double tmp;
if (b <= 4e+67) {
tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * ((a * (0.041666666666666664 + (a * -0.008333333333333333))) - 0.16666666666666666)))) + -1.0)));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * (0.16666666666666666 + (b * 0.041666666666666664))))))));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 4d+67) then
tmp = 1.0d0 / (2.0d0 + (a * ((a * (0.5d0 + (a * ((a * (0.041666666666666664d0 + (a * (-0.008333333333333333d0)))) - 0.16666666666666666d0)))) + (-1.0d0))))
else
tmp = 1.0d0 / (2.0d0 + (b * (1.0d0 + (b * (0.5d0 + (b * (0.16666666666666666d0 + (b * 0.041666666666666664d0))))))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 4e+67) {
tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * ((a * (0.041666666666666664 + (a * -0.008333333333333333))) - 0.16666666666666666)))) + -1.0)));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * (0.16666666666666666 + (b * 0.041666666666666664))))))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 4e+67: tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * ((a * (0.041666666666666664 + (a * -0.008333333333333333))) - 0.16666666666666666)))) + -1.0))) else: tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * (0.16666666666666666 + (b * 0.041666666666666664)))))))) return tmp
function code(a, b) tmp = 0.0 if (b <= 4e+67) tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(Float64(a * Float64(0.5 + Float64(a * Float64(Float64(a * Float64(0.041666666666666664 + Float64(a * -0.008333333333333333))) - 0.16666666666666666)))) + -1.0)))); else tmp = Float64(1.0 / Float64(2.0 + Float64(b * Float64(1.0 + Float64(b * Float64(0.5 + Float64(b * Float64(0.16666666666666666 + Float64(b * 0.041666666666666664))))))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 4e+67) tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * ((a * (0.041666666666666664 + (a * -0.008333333333333333))) - 0.16666666666666666)))) + -1.0))); else tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * (0.16666666666666666 + (b * 0.041666666666666664)))))))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 4e+67], N[(1.0 / N[(2.0 + N[(a * N[(N[(a * N[(0.5 + N[(a * N[(N[(a * N[(0.041666666666666664 + N[(a * -0.008333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision]), $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 * N[(0.16666666666666666 + N[(b * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4 \cdot 10^{+67}:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(a \cdot \left(0.5 + a \cdot \left(a \cdot \left(0.041666666666666664 + a \cdot -0.008333333333333333\right) - 0.16666666666666666\right)\right) + -1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + b \cdot \left(1 + b \cdot \left(0.5 + b \cdot \left(0.16666666666666666 + b \cdot 0.041666666666666664\right)\right)\right)}\\
\end{array}
\end{array}
if b < 3.99999999999999993e67Initial program 98.9%
*-lft-identity98.9%
associate-*l/98.9%
associate-/r/98.9%
remove-double-neg98.9%
unsub-neg98.9%
div-sub78.6%
*-lft-identity78.6%
associate-*l/78.6%
lft-mult-inverse98.9%
sub-neg98.9%
distribute-frac-neg98.9%
remove-double-neg98.9%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 74.0%
Taylor expanded in a around 0 70.0%
if 3.99999999999999993e67 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub73.9%
*-lft-identity73.9%
associate-*l/73.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 94.8%
*-commutative94.8%
Simplified94.8%
Final simplification76.7%
(FPCore (a b)
:precision binary64
(if (<= b 1.35e+48)
(/
1.0
(+
2.0
(*
a
(+
(*
a
(+
0.5
(*
a
(-
(* a (+ 0.041666666666666664 (* a -0.008333333333333333)))
0.16666666666666666))))
-1.0))))
(/
1.0
(+
2.0
(*
b
(+
1.0
(*
b
(+
0.5
(*
b
(+
0.16666666666666666
(* b (+ 0.041666666666666664 (* b 0.008333333333333333)))))))))))))
double code(double a, double b) {
double tmp;
if (b <= 1.35e+48) {
tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * ((a * (0.041666666666666664 + (a * -0.008333333333333333))) - 0.16666666666666666)))) + -1.0)));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * (0.16666666666666666 + (b * (0.041666666666666664 + (b * 0.008333333333333333))))))))));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 1.35d+48) then
tmp = 1.0d0 / (2.0d0 + (a * ((a * (0.5d0 + (a * ((a * (0.041666666666666664d0 + (a * (-0.008333333333333333d0)))) - 0.16666666666666666d0)))) + (-1.0d0))))
else
tmp = 1.0d0 / (2.0d0 + (b * (1.0d0 + (b * (0.5d0 + (b * (0.16666666666666666d0 + (b * (0.041666666666666664d0 + (b * 0.008333333333333333d0))))))))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 1.35e+48) {
tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * ((a * (0.041666666666666664 + (a * -0.008333333333333333))) - 0.16666666666666666)))) + -1.0)));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * (0.16666666666666666 + (b * (0.041666666666666664 + (b * 0.008333333333333333))))))))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 1.35e+48: tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * ((a * (0.041666666666666664 + (a * -0.008333333333333333))) - 0.16666666666666666)))) + -1.0))) else: tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * (0.16666666666666666 + (b * (0.041666666666666664 + (b * 0.008333333333333333)))))))))) return tmp
function code(a, b) tmp = 0.0 if (b <= 1.35e+48) tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(Float64(a * Float64(0.5 + Float64(a * Float64(Float64(a * Float64(0.041666666666666664 + Float64(a * -0.008333333333333333))) - 0.16666666666666666)))) + -1.0)))); else tmp = Float64(1.0 / Float64(2.0 + Float64(b * Float64(1.0 + Float64(b * Float64(0.5 + Float64(b * Float64(0.16666666666666666 + Float64(b * Float64(0.041666666666666664 + Float64(b * 0.008333333333333333))))))))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 1.35e+48) tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * ((a * (0.041666666666666664 + (a * -0.008333333333333333))) - 0.16666666666666666)))) + -1.0))); else tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * (0.16666666666666666 + (b * (0.041666666666666664 + (b * 0.008333333333333333)))))))))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 1.35e+48], N[(1.0 / N[(2.0 + N[(a * N[(N[(a * N[(0.5 + N[(a * N[(N[(a * N[(0.041666666666666664 + N[(a * -0.008333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision]), $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 * N[(0.16666666666666666 + N[(b * N[(0.041666666666666664 + N[(b * 0.008333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.35 \cdot 10^{+48}:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(a \cdot \left(0.5 + a \cdot \left(a \cdot \left(0.041666666666666664 + a \cdot -0.008333333333333333\right) - 0.16666666666666666\right)\right) + -1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + b \cdot \left(1 + b \cdot \left(0.5 + b \cdot \left(0.16666666666666666 + b \cdot \left(0.041666666666666664 + b \cdot 0.008333333333333333\right)\right)\right)\right)}\\
\end{array}
\end{array}
if b < 1.35000000000000002e48Initial program 98.9%
*-lft-identity98.9%
associate-*l/98.9%
associate-/r/98.9%
remove-double-neg98.9%
unsub-neg98.9%
div-sub79.1%
*-lft-identity79.1%
associate-*l/79.1%
lft-mult-inverse98.9%
sub-neg98.9%
distribute-frac-neg98.9%
remove-double-neg98.9%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 74.9%
Taylor expanded in a around 0 71.3%
if 1.35000000000000002e48 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub73.0%
*-lft-identity73.0%
associate-*l/73.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 96.3%
*-commutative96.3%
Simplified96.3%
Final simplification78.5%
(FPCore (a b)
:precision binary64
(if (<= b 1.35e+48)
(/
1.0
(+
2.0
(*
a
(+
(* a (+ 0.5 (* a (- (* a 0.041666666666666664) 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 <= 1.35e+48) {
tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * ((a * 0.041666666666666664) - 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 <= 1.35d+48) then
tmp = 1.0d0 / (2.0d0 + (a * ((a * (0.5d0 + (a * ((a * 0.041666666666666664d0) - 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 <= 1.35e+48) {
tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * ((a * 0.041666666666666664) - 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 <= 1.35e+48: tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * ((a * 0.041666666666666664) - 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 <= 1.35e+48) tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(Float64(a * Float64(0.5 + Float64(a * Float64(Float64(a * 0.041666666666666664) - 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 <= 1.35e+48) tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * ((a * 0.041666666666666664) - 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, 1.35e+48], N[(1.0 / N[(2.0 + N[(a * N[(N[(a * N[(0.5 + N[(a * N[(N[(a * 0.041666666666666664), $MachinePrecision] - 0.16666666666666666), $MachinePrecision]), $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 1.35 \cdot 10^{+48}:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(a \cdot \left(0.5 + a \cdot \left(a \cdot 0.041666666666666664 - 0.16666666666666666\right)\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 < 1.35000000000000002e48Initial program 98.9%
*-lft-identity98.9%
associate-*l/98.9%
associate-/r/98.9%
remove-double-neg98.9%
unsub-neg98.9%
div-sub79.1%
*-lft-identity79.1%
associate-*l/79.1%
lft-mult-inverse98.9%
sub-neg98.9%
distribute-frac-neg98.9%
remove-double-neg98.9%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 74.9%
Taylor expanded in a around 0 71.2%
if 1.35000000000000002e48 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub73.0%
*-lft-identity73.0%
associate-*l/73.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 86.1%
*-commutative86.1%
Simplified86.1%
Final simplification75.5%
(FPCore (a b)
:precision binary64
(if (<= b 1.35e+48)
(/
1.0
(+
2.0
(*
a
(+
(* a (+ 0.5 (* a (- (* a 0.041666666666666664) 0.16666666666666666))))
-1.0))))
(/
1.0
(+
2.0
(*
b
(+
1.0
(*
b
(+ 0.5 (* b (+ 0.16666666666666666 (* b 0.041666666666666664)))))))))))
double code(double a, double b) {
double tmp;
if (b <= 1.35e+48) {
tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * ((a * 0.041666666666666664) - 0.16666666666666666)))) + -1.0)));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * (0.16666666666666666 + (b * 0.041666666666666664))))))));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 1.35d+48) then
tmp = 1.0d0 / (2.0d0 + (a * ((a * (0.5d0 + (a * ((a * 0.041666666666666664d0) - 0.16666666666666666d0)))) + (-1.0d0))))
else
tmp = 1.0d0 / (2.0d0 + (b * (1.0d0 + (b * (0.5d0 + (b * (0.16666666666666666d0 + (b * 0.041666666666666664d0))))))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 1.35e+48) {
tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * ((a * 0.041666666666666664) - 0.16666666666666666)))) + -1.0)));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * (0.16666666666666666 + (b * 0.041666666666666664))))))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 1.35e+48: tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * ((a * 0.041666666666666664) - 0.16666666666666666)))) + -1.0))) else: tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * (0.16666666666666666 + (b * 0.041666666666666664)))))))) return tmp
function code(a, b) tmp = 0.0 if (b <= 1.35e+48) tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(Float64(a * Float64(0.5 + Float64(a * Float64(Float64(a * 0.041666666666666664) - 0.16666666666666666)))) + -1.0)))); else tmp = Float64(1.0 / Float64(2.0 + Float64(b * Float64(1.0 + Float64(b * Float64(0.5 + Float64(b * Float64(0.16666666666666666 + Float64(b * 0.041666666666666664))))))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 1.35e+48) tmp = 1.0 / (2.0 + (a * ((a * (0.5 + (a * ((a * 0.041666666666666664) - 0.16666666666666666)))) + -1.0))); else tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * (0.16666666666666666 + (b * 0.041666666666666664)))))))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 1.35e+48], N[(1.0 / N[(2.0 + N[(a * N[(N[(a * N[(0.5 + N[(a * N[(N[(a * 0.041666666666666664), $MachinePrecision] - 0.16666666666666666), $MachinePrecision]), $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 * N[(0.16666666666666666 + N[(b * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.35 \cdot 10^{+48}:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(a \cdot \left(0.5 + a \cdot \left(a \cdot 0.041666666666666664 - 0.16666666666666666\right)\right) + -1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + b \cdot \left(1 + b \cdot \left(0.5 + b \cdot \left(0.16666666666666666 + b \cdot 0.041666666666666664\right)\right)\right)}\\
\end{array}
\end{array}
if b < 1.35000000000000002e48Initial program 98.9%
*-lft-identity98.9%
associate-*l/98.9%
associate-/r/98.9%
remove-double-neg98.9%
unsub-neg98.9%
div-sub79.1%
*-lft-identity79.1%
associate-*l/79.1%
lft-mult-inverse98.9%
sub-neg98.9%
distribute-frac-neg98.9%
remove-double-neg98.9%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 74.9%
Taylor expanded in a around 0 71.2%
if 1.35000000000000002e48 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub73.0%
*-lft-identity73.0%
associate-*l/73.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 88.9%
*-commutative88.9%
Simplified88.9%
Final simplification76.3%
(FPCore (a b) :precision binary64 (if (<= b 1.85e+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 <= 1.85e+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 <= 1.85d+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 <= 1.85e+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 <= 1.85e+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 <= 1.85e+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 <= 1.85e+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, 1.85e+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 1.85 \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 < 1.8499999999999999e127Initial program 99.0%
*-lft-identity99.0%
associate-*l/99.0%
associate-/r/99.0%
remove-double-neg99.0%
unsub-neg99.0%
div-sub79.0%
*-lft-identity79.0%
associate-*l/79.0%
lft-mult-inverse99.0%
sub-neg99.0%
distribute-frac-neg99.0%
remove-double-neg99.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 70.4%
Taylor expanded in a around 0 63.2%
if 1.8499999999999999e127 < 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.4%
*-lft-identity71.4%
associate-*l/71.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 95.1%
*-commutative95.1%
Simplified95.1%
Final simplification70.2%
(FPCore (a b) :precision binary64 (if (<= b 1.1e+48) (/ 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 <= 1.1e+48) {
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 <= 1.1d+48) 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 <= 1.1e+48) {
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 <= 1.1e+48: 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 <= 1.1e+48) 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 <= 1.1e+48) 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, 1.1e+48], 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 1.1 \cdot 10^{+48}:\\
\;\;\;\;\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 < 1.1e48Initial program 98.9%
*-lft-identity98.9%
associate-*l/98.9%
associate-/r/98.9%
remove-double-neg98.9%
unsub-neg98.9%
div-sub79.1%
*-lft-identity79.1%
associate-*l/79.1%
lft-mult-inverse98.9%
sub-neg98.9%
distribute-frac-neg98.9%
remove-double-neg98.9%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 74.9%
Taylor expanded in a around 0 68.6%
if 1.1e48 < b Initial program 100.0%
*-lft-identity100.0%
associate-*l/100.0%
associate-/r/100.0%
remove-double-neg100.0%
unsub-neg100.0%
div-sub73.0%
*-lft-identity73.0%
associate-*l/73.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 86.1%
*-commutative86.1%
Simplified86.1%
Final simplification73.6%
(FPCore (a b) :precision binary64 (if (<= b 1.85e+127) (/ 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 <= 1.85e+127) {
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 <= 1.85d+127) 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 <= 1.85e+127) {
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 <= 1.85e+127: 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 <= 1.85e+127) 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 <= 1.85e+127) 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, 1.85e+127], 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 1.85 \cdot 10^{+127}:\\
\;\;\;\;\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 < 1.8499999999999999e127Initial program 99.0%
*-lft-identity99.0%
associate-*l/99.0%
associate-/r/99.0%
remove-double-neg99.0%
unsub-neg99.0%
div-sub79.0%
*-lft-identity79.0%
associate-*l/79.0%
lft-mult-inverse99.0%
sub-neg99.0%
distribute-frac-neg99.0%
remove-double-neg99.0%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 70.4%
Taylor expanded in a around 0 59.3%
if 1.8499999999999999e127 < 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.4%
*-lft-identity71.4%
associate-*l/71.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 95.1%
*-commutative95.1%
Simplified95.1%
Final simplification67.1%
(FPCore (a b) :precision binary64 (/ 1.0 (+ 2.0 (* a (+ (* a 0.5) -1.0)))))
double code(double a, double b) {
return 1.0 / (2.0 + (a * ((a * 0.5) + -1.0)));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 1.0d0 / (2.0d0 + (a * ((a * 0.5d0) + (-1.0d0))))
end function
public static double code(double a, double b) {
return 1.0 / (2.0 + (a * ((a * 0.5) + -1.0)));
}
def code(a, b): return 1.0 / (2.0 + (a * ((a * 0.5) + -1.0)))
function code(a, b) return Float64(1.0 / Float64(2.0 + Float64(a * Float64(Float64(a * 0.5) + -1.0)))) end
function tmp = code(a, b) tmp = 1.0 / (2.0 + (a * ((a * 0.5) + -1.0))); end
code[a_, b_] := N[(1.0 / N[(2.0 + N[(a * N[(N[(a * 0.5), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{2 + a \cdot \left(a \cdot 0.5 + -1\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-sub77.3%
*-lft-identity77.3%
associate-*l/77.3%
lft-mult-inverse99.2%
sub-neg99.2%
distribute-frac-neg99.2%
remove-double-neg99.2%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 61.7%
Taylor expanded in a around 0 50.0%
Final simplification50.0%
(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.2%
*-lft-identity99.2%
associate-*l/99.2%
associate-/r/99.2%
remove-double-neg99.2%
unsub-neg99.2%
div-sub77.3%
*-lft-identity77.3%
associate-*l/77.3%
lft-mult-inverse99.2%
sub-neg99.2%
distribute-frac-neg99.2%
remove-double-neg99.2%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 61.7%
Taylor expanded in a around 0 40.1%
*-commutative40.1%
Simplified40.1%
Final simplification40.1%
(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-sub77.3%
*-lft-identity77.3%
associate-*l/77.3%
lft-mult-inverse99.2%
sub-neg99.2%
distribute-frac-neg99.2%
remove-double-neg99.2%
div-exp100.0%
Simplified100.0%
Taylor expanded in b around 0 61.7%
Taylor expanded in a around 0 40.6%
neg-mul-140.6%
unsub-neg40.6%
Simplified40.6%
Final simplification40.6%
(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-sub77.3%
*-lft-identity77.3%
associate-*l/77.3%
lft-mult-inverse99.2%
sub-neg99.2%
distribute-frac-neg99.2%
remove-double-neg99.2%
div-exp100.0%
Simplified100.0%
Taylor expanded in a around 0 87.0%
Taylor expanded in b around 0 39.8%
Final simplification39.8%
(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 2024053
(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))))