
(FPCore (K m n M l) :precision binary64 (* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l): return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
function code(K, m, n, M, l) return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n)))))) end
function tmp = code(K, m, n, M, l) tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-((((m + n) / 2.0) - M) ^ 2.0) - (l - abs((m - n))))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (K m n M l) :precision binary64 (* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l): return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
function code(K, m, n, M, l) return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n)))))) end
function tmp = code(K, m, n, M, l) tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-((((m + n) / 2.0) - M) ^ 2.0) - (l - abs((m - n))))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\end{array}
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- m n)))
(t_1 (exp (- (- t_0 l) (pow (- (/ (+ m n) 2.0) M) 2.0))))
(t_2 (* K (+ m n)))
(t_3 (* 0.5 t_2)))
(if (<= (* (cos (- (/ t_2 2.0) M)) t_1) INFINITY)
(* t_1 (fma M (sin t_3) (cos t_3)))
(exp (- t_0 (fma 0.25 (* (+ m n) (+ m n)) l))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((m - n));
double t_1 = exp(((t_0 - l) - pow((((m + n) / 2.0) - M), 2.0)));
double t_2 = K * (m + n);
double t_3 = 0.5 * t_2;
double tmp;
if ((cos(((t_2 / 2.0) - M)) * t_1) <= ((double) INFINITY)) {
tmp = t_1 * fma(M, sin(t_3), cos(t_3));
} else {
tmp = exp((t_0 - fma(0.25, ((m + n) * (m + n)), l)));
}
return tmp;
}
function code(K, m, n, M, l) t_0 = abs(Float64(m - n)) t_1 = exp(Float64(Float64(t_0 - l) - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0))) t_2 = Float64(K * Float64(m + n)) t_3 = Float64(0.5 * t_2) tmp = 0.0 if (Float64(cos(Float64(Float64(t_2 / 2.0) - M)) * t_1) <= Inf) tmp = Float64(t_1 * fma(M, sin(t_3), cos(t_3))); else tmp = exp(Float64(t_0 - fma(0.25, Float64(Float64(m + n) * Float64(m + n)), l))); end return tmp end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(N[(t$95$0 - l), $MachinePrecision] - N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(0.5 * t$95$2), $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(N[(t$95$2 / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision], Infinity], N[(t$95$1 * N[(M * N[Sin[t$95$3], $MachinePrecision] + N[Cos[t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Exp[N[(t$95$0 - N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|m - n\right|\\
t_1 := e^{\left(t\_0 - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}\\
t_2 := K \cdot \left(m + n\right)\\
t_3 := 0.5 \cdot t\_2\\
\mathbf{if}\;\cos \left(\frac{t\_2}{2} - M\right) \cdot t\_1 \leq \infty:\\
\;\;\;\;t\_1 \cdot \mathsf{fma}\left(M, \sin t\_3, \cos t\_3\right)\\
\mathbf{else}:\\
\;\;\;\;e^{t\_0 - \mathsf{fma}\left(0.25, \left(m + n\right) \cdot \left(m + n\right), \ell\right)}\\
\end{array}
\end{array}
if (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) #s(literal 2 binary64)) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) #s(literal 2 binary64)) M) #s(literal 2 binary64))) (-.f64 l (fabs.f64 (-.f64 m n)))))) < +inf.0Initial program 95.7%
Taylor expanded in M around 0
+-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6496.2
Simplified96.2%
if +inf.0 < (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) #s(literal 2 binary64)) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) #s(literal 2 binary64)) M) #s(literal 2 binary64))) (-.f64 l (fabs.f64 (-.f64 m n)))))) Initial program 0.0%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6498.1
Simplified98.1%
Taylor expanded in M around 0
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
sub-negN/A
mul-1-negN/A
lower-fabs.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6498.1
Simplified98.1%
Final simplification96.6%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (exp (* M (- M)))))
(if (<= M -126.0)
t_0
(if (<= M 45.0)
(exp (- (fabs (- m n)) (fma 0.25 (* (+ m n) (+ m n)) l)))
t_0))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp((M * -M));
double tmp;
if (M <= -126.0) {
tmp = t_0;
} else if (M <= 45.0) {
tmp = exp((fabs((m - n)) - fma(0.25, ((m + n) * (m + n)), l)));
} else {
tmp = t_0;
}
return tmp;
}
function code(K, m, n, M, l) t_0 = exp(Float64(M * Float64(-M))) tmp = 0.0 if (M <= -126.0) tmp = t_0; elseif (M <= 45.0) tmp = exp(Float64(abs(Float64(m - n)) - fma(0.25, Float64(Float64(m + n) * Float64(m + n)), l))); else tmp = t_0; end return tmp end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[M, -126.0], t$95$0, If[LessEqual[M, 45.0], N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{M \cdot \left(-M\right)}\\
\mathbf{if}\;M \leq -126:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;M \leq 45:\\
\;\;\;\;e^{\left|m - n\right| - \mathsf{fma}\left(0.25, \left(m + n\right) \cdot \left(m + n\right), \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if M < -126 or 45 < M Initial program 77.6%
Taylor expanded in M around 0
lower-cos.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6477.6
Simplified77.6%
Taylor expanded in K around 0
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
sub-negN/A
mul-1-negN/A
lower-fabs.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6497.6
Simplified97.6%
Taylor expanded in M around inf
mul-1-negN/A
unpow2N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-neg.f6496.9
Simplified96.9%
if -126 < M < 45Initial program 75.1%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6492.6
Simplified92.6%
Taylor expanded in M around 0
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
sub-negN/A
mul-1-negN/A
lower-fabs.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6492.6
Simplified92.6%
Final simplification94.7%
(FPCore (K m n M l) :precision binary64 (let* ((t_0 (- (* 0.5 (+ m n)) M))) (exp (- (fabs (- m n)) (fma t_0 t_0 l)))))
double code(double K, double m, double n, double M, double l) {
double t_0 = (0.5 * (m + n)) - M;
return exp((fabs((m - n)) - fma(t_0, t_0, l)));
}
function code(K, m, n, M, l) t_0 = Float64(Float64(0.5 * Float64(m + n)) - M) return exp(Float64(abs(Float64(m - n)) - fma(t_0, t_0, l))) end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[(0.5 * N[(m + n), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]}, N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - N[(t$95$0 * t$95$0 + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(m + n\right) - M\\
e^{\left|m - n\right| - \mathsf{fma}\left(t\_0, t\_0, \ell\right)}
\end{array}
\end{array}
Initial program 76.3%
Taylor expanded in M around 0
lower-cos.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6476.3
Simplified76.3%
Taylor expanded in K around 0
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
sub-negN/A
mul-1-negN/A
lower-fabs.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6495.0
Simplified95.0%
Final simplification95.0%
(FPCore (K m n M l)
:precision binary64
(if (<= m -530000000.0)
(exp (* (* m m) -0.25))
(if (<= m -2.45e-296)
(exp (* M (- M)))
(exp (- (fabs (- m n)) (* 0.25 (* n n)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -530000000.0) {
tmp = exp(((m * m) * -0.25));
} else if (m <= -2.45e-296) {
tmp = exp((M * -M));
} else {
tmp = exp((fabs((m - n)) - (0.25 * (n * n))));
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: tmp
if (m <= (-530000000.0d0)) then
tmp = exp(((m * m) * (-0.25d0)))
else if (m <= (-2.45d-296)) then
tmp = exp((m_1 * -m_1))
else
tmp = exp((abs((m - n)) - (0.25d0 * (n * n))))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -530000000.0) {
tmp = Math.exp(((m * m) * -0.25));
} else if (m <= -2.45e-296) {
tmp = Math.exp((M * -M));
} else {
tmp = Math.exp((Math.abs((m - n)) - (0.25 * (n * n))));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -530000000.0: tmp = math.exp(((m * m) * -0.25)) elif m <= -2.45e-296: tmp = math.exp((M * -M)) else: tmp = math.exp((math.fabs((m - n)) - (0.25 * (n * n)))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -530000000.0) tmp = exp(Float64(Float64(m * m) * -0.25)); elseif (m <= -2.45e-296) tmp = exp(Float64(M * Float64(-M))); else tmp = exp(Float64(abs(Float64(m - n)) - Float64(0.25 * Float64(n * n)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -530000000.0) tmp = exp(((m * m) * -0.25)); elseif (m <= -2.45e-296) tmp = exp((M * -M)); else tmp = exp((abs((m - n)) - (0.25 * (n * n)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -530000000.0], N[Exp[N[(N[(m * m), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, -2.45e-296], N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision], N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - N[(0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -530000000:\\
\;\;\;\;e^{\left(m \cdot m\right) \cdot -0.25}\\
\mathbf{elif}\;m \leq -2.45 \cdot 10^{-296}:\\
\;\;\;\;e^{M \cdot \left(-M\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{\left|m - n\right| - 0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if m < -5.3e8Initial program 65.0%
Taylor expanded in M around 0
lower-cos.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6465.0
Simplified65.0%
Taylor expanded in K around 0
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
sub-negN/A
mul-1-negN/A
lower-fabs.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64100.0
Simplified100.0%
Taylor expanded in m around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6498.4
Simplified98.4%
if -5.3e8 < m < -2.4499999999999999e-296Initial program 81.6%
Taylor expanded in M around 0
lower-cos.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6481.6
Simplified81.6%
Taylor expanded in K around 0
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
sub-negN/A
mul-1-negN/A
lower-fabs.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6490.6
Simplified90.6%
Taylor expanded in M around inf
mul-1-negN/A
unpow2N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-neg.f6462.6
Simplified62.6%
if -2.4499999999999999e-296 < m Initial program 78.9%
Taylor expanded in M around 0
lower-cos.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6478.9
Simplified78.9%
Taylor expanded in K around 0
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
sub-negN/A
mul-1-negN/A
lower-fabs.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6494.8
Simplified94.8%
Taylor expanded in n around inf
lower-*.f64N/A
unpow2N/A
lower-*.f6452.8
Simplified52.8%
Final simplification65.8%
(FPCore (K m n M l) :precision binary64 (if (<= m -530000000.0) (exp (* (* m m) -0.25)) (if (<= m 2e-194) (exp (* M (- M))) (exp (* -0.25 (* n n))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -530000000.0) {
tmp = exp(((m * m) * -0.25));
} else if (m <= 2e-194) {
tmp = exp((M * -M));
} else {
tmp = exp((-0.25 * (n * n)));
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: tmp
if (m <= (-530000000.0d0)) then
tmp = exp(((m * m) * (-0.25d0)))
else if (m <= 2d-194) then
tmp = exp((m_1 * -m_1))
else
tmp = exp(((-0.25d0) * (n * n)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -530000000.0) {
tmp = Math.exp(((m * m) * -0.25));
} else if (m <= 2e-194) {
tmp = Math.exp((M * -M));
} else {
tmp = Math.exp((-0.25 * (n * n)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -530000000.0: tmp = math.exp(((m * m) * -0.25)) elif m <= 2e-194: tmp = math.exp((M * -M)) else: tmp = math.exp((-0.25 * (n * n))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -530000000.0) tmp = exp(Float64(Float64(m * m) * -0.25)); elseif (m <= 2e-194) tmp = exp(Float64(M * Float64(-M))); else tmp = exp(Float64(-0.25 * Float64(n * n))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -530000000.0) tmp = exp(((m * m) * -0.25)); elseif (m <= 2e-194) tmp = exp((M * -M)); else tmp = exp((-0.25 * (n * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -530000000.0], N[Exp[N[(N[(m * m), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, 2e-194], N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision], N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -530000000:\\
\;\;\;\;e^{\left(m \cdot m\right) \cdot -0.25}\\
\mathbf{elif}\;m \leq 2 \cdot 10^{-194}:\\
\;\;\;\;e^{M \cdot \left(-M\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if m < -5.3e8Initial program 65.0%
Taylor expanded in M around 0
lower-cos.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6465.0
Simplified65.0%
Taylor expanded in K around 0
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
sub-negN/A
mul-1-negN/A
lower-fabs.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64100.0
Simplified100.0%
Taylor expanded in m around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6498.4
Simplified98.4%
if -5.3e8 < m < 2.00000000000000004e-194Initial program 83.1%
Taylor expanded in M around 0
lower-cos.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6483.1
Simplified83.1%
Taylor expanded in K around 0
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
sub-negN/A
mul-1-negN/A
lower-fabs.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6492.4
Simplified92.4%
Taylor expanded in M around inf
mul-1-negN/A
unpow2N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-neg.f6462.8
Simplified62.8%
if 2.00000000000000004e-194 < m Initial program 77.0%
Taylor expanded in M around 0
lower-cos.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6477.0
Simplified77.0%
Taylor expanded in K around 0
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
sub-negN/A
mul-1-negN/A
lower-fabs.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6494.4
Simplified94.4%
Taylor expanded in n around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6456.4
Simplified56.4%
Final simplification68.4%
(FPCore (K m n M l) :precision binary64 (let* ((t_0 (exp (* M (- M))))) (if (<= M -110.0) t_0 (if (<= M 1.2e-11) (exp (* (* m m) -0.25)) t_0))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp((M * -M));
double tmp;
if (M <= -110.0) {
tmp = t_0;
} else if (M <= 1.2e-11) {
tmp = exp(((m * m) * -0.25));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: t_0
real(8) :: tmp
t_0 = exp((m_1 * -m_1))
if (m_1 <= (-110.0d0)) then
tmp = t_0
else if (m_1 <= 1.2d-11) then
tmp = exp(((m * m) * (-0.25d0)))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.exp((M * -M));
double tmp;
if (M <= -110.0) {
tmp = t_0;
} else if (M <= 1.2e-11) {
tmp = Math.exp(((m * m) * -0.25));
} else {
tmp = t_0;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp((M * -M)) tmp = 0 if M <= -110.0: tmp = t_0 elif M <= 1.2e-11: tmp = math.exp(((m * m) * -0.25)) else: tmp = t_0 return tmp
function code(K, m, n, M, l) t_0 = exp(Float64(M * Float64(-M))) tmp = 0.0 if (M <= -110.0) tmp = t_0; elseif (M <= 1.2e-11) tmp = exp(Float64(Float64(m * m) * -0.25)); else tmp = t_0; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp((M * -M)); tmp = 0.0; if (M <= -110.0) tmp = t_0; elseif (M <= 1.2e-11) tmp = exp(((m * m) * -0.25)); else tmp = t_0; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[M, -110.0], t$95$0, If[LessEqual[M, 1.2e-11], N[Exp[N[(N[(m * m), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{M \cdot \left(-M\right)}\\
\mathbf{if}\;M \leq -110:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;M \leq 1.2 \cdot 10^{-11}:\\
\;\;\;\;e^{\left(m \cdot m\right) \cdot -0.25}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if M < -110 or 1.2000000000000001e-11 < M Initial program 77.8%
Taylor expanded in M around 0
lower-cos.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6477.8
Simplified77.8%
Taylor expanded in K around 0
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
sub-negN/A
mul-1-negN/A
lower-fabs.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6497.6
Simplified97.6%
Taylor expanded in M around inf
mul-1-negN/A
unpow2N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-neg.f6496.1
Simplified96.1%
if -110 < M < 1.2000000000000001e-11Initial program 74.9%
Taylor expanded in M around 0
lower-cos.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6474.9
Simplified74.9%
Taylor expanded in K around 0
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
sub-negN/A
mul-1-negN/A
lower-fabs.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6492.5
Simplified92.5%
Taylor expanded in m around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6458.8
Simplified58.8%
(FPCore (K m n M l) :precision binary64 (let* ((t_0 (exp (* M (- M))))) (if (<= M -2.75e-5) t_0 (if (<= M 4e-14) (exp (- l)) t_0))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp((M * -M));
double tmp;
if (M <= -2.75e-5) {
tmp = t_0;
} else if (M <= 4e-14) {
tmp = exp(-l);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: t_0
real(8) :: tmp
t_0 = exp((m_1 * -m_1))
if (m_1 <= (-2.75d-5)) then
tmp = t_0
else if (m_1 <= 4d-14) then
tmp = exp(-l)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.exp((M * -M));
double tmp;
if (M <= -2.75e-5) {
tmp = t_0;
} else if (M <= 4e-14) {
tmp = Math.exp(-l);
} else {
tmp = t_0;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp((M * -M)) tmp = 0 if M <= -2.75e-5: tmp = t_0 elif M <= 4e-14: tmp = math.exp(-l) else: tmp = t_0 return tmp
function code(K, m, n, M, l) t_0 = exp(Float64(M * Float64(-M))) tmp = 0.0 if (M <= -2.75e-5) tmp = t_0; elseif (M <= 4e-14) tmp = exp(Float64(-l)); else tmp = t_0; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp((M * -M)); tmp = 0.0; if (M <= -2.75e-5) tmp = t_0; elseif (M <= 4e-14) tmp = exp(-l); else tmp = t_0; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[M, -2.75e-5], t$95$0, If[LessEqual[M, 4e-14], N[Exp[(-l)], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{M \cdot \left(-M\right)}\\
\mathbf{if}\;M \leq -2.75 \cdot 10^{-5}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;M \leq 4 \cdot 10^{-14}:\\
\;\;\;\;e^{-\ell}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if M < -2.7500000000000001e-5 or 4e-14 < M Initial program 77.5%
Taylor expanded in M around 0
lower-cos.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6477.5
Simplified77.5%
Taylor expanded in K around 0
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
sub-negN/A
mul-1-negN/A
lower-fabs.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6497.7
Simplified97.7%
Taylor expanded in M around inf
mul-1-negN/A
unpow2N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-neg.f6494.7
Simplified94.7%
if -2.7500000000000001e-5 < M < 4e-14Initial program 75.1%
Taylor expanded in M around 0
lower-cos.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6475.1
Simplified75.1%
Taylor expanded in K around 0
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
sub-negN/A
mul-1-negN/A
lower-fabs.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6492.4
Simplified92.4%
Taylor expanded in l around inf
neg-mul-1N/A
lower-neg.f6446.6
Simplified46.6%
(FPCore (K m n M l) :precision binary64 (exp (- l)))
double code(double K, double m, double n, double M, double l) {
return exp(-l);
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = exp(-l)
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp(-l);
}
def code(K, m, n, M, l): return math.exp(-l)
function code(K, m, n, M, l) return exp(Float64(-l)) end
function tmp = code(K, m, n, M, l) tmp = exp(-l); end
code[K_, m_, n_, M_, l_] := N[Exp[(-l)], $MachinePrecision]
\begin{array}{l}
\\
e^{-\ell}
\end{array}
Initial program 76.3%
Taylor expanded in M around 0
lower-cos.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6476.3
Simplified76.3%
Taylor expanded in K around 0
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
sub-negN/A
mul-1-negN/A
lower-fabs.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6495.0
Simplified95.0%
Taylor expanded in l around inf
neg-mul-1N/A
lower-neg.f6432.4
Simplified32.4%
(FPCore (K m n M l) :precision binary64 (cos M))
double code(double K, double m, double n, double M, double l) {
return cos(M);
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos(m_1)
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M);
}
def code(K, m, n, M, l): return math.cos(M)
function code(K, m, n, M, l) return cos(M) end
function tmp = code(K, m, n, M, l) tmp = cos(M); end
code[K_, m_, n_, M_, l_] := N[Cos[M], $MachinePrecision]
\begin{array}{l}
\\
\cos M
\end{array}
Initial program 76.3%
Taylor expanded in m around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6439.8
Simplified39.8%
Taylor expanded in m around 0
lower-cos.f64N/A
sub-negN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f647.5
Simplified7.5%
Taylor expanded in n around 0
cos-negN/A
lower-cos.f647.5
Simplified7.5%
(FPCore (K m n M l) :precision binary64 1.0)
double code(double K, double m, double n, double M, double l) {
return 1.0;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = 1.0d0
end function
public static double code(double K, double m, double n, double M, double l) {
return 1.0;
}
def code(K, m, n, M, l): return 1.0
function code(K, m, n, M, l) return 1.0 end
function tmp = code(K, m, n, M, l) tmp = 1.0; end
code[K_, m_, n_, M_, l_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 76.3%
Taylor expanded in m around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6439.8
Simplified39.8%
Taylor expanded in m around 0
lower-cos.f64N/A
sub-negN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f647.5
Simplified7.5%
Taylor expanded in n around 0
cos-negN/A
lower-cos.f647.5
Simplified7.5%
Taylor expanded in M around 0
Simplified7.5%
herbie shell --seed 2024208
(FPCore (K m n M l)
:name "Maksimov and Kolovsky, Equation (32)"
:precision binary64
(* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))