
(FPCore (c_p c_n t s)
:precision binary64
(let* ((t_1 (/ 1.0 (+ 1.0 (exp (- t))))) (t_2 (/ 1.0 (+ 1.0 (exp (- s))))))
(/
(* (pow t_2 c_p) (pow (- 1.0 t_2) c_n))
(* (pow t_1 c_p) (pow (- 1.0 t_1) c_n)))))
double code(double c_p, double c_n, double t, double s) {
double t_1 = 1.0 / (1.0 + exp(-t));
double t_2 = 1.0 / (1.0 + exp(-s));
return (pow(t_2, c_p) * pow((1.0 - t_2), c_n)) / (pow(t_1, c_p) * pow((1.0 - t_1), c_n));
}
real(8) function code(c_p, c_n, t, s)
real(8), intent (in) :: c_p
real(8), intent (in) :: c_n
real(8), intent (in) :: t
real(8), intent (in) :: s
real(8) :: t_1
real(8) :: t_2
t_1 = 1.0d0 / (1.0d0 + exp(-t))
t_2 = 1.0d0 / (1.0d0 + exp(-s))
code = ((t_2 ** c_p) * ((1.0d0 - t_2) ** c_n)) / ((t_1 ** c_p) * ((1.0d0 - t_1) ** c_n))
end function
public static double code(double c_p, double c_n, double t, double s) {
double t_1 = 1.0 / (1.0 + Math.exp(-t));
double t_2 = 1.0 / (1.0 + Math.exp(-s));
return (Math.pow(t_2, c_p) * Math.pow((1.0 - t_2), c_n)) / (Math.pow(t_1, c_p) * Math.pow((1.0 - t_1), c_n));
}
def code(c_p, c_n, t, s): t_1 = 1.0 / (1.0 + math.exp(-t)) t_2 = 1.0 / (1.0 + math.exp(-s)) return (math.pow(t_2, c_p) * math.pow((1.0 - t_2), c_n)) / (math.pow(t_1, c_p) * math.pow((1.0 - t_1), c_n))
function code(c_p, c_n, t, s) t_1 = Float64(1.0 / Float64(1.0 + exp(Float64(-t)))) t_2 = Float64(1.0 / Float64(1.0 + exp(Float64(-s)))) return Float64(Float64((t_2 ^ c_p) * (Float64(1.0 - t_2) ^ c_n)) / Float64((t_1 ^ c_p) * (Float64(1.0 - t_1) ^ c_n))) end
function tmp = code(c_p, c_n, t, s) t_1 = 1.0 / (1.0 + exp(-t)); t_2 = 1.0 / (1.0 + exp(-s)); tmp = ((t_2 ^ c_p) * ((1.0 - t_2) ^ c_n)) / ((t_1 ^ c_p) * ((1.0 - t_1) ^ c_n)); end
code[c$95$p_, c$95$n_, t_, s_] := Block[{t$95$1 = N[(1.0 / N[(1.0 + N[Exp[(-t)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 / N[(1.0 + N[Exp[(-s)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Power[t$95$2, c$95$p], $MachinePrecision] * N[Power[N[(1.0 - t$95$2), $MachinePrecision], c$95$n], $MachinePrecision]), $MachinePrecision] / N[(N[Power[t$95$1, c$95$p], $MachinePrecision] * N[Power[N[(1.0 - t$95$1), $MachinePrecision], c$95$n], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{1}{1 + e^{-t}}\\
t_2 := \frac{1}{1 + e^{-s}}\\
\frac{{t\_2}^{c\_p} \cdot {\left(1 - t\_2\right)}^{c\_n}}{{t\_1}^{c\_p} \cdot {\left(1 - t\_1\right)}^{c\_n}}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (c_p c_n t s)
:precision binary64
(let* ((t_1 (/ 1.0 (+ 1.0 (exp (- t))))) (t_2 (/ 1.0 (+ 1.0 (exp (- s))))))
(/
(* (pow t_2 c_p) (pow (- 1.0 t_2) c_n))
(* (pow t_1 c_p) (pow (- 1.0 t_1) c_n)))))
double code(double c_p, double c_n, double t, double s) {
double t_1 = 1.0 / (1.0 + exp(-t));
double t_2 = 1.0 / (1.0 + exp(-s));
return (pow(t_2, c_p) * pow((1.0 - t_2), c_n)) / (pow(t_1, c_p) * pow((1.0 - t_1), c_n));
}
real(8) function code(c_p, c_n, t, s)
real(8), intent (in) :: c_p
real(8), intent (in) :: c_n
real(8), intent (in) :: t
real(8), intent (in) :: s
real(8) :: t_1
real(8) :: t_2
t_1 = 1.0d0 / (1.0d0 + exp(-t))
t_2 = 1.0d0 / (1.0d0 + exp(-s))
code = ((t_2 ** c_p) * ((1.0d0 - t_2) ** c_n)) / ((t_1 ** c_p) * ((1.0d0 - t_1) ** c_n))
end function
public static double code(double c_p, double c_n, double t, double s) {
double t_1 = 1.0 / (1.0 + Math.exp(-t));
double t_2 = 1.0 / (1.0 + Math.exp(-s));
return (Math.pow(t_2, c_p) * Math.pow((1.0 - t_2), c_n)) / (Math.pow(t_1, c_p) * Math.pow((1.0 - t_1), c_n));
}
def code(c_p, c_n, t, s): t_1 = 1.0 / (1.0 + math.exp(-t)) t_2 = 1.0 / (1.0 + math.exp(-s)) return (math.pow(t_2, c_p) * math.pow((1.0 - t_2), c_n)) / (math.pow(t_1, c_p) * math.pow((1.0 - t_1), c_n))
function code(c_p, c_n, t, s) t_1 = Float64(1.0 / Float64(1.0 + exp(Float64(-t)))) t_2 = Float64(1.0 / Float64(1.0 + exp(Float64(-s)))) return Float64(Float64((t_2 ^ c_p) * (Float64(1.0 - t_2) ^ c_n)) / Float64((t_1 ^ c_p) * (Float64(1.0 - t_1) ^ c_n))) end
function tmp = code(c_p, c_n, t, s) t_1 = 1.0 / (1.0 + exp(-t)); t_2 = 1.0 / (1.0 + exp(-s)); tmp = ((t_2 ^ c_p) * ((1.0 - t_2) ^ c_n)) / ((t_1 ^ c_p) * ((1.0 - t_1) ^ c_n)); end
code[c$95$p_, c$95$n_, t_, s_] := Block[{t$95$1 = N[(1.0 / N[(1.0 + N[Exp[(-t)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 / N[(1.0 + N[Exp[(-s)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Power[t$95$2, c$95$p], $MachinePrecision] * N[Power[N[(1.0 - t$95$2), $MachinePrecision], c$95$n], $MachinePrecision]), $MachinePrecision] / N[(N[Power[t$95$1, c$95$p], $MachinePrecision] * N[Power[N[(1.0 - t$95$1), $MachinePrecision], c$95$n], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{1}{1 + e^{-t}}\\
t_2 := \frac{1}{1 + e^{-s}}\\
\frac{{t\_2}^{c\_p} \cdot {\left(1 - t\_2\right)}^{c\_n}}{{t\_1}^{c\_p} \cdot {\left(1 - t\_1\right)}^{c\_n}}
\end{array}
\end{array}
(FPCore (c_p c_n t s)
:precision binary64
(let* ((t_1 (exp (- s))) (t_2 (exp (- t))))
(if (<= c_p 6e-71)
(exp
(* c_n (- (log1p (/ -1.0 (+ 1.0 t_1))) (log1p (/ -1.0 (+ 1.0 t_2))))))
(exp
(+
(-
(- (* c_n (log1p (/ 1.0 (- -1.0 t_1)))) (* c_p (log1p t_1)))
(* c_n (log1p (/ 1.0 (- -1.0 t_2)))))
(* c_p (log1p t_2)))))))
double code(double c_p, double c_n, double t, double s) {
double t_1 = exp(-s);
double t_2 = exp(-t);
double tmp;
if (c_p <= 6e-71) {
tmp = exp((c_n * (log1p((-1.0 / (1.0 + t_1))) - log1p((-1.0 / (1.0 + t_2))))));
} else {
tmp = exp(((((c_n * log1p((1.0 / (-1.0 - t_1)))) - (c_p * log1p(t_1))) - (c_n * log1p((1.0 / (-1.0 - t_2))))) + (c_p * log1p(t_2))));
}
return tmp;
}
public static double code(double c_p, double c_n, double t, double s) {
double t_1 = Math.exp(-s);
double t_2 = Math.exp(-t);
double tmp;
if (c_p <= 6e-71) {
tmp = Math.exp((c_n * (Math.log1p((-1.0 / (1.0 + t_1))) - Math.log1p((-1.0 / (1.0 + t_2))))));
} else {
tmp = Math.exp(((((c_n * Math.log1p((1.0 / (-1.0 - t_1)))) - (c_p * Math.log1p(t_1))) - (c_n * Math.log1p((1.0 / (-1.0 - t_2))))) + (c_p * Math.log1p(t_2))));
}
return tmp;
}
def code(c_p, c_n, t, s): t_1 = math.exp(-s) t_2 = math.exp(-t) tmp = 0 if c_p <= 6e-71: tmp = math.exp((c_n * (math.log1p((-1.0 / (1.0 + t_1))) - math.log1p((-1.0 / (1.0 + t_2)))))) else: tmp = math.exp(((((c_n * math.log1p((1.0 / (-1.0 - t_1)))) - (c_p * math.log1p(t_1))) - (c_n * math.log1p((1.0 / (-1.0 - t_2))))) + (c_p * math.log1p(t_2)))) return tmp
function code(c_p, c_n, t, s) t_1 = exp(Float64(-s)) t_2 = exp(Float64(-t)) tmp = 0.0 if (c_p <= 6e-71) tmp = exp(Float64(c_n * Float64(log1p(Float64(-1.0 / Float64(1.0 + t_1))) - log1p(Float64(-1.0 / Float64(1.0 + t_2)))))); else tmp = exp(Float64(Float64(Float64(Float64(c_n * log1p(Float64(1.0 / Float64(-1.0 - t_1)))) - Float64(c_p * log1p(t_1))) - Float64(c_n * log1p(Float64(1.0 / Float64(-1.0 - t_2))))) + Float64(c_p * log1p(t_2)))); end return tmp end
code[c$95$p_, c$95$n_, t_, s_] := Block[{t$95$1 = N[Exp[(-s)], $MachinePrecision]}, Block[{t$95$2 = N[Exp[(-t)], $MachinePrecision]}, If[LessEqual[c$95$p, 6e-71], N[Exp[N[(c$95$n * N[(N[Log[1 + N[(-1.0 / N[(1.0 + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Log[1 + N[(-1.0 / N[(1.0 + t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[N[(N[(N[(N[(c$95$n * N[Log[1 + N[(1.0 / N[(-1.0 - t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(c$95$p * N[Log[1 + t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(c$95$n * N[Log[1 + N[(1.0 / N[(-1.0 - t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(c$95$p * N[Log[1 + t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := e^{-s}\\
t_2 := e^{-t}\\
\mathbf{if}\;c\_p \leq 6 \cdot 10^{-71}:\\
\;\;\;\;e^{c\_n \cdot \left(\mathsf{log1p}\left(\frac{-1}{1 + t\_1}\right) - \mathsf{log1p}\left(\frac{-1}{1 + t\_2}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{\left(\left(c\_n \cdot \mathsf{log1p}\left(\frac{1}{-1 - t\_1}\right) - c\_p \cdot \mathsf{log1p}\left(t\_1\right)\right) - c\_n \cdot \mathsf{log1p}\left(\frac{1}{-1 - t\_2}\right)\right) + c\_p \cdot \mathsf{log1p}\left(t\_2\right)}\\
\end{array}
\end{array}
if c_p < 6.0000000000000003e-71Initial program 92.9%
associate-/l/92.9%
Simplified92.9%
add-exp-log92.9%
log-div92.9%
Applied egg-rr95.7%
Taylor expanded in c_n around inf 99.5%
sub-neg99.5%
log1p-undefine99.5%
distribute-neg-frac99.5%
metadata-eval99.5%
sub-neg99.5%
log1p-define99.5%
distribute-neg-frac99.5%
metadata-eval99.5%
Simplified99.5%
if 6.0000000000000003e-71 < c_p Initial program 81.1%
associate-/l/81.1%
Simplified81.1%
add-exp-log81.1%
log-div81.1%
Applied egg-rr97.8%
Final simplification99.0%
(FPCore (c_p c_n t s)
:precision binary64
(if (<= (- s) 5e-165)
(exp
(*
c_n
(-
(log1p (/ -1.0 (+ 1.0 (exp (- s)))))
(log1p (/ -1.0 (+ 1.0 (exp (- t))))))))
(pow
(/ 1.0 (+ 2.0 (* s (+ -1.0 (* s (+ 0.5 (* s -0.16666666666666666)))))))
c_p)))
double code(double c_p, double c_n, double t, double s) {
double tmp;
if (-s <= 5e-165) {
tmp = exp((c_n * (log1p((-1.0 / (1.0 + exp(-s)))) - log1p((-1.0 / (1.0 + exp(-t)))))));
} else {
tmp = pow((1.0 / (2.0 + (s * (-1.0 + (s * (0.5 + (s * -0.16666666666666666))))))), c_p);
}
return tmp;
}
public static double code(double c_p, double c_n, double t, double s) {
double tmp;
if (-s <= 5e-165) {
tmp = Math.exp((c_n * (Math.log1p((-1.0 / (1.0 + Math.exp(-s)))) - Math.log1p((-1.0 / (1.0 + Math.exp(-t)))))));
} else {
tmp = Math.pow((1.0 / (2.0 + (s * (-1.0 + (s * (0.5 + (s * -0.16666666666666666))))))), c_p);
}
return tmp;
}
def code(c_p, c_n, t, s): tmp = 0 if -s <= 5e-165: tmp = math.exp((c_n * (math.log1p((-1.0 / (1.0 + math.exp(-s)))) - math.log1p((-1.0 / (1.0 + math.exp(-t))))))) else: tmp = math.pow((1.0 / (2.0 + (s * (-1.0 + (s * (0.5 + (s * -0.16666666666666666))))))), c_p) return tmp
function code(c_p, c_n, t, s) tmp = 0.0 if (Float64(-s) <= 5e-165) tmp = exp(Float64(c_n * Float64(log1p(Float64(-1.0 / Float64(1.0 + exp(Float64(-s))))) - log1p(Float64(-1.0 / Float64(1.0 + exp(Float64(-t)))))))); else tmp = Float64(1.0 / Float64(2.0 + Float64(s * Float64(-1.0 + Float64(s * Float64(0.5 + Float64(s * -0.16666666666666666))))))) ^ c_p; end return tmp end
code[c$95$p_, c$95$n_, t_, s_] := If[LessEqual[(-s), 5e-165], N[Exp[N[(c$95$n * N[(N[Log[1 + N[(-1.0 / N[(1.0 + N[Exp[(-s)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Log[1 + N[(-1.0 / N[(1.0 + N[Exp[(-t)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Power[N[(1.0 / N[(2.0 + N[(s * N[(-1.0 + N[(s * N[(0.5 + N[(s * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], c$95$p], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-s \leq 5 \cdot 10^{-165}:\\
\;\;\;\;e^{c\_n \cdot \left(\mathsf{log1p}\left(\frac{-1}{1 + e^{-s}}\right) - \mathsf{log1p}\left(\frac{-1}{1 + e^{-t}}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{1}{2 + s \cdot \left(-1 + s \cdot \left(0.5 + s \cdot -0.16666666666666666\right)\right)}\right)}^{c\_p}\\
\end{array}
\end{array}
if (neg.f64 s) < 4.99999999999999981e-165Initial program 90.7%
associate-/l/90.7%
Simplified90.7%
add-exp-log90.7%
log-div90.7%
Applied egg-rr97.7%
Taylor expanded in c_n around inf 99.5%
sub-neg99.5%
log1p-undefine99.5%
distribute-neg-frac99.5%
metadata-eval99.5%
sub-neg99.5%
log1p-define99.5%
distribute-neg-frac99.5%
metadata-eval99.5%
Simplified99.5%
if 4.99999999999999981e-165 < (neg.f64 s) Initial program 85.7%
associate-/l*85.7%
Simplified85.7%
Taylor expanded in c_n around 0 87.3%
Taylor expanded in c_p around 0 93.1%
Taylor expanded in s around 0 96.2%
Final simplification98.7%
(FPCore (c_p c_n t s)
:precision binary64
(if (<= (- s) -2e+51)
(pow (+ -1.0 (+ 1.0 (/ -1.0 (+ 1.0 (exp s))))) c_p)
(if (<= (- s) 5e-165)
(exp (* c_n (- (log 0.5) (log1p (/ -1.0 (+ 1.0 (exp (- t))))))))
(pow
(/ 1.0 (+ 2.0 (* s (+ -1.0 (* s (+ 0.5 (* s -0.16666666666666666)))))))
c_p))))
double code(double c_p, double c_n, double t, double s) {
double tmp;
if (-s <= -2e+51) {
tmp = pow((-1.0 + (1.0 + (-1.0 / (1.0 + exp(s))))), c_p);
} else if (-s <= 5e-165) {
tmp = exp((c_n * (log(0.5) - log1p((-1.0 / (1.0 + exp(-t)))))));
} else {
tmp = pow((1.0 / (2.0 + (s * (-1.0 + (s * (0.5 + (s * -0.16666666666666666))))))), c_p);
}
return tmp;
}
public static double code(double c_p, double c_n, double t, double s) {
double tmp;
if (-s <= -2e+51) {
tmp = Math.pow((-1.0 + (1.0 + (-1.0 / (1.0 + Math.exp(s))))), c_p);
} else if (-s <= 5e-165) {
tmp = Math.exp((c_n * (Math.log(0.5) - Math.log1p((-1.0 / (1.0 + Math.exp(-t)))))));
} else {
tmp = Math.pow((1.0 / (2.0 + (s * (-1.0 + (s * (0.5 + (s * -0.16666666666666666))))))), c_p);
}
return tmp;
}
def code(c_p, c_n, t, s): tmp = 0 if -s <= -2e+51: tmp = math.pow((-1.0 + (1.0 + (-1.0 / (1.0 + math.exp(s))))), c_p) elif -s <= 5e-165: tmp = math.exp((c_n * (math.log(0.5) - math.log1p((-1.0 / (1.0 + math.exp(-t))))))) else: tmp = math.pow((1.0 / (2.0 + (s * (-1.0 + (s * (0.5 + (s * -0.16666666666666666))))))), c_p) return tmp
function code(c_p, c_n, t, s) tmp = 0.0 if (Float64(-s) <= -2e+51) tmp = Float64(-1.0 + Float64(1.0 + Float64(-1.0 / Float64(1.0 + exp(s))))) ^ c_p; elseif (Float64(-s) <= 5e-165) tmp = exp(Float64(c_n * Float64(log(0.5) - log1p(Float64(-1.0 / Float64(1.0 + exp(Float64(-t)))))))); else tmp = Float64(1.0 / Float64(2.0 + Float64(s * Float64(-1.0 + Float64(s * Float64(0.5 + Float64(s * -0.16666666666666666))))))) ^ c_p; end return tmp end
code[c$95$p_, c$95$n_, t_, s_] := If[LessEqual[(-s), -2e+51], N[Power[N[(-1.0 + N[(1.0 + N[(-1.0 / N[(1.0 + N[Exp[s], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], c$95$p], $MachinePrecision], If[LessEqual[(-s), 5e-165], N[Exp[N[(c$95$n * N[(N[Log[0.5], $MachinePrecision] - N[Log[1 + N[(-1.0 / N[(1.0 + N[Exp[(-t)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Power[N[(1.0 / N[(2.0 + N[(s * N[(-1.0 + N[(s * N[(0.5 + N[(s * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], c$95$p], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-s \leq -2 \cdot 10^{+51}:\\
\;\;\;\;{\left(-1 + \left(1 + \frac{-1}{1 + e^{s}}\right)\right)}^{c\_p}\\
\mathbf{elif}\;-s \leq 5 \cdot 10^{-165}:\\
\;\;\;\;e^{c\_n \cdot \left(\log 0.5 - \mathsf{log1p}\left(\frac{-1}{1 + e^{-t}}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{1}{2 + s \cdot \left(-1 + s \cdot \left(0.5 + s \cdot -0.16666666666666666\right)\right)}\right)}^{c\_p}\\
\end{array}
\end{array}
if (neg.f64 s) < -2e51Initial program 33.3%
associate-/l*33.3%
Simplified33.3%
Taylor expanded in c_n around 0 2.6%
Taylor expanded in c_p around 0 3.1%
expm1-log1p-u3.1%
expm1-undefine3.1%
Applied egg-rr100.0%
if -2e51 < (neg.f64 s) < 4.99999999999999981e-165Initial program 92.6%
associate-/l/92.6%
Simplified92.6%
add-exp-log92.6%
log-div92.6%
Applied egg-rr98.1%
Taylor expanded in c_n around inf 99.4%
sub-neg99.4%
log1p-undefine99.4%
distribute-neg-frac99.4%
metadata-eval99.4%
sub-neg99.4%
log1p-define99.4%
distribute-neg-frac99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in s around 0 99.4%
*-commutative99.4%
sub-neg99.4%
log1p-define99.4%
distribute-neg-frac99.4%
metadata-eval99.4%
Simplified99.4%
if 4.99999999999999981e-165 < (neg.f64 s) Initial program 85.7%
associate-/l*85.7%
Simplified85.7%
Taylor expanded in c_n around 0 87.3%
Taylor expanded in c_p around 0 93.1%
Taylor expanded in s around 0 96.2%
Final simplification98.7%
(FPCore (c_p c_n t s)
:precision binary64
(if (<= (- s) -2e+51)
(pow (+ -1.0 (+ 1.0 (/ -1.0 (+ 1.0 (exp s))))) c_p)
(if (<= (- s) 5e-165)
(exp
(*
t
(+
(* c_n 0.5)
(*
t
(+ (* -0.005208333333333333 (* c_n (pow t 2.0))) (* c_n 0.125))))))
(pow
(/ 1.0 (+ 2.0 (* s (+ -1.0 (* s (+ 0.5 (* s -0.16666666666666666)))))))
c_p))))
double code(double c_p, double c_n, double t, double s) {
double tmp;
if (-s <= -2e+51) {
tmp = pow((-1.0 + (1.0 + (-1.0 / (1.0 + exp(s))))), c_p);
} else if (-s <= 5e-165) {
tmp = exp((t * ((c_n * 0.5) + (t * ((-0.005208333333333333 * (c_n * pow(t, 2.0))) + (c_n * 0.125))))));
} else {
tmp = pow((1.0 / (2.0 + (s * (-1.0 + (s * (0.5 + (s * -0.16666666666666666))))))), c_p);
}
return tmp;
}
real(8) function code(c_p, c_n, t, s)
real(8), intent (in) :: c_p
real(8), intent (in) :: c_n
real(8), intent (in) :: t
real(8), intent (in) :: s
real(8) :: tmp
if (-s <= (-2d+51)) then
tmp = ((-1.0d0) + (1.0d0 + ((-1.0d0) / (1.0d0 + exp(s))))) ** c_p
else if (-s <= 5d-165) then
tmp = exp((t * ((c_n * 0.5d0) + (t * (((-0.005208333333333333d0) * (c_n * (t ** 2.0d0))) + (c_n * 0.125d0))))))
else
tmp = (1.0d0 / (2.0d0 + (s * ((-1.0d0) + (s * (0.5d0 + (s * (-0.16666666666666666d0)))))))) ** c_p
end if
code = tmp
end function
public static double code(double c_p, double c_n, double t, double s) {
double tmp;
if (-s <= -2e+51) {
tmp = Math.pow((-1.0 + (1.0 + (-1.0 / (1.0 + Math.exp(s))))), c_p);
} else if (-s <= 5e-165) {
tmp = Math.exp((t * ((c_n * 0.5) + (t * ((-0.005208333333333333 * (c_n * Math.pow(t, 2.0))) + (c_n * 0.125))))));
} else {
tmp = Math.pow((1.0 / (2.0 + (s * (-1.0 + (s * (0.5 + (s * -0.16666666666666666))))))), c_p);
}
return tmp;
}
def code(c_p, c_n, t, s): tmp = 0 if -s <= -2e+51: tmp = math.pow((-1.0 + (1.0 + (-1.0 / (1.0 + math.exp(s))))), c_p) elif -s <= 5e-165: tmp = math.exp((t * ((c_n * 0.5) + (t * ((-0.005208333333333333 * (c_n * math.pow(t, 2.0))) + (c_n * 0.125)))))) else: tmp = math.pow((1.0 / (2.0 + (s * (-1.0 + (s * (0.5 + (s * -0.16666666666666666))))))), c_p) return tmp
function code(c_p, c_n, t, s) tmp = 0.0 if (Float64(-s) <= -2e+51) tmp = Float64(-1.0 + Float64(1.0 + Float64(-1.0 / Float64(1.0 + exp(s))))) ^ c_p; elseif (Float64(-s) <= 5e-165) tmp = exp(Float64(t * Float64(Float64(c_n * 0.5) + Float64(t * Float64(Float64(-0.005208333333333333 * Float64(c_n * (t ^ 2.0))) + Float64(c_n * 0.125)))))); else tmp = Float64(1.0 / Float64(2.0 + Float64(s * Float64(-1.0 + Float64(s * Float64(0.5 + Float64(s * -0.16666666666666666))))))) ^ c_p; end return tmp end
function tmp_2 = code(c_p, c_n, t, s) tmp = 0.0; if (-s <= -2e+51) tmp = (-1.0 + (1.0 + (-1.0 / (1.0 + exp(s))))) ^ c_p; elseif (-s <= 5e-165) tmp = exp((t * ((c_n * 0.5) + (t * ((-0.005208333333333333 * (c_n * (t ^ 2.0))) + (c_n * 0.125)))))); else tmp = (1.0 / (2.0 + (s * (-1.0 + (s * (0.5 + (s * -0.16666666666666666))))))) ^ c_p; end tmp_2 = tmp; end
code[c$95$p_, c$95$n_, t_, s_] := If[LessEqual[(-s), -2e+51], N[Power[N[(-1.0 + N[(1.0 + N[(-1.0 / N[(1.0 + N[Exp[s], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], c$95$p], $MachinePrecision], If[LessEqual[(-s), 5e-165], N[Exp[N[(t * N[(N[(c$95$n * 0.5), $MachinePrecision] + N[(t * N[(N[(-0.005208333333333333 * N[(c$95$n * N[Power[t, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(c$95$n * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Power[N[(1.0 / N[(2.0 + N[(s * N[(-1.0 + N[(s * N[(0.5 + N[(s * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], c$95$p], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-s \leq -2 \cdot 10^{+51}:\\
\;\;\;\;{\left(-1 + \left(1 + \frac{-1}{1 + e^{s}}\right)\right)}^{c\_p}\\
\mathbf{elif}\;-s \leq 5 \cdot 10^{-165}:\\
\;\;\;\;e^{t \cdot \left(c\_n \cdot 0.5 + t \cdot \left(-0.005208333333333333 \cdot \left(c\_n \cdot {t}^{2}\right) + c\_n \cdot 0.125\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{1}{2 + s \cdot \left(-1 + s \cdot \left(0.5 + s \cdot -0.16666666666666666\right)\right)}\right)}^{c\_p}\\
\end{array}
\end{array}
if (neg.f64 s) < -2e51Initial program 33.3%
associate-/l*33.3%
Simplified33.3%
Taylor expanded in c_n around 0 2.6%
Taylor expanded in c_p around 0 3.1%
expm1-log1p-u3.1%
expm1-undefine3.1%
Applied egg-rr100.0%
if -2e51 < (neg.f64 s) < 4.99999999999999981e-165Initial program 92.6%
associate-/l/92.6%
Simplified92.6%
add-exp-log92.6%
log-div92.6%
Applied egg-rr98.1%
Taylor expanded in c_n around inf 99.4%
sub-neg99.4%
log1p-undefine99.4%
distribute-neg-frac99.4%
metadata-eval99.4%
sub-neg99.4%
log1p-define99.4%
distribute-neg-frac99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in s around 0 99.4%
*-commutative99.4%
sub-neg99.4%
log1p-define99.4%
distribute-neg-frac99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in t around 0 99.2%
if 4.99999999999999981e-165 < (neg.f64 s) Initial program 85.7%
associate-/l*85.7%
Simplified85.7%
Taylor expanded in c_n around 0 87.3%
Taylor expanded in c_p around 0 93.1%
Taylor expanded in s around 0 96.2%
Final simplification98.5%
(FPCore (c_p c_n t s)
:precision binary64
(if (<= s -1e-161)
(pow
(/ 1.0 (+ 2.0 (* s (+ -1.0 (* s (+ 0.5 (* s -0.16666666666666666)))))))
c_p)
(if (<= s 375.0)
(exp (* t (* c_n 0.5)))
(pow (+ -1.0 (+ 1.0 (/ -1.0 (+ 1.0 (exp s))))) c_p))))
double code(double c_p, double c_n, double t, double s) {
double tmp;
if (s <= -1e-161) {
tmp = pow((1.0 / (2.0 + (s * (-1.0 + (s * (0.5 + (s * -0.16666666666666666))))))), c_p);
} else if (s <= 375.0) {
tmp = exp((t * (c_n * 0.5)));
} else {
tmp = pow((-1.0 + (1.0 + (-1.0 / (1.0 + exp(s))))), c_p);
}
return tmp;
}
real(8) function code(c_p, c_n, t, s)
real(8), intent (in) :: c_p
real(8), intent (in) :: c_n
real(8), intent (in) :: t
real(8), intent (in) :: s
real(8) :: tmp
if (s <= (-1d-161)) then
tmp = (1.0d0 / (2.0d0 + (s * ((-1.0d0) + (s * (0.5d0 + (s * (-0.16666666666666666d0)))))))) ** c_p
else if (s <= 375.0d0) then
tmp = exp((t * (c_n * 0.5d0)))
else
tmp = ((-1.0d0) + (1.0d0 + ((-1.0d0) / (1.0d0 + exp(s))))) ** c_p
end if
code = tmp
end function
public static double code(double c_p, double c_n, double t, double s) {
double tmp;
if (s <= -1e-161) {
tmp = Math.pow((1.0 / (2.0 + (s * (-1.0 + (s * (0.5 + (s * -0.16666666666666666))))))), c_p);
} else if (s <= 375.0) {
tmp = Math.exp((t * (c_n * 0.5)));
} else {
tmp = Math.pow((-1.0 + (1.0 + (-1.0 / (1.0 + Math.exp(s))))), c_p);
}
return tmp;
}
def code(c_p, c_n, t, s): tmp = 0 if s <= -1e-161: tmp = math.pow((1.0 / (2.0 + (s * (-1.0 + (s * (0.5 + (s * -0.16666666666666666))))))), c_p) elif s <= 375.0: tmp = math.exp((t * (c_n * 0.5))) else: tmp = math.pow((-1.0 + (1.0 + (-1.0 / (1.0 + math.exp(s))))), c_p) return tmp
function code(c_p, c_n, t, s) tmp = 0.0 if (s <= -1e-161) tmp = Float64(1.0 / Float64(2.0 + Float64(s * Float64(-1.0 + Float64(s * Float64(0.5 + Float64(s * -0.16666666666666666))))))) ^ c_p; elseif (s <= 375.0) tmp = exp(Float64(t * Float64(c_n * 0.5))); else tmp = Float64(-1.0 + Float64(1.0 + Float64(-1.0 / Float64(1.0 + exp(s))))) ^ c_p; end return tmp end
function tmp_2 = code(c_p, c_n, t, s) tmp = 0.0; if (s <= -1e-161) tmp = (1.0 / (2.0 + (s * (-1.0 + (s * (0.5 + (s * -0.16666666666666666))))))) ^ c_p; elseif (s <= 375.0) tmp = exp((t * (c_n * 0.5))); else tmp = (-1.0 + (1.0 + (-1.0 / (1.0 + exp(s))))) ^ c_p; end tmp_2 = tmp; end
code[c$95$p_, c$95$n_, t_, s_] := If[LessEqual[s, -1e-161], N[Power[N[(1.0 / N[(2.0 + N[(s * N[(-1.0 + N[(s * N[(0.5 + N[(s * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], c$95$p], $MachinePrecision], If[LessEqual[s, 375.0], N[Exp[N[(t * N[(c$95$n * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Power[N[(-1.0 + N[(1.0 + N[(-1.0 / N[(1.0 + N[Exp[s], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], c$95$p], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;s \leq -1 \cdot 10^{-161}:\\
\;\;\;\;{\left(\frac{1}{2 + s \cdot \left(-1 + s \cdot \left(0.5 + s \cdot -0.16666666666666666\right)\right)}\right)}^{c\_p}\\
\mathbf{elif}\;s \leq 375:\\
\;\;\;\;e^{t \cdot \left(c\_n \cdot 0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;{\left(-1 + \left(1 + \frac{-1}{1 + e^{s}}\right)\right)}^{c\_p}\\
\end{array}
\end{array}
if s < -1.00000000000000003e-161Initial program 85.5%
associate-/l*85.5%
Simplified85.5%
Taylor expanded in c_n around 0 87.1%
Taylor expanded in c_p around 0 93.0%
Taylor expanded in s around 0 96.2%
if -1.00000000000000003e-161 < s < 375Initial program 93.6%
associate-/l/93.6%
Simplified93.6%
add-exp-log93.6%
log-div93.6%
Applied egg-rr98.6%
Taylor expanded in c_n around inf 100.0%
sub-neg100.0%
log1p-undefine100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
sub-neg100.0%
log1p-define100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in s around 0 100.0%
*-commutative100.0%
sub-neg100.0%
log1p-define100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in t around 0 99.6%
associate-*r*99.6%
Simplified99.6%
if 375 < s Initial program 25.4%
associate-/l*25.4%
Simplified25.4%
Taylor expanded in c_n around 0 14.8%
Taylor expanded in c_p around 0 15.2%
expm1-log1p-u15.2%
expm1-undefine15.2%
Applied egg-rr87.9%
Final simplification98.4%
(FPCore (c_p c_n t s)
:precision binary64
(if (<= s -1e-161)
(pow
(/ 1.0 (+ 2.0 (* s (+ -1.0 (* s (+ 0.5 (* s -0.16666666666666666)))))))
c_p)
(exp (* t (* c_n 0.5)))))
double code(double c_p, double c_n, double t, double s) {
double tmp;
if (s <= -1e-161) {
tmp = pow((1.0 / (2.0 + (s * (-1.0 + (s * (0.5 + (s * -0.16666666666666666))))))), c_p);
} else {
tmp = exp((t * (c_n * 0.5)));
}
return tmp;
}
real(8) function code(c_p, c_n, t, s)
real(8), intent (in) :: c_p
real(8), intent (in) :: c_n
real(8), intent (in) :: t
real(8), intent (in) :: s
real(8) :: tmp
if (s <= (-1d-161)) then
tmp = (1.0d0 / (2.0d0 + (s * ((-1.0d0) + (s * (0.5d0 + (s * (-0.16666666666666666d0)))))))) ** c_p
else
tmp = exp((t * (c_n * 0.5d0)))
end if
code = tmp
end function
public static double code(double c_p, double c_n, double t, double s) {
double tmp;
if (s <= -1e-161) {
tmp = Math.pow((1.0 / (2.0 + (s * (-1.0 + (s * (0.5 + (s * -0.16666666666666666))))))), c_p);
} else {
tmp = Math.exp((t * (c_n * 0.5)));
}
return tmp;
}
def code(c_p, c_n, t, s): tmp = 0 if s <= -1e-161: tmp = math.pow((1.0 / (2.0 + (s * (-1.0 + (s * (0.5 + (s * -0.16666666666666666))))))), c_p) else: tmp = math.exp((t * (c_n * 0.5))) return tmp
function code(c_p, c_n, t, s) tmp = 0.0 if (s <= -1e-161) tmp = Float64(1.0 / Float64(2.0 + Float64(s * Float64(-1.0 + Float64(s * Float64(0.5 + Float64(s * -0.16666666666666666))))))) ^ c_p; else tmp = exp(Float64(t * Float64(c_n * 0.5))); end return tmp end
function tmp_2 = code(c_p, c_n, t, s) tmp = 0.0; if (s <= -1e-161) tmp = (1.0 / (2.0 + (s * (-1.0 + (s * (0.5 + (s * -0.16666666666666666))))))) ^ c_p; else tmp = exp((t * (c_n * 0.5))); end tmp_2 = tmp; end
code[c$95$p_, c$95$n_, t_, s_] := If[LessEqual[s, -1e-161], N[Power[N[(1.0 / N[(2.0 + N[(s * N[(-1.0 + N[(s * N[(0.5 + N[(s * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], c$95$p], $MachinePrecision], N[Exp[N[(t * N[(c$95$n * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;s \leq -1 \cdot 10^{-161}:\\
\;\;\;\;{\left(\frac{1}{2 + s \cdot \left(-1 + s \cdot \left(0.5 + s \cdot -0.16666666666666666\right)\right)}\right)}^{c\_p}\\
\mathbf{else}:\\
\;\;\;\;e^{t \cdot \left(c\_n \cdot 0.5\right)}\\
\end{array}
\end{array}
if s < -1.00000000000000003e-161Initial program 85.5%
associate-/l*85.5%
Simplified85.5%
Taylor expanded in c_n around 0 87.1%
Taylor expanded in c_p around 0 93.0%
Taylor expanded in s around 0 96.2%
if -1.00000000000000003e-161 < s Initial program 90.8%
associate-/l/90.8%
Simplified90.8%
add-exp-log90.8%
log-div90.8%
Applied egg-rr97.7%
Taylor expanded in c_n around inf 99.5%
sub-neg99.5%
log1p-undefine99.5%
distribute-neg-frac99.5%
metadata-eval99.5%
sub-neg99.5%
log1p-define99.5%
distribute-neg-frac99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in s around 0 97.0%
*-commutative97.0%
sub-neg97.0%
log1p-define97.0%
distribute-neg-frac97.0%
metadata-eval97.0%
Simplified97.0%
Taylor expanded in t around 0 96.6%
associate-*r*96.6%
Simplified96.6%
Final simplification96.5%
(FPCore (c_p c_n t s) :precision binary64 (if (<= s -1.55e-161) (pow (/ 1.0 (+ 2.0 (* s (+ -1.0 (* s 0.5))))) c_p) (exp (* t (* c_n 0.5)))))
double code(double c_p, double c_n, double t, double s) {
double tmp;
if (s <= -1.55e-161) {
tmp = pow((1.0 / (2.0 + (s * (-1.0 + (s * 0.5))))), c_p);
} else {
tmp = exp((t * (c_n * 0.5)));
}
return tmp;
}
real(8) function code(c_p, c_n, t, s)
real(8), intent (in) :: c_p
real(8), intent (in) :: c_n
real(8), intent (in) :: t
real(8), intent (in) :: s
real(8) :: tmp
if (s <= (-1.55d-161)) then
tmp = (1.0d0 / (2.0d0 + (s * ((-1.0d0) + (s * 0.5d0))))) ** c_p
else
tmp = exp((t * (c_n * 0.5d0)))
end if
code = tmp
end function
public static double code(double c_p, double c_n, double t, double s) {
double tmp;
if (s <= -1.55e-161) {
tmp = Math.pow((1.0 / (2.0 + (s * (-1.0 + (s * 0.5))))), c_p);
} else {
tmp = Math.exp((t * (c_n * 0.5)));
}
return tmp;
}
def code(c_p, c_n, t, s): tmp = 0 if s <= -1.55e-161: tmp = math.pow((1.0 / (2.0 + (s * (-1.0 + (s * 0.5))))), c_p) else: tmp = math.exp((t * (c_n * 0.5))) return tmp
function code(c_p, c_n, t, s) tmp = 0.0 if (s <= -1.55e-161) tmp = Float64(1.0 / Float64(2.0 + Float64(s * Float64(-1.0 + Float64(s * 0.5))))) ^ c_p; else tmp = exp(Float64(t * Float64(c_n * 0.5))); end return tmp end
function tmp_2 = code(c_p, c_n, t, s) tmp = 0.0; if (s <= -1.55e-161) tmp = (1.0 / (2.0 + (s * (-1.0 + (s * 0.5))))) ^ c_p; else tmp = exp((t * (c_n * 0.5))); end tmp_2 = tmp; end
code[c$95$p_, c$95$n_, t_, s_] := If[LessEqual[s, -1.55e-161], N[Power[N[(1.0 / N[(2.0 + N[(s * N[(-1.0 + N[(s * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], c$95$p], $MachinePrecision], N[Exp[N[(t * N[(c$95$n * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;s \leq -1.55 \cdot 10^{-161}:\\
\;\;\;\;{\left(\frac{1}{2 + s \cdot \left(-1 + s \cdot 0.5\right)}\right)}^{c\_p}\\
\mathbf{else}:\\
\;\;\;\;e^{t \cdot \left(c\_n \cdot 0.5\right)}\\
\end{array}
\end{array}
if s < -1.5499999999999999e-161Initial program 85.5%
associate-/l*85.5%
Simplified85.5%
Taylor expanded in c_n around 0 87.1%
Taylor expanded in c_p around 0 93.0%
Taylor expanded in s around 0 96.2%
if -1.5499999999999999e-161 < s Initial program 90.8%
associate-/l/90.8%
Simplified90.8%
add-exp-log90.8%
log-div90.8%
Applied egg-rr97.7%
Taylor expanded in c_n around inf 99.5%
sub-neg99.5%
log1p-undefine99.5%
distribute-neg-frac99.5%
metadata-eval99.5%
sub-neg99.5%
log1p-define99.5%
distribute-neg-frac99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in s around 0 97.0%
*-commutative97.0%
sub-neg97.0%
log1p-define97.0%
distribute-neg-frac97.0%
metadata-eval97.0%
Simplified97.0%
Taylor expanded in t around 0 96.6%
associate-*r*96.6%
Simplified96.6%
Final simplification96.5%
(FPCore (c_p c_n t s) :precision binary64 (if (<= s -1e-161) (pow (/ 1.0 (- 2.0 s)) c_p) (exp (* t (* c_n 0.5)))))
double code(double c_p, double c_n, double t, double s) {
double tmp;
if (s <= -1e-161) {
tmp = pow((1.0 / (2.0 - s)), c_p);
} else {
tmp = exp((t * (c_n * 0.5)));
}
return tmp;
}
real(8) function code(c_p, c_n, t, s)
real(8), intent (in) :: c_p
real(8), intent (in) :: c_n
real(8), intent (in) :: t
real(8), intent (in) :: s
real(8) :: tmp
if (s <= (-1d-161)) then
tmp = (1.0d0 / (2.0d0 - s)) ** c_p
else
tmp = exp((t * (c_n * 0.5d0)))
end if
code = tmp
end function
public static double code(double c_p, double c_n, double t, double s) {
double tmp;
if (s <= -1e-161) {
tmp = Math.pow((1.0 / (2.0 - s)), c_p);
} else {
tmp = Math.exp((t * (c_n * 0.5)));
}
return tmp;
}
def code(c_p, c_n, t, s): tmp = 0 if s <= -1e-161: tmp = math.pow((1.0 / (2.0 - s)), c_p) else: tmp = math.exp((t * (c_n * 0.5))) return tmp
function code(c_p, c_n, t, s) tmp = 0.0 if (s <= -1e-161) tmp = Float64(1.0 / Float64(2.0 - s)) ^ c_p; else tmp = exp(Float64(t * Float64(c_n * 0.5))); end return tmp end
function tmp_2 = code(c_p, c_n, t, s) tmp = 0.0; if (s <= -1e-161) tmp = (1.0 / (2.0 - s)) ^ c_p; else tmp = exp((t * (c_n * 0.5))); end tmp_2 = tmp; end
code[c$95$p_, c$95$n_, t_, s_] := If[LessEqual[s, -1e-161], N[Power[N[(1.0 / N[(2.0 - s), $MachinePrecision]), $MachinePrecision], c$95$p], $MachinePrecision], N[Exp[N[(t * N[(c$95$n * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;s \leq -1 \cdot 10^{-161}:\\
\;\;\;\;{\left(\frac{1}{2 - s}\right)}^{c\_p}\\
\mathbf{else}:\\
\;\;\;\;e^{t \cdot \left(c\_n \cdot 0.5\right)}\\
\end{array}
\end{array}
if s < -1.00000000000000003e-161Initial program 85.5%
associate-/l*85.5%
Simplified85.5%
Taylor expanded in c_n around 0 87.1%
Taylor expanded in c_p around 0 93.0%
Taylor expanded in s around 0 94.6%
neg-mul-194.6%
unsub-neg94.6%
Simplified94.6%
if -1.00000000000000003e-161 < s Initial program 90.8%
associate-/l/90.8%
Simplified90.8%
add-exp-log90.8%
log-div90.8%
Applied egg-rr97.7%
Taylor expanded in c_n around inf 99.5%
sub-neg99.5%
log1p-undefine99.5%
distribute-neg-frac99.5%
metadata-eval99.5%
sub-neg99.5%
log1p-define99.5%
distribute-neg-frac99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in s around 0 97.0%
*-commutative97.0%
sub-neg97.0%
log1p-define97.0%
distribute-neg-frac97.0%
metadata-eval97.0%
Simplified97.0%
Taylor expanded in t around 0 96.6%
associate-*r*96.6%
Simplified96.6%
Final simplification96.1%
(FPCore (c_p c_n t s) :precision binary64 (exp (* t (* c_n 0.5))))
double code(double c_p, double c_n, double t, double s) {
return exp((t * (c_n * 0.5)));
}
real(8) function code(c_p, c_n, t, s)
real(8), intent (in) :: c_p
real(8), intent (in) :: c_n
real(8), intent (in) :: t
real(8), intent (in) :: s
code = exp((t * (c_n * 0.5d0)))
end function
public static double code(double c_p, double c_n, double t, double s) {
return Math.exp((t * (c_n * 0.5)));
}
def code(c_p, c_n, t, s): return math.exp((t * (c_n * 0.5)))
function code(c_p, c_n, t, s) return exp(Float64(t * Float64(c_n * 0.5))) end
function tmp = code(c_p, c_n, t, s) tmp = exp((t * (c_n * 0.5))); end
code[c$95$p_, c$95$n_, t_, s_] := N[Exp[N[(t * N[(c$95$n * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{t \cdot \left(c\_n \cdot 0.5\right)}
\end{array}
Initial program 89.5%
associate-/l/89.5%
Simplified89.5%
add-exp-log89.5%
log-div89.5%
Applied egg-rr96.3%
Taylor expanded in c_n around inf 96.6%
sub-neg96.6%
log1p-undefine96.6%
distribute-neg-frac96.6%
metadata-eval96.6%
sub-neg96.6%
log1p-define96.6%
distribute-neg-frac96.6%
metadata-eval96.6%
Simplified96.6%
Taylor expanded in s around 0 94.7%
*-commutative94.7%
sub-neg94.7%
log1p-define94.7%
distribute-neg-frac94.7%
metadata-eval94.7%
Simplified94.7%
Taylor expanded in t around 0 94.4%
associate-*r*94.4%
Simplified94.4%
Final simplification94.4%
(FPCore (c_p c_n t s) :precision binary64 1.0)
double code(double c_p, double c_n, double t, double s) {
return 1.0;
}
real(8) function code(c_p, c_n, t, s)
real(8), intent (in) :: c_p
real(8), intent (in) :: c_n
real(8), intent (in) :: t
real(8), intent (in) :: s
code = 1.0d0
end function
public static double code(double c_p, double c_n, double t, double s) {
return 1.0;
}
def code(c_p, c_n, t, s): return 1.0
function code(c_p, c_n, t, s) return 1.0 end
function tmp = code(c_p, c_n, t, s) tmp = 1.0; end
code[c$95$p_, c$95$n_, t_, s_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 89.5%
associate-/l*89.5%
Simplified89.5%
Taylor expanded in c_n around 0 92.4%
Taylor expanded in c_p around 0 93.2%
(FPCore (c_p c_n t s) :precision binary64 (* (pow (/ (+ 1.0 (exp (- t))) (+ 1.0 (exp (- s)))) c_p) (pow (/ (+ 1.0 (exp t)) (+ 1.0 (exp s))) c_n)))
double code(double c_p, double c_n, double t, double s) {
return pow(((1.0 + exp(-t)) / (1.0 + exp(-s))), c_p) * pow(((1.0 + exp(t)) / (1.0 + exp(s))), c_n);
}
real(8) function code(c_p, c_n, t, s)
real(8), intent (in) :: c_p
real(8), intent (in) :: c_n
real(8), intent (in) :: t
real(8), intent (in) :: s
code = (((1.0d0 + exp(-t)) / (1.0d0 + exp(-s))) ** c_p) * (((1.0d0 + exp(t)) / (1.0d0 + exp(s))) ** c_n)
end function
public static double code(double c_p, double c_n, double t, double s) {
return Math.pow(((1.0 + Math.exp(-t)) / (1.0 + Math.exp(-s))), c_p) * Math.pow(((1.0 + Math.exp(t)) / (1.0 + Math.exp(s))), c_n);
}
def code(c_p, c_n, t, s): return math.pow(((1.0 + math.exp(-t)) / (1.0 + math.exp(-s))), c_p) * math.pow(((1.0 + math.exp(t)) / (1.0 + math.exp(s))), c_n)
function code(c_p, c_n, t, s) return Float64((Float64(Float64(1.0 + exp(Float64(-t))) / Float64(1.0 + exp(Float64(-s)))) ^ c_p) * (Float64(Float64(1.0 + exp(t)) / Float64(1.0 + exp(s))) ^ c_n)) end
function tmp = code(c_p, c_n, t, s) tmp = (((1.0 + exp(-t)) / (1.0 + exp(-s))) ^ c_p) * (((1.0 + exp(t)) / (1.0 + exp(s))) ^ c_n); end
code[c$95$p_, c$95$n_, t_, s_] := N[(N[Power[N[(N[(1.0 + N[Exp[(-t)], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[Exp[(-s)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], c$95$p], $MachinePrecision] * N[Power[N[(N[(1.0 + N[Exp[t], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[Exp[s], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], c$95$n], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(\frac{1 + e^{-t}}{1 + e^{-s}}\right)}^{c\_p} \cdot {\left(\frac{1 + e^{t}}{1 + e^{s}}\right)}^{c\_n}
\end{array}
herbie shell --seed 2024096
(FPCore (c_p c_n t s)
:name "Harley's example"
:precision binary64
:pre (and (< 0.0 c_p) (< 0.0 c_n))
:alt
(* (pow (/ (+ 1.0 (exp (- t))) (+ 1.0 (exp (- s)))) c_p) (pow (/ (+ 1.0 (exp t)) (+ 1.0 (exp s))) c_n))
(/ (* (pow (/ 1.0 (+ 1.0 (exp (- s)))) c_p) (pow (- 1.0 (/ 1.0 (+ 1.0 (exp (- s))))) c_n)) (* (pow (/ 1.0 (+ 1.0 (exp (- t)))) c_p) (pow (- 1.0 (/ 1.0 (+ 1.0 (exp (- t))))) c_n))))