
(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 6 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 (- (* (+ m n) 0.5) M))) (* (cos M) (exp (- (fabs (- m n)) (+ (* t_0 t_0) l))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = ((m + n) * 0.5) - M;
return cos(M) * exp((fabs((m - n)) - ((t_0 * t_0) + 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
real(8) :: t_0
t_0 = ((m + n) * 0.5d0) - m_1
code = cos(m_1) * exp((abs((m - n)) - ((t_0 * t_0) + l)))
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = ((m + n) * 0.5) - M;
return Math.cos(M) * Math.exp((Math.abs((m - n)) - ((t_0 * t_0) + l)));
}
def code(K, m, n, M, l): t_0 = ((m + n) * 0.5) - M return math.cos(M) * math.exp((math.fabs((m - n)) - ((t_0 * t_0) + l)))
function code(K, m, n, M, l) t_0 = Float64(Float64(Float64(m + n) * 0.5) - M) return Float64(cos(M) * exp(Float64(abs(Float64(m - n)) - Float64(Float64(t_0 * t_0) + l)))) end
function tmp = code(K, m, n, M, l) t_0 = ((m + n) * 0.5) - M; tmp = cos(M) * exp((abs((m - n)) - ((t_0 * t_0) + l))); end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[(N[(m + n), $MachinePrecision] * 0.5), $MachinePrecision] - M), $MachinePrecision]}, N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - N[(N[(t$95$0 * t$95$0), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(m + n\right) \cdot 0.5 - M\\
\cos M \cdot e^{\left|m - n\right| - \left(t_0 \cdot t_0 + \ell\right)}
\end{array}
\end{array}
Initial program 77.2%
Simplified77.6%
Taylor expanded in K around 0 97.1%
cos-neg97.1%
Simplified97.1%
unpow297.1%
div-inv97.1%
metadata-eval97.1%
div-inv97.1%
metadata-eval97.1%
Applied egg-rr97.1%
Final simplification97.1%
(FPCore (K m n M l) :precision binary64 (exp (- (- (fabs (- m n)) l) (pow (- (* (+ m n) 0.5) M) 2.0))))
double code(double K, double m, double n, double M, double l) {
return exp(((fabs((m - n)) - l) - pow((((m + n) * 0.5) - M), 2.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 = exp(((abs((m - n)) - l) - ((((m + n) * 0.5d0) - m_1) ** 2.0d0)))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp(((Math.abs((m - n)) - l) - Math.pow((((m + n) * 0.5) - M), 2.0)));
}
def code(K, m, n, M, l): return math.exp(((math.fabs((m - n)) - l) - math.pow((((m + n) * 0.5) - M), 2.0)))
function code(K, m, n, M, l) return exp(Float64(Float64(abs(Float64(m - n)) - l) - (Float64(Float64(Float64(m + n) * 0.5) - M) ^ 2.0))) end
function tmp = code(K, m, n, M, l) tmp = exp(((abs((m - n)) - l) - ((((m + n) * 0.5) - M) ^ 2.0))); end
code[K_, m_, n_, M_, l_] := N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[Power[N[(N[(N[(m + n), $MachinePrecision] * 0.5), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left(\left|m - n\right| - \ell\right) - {\left(\left(m + n\right) \cdot 0.5 - M\right)}^{2}}
\end{array}
Initial program 77.2%
Simplified77.6%
Taylor expanded in M around 0 76.9%
*-commutative76.9%
*-commutative76.9%
associate-*r*76.9%
Simplified76.9%
Taylor expanded in K around 0 96.8%
associate--r+96.8%
*-commutative96.8%
sub-neg96.8%
mul-1-neg96.8%
+-commutative96.8%
*-commutative96.8%
Simplified96.8%
Final simplification96.8%
(FPCore (K m n M l) :precision binary64 (exp (- (fabs (- m n)) (+ l (* 0.25 (* (+ m n) (+ m n)))))))
double code(double K, double m, double n, double M, double l) {
return exp((fabs((m - n)) - (l + (0.25 * ((m + n) * (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 = exp((abs((m - n)) - (l + (0.25d0 * ((m + n) * (m + n))))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp((Math.abs((m - n)) - (l + (0.25 * ((m + n) * (m + n))))));
}
def code(K, m, n, M, l): return math.exp((math.fabs((m - n)) - (l + (0.25 * ((m + n) * (m + n))))))
function code(K, m, n, M, l) return exp(Float64(abs(Float64(m - n)) - Float64(l + Float64(0.25 * Float64(Float64(m + n) * Float64(m + n)))))) end
function tmp = code(K, m, n, M, l) tmp = exp((abs((m - n)) - (l + (0.25 * ((m + n) * (m + n)))))); end
code[K_, m_, n_, M_, l_] := N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - N[(l + N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left|m - n\right| - \left(\ell + 0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right)\right)}
\end{array}
Initial program 77.2%
Simplified77.6%
Taylor expanded in K around 0 86.0%
cos-neg86.0%
associate-*r*86.0%
*-commutative86.0%
sin-neg86.0%
Simplified86.0%
Taylor expanded in M around 0 88.8%
+-commutative88.8%
+-commutative88.8%
Simplified88.8%
unpow288.8%
+-commutative88.8%
+-commutative88.8%
Applied egg-rr88.8%
Final simplification88.8%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (- (* m 0.5) M))
(t_1 (- (* n 0.5) M))
(t_2 (exp (- (+ n (* t_1 (+ m t_1))) (+ m l)))))
(if (<= n -1.08e-184)
t_2
(if (<= n 4.0)
(exp (- (+ n (* 0.25 (pow n 2.0))) (+ m l)))
(if (<= n 2e+140) t_2 (exp (- (+ n (* t_0 (+ n t_0))) (+ m l))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = (m * 0.5) - M;
double t_1 = (n * 0.5) - M;
double t_2 = exp(((n + (t_1 * (m + t_1))) - (m + l)));
double tmp;
if (n <= -1.08e-184) {
tmp = t_2;
} else if (n <= 4.0) {
tmp = exp(((n + (0.25 * pow(n, 2.0))) - (m + l)));
} else if (n <= 2e+140) {
tmp = t_2;
} else {
tmp = exp(((n + (t_0 * (n + t_0))) - (m + l)));
}
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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = (m * 0.5d0) - m_1
t_1 = (n * 0.5d0) - m_1
t_2 = exp(((n + (t_1 * (m + t_1))) - (m + l)))
if (n <= (-1.08d-184)) then
tmp = t_2
else if (n <= 4.0d0) then
tmp = exp(((n + (0.25d0 * (n ** 2.0d0))) - (m + l)))
else if (n <= 2d+140) then
tmp = t_2
else
tmp = exp(((n + (t_0 * (n + t_0))) - (m + l)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = (m * 0.5) - M;
double t_1 = (n * 0.5) - M;
double t_2 = Math.exp(((n + (t_1 * (m + t_1))) - (m + l)));
double tmp;
if (n <= -1.08e-184) {
tmp = t_2;
} else if (n <= 4.0) {
tmp = Math.exp(((n + (0.25 * Math.pow(n, 2.0))) - (m + l)));
} else if (n <= 2e+140) {
tmp = t_2;
} else {
tmp = Math.exp(((n + (t_0 * (n + t_0))) - (m + l)));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = (m * 0.5) - M t_1 = (n * 0.5) - M t_2 = math.exp(((n + (t_1 * (m + t_1))) - (m + l))) tmp = 0 if n <= -1.08e-184: tmp = t_2 elif n <= 4.0: tmp = math.exp(((n + (0.25 * math.pow(n, 2.0))) - (m + l))) elif n <= 2e+140: tmp = t_2 else: tmp = math.exp(((n + (t_0 * (n + t_0))) - (m + l))) return tmp
function code(K, m, n, M, l) t_0 = Float64(Float64(m * 0.5) - M) t_1 = Float64(Float64(n * 0.5) - M) t_2 = exp(Float64(Float64(n + Float64(t_1 * Float64(m + t_1))) - Float64(m + l))) tmp = 0.0 if (n <= -1.08e-184) tmp = t_2; elseif (n <= 4.0) tmp = exp(Float64(Float64(n + Float64(0.25 * (n ^ 2.0))) - Float64(m + l))); elseif (n <= 2e+140) tmp = t_2; else tmp = exp(Float64(Float64(n + Float64(t_0 * Float64(n + t_0))) - Float64(m + l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = (m * 0.5) - M; t_1 = (n * 0.5) - M; t_2 = exp(((n + (t_1 * (m + t_1))) - (m + l))); tmp = 0.0; if (n <= -1.08e-184) tmp = t_2; elseif (n <= 4.0) tmp = exp(((n + (0.25 * (n ^ 2.0))) - (m + l))); elseif (n <= 2e+140) tmp = t_2; else tmp = exp(((n + (t_0 * (n + t_0))) - (m + l))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision]}, Block[{t$95$1 = N[(N[(n * 0.5), $MachinePrecision] - M), $MachinePrecision]}, Block[{t$95$2 = N[Exp[N[(N[(n + N[(t$95$1 * N[(m + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(m + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, -1.08e-184], t$95$2, If[LessEqual[n, 4.0], N[Exp[N[(N[(n + N[(0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(m + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[n, 2e+140], t$95$2, N[Exp[N[(N[(n + N[(t$95$0 * N[(n + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(m + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := m \cdot 0.5 - M\\
t_1 := n \cdot 0.5 - M\\
t_2 := e^{\left(n + t_1 \cdot \left(m + t_1\right)\right) - \left(m + \ell\right)}\\
\mathbf{if}\;n \leq -1.08 \cdot 10^{-184}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;n \leq 4:\\
\;\;\;\;e^{\left(n + 0.25 \cdot {n}^{2}\right) - \left(m + \ell\right)}\\
\mathbf{elif}\;n \leq 2 \cdot 10^{+140}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;e^{\left(n + t_0 \cdot \left(n + t_0\right)\right) - \left(m + \ell\right)}\\
\end{array}
\end{array}
if n < -1.07999999999999995e-184 or 4 < n < 2.00000000000000012e140Initial program 77.8%
Simplified78.6%
Taylor expanded in M around 0 77.0%
*-commutative77.0%
*-commutative77.0%
associate-*r*77.0%
Simplified77.0%
log1p-expm1-u77.0%
associate-+l-77.0%
Applied egg-rr9.5%
Taylor expanded in K around 0 9.8%
Taylor expanded in m around 0 24.2%
+-commutative24.2%
unpow224.2%
distribute-rgt-out27.4%
Simplified27.4%
if -1.07999999999999995e-184 < n < 4Initial program 81.3%
Simplified81.3%
Taylor expanded in M around 0 81.3%
*-commutative81.3%
*-commutative81.3%
associate-*r*81.3%
Simplified81.3%
log1p-expm1-u81.3%
associate-+l-81.3%
Applied egg-rr25.7%
Taylor expanded in K around 0 24.6%
Taylor expanded in n around inf 52.6%
if 2.00000000000000012e140 < n Initial program 69.4%
Simplified69.4%
Taylor expanded in M around 0 69.4%
*-commutative69.4%
*-commutative69.4%
associate-*r*69.4%
Simplified69.4%
log1p-expm1-u69.4%
associate-+l-69.4%
Applied egg-rr1.1%
Taylor expanded in K around 0 1.6%
Taylor expanded in n around 0 17.2%
+-commutative17.2%
unpow217.2%
distribute-rgt-out33.7%
Simplified33.7%
Final simplification36.3%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (- (* m 0.5) M)) (t_1 (- (* n 0.5) M)))
(if (<= n 1e+134)
(exp (- (+ n (* t_1 (+ m t_1))) (+ m l)))
(exp (- (+ n (* t_0 (+ n t_0))) (+ m l))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = (m * 0.5) - M;
double t_1 = (n * 0.5) - M;
double tmp;
if (n <= 1e+134) {
tmp = exp(((n + (t_1 * (m + t_1))) - (m + l)));
} else {
tmp = exp(((n + (t_0 * (n + t_0))) - (m + l)));
}
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) :: t_1
real(8) :: tmp
t_0 = (m * 0.5d0) - m_1
t_1 = (n * 0.5d0) - m_1
if (n <= 1d+134) then
tmp = exp(((n + (t_1 * (m + t_1))) - (m + l)))
else
tmp = exp(((n + (t_0 * (n + t_0))) - (m + l)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = (m * 0.5) - M;
double t_1 = (n * 0.5) - M;
double tmp;
if (n <= 1e+134) {
tmp = Math.exp(((n + (t_1 * (m + t_1))) - (m + l)));
} else {
tmp = Math.exp(((n + (t_0 * (n + t_0))) - (m + l)));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = (m * 0.5) - M t_1 = (n * 0.5) - M tmp = 0 if n <= 1e+134: tmp = math.exp(((n + (t_1 * (m + t_1))) - (m + l))) else: tmp = math.exp(((n + (t_0 * (n + t_0))) - (m + l))) return tmp
function code(K, m, n, M, l) t_0 = Float64(Float64(m * 0.5) - M) t_1 = Float64(Float64(n * 0.5) - M) tmp = 0.0 if (n <= 1e+134) tmp = exp(Float64(Float64(n + Float64(t_1 * Float64(m + t_1))) - Float64(m + l))); else tmp = exp(Float64(Float64(n + Float64(t_0 * Float64(n + t_0))) - Float64(m + l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = (m * 0.5) - M; t_1 = (n * 0.5) - M; tmp = 0.0; if (n <= 1e+134) tmp = exp(((n + (t_1 * (m + t_1))) - (m + l))); else tmp = exp(((n + (t_0 * (n + t_0))) - (m + l))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision]}, Block[{t$95$1 = N[(N[(n * 0.5), $MachinePrecision] - M), $MachinePrecision]}, If[LessEqual[n, 1e+134], N[Exp[N[(N[(n + N[(t$95$1 * N[(m + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(m + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[N[(N[(n + N[(t$95$0 * N[(n + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(m + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := m \cdot 0.5 - M\\
t_1 := n \cdot 0.5 - M\\
\mathbf{if}\;n \leq 10^{+134}:\\
\;\;\;\;e^{\left(n + t_1 \cdot \left(m + t_1\right)\right) - \left(m + \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{\left(n + t_0 \cdot \left(n + t_0\right)\right) - \left(m + \ell\right)}\\
\end{array}
\end{array}
if n < 9.99999999999999921e133Initial program 79.1%
Simplified79.6%
Taylor expanded in M around 0 78.6%
*-commutative78.6%
*-commutative78.6%
associate-*r*78.6%
Simplified78.6%
log1p-expm1-u78.6%
associate-+l-78.6%
Applied egg-rr15.6%
Taylor expanded in K around 0 15.4%
Taylor expanded in m around 0 30.5%
+-commutative30.5%
unpow230.5%
distribute-rgt-out32.5%
Simplified32.5%
if 9.99999999999999921e133 < n Initial program 69.4%
Simplified69.4%
Taylor expanded in M around 0 69.4%
*-commutative69.4%
*-commutative69.4%
associate-*r*69.4%
Simplified69.4%
log1p-expm1-u69.4%
associate-+l-69.4%
Applied egg-rr1.1%
Taylor expanded in K around 0 1.6%
Taylor expanded in n around 0 17.2%
+-commutative17.2%
unpow217.2%
distribute-rgt-out33.7%
Simplified33.7%
Final simplification32.7%
(FPCore (K m n M l) :precision binary64 (let* ((t_0 (- (* m 0.5) M))) (exp (- (+ n (* t_0 (+ n t_0))) (+ m l)))))
double code(double K, double m, double n, double M, double l) {
double t_0 = (m * 0.5) - M;
return exp(((n + (t_0 * (n + t_0))) - (m + 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
real(8) :: t_0
t_0 = (m * 0.5d0) - m_1
code = exp(((n + (t_0 * (n + t_0))) - (m + l)))
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = (m * 0.5) - M;
return Math.exp(((n + (t_0 * (n + t_0))) - (m + l)));
}
def code(K, m, n, M, l): t_0 = (m * 0.5) - M return math.exp(((n + (t_0 * (n + t_0))) - (m + l)))
function code(K, m, n, M, l) t_0 = Float64(Float64(m * 0.5) - M) return exp(Float64(Float64(n + Float64(t_0 * Float64(n + t_0))) - Float64(m + l))) end
function tmp = code(K, m, n, M, l) t_0 = (m * 0.5) - M; tmp = exp(((n + (t_0 * (n + t_0))) - (m + l))); end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision]}, N[Exp[N[(N[(n + N[(t$95$0 * N[(n + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(m + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := m \cdot 0.5 - M\\
e^{\left(n + t_0 \cdot \left(n + t_0\right)\right) - \left(m + \ell\right)}
\end{array}
\end{array}
Initial program 77.2%
Simplified77.6%
Taylor expanded in M around 0 76.9%
*-commutative76.9%
*-commutative76.9%
associate-*r*76.9%
Simplified76.9%
log1p-expm1-u76.9%
associate-+l-76.9%
Applied egg-rr12.8%
Taylor expanded in K around 0 12.8%
Taylor expanded in n around 0 24.5%
+-commutative24.5%
unpow224.5%
distribute-rgt-out29.7%
Simplified29.7%
Final simplification29.7%
herbie shell --seed 2023336
(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)))))))