
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b))))
double code(double a, double b) {
return exp(a) / (exp(a) + exp(b));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = exp(a) / (exp(a) + exp(b))
end function
public static double code(double a, double b) {
return Math.exp(a) / (Math.exp(a) + Math.exp(b));
}
def code(a, b): return math.exp(a) / (math.exp(a) + math.exp(b))
function code(a, b) return Float64(exp(a) / Float64(exp(a) + exp(b))) end
function tmp = code(a, b) tmp = exp(a) / (exp(a) + exp(b)); end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{a}}{e^{a} + e^{b}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b))))
double code(double a, double b) {
return exp(a) / (exp(a) + exp(b));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = exp(a) / (exp(a) + exp(b))
end function
public static double code(double a, double b) {
return Math.exp(a) / (Math.exp(a) + Math.exp(b));
}
def code(a, b): return math.exp(a) / (math.exp(a) + math.exp(b))
function code(a, b) return Float64(exp(a) / Float64(exp(a) + exp(b))) end
function tmp = code(a, b) tmp = exp(a) / (exp(a) + exp(b)); end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{a}}{e^{a} + e^{b}}
\end{array}
(FPCore (a b) :precision binary64 (/ 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}
Initial program 98.0%
*-lft-identity98.0%
associate-/l*98.0%
remove-double-div98.0%
exp-neg98.0%
associate-/r/98.0%
/-rgt-identity98.0%
*-commutative98.0%
distribute-rgt-in69.9%
exp-neg69.9%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (a b) :precision binary64 (if (or (<= a -0.022) (not (<= a 0.00018))) (/ 1.0 (+ 1.0 (exp (- a)))) (/ 1.0 (+ 1.0 (exp b)))))
double code(double a, double b) {
double tmp;
if ((a <= -0.022) || !(a <= 0.00018)) {
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 <= (-0.022d0)) .or. (.not. (a <= 0.00018d0))) 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 <= -0.022) || !(a <= 0.00018)) {
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 <= -0.022) or not (a <= 0.00018): 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 <= -0.022) || !(a <= 0.00018)) 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 <= -0.022) || ~((a <= 0.00018))) tmp = 1.0 / (1.0 + exp(-a)); else tmp = 1.0 / (1.0 + exp(b)); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -0.022], N[Not[LessEqual[a, 0.00018]], $MachinePrecision]], 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 -0.022 \lor \neg \left(a \leq 0.00018\right):\\
\;\;\;\;\frac{1}{1 + e^{-a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + e^{b}}\\
\end{array}
\end{array}
if a < -0.021999999999999999 or 1.80000000000000011e-4 < a Initial program 93.7%
*-lft-identity93.7%
associate-/l*93.7%
remove-double-div93.7%
exp-neg93.7%
associate-/r/93.7%
/-rgt-identity93.7%
*-commutative93.7%
distribute-rgt-in2.5%
exp-neg2.5%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in b around 0 100.0%
if -0.021999999999999999 < a < 1.80000000000000011e-4Initial program 100.0%
*-lft-identity100.0%
associate-/l*100.0%
remove-double-div100.0%
exp-neg100.0%
associate-/r/100.0%
/-rgt-identity100.0%
*-commutative100.0%
distribute-rgt-in100.0%
exp-neg100.0%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in a around 0 99.9%
Final simplification99.9%
(FPCore (a b)
:precision binary64
(if (<= a -1.35e+154)
(/ 2.0 (* a a))
(if (<= a -1.6e+102)
(/ (+ (* a a) (* a 2.0)) (* (- a) (* a a)))
(/ 1.0 (+ 1.0 (exp b))))))
double code(double a, double b) {
double tmp;
if (a <= -1.35e+154) {
tmp = 2.0 / (a * a);
} else if (a <= -1.6e+102) {
tmp = ((a * a) + (a * 2.0)) / (-a * (a * 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 <= (-1.35d+154)) then
tmp = 2.0d0 / (a * a)
else if (a <= (-1.6d+102)) then
tmp = ((a * a) + (a * 2.0d0)) / (-a * (a * 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 <= -1.35e+154) {
tmp = 2.0 / (a * a);
} else if (a <= -1.6e+102) {
tmp = ((a * a) + (a * 2.0)) / (-a * (a * a));
} else {
tmp = 1.0 / (1.0 + Math.exp(b));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -1.35e+154: tmp = 2.0 / (a * a) elif a <= -1.6e+102: tmp = ((a * a) + (a * 2.0)) / (-a * (a * a)) else: tmp = 1.0 / (1.0 + math.exp(b)) return tmp
function code(a, b) tmp = 0.0 if (a <= -1.35e+154) tmp = Float64(2.0 / Float64(a * a)); elseif (a <= -1.6e+102) tmp = Float64(Float64(Float64(a * a) + Float64(a * 2.0)) / Float64(Float64(-a) * Float64(a * 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 <= -1.35e+154) tmp = 2.0 / (a * a); elseif (a <= -1.6e+102) tmp = ((a * a) + (a * 2.0)) / (-a * (a * a)); else tmp = 1.0 / (1.0 + exp(b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -1.35e+154], N[(2.0 / N[(a * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, -1.6e+102], N[(N[(N[(a * a), $MachinePrecision] + N[(a * 2.0), $MachinePrecision]), $MachinePrecision] / N[((-a) * N[(a * 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 -1.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{2}{a \cdot a}\\
\mathbf{elif}\;a \leq -1.6 \cdot 10^{+102}:\\
\;\;\;\;\frac{a \cdot a + a \cdot 2}{\left(-a\right) \cdot \left(a \cdot a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + e^{b}}\\
\end{array}
\end{array}
if a < -1.35000000000000003e154Initial program 100.0%
*-lft-identity100.0%
associate-/l*100.0%
remove-double-div100.0%
exp-neg100.0%
associate-/r/100.0%
/-rgt-identity100.0%
*-commutative100.0%
distribute-rgt-in0.0%
exp-neg0.0%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in b around 0 100.0%
Taylor expanded in a around 0 100.0%
+-commutative100.0%
neg-mul-1100.0%
unsub-neg100.0%
unpow2100.0%
associate-*r*100.0%
Simplified100.0%
Taylor expanded in a around inf 100.0%
unpow2100.0%
Simplified100.0%
if -1.35000000000000003e154 < a < -1.6e102Initial program 100.0%
*-lft-identity100.0%
associate-/l*100.0%
remove-double-div100.0%
exp-neg100.0%
associate-/r/100.0%
/-rgt-identity100.0%
*-commutative100.0%
distribute-rgt-in0.0%
exp-neg0.0%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in b around 0 100.0%
Taylor expanded in a around 0 4.3%
neg-mul-14.3%
unsub-neg4.3%
Simplified4.3%
Taylor expanded in a around inf 4.3%
distribute-neg-in4.3%
unsub-neg4.3%
distribute-neg-frac4.3%
metadata-eval4.3%
associate-*r/4.3%
metadata-eval4.3%
unpow24.3%
associate-/r*4.3%
Simplified4.3%
frac-2neg4.3%
metadata-eval4.3%
associate-/l/4.3%
frac-sub89.3%
*-un-lft-identity89.3%
Applied egg-rr89.3%
if -1.6e102 < a Initial program 97.6%
*-lft-identity97.6%
associate-/l*97.6%
remove-double-div97.5%
exp-neg97.5%
associate-/r/97.6%
/-rgt-identity97.6%
*-commutative97.6%
distribute-rgt-in86.4%
exp-neg86.4%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in a around 0 90.7%
Final simplification92.1%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* 0.5 (* b b))))
(if (<= b -2.7)
1.0
(if (<= b 7.6e+62)
(/ 1.0 (+ 2.0 (* a (+ (* a 0.5) -1.0))))
(if (<= b 1.35e+154) (/ (- t_0 b) (* b t_0)) (/ -2.0 (* b b)))))))
double code(double a, double b) {
double t_0 = 0.5 * (b * b);
double tmp;
if (b <= -2.7) {
tmp = 1.0;
} else if (b <= 7.6e+62) {
tmp = 1.0 / (2.0 + (a * ((a * 0.5) + -1.0)));
} else if (b <= 1.35e+154) {
tmp = (t_0 - b) / (b * t_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) :: t_0
real(8) :: tmp
t_0 = 0.5d0 * (b * b)
if (b <= (-2.7d0)) then
tmp = 1.0d0
else if (b <= 7.6d+62) then
tmp = 1.0d0 / (2.0d0 + (a * ((a * 0.5d0) + (-1.0d0))))
else if (b <= 1.35d+154) then
tmp = (t_0 - b) / (b * t_0)
else
tmp = (-2.0d0) / (b * b)
end if
code = tmp
end function
public static double code(double a, double b) {
double t_0 = 0.5 * (b * b);
double tmp;
if (b <= -2.7) {
tmp = 1.0;
} else if (b <= 7.6e+62) {
tmp = 1.0 / (2.0 + (a * ((a * 0.5) + -1.0)));
} else if (b <= 1.35e+154) {
tmp = (t_0 - b) / (b * t_0);
} else {
tmp = -2.0 / (b * b);
}
return tmp;
}
def code(a, b): t_0 = 0.5 * (b * b) tmp = 0 if b <= -2.7: tmp = 1.0 elif b <= 7.6e+62: tmp = 1.0 / (2.0 + (a * ((a * 0.5) + -1.0))) elif b <= 1.35e+154: tmp = (t_0 - b) / (b * t_0) else: tmp = -2.0 / (b * b) return tmp
function code(a, b) t_0 = Float64(0.5 * Float64(b * b)) tmp = 0.0 if (b <= -2.7) tmp = 1.0; elseif (b <= 7.6e+62) tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(Float64(a * 0.5) + -1.0)))); elseif (b <= 1.35e+154) tmp = Float64(Float64(t_0 - b) / Float64(b * t_0)); else tmp = Float64(-2.0 / Float64(b * b)); end return tmp end
function tmp_2 = code(a, b) t_0 = 0.5 * (b * b); tmp = 0.0; if (b <= -2.7) tmp = 1.0; elseif (b <= 7.6e+62) tmp = 1.0 / (2.0 + (a * ((a * 0.5) + -1.0))); elseif (b <= 1.35e+154) tmp = (t_0 - b) / (b * t_0); else tmp = -2.0 / (b * b); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(0.5 * N[(b * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -2.7], 1.0, If[LessEqual[b, 7.6e+62], N[(1.0 / N[(2.0 + N[(a * N[(N[(a * 0.5), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.35e+154], N[(N[(t$95$0 - b), $MachinePrecision] / N[(b * t$95$0), $MachinePrecision]), $MachinePrecision], N[(-2.0 / N[(b * b), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(b \cdot b\right)\\
\mathbf{if}\;b \leq -2.7:\\
\;\;\;\;1\\
\mathbf{elif}\;b \leq 7.6 \cdot 10^{+62}:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(a \cdot 0.5 + -1\right)}\\
\mathbf{elif}\;b \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{t_0 - b}{b \cdot t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2}{b \cdot b}\\
\end{array}
\end{array}
if b < -2.7000000000000002Initial program 97.8%
*-lft-identity97.8%
associate-/l*97.8%
remove-double-div97.7%
exp-neg97.7%
associate-/r/97.8%
/-rgt-identity97.8%
*-commutative97.8%
distribute-rgt-in97.8%
exp-neg97.8%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
add-exp-log100.0%
log-rec100.0%
log1p-udef100.0%
Applied egg-rr100.0%
Taylor expanded in a around 0 100.0%
log1p-def100.0%
Simplified100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
exp-neg100.0%
inv-pow100.0%
pow-exp100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
sqr-neg100.0%
sqrt-unprod100.0%
add-sqr-sqrt100.0%
add-log-exp100.0%
pow-to-exp100.0%
pow1100.0%
pow-prod-up100.0%
metadata-eval100.0%
Applied egg-rr100.0%
if -2.7000000000000002 < b < 7.59999999999999967e62Initial program 97.4%
*-lft-identity97.4%
associate-/l*97.4%
remove-double-div97.4%
exp-neg97.4%
associate-/r/97.4%
/-rgt-identity97.4%
*-commutative97.4%
distribute-rgt-in62.8%
exp-neg62.8%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in b around 0 95.3%
Taylor expanded in a around 0 77.9%
+-commutative77.9%
neg-mul-177.9%
unsub-neg77.9%
unpow277.9%
associate-*r*77.9%
Simplified77.9%
*-un-lft-identity77.9%
distribute-rgt-out--77.9%
Applied egg-rr77.9%
if 7.59999999999999967e62 < b < 1.35000000000000003e154Initial program 100.0%
*-lft-identity100.0%
associate-/l*100.0%
remove-double-div100.0%
exp-neg100.0%
associate-/r/100.0%
/-rgt-identity100.0%
*-commutative100.0%
distribute-rgt-in76.0%
exp-neg76.0%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 4.2%
+-commutative4.2%
Simplified4.2%
Taylor expanded in b around inf 4.2%
associate-*r/4.2%
metadata-eval4.2%
unpow24.2%
Simplified4.2%
clear-num4.2%
frac-sub69.2%
*-un-lft-identity69.2%
div-inv69.2%
metadata-eval69.2%
*-commutative69.2%
*-un-lft-identity69.2%
div-inv69.2%
metadata-eval69.2%
Applied egg-rr69.2%
if 1.35000000000000003e154 < b Initial program 100.0%
*-lft-identity100.0%
associate-/l*100.0%
remove-double-div100.0%
exp-neg100.0%
associate-/r/100.0%
/-rgt-identity100.0%
*-commutative100.0%
distribute-rgt-in60.0%
exp-neg60.0%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 7.3%
+-commutative7.3%
Simplified7.3%
Taylor expanded in b around inf 7.3%
associate-*r/7.3%
metadata-eval7.3%
unpow27.3%
Simplified7.3%
Taylor expanded in b around 0 100.0%
unpow2100.0%
Simplified100.0%
Final simplification83.5%
(FPCore (a b)
:precision binary64
(if (<= b -4.4)
1.0
(if (<= b 2.6e+141)
(/ 1.0 (+ 2.0 (* a (+ (* a 0.5) -1.0))))
(/ -2.0 (* b b)))))
double code(double a, double b) {
double tmp;
if (b <= -4.4) {
tmp = 1.0;
} else if (b <= 2.6e+141) {
tmp = 1.0 / (2.0 + (a * ((a * 0.5) + -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 <= (-4.4d0)) then
tmp = 1.0d0
else if (b <= 2.6d+141) then
tmp = 1.0d0 / (2.0d0 + (a * ((a * 0.5d0) + (-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 <= -4.4) {
tmp = 1.0;
} else if (b <= 2.6e+141) {
tmp = 1.0 / (2.0 + (a * ((a * 0.5) + -1.0)));
} else {
tmp = -2.0 / (b * b);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -4.4: tmp = 1.0 elif b <= 2.6e+141: tmp = 1.0 / (2.0 + (a * ((a * 0.5) + -1.0))) else: tmp = -2.0 / (b * b) return tmp
function code(a, b) tmp = 0.0 if (b <= -4.4) tmp = 1.0; elseif (b <= 2.6e+141) tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(Float64(a * 0.5) + -1.0)))); else tmp = Float64(-2.0 / Float64(b * b)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= -4.4) tmp = 1.0; elseif (b <= 2.6e+141) tmp = 1.0 / (2.0 + (a * ((a * 0.5) + -1.0))); else tmp = -2.0 / (b * b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -4.4], 1.0, If[LessEqual[b, 2.6e+141], N[(1.0 / N[(2.0 + N[(a * N[(N[(a * 0.5), $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 -4.4:\\
\;\;\;\;1\\
\mathbf{elif}\;b \leq 2.6 \cdot 10^{+141}:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(a \cdot 0.5 + -1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2}{b \cdot b}\\
\end{array}
\end{array}
if b < -4.4000000000000004Initial program 97.8%
*-lft-identity97.8%
associate-/l*97.8%
remove-double-div97.7%
exp-neg97.7%
associate-/r/97.8%
/-rgt-identity97.8%
*-commutative97.8%
distribute-rgt-in97.8%
exp-neg97.8%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
add-exp-log100.0%
log-rec100.0%
log1p-udef100.0%
Applied egg-rr100.0%
Taylor expanded in a around 0 100.0%
log1p-def100.0%
Simplified100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
exp-neg100.0%
inv-pow100.0%
pow-exp100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
sqr-neg100.0%
sqrt-unprod100.0%
add-sqr-sqrt100.0%
add-log-exp100.0%
pow-to-exp100.0%
pow1100.0%
pow-prod-up100.0%
metadata-eval100.0%
Applied egg-rr100.0%
if -4.4000000000000004 < b < 2.5999999999999999e141Initial program 97.7%
*-lft-identity97.7%
associate-/l*97.7%
remove-double-div97.7%
exp-neg97.7%
associate-/r/97.7%
/-rgt-identity97.7%
*-commutative97.7%
distribute-rgt-in63.6%
exp-neg63.6%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in b around 0 88.2%
Taylor expanded in a around 0 72.1%
+-commutative72.1%
neg-mul-172.1%
unsub-neg72.1%
unpow272.1%
associate-*r*72.1%
Simplified72.1%
*-un-lft-identity72.1%
distribute-rgt-out--72.1%
Applied egg-rr72.1%
if 2.5999999999999999e141 < b Initial program 100.0%
*-lft-identity100.0%
associate-/l*100.0%
remove-double-div100.0%
exp-neg100.0%
associate-/r/100.0%
/-rgt-identity100.0%
*-commutative100.0%
distribute-rgt-in65.7%
exp-neg65.7%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 6.9%
+-commutative6.9%
Simplified6.9%
Taylor expanded in b around inf 6.9%
associate-*r/6.9%
metadata-eval6.9%
unpow26.9%
Simplified6.9%
Taylor expanded in b around 0 87.4%
unpow287.4%
Simplified87.4%
Final simplification79.1%
(FPCore (a b)
:precision binary64
(if (<= b -5.5)
1.0
(if (<= b 2.65e+141)
(/ 1.0 (+ 2.0 (* a (+ (* a 0.5) -1.0))))
(/ 1.0 (+ (* 0.5 (* b b)) (+ b 2.0))))))
double code(double a, double b) {
double tmp;
if (b <= -5.5) {
tmp = 1.0;
} else if (b <= 2.65e+141) {
tmp = 1.0 / (2.0 + (a * ((a * 0.5) + -1.0)));
} else {
tmp = 1.0 / ((0.5 * (b * 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 <= (-5.5d0)) then
tmp = 1.0d0
else if (b <= 2.65d+141) then
tmp = 1.0d0 / (2.0d0 + (a * ((a * 0.5d0) + (-1.0d0))))
else
tmp = 1.0d0 / ((0.5d0 * (b * b)) + (b + 2.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= -5.5) {
tmp = 1.0;
} else if (b <= 2.65e+141) {
tmp = 1.0 / (2.0 + (a * ((a * 0.5) + -1.0)));
} else {
tmp = 1.0 / ((0.5 * (b * b)) + (b + 2.0));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -5.5: tmp = 1.0 elif b <= 2.65e+141: tmp = 1.0 / (2.0 + (a * ((a * 0.5) + -1.0))) else: tmp = 1.0 / ((0.5 * (b * b)) + (b + 2.0)) return tmp
function code(a, b) tmp = 0.0 if (b <= -5.5) tmp = 1.0; elseif (b <= 2.65e+141) tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(Float64(a * 0.5) + -1.0)))); else tmp = Float64(1.0 / Float64(Float64(0.5 * Float64(b * b)) + Float64(b + 2.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= -5.5) tmp = 1.0; elseif (b <= 2.65e+141) tmp = 1.0 / (2.0 + (a * ((a * 0.5) + -1.0))); else tmp = 1.0 / ((0.5 * (b * b)) + (b + 2.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -5.5], 1.0, If[LessEqual[b, 2.65e+141], N[(1.0 / N[(2.0 + N[(a * N[(N[(a * 0.5), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(0.5 * N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(b + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.5:\\
\;\;\;\;1\\
\mathbf{elif}\;b \leq 2.65 \cdot 10^{+141}:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(a \cdot 0.5 + -1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{0.5 \cdot \left(b \cdot b\right) + \left(b + 2\right)}\\
\end{array}
\end{array}
if b < -5.5Initial program 97.8%
*-lft-identity97.8%
associate-/l*97.8%
remove-double-div97.7%
exp-neg97.7%
associate-/r/97.8%
/-rgt-identity97.8%
*-commutative97.8%
distribute-rgt-in97.8%
exp-neg97.8%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
add-exp-log100.0%
log-rec100.0%
log1p-udef100.0%
Applied egg-rr100.0%
Taylor expanded in a around 0 100.0%
log1p-def100.0%
Simplified100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
exp-neg100.0%
inv-pow100.0%
pow-exp100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
sqr-neg100.0%
sqrt-unprod100.0%
add-sqr-sqrt100.0%
add-log-exp100.0%
pow-to-exp100.0%
pow1100.0%
pow-prod-up100.0%
metadata-eval100.0%
Applied egg-rr100.0%
if -5.5 < b < 2.65e141Initial program 97.7%
*-lft-identity97.7%
associate-/l*97.7%
remove-double-div97.7%
exp-neg97.7%
associate-/r/97.7%
/-rgt-identity97.7%
*-commutative97.7%
distribute-rgt-in63.6%
exp-neg63.6%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in b around 0 88.2%
Taylor expanded in a around 0 72.1%
+-commutative72.1%
neg-mul-172.1%
unsub-neg72.1%
unpow272.1%
associate-*r*72.1%
Simplified72.1%
*-un-lft-identity72.1%
distribute-rgt-out--72.1%
Applied egg-rr72.1%
if 2.65e141 < b Initial program 100.0%
*-lft-identity100.0%
associate-/l*100.0%
remove-double-div100.0%
exp-neg100.0%
associate-/r/100.0%
/-rgt-identity100.0%
*-commutative100.0%
distribute-rgt-in65.7%
exp-neg65.7%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 87.4%
associate-+r+87.4%
+-commutative87.4%
*-commutative87.4%
unpow287.4%
Simplified87.4%
Final simplification79.1%
(FPCore (a b) :precision binary64 (if (<= b -10.5) 1.0 (if (<= b 2.35e+141) (/ (+ a 2.0) (- 4.0 (* a a))) (/ -2.0 (* b b)))))
double code(double a, double b) {
double tmp;
if (b <= -10.5) {
tmp = 1.0;
} else if (b <= 2.35e+141) {
tmp = (a + 2.0) / (4.0 - (a * 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 <= (-10.5d0)) then
tmp = 1.0d0
else if (b <= 2.35d+141) then
tmp = (a + 2.0d0) / (4.0d0 - (a * 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 <= -10.5) {
tmp = 1.0;
} else if (b <= 2.35e+141) {
tmp = (a + 2.0) / (4.0 - (a * a));
} else {
tmp = -2.0 / (b * b);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -10.5: tmp = 1.0 elif b <= 2.35e+141: tmp = (a + 2.0) / (4.0 - (a * a)) else: tmp = -2.0 / (b * b) return tmp
function code(a, b) tmp = 0.0 if (b <= -10.5) tmp = 1.0; elseif (b <= 2.35e+141) tmp = Float64(Float64(a + 2.0) / Float64(4.0 - Float64(a * a))); else tmp = Float64(-2.0 / Float64(b * b)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= -10.5) tmp = 1.0; elseif (b <= 2.35e+141) tmp = (a + 2.0) / (4.0 - (a * a)); else tmp = -2.0 / (b * b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -10.5], 1.0, If[LessEqual[b, 2.35e+141], N[(N[(a + 2.0), $MachinePrecision] / N[(4.0 - N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 / N[(b * b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -10.5:\\
\;\;\;\;1\\
\mathbf{elif}\;b \leq 2.35 \cdot 10^{+141}:\\
\;\;\;\;\frac{a + 2}{4 - a \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2}{b \cdot b}\\
\end{array}
\end{array}
if b < -10.5Initial program 97.8%
*-lft-identity97.8%
associate-/l*97.8%
remove-double-div97.7%
exp-neg97.7%
associate-/r/97.8%
/-rgt-identity97.8%
*-commutative97.8%
distribute-rgt-in97.8%
exp-neg97.8%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
add-exp-log100.0%
log-rec100.0%
log1p-udef100.0%
Applied egg-rr100.0%
Taylor expanded in a around 0 100.0%
log1p-def100.0%
Simplified100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
exp-neg100.0%
inv-pow100.0%
pow-exp100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
sqr-neg100.0%
sqrt-unprod100.0%
add-sqr-sqrt100.0%
add-log-exp100.0%
pow-to-exp100.0%
pow1100.0%
pow-prod-up100.0%
metadata-eval100.0%
Applied egg-rr100.0%
if -10.5 < b < 2.3499999999999999e141Initial program 97.7%
*-lft-identity97.7%
associate-/l*97.7%
remove-double-div97.7%
exp-neg97.7%
associate-/r/97.7%
/-rgt-identity97.7%
*-commutative97.7%
distribute-rgt-in63.6%
exp-neg63.6%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in b around 0 88.2%
Taylor expanded in a around 0 53.1%
neg-mul-153.1%
unsub-neg53.1%
Simplified53.1%
flip--71.6%
associate-/r/71.6%
metadata-eval71.6%
Applied egg-rr71.6%
associate-*l/71.6%
*-lft-identity71.6%
Simplified71.6%
if 2.3499999999999999e141 < b Initial program 100.0%
*-lft-identity100.0%
associate-/l*100.0%
remove-double-div100.0%
exp-neg100.0%
associate-/r/100.0%
/-rgt-identity100.0%
*-commutative100.0%
distribute-rgt-in65.7%
exp-neg65.7%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 6.9%
+-commutative6.9%
Simplified6.9%
Taylor expanded in b around inf 6.9%
associate-*r/6.9%
metadata-eval6.9%
unpow26.9%
Simplified6.9%
Taylor expanded in b around 0 87.4%
unpow287.4%
Simplified87.4%
Final simplification78.8%
(FPCore (a b)
:precision binary64
(if (<= b -0.175)
1.0
(if (<= b 185.0)
(/ 1.0 (- 2.0 a))
(if (<= b 2.9e+139) (/ 2.0 (* a a)) (/ -2.0 (* b b))))))
double code(double a, double b) {
double tmp;
if (b <= -0.175) {
tmp = 1.0;
} else if (b <= 185.0) {
tmp = 1.0 / (2.0 - a);
} else if (b <= 2.9e+139) {
tmp = 2.0 / (a * 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 <= (-0.175d0)) then
tmp = 1.0d0
else if (b <= 185.0d0) then
tmp = 1.0d0 / (2.0d0 - a)
else if (b <= 2.9d+139) then
tmp = 2.0d0 / (a * 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 <= -0.175) {
tmp = 1.0;
} else if (b <= 185.0) {
tmp = 1.0 / (2.0 - a);
} else if (b <= 2.9e+139) {
tmp = 2.0 / (a * a);
} else {
tmp = -2.0 / (b * b);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -0.175: tmp = 1.0 elif b <= 185.0: tmp = 1.0 / (2.0 - a) elif b <= 2.9e+139: tmp = 2.0 / (a * a) else: tmp = -2.0 / (b * b) return tmp
function code(a, b) tmp = 0.0 if (b <= -0.175) tmp = 1.0; elseif (b <= 185.0) tmp = Float64(1.0 / Float64(2.0 - a)); elseif (b <= 2.9e+139) tmp = Float64(2.0 / Float64(a * a)); else tmp = Float64(-2.0 / Float64(b * b)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= -0.175) tmp = 1.0; elseif (b <= 185.0) tmp = 1.0 / (2.0 - a); elseif (b <= 2.9e+139) tmp = 2.0 / (a * a); else tmp = -2.0 / (b * b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -0.175], 1.0, If[LessEqual[b, 185.0], N[(1.0 / N[(2.0 - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.9e+139], N[(2.0 / N[(a * a), $MachinePrecision]), $MachinePrecision], N[(-2.0 / N[(b * b), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.175:\\
\;\;\;\;1\\
\mathbf{elif}\;b \leq 185:\\
\;\;\;\;\frac{1}{2 - a}\\
\mathbf{elif}\;b \leq 2.9 \cdot 10^{+139}:\\
\;\;\;\;\frac{2}{a \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2}{b \cdot b}\\
\end{array}
\end{array}
if b < -0.17499999999999999Initial program 97.8%
*-lft-identity97.8%
associate-/l*97.8%
remove-double-div97.7%
exp-neg97.7%
associate-/r/97.8%
/-rgt-identity97.8%
*-commutative97.8%
distribute-rgt-in97.8%
exp-neg97.8%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
add-exp-log100.0%
log-rec100.0%
log1p-udef100.0%
Applied egg-rr100.0%
Taylor expanded in a around 0 100.0%
log1p-def100.0%
Simplified100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
exp-neg100.0%
inv-pow100.0%
pow-exp100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
sqr-neg100.0%
sqrt-unprod100.0%
add-sqr-sqrt100.0%
add-log-exp100.0%
pow-to-exp100.0%
pow1100.0%
pow-prod-up100.0%
metadata-eval100.0%
Applied egg-rr100.0%
if -0.17499999999999999 < b < 185Initial program 97.2%
*-lft-identity97.2%
associate-/l*97.2%
remove-double-div97.2%
exp-neg97.2%
associate-/r/97.2%
/-rgt-identity97.2%
*-commutative97.2%
distribute-rgt-in63.9%
exp-neg63.9%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in b around 0 97.7%
Taylor expanded in a around 0 62.8%
neg-mul-162.8%
unsub-neg62.8%
Simplified62.8%
if 185 < b < 2.8999999999999999e139Initial program 100.0%
*-lft-identity100.0%
associate-/l*100.0%
remove-double-div100.0%
exp-neg100.0%
associate-/r/100.0%
/-rgt-identity100.0%
*-commutative100.0%
distribute-rgt-in62.1%
exp-neg62.1%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in b around 0 39.9%
Taylor expanded in a around 0 30.0%
+-commutative30.0%
neg-mul-130.0%
unsub-neg30.0%
unpow230.0%
associate-*r*30.0%
Simplified30.0%
Taylor expanded in a around inf 29.2%
unpow229.2%
Simplified29.2%
if 2.8999999999999999e139 < b Initial program 100.0%
*-lft-identity100.0%
associate-/l*100.0%
remove-double-div100.0%
exp-neg100.0%
associate-/r/100.0%
/-rgt-identity100.0%
*-commutative100.0%
distribute-rgt-in65.7%
exp-neg65.7%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 6.9%
+-commutative6.9%
Simplified6.9%
Taylor expanded in b around inf 6.9%
associate-*r/6.9%
metadata-eval6.9%
unpow26.9%
Simplified6.9%
Taylor expanded in b around 0 87.4%
unpow287.4%
Simplified87.4%
Final simplification68.9%
(FPCore (a b) :precision binary64 (if (<= b -1.55) 1.0 (if (<= b 2.9) (+ 0.5 (* b -0.25)) (/ -2.0 (* b b)))))
double code(double a, double b) {
double tmp;
if (b <= -1.55) {
tmp = 1.0;
} else if (b <= 2.9) {
tmp = 0.5 + (b * -0.25);
} 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 <= (-1.55d0)) then
tmp = 1.0d0
else if (b <= 2.9d0) then
tmp = 0.5d0 + (b * (-0.25d0))
else
tmp = (-2.0d0) / (b * b)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= -1.55) {
tmp = 1.0;
} else if (b <= 2.9) {
tmp = 0.5 + (b * -0.25);
} else {
tmp = -2.0 / (b * b);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -1.55: tmp = 1.0 elif b <= 2.9: tmp = 0.5 + (b * -0.25) else: tmp = -2.0 / (b * b) return tmp
function code(a, b) tmp = 0.0 if (b <= -1.55) tmp = 1.0; elseif (b <= 2.9) tmp = Float64(0.5 + Float64(b * -0.25)); else tmp = Float64(-2.0 / Float64(b * b)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= -1.55) tmp = 1.0; elseif (b <= 2.9) tmp = 0.5 + (b * -0.25); else tmp = -2.0 / (b * b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -1.55], 1.0, If[LessEqual[b, 2.9], N[(0.5 + N[(b * -0.25), $MachinePrecision]), $MachinePrecision], N[(-2.0 / N[(b * b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.55:\\
\;\;\;\;1\\
\mathbf{elif}\;b \leq 2.9:\\
\;\;\;\;0.5 + b \cdot -0.25\\
\mathbf{else}:\\
\;\;\;\;\frac{-2}{b \cdot b}\\
\end{array}
\end{array}
if b < -1.55000000000000004Initial program 97.8%
*-lft-identity97.8%
associate-/l*97.8%
remove-double-div97.7%
exp-neg97.7%
associate-/r/97.8%
/-rgt-identity97.8%
*-commutative97.8%
distribute-rgt-in97.8%
exp-neg97.8%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
add-exp-log100.0%
log-rec100.0%
log1p-udef100.0%
Applied egg-rr100.0%
Taylor expanded in a around 0 100.0%
log1p-def100.0%
Simplified100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
exp-neg100.0%
inv-pow100.0%
pow-exp100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
sqr-neg100.0%
sqrt-unprod100.0%
add-sqr-sqrt100.0%
add-log-exp100.0%
pow-to-exp100.0%
pow1100.0%
pow-prod-up100.0%
metadata-eval100.0%
Applied egg-rr100.0%
if -1.55000000000000004 < b < 2.89999999999999991Initial program 97.2%
*-lft-identity97.2%
associate-/l*97.2%
remove-double-div97.2%
exp-neg97.2%
associate-/r/97.2%
/-rgt-identity97.2%
*-commutative97.2%
distribute-rgt-in63.4%
exp-neg63.4%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in a around 0 64.0%
Taylor expanded in b around 0 63.6%
*-commutative63.6%
Simplified63.6%
if 2.89999999999999991 < b Initial program 100.0%
*-lft-identity100.0%
associate-/l*100.0%
remove-double-div100.0%
exp-neg100.0%
associate-/r/100.0%
/-rgt-identity100.0%
*-commutative100.0%
distribute-rgt-in65.2%
exp-neg65.2%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 5.7%
+-commutative5.7%
Simplified5.7%
Taylor expanded in b around inf 5.7%
associate-*r/5.7%
metadata-eval5.7%
unpow25.7%
Simplified5.7%
Taylor expanded in b around 0 48.7%
unpow248.7%
Simplified48.7%
Final simplification66.2%
(FPCore (a b) :precision binary64 (if (<= b -0.54) 1.0 (if (<= b 6.2e+54) (/ 1.0 (- 2.0 a)) (/ -2.0 (* b b)))))
double code(double a, double b) {
double tmp;
if (b <= -0.54) {
tmp = 1.0;
} else if (b <= 6.2e+54) {
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 <= (-0.54d0)) then
tmp = 1.0d0
else if (b <= 6.2d+54) 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 <= -0.54) {
tmp = 1.0;
} else if (b <= 6.2e+54) {
tmp = 1.0 / (2.0 - a);
} else {
tmp = -2.0 / (b * b);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -0.54: tmp = 1.0 elif b <= 6.2e+54: tmp = 1.0 / (2.0 - a) else: tmp = -2.0 / (b * b) return tmp
function code(a, b) tmp = 0.0 if (b <= -0.54) tmp = 1.0; elseif (b <= 6.2e+54) tmp = Float64(1.0 / Float64(2.0 - a)); else tmp = Float64(-2.0 / Float64(b * b)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= -0.54) tmp = 1.0; elseif (b <= 6.2e+54) tmp = 1.0 / (2.0 - a); else tmp = -2.0 / (b * b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -0.54], 1.0, If[LessEqual[b, 6.2e+54], 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 -0.54:\\
\;\;\;\;1\\
\mathbf{elif}\;b \leq 6.2 \cdot 10^{+54}:\\
\;\;\;\;\frac{1}{2 - a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2}{b \cdot b}\\
\end{array}
\end{array}
if b < -0.54000000000000004Initial program 97.8%
*-lft-identity97.8%
associate-/l*97.8%
remove-double-div97.7%
exp-neg97.7%
associate-/r/97.8%
/-rgt-identity97.8%
*-commutative97.8%
distribute-rgt-in97.8%
exp-neg97.8%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
add-exp-log100.0%
log-rec100.0%
log1p-udef100.0%
Applied egg-rr100.0%
Taylor expanded in a around 0 100.0%
log1p-def100.0%
Simplified100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
exp-neg100.0%
inv-pow100.0%
pow-exp100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
sqr-neg100.0%
sqrt-unprod100.0%
add-sqr-sqrt100.0%
add-log-exp100.0%
pow-to-exp100.0%
pow1100.0%
pow-prod-up100.0%
metadata-eval100.0%
Applied egg-rr100.0%
if -0.54000000000000004 < b < 6.1999999999999999e54Initial program 97.4%
*-lft-identity97.4%
associate-/l*97.4%
remove-double-div97.4%
exp-neg97.4%
associate-/r/97.4%
/-rgt-identity97.4%
*-commutative97.4%
distribute-rgt-in62.8%
exp-neg62.8%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in b around 0 95.3%
Taylor expanded in a around 0 59.4%
neg-mul-159.4%
unsub-neg59.4%
Simplified59.4%
if 6.1999999999999999e54 < b Initial program 100.0%
*-lft-identity100.0%
associate-/l*100.0%
remove-double-div100.0%
exp-neg100.0%
associate-/r/100.0%
/-rgt-identity100.0%
*-commutative100.0%
distribute-rgt-in67.3%
exp-neg67.3%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
Taylor expanded in b around 0 5.9%
+-commutative5.9%
Simplified5.9%
Taylor expanded in b around inf 5.9%
associate-*r/5.9%
metadata-eval5.9%
unpow25.9%
Simplified5.9%
Taylor expanded in b around 0 57.8%
unpow257.8%
Simplified57.8%
Final simplification66.2%
(FPCore (a b) :precision binary64 (if (<= b -1.25) 1.0 (+ 0.5 (* b -0.25))))
double code(double a, double b) {
double tmp;
if (b <= -1.25) {
tmp = 1.0;
} else {
tmp = 0.5 + (b * -0.25);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= (-1.25d0)) then
tmp = 1.0d0
else
tmp = 0.5d0 + (b * (-0.25d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= -1.25) {
tmp = 1.0;
} else {
tmp = 0.5 + (b * -0.25);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -1.25: tmp = 1.0 else: tmp = 0.5 + (b * -0.25) return tmp
function code(a, b) tmp = 0.0 if (b <= -1.25) tmp = 1.0; else tmp = Float64(0.5 + Float64(b * -0.25)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= -1.25) tmp = 1.0; else tmp = 0.5 + (b * -0.25); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -1.25], 1.0, N[(0.5 + N[(b * -0.25), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.25:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0.5 + b \cdot -0.25\\
\end{array}
\end{array}
if b < -1.25Initial program 97.8%
*-lft-identity97.8%
associate-/l*97.8%
remove-double-div97.7%
exp-neg97.7%
associate-/r/97.8%
/-rgt-identity97.8%
*-commutative97.8%
distribute-rgt-in97.8%
exp-neg97.8%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
add-exp-log100.0%
log-rec100.0%
log1p-udef100.0%
Applied egg-rr100.0%
Taylor expanded in a around 0 100.0%
log1p-def100.0%
Simplified100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
exp-neg100.0%
inv-pow100.0%
pow-exp100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
sqr-neg100.0%
sqrt-unprod100.0%
add-sqr-sqrt100.0%
add-log-exp100.0%
pow-to-exp100.0%
pow1100.0%
pow-prod-up100.0%
metadata-eval100.0%
Applied egg-rr100.0%
if -1.25 < b Initial program 98.1%
*-lft-identity98.1%
associate-/l*98.1%
remove-double-div98.1%
exp-neg98.1%
associate-/r/98.1%
/-rgt-identity98.1%
*-commutative98.1%
distribute-rgt-in64.0%
exp-neg64.0%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in a around 0 75.2%
Taylor expanded in b around 0 44.4%
*-commutative44.4%
Simplified44.4%
Final simplification54.2%
(FPCore (a b) :precision binary64 (if (<= b -0.9) 1.0 0.5))
double code(double a, double b) {
double tmp;
if (b <= -0.9) {
tmp = 1.0;
} else {
tmp = 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 <= (-0.9d0)) then
tmp = 1.0d0
else
tmp = 0.5d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= -0.9) {
tmp = 1.0;
} else {
tmp = 0.5;
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -0.9: tmp = 1.0 else: tmp = 0.5 return tmp
function code(a, b) tmp = 0.0 if (b <= -0.9) tmp = 1.0; else tmp = 0.5; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= -0.9) tmp = 1.0; else tmp = 0.5; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -0.9], 1.0, 0.5]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -0.9:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if b < -0.900000000000000022Initial program 97.8%
*-lft-identity97.8%
associate-/l*97.8%
remove-double-div97.7%
exp-neg97.7%
associate-/r/97.8%
/-rgt-identity97.8%
*-commutative97.8%
distribute-rgt-in97.8%
exp-neg97.8%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
add-exp-log100.0%
log-rec100.0%
log1p-udef100.0%
Applied egg-rr100.0%
Taylor expanded in a around 0 100.0%
log1p-def100.0%
Simplified100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
exp-neg100.0%
inv-pow100.0%
pow-exp100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
sqr-neg100.0%
sqrt-unprod100.0%
add-sqr-sqrt100.0%
add-log-exp100.0%
pow-to-exp100.0%
pow1100.0%
pow-prod-up100.0%
metadata-eval100.0%
Applied egg-rr100.0%
if -0.900000000000000022 < b Initial program 98.1%
*-lft-identity98.1%
associate-/l*98.1%
remove-double-div98.1%
exp-neg98.1%
associate-/r/98.1%
/-rgt-identity98.1%
*-commutative98.1%
distribute-rgt-in64.0%
exp-neg64.0%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in a around 0 75.2%
Taylor expanded in b around 0 44.3%
Final simplification54.1%
(FPCore (a b) :precision binary64 0.5)
double code(double a, double b) {
return 0.5;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 0.5d0
end function
public static double code(double a, double b) {
return 0.5;
}
def code(a, b): return 0.5
function code(a, b) return 0.5 end
function tmp = code(a, b) tmp = 0.5; end
code[a_, b_] := 0.5
\begin{array}{l}
\\
0.5
\end{array}
Initial program 98.0%
*-lft-identity98.0%
associate-/l*98.0%
remove-double-div98.0%
exp-neg98.0%
associate-/r/98.0%
/-rgt-identity98.0%
*-commutative98.0%
distribute-rgt-in69.9%
exp-neg69.9%
rgt-mult-inverse100.0%
prod-exp100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in a around 0 79.6%
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 2023285
(FPCore (a b)
:name "Quotient of sum of exps"
:precision binary64
:herbie-target
(/ 1.0 (+ 1.0 (exp (- b a))))
(/ (exp a) (+ (exp a) (exp b))))