
(FPCore (J l K U) :precision binary64 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U): return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) end
function tmp = code(J, l, K, U) tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (J l K U) :precision binary64 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U): return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) end
function tmp = code(J, l, K, U) tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (- (exp l) (exp (- l)))))
(if (or (<= t_0 -2.0) (not (<= t_0 0.0)))
(+ (* (* t_0 J) (cos (/ K 2.0))) U)
(fma (* l J) (* 2.0 (cos (* K 0.5))) U))))
double code(double J, double l, double K, double U) {
double t_0 = exp(l) - exp(-l);
double tmp;
if ((t_0 <= -2.0) || !(t_0 <= 0.0)) {
tmp = ((t_0 * J) * cos((K / 2.0))) + U;
} else {
tmp = fma((l * J), (2.0 * cos((K * 0.5))), U);
}
return tmp;
}
function code(J, l, K, U) t_0 = Float64(exp(l) - exp(Float64(-l))) tmp = 0.0 if ((t_0 <= -2.0) || !(t_0 <= 0.0)) tmp = Float64(Float64(Float64(t_0 * J) * cos(Float64(K / 2.0))) + U); else tmp = fma(Float64(l * J), Float64(2.0 * cos(Float64(K * 0.5))), U); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -2.0], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], N[(N[(N[(t$95$0 * J), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(l * J), $MachinePrecision] * N[(2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t_0 \leq -2 \lor \neg \left(t_0 \leq 0\right):\\
\;\;\;\;\left(t_0 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right) + U\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\ell \cdot J, 2 \cdot \cos \left(K \cdot 0.5\right), U\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -2 or 0.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
if -2 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 0.0Initial program 72.2%
Taylor expanded in l around 0 99.9%
+-commutative99.9%
*-commutative99.9%
associate-*r*99.9%
associate-*l*99.9%
fma-def99.9%
*-commutative99.9%
*-commutative99.9%
Simplified99.9%
Final simplification100.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (- (exp l) (exp (- l)))))
(if (or (<= t_0 -2.0) (not (<= t_0 0.0)))
(+ (* t_0 J) U)
(+ U (* (cos (/ K 2.0)) (* J (* l 2.0)))))))
double code(double J, double l, double K, double U) {
double t_0 = exp(l) - exp(-l);
double tmp;
if ((t_0 <= -2.0) || !(t_0 <= 0.0)) {
tmp = (t_0 * J) + U;
} else {
tmp = U + (cos((K / 2.0)) * (J * (l * 2.0)));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: tmp
t_0 = exp(l) - exp(-l)
if ((t_0 <= (-2.0d0)) .or. (.not. (t_0 <= 0.0d0))) then
tmp = (t_0 * j) + u
else
tmp = u + (cos((k / 2.0d0)) * (j * (l * 2.0d0)))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = Math.exp(l) - Math.exp(-l);
double tmp;
if ((t_0 <= -2.0) || !(t_0 <= 0.0)) {
tmp = (t_0 * J) + U;
} else {
tmp = U + (Math.cos((K / 2.0)) * (J * (l * 2.0)));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.exp(l) - math.exp(-l) tmp = 0 if (t_0 <= -2.0) or not (t_0 <= 0.0): tmp = (t_0 * J) + U else: tmp = U + (math.cos((K / 2.0)) * (J * (l * 2.0))) return tmp
function code(J, l, K, U) t_0 = Float64(exp(l) - exp(Float64(-l))) tmp = 0.0 if ((t_0 <= -2.0) || !(t_0 <= 0.0)) tmp = Float64(Float64(t_0 * J) + U); else tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * 2.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = exp(l) - exp(-l); tmp = 0.0; if ((t_0 <= -2.0) || ~((t_0 <= 0.0))) tmp = (t_0 * J) + U; else tmp = U + (cos((K / 2.0)) * (J * (l * 2.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -2.0], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], N[(N[(t$95$0 * J), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t_0 \leq -2 \lor \neg \left(t_0 \leq 0\right):\\
\;\;\;\;t_0 \cdot J + U\\
\mathbf{else}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -2 or 0.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
Taylor expanded in K around 0 72.1%
if -2 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 0.0Initial program 72.2%
Taylor expanded in l around 0 99.9%
Final simplification86.7%
(FPCore (J l K U)
:precision binary64
(let* ((t_0
(+ U (* (cos (/ K 2.0)) (* (pow l 3.0) (* J 0.3333333333333333)))))
(t_1 (+ (* (- (exp l) (exp (- l))) J) U)))
(if (<= l -7.6e+70)
t_0
(if (<= l -0.00027)
t_1
(if (<= l 0.00019)
(fma (* l J) (* 2.0 (cos (* K 0.5))) U)
(if (<= l 3.5e+82) t_1 t_0))))))
double code(double J, double l, double K, double U) {
double t_0 = U + (cos((K / 2.0)) * (pow(l, 3.0) * (J * 0.3333333333333333)));
double t_1 = ((exp(l) - exp(-l)) * J) + U;
double tmp;
if (l <= -7.6e+70) {
tmp = t_0;
} else if (l <= -0.00027) {
tmp = t_1;
} else if (l <= 0.00019) {
tmp = fma((l * J), (2.0 * cos((K * 0.5))), U);
} else if (l <= 3.5e+82) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
function code(J, l, K, U) t_0 = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64((l ^ 3.0) * Float64(J * 0.3333333333333333)))) t_1 = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U) tmp = 0.0 if (l <= -7.6e+70) tmp = t_0; elseif (l <= -0.00027) tmp = t_1; elseif (l <= 0.00019) tmp = fma(Float64(l * J), Float64(2.0 * cos(Float64(K * 0.5))), U); elseif (l <= 3.5e+82) tmp = t_1; else tmp = t_0; end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]}, If[LessEqual[l, -7.6e+70], t$95$0, If[LessEqual[l, -0.00027], t$95$1, If[LessEqual[l, 0.00019], N[(N[(l * J), $MachinePrecision] * N[(2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 3.5e+82], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\
t_1 := \left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{if}\;\ell \leq -7.6 \cdot 10^{+70}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq -0.00027:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\ell \leq 0.00019:\\
\;\;\;\;\mathsf{fma}\left(\ell \cdot J, 2 \cdot \cos \left(K \cdot 0.5\right), U\right)\\
\mathbf{elif}\;\ell \leq 3.5 \cdot 10^{+82}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if l < -7.5999999999999996e70 or 3.5e82 < l Initial program 100.0%
Taylor expanded in l around 0 98.9%
Taylor expanded in l around inf 98.9%
associate-*r*68.5%
Simplified98.9%
if -7.5999999999999996e70 < l < -2.70000000000000003e-4 or 1.9000000000000001e-4 < l < 3.5e82Initial program 99.9%
Taylor expanded in K around 0 79.9%
if -2.70000000000000003e-4 < l < 1.9000000000000001e-4Initial program 72.2%
Taylor expanded in l around 0 99.9%
+-commutative99.9%
*-commutative99.9%
associate-*r*99.9%
associate-*l*99.9%
fma-def99.9%
*-commutative99.9%
*-commutative99.9%
Simplified99.9%
Final simplification97.2%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 -0.055)
(+ U (* t_0 (* J (* l 2.0))))
(+ U (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double tmp;
if (t_0 <= -0.055) {
tmp = U + (t_0 * (J * (l * 2.0)));
} else {
tmp = U + (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0)));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: tmp
t_0 = cos((k / 2.0d0))
if (t_0 <= (-0.055d0)) then
tmp = u + (t_0 * (j * (l * 2.0d0)))
else
tmp = u + (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0)))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double tmp;
if (t_0 <= -0.055) {
tmp = U + (t_0 * (J * (l * 2.0)));
} else {
tmp = U + (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0)));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) tmp = 0 if t_0 <= -0.055: tmp = U + (t_0 * (J * (l * 2.0))) else: tmp = U + (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0))) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= -0.055) tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * 2.0)))); else tmp = Float64(U + Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K / 2.0)); tmp = 0.0; if (t_0 <= -0.055) tmp = U + (t_0 * (J * (l * 2.0))); else tmp = U + (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, -0.055], N[(U + N[(t$95$0 * N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t_0 \leq -0.055:\\
\;\;\;\;U + t_0 \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < -0.0550000000000000003Initial program 86.5%
Taylor expanded in l around 0 65.4%
if -0.0550000000000000003 < (cos.f64 (/.f64 K 2)) Initial program 85.1%
Taylor expanded in l around 0 90.8%
Taylor expanded in K around 0 87.3%
Final simplification81.4%
(FPCore (J l K U) :precision binary64 (+ U (* (cos (/ K 2.0)) (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0))))))
double code(double J, double l, double K, double U) {
return U + (cos((K / 2.0)) * (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0))));
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u + (cos((k / 2.0d0)) * (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))))
end function
public static double code(double J, double l, double K, double U) {
return U + (Math.cos((K / 2.0)) * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))));
}
def code(J, l, K, U): return U + (math.cos((K / 2.0)) * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0))))
function code(J, l, K, U) return Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0))))) end
function tmp = code(J, l, K, U) tmp = U + (cos((K / 2.0)) * (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)))); end
code[J_, l_, K_, U_] := N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)
\end{array}
Initial program 85.5%
Taylor expanded in l around 0 91.8%
Final simplification91.8%
(FPCore (J l K U) :precision binary64 (if (or (<= l -0.00265) (not (<= l 0.00048))) (+ (* (- (exp l) (exp (- l))) J) U) (fma (* l J) (* 2.0 (cos (* K 0.5))) U)))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -0.00265) || !(l <= 0.00048)) {
tmp = ((exp(l) - exp(-l)) * J) + U;
} else {
tmp = fma((l * J), (2.0 * cos((K * 0.5))), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if ((l <= -0.00265) || !(l <= 0.00048)) tmp = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U); else tmp = fma(Float64(l * J), Float64(2.0 * cos(Float64(K * 0.5))), U); end return tmp end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -0.00265], N[Not[LessEqual[l, 0.00048]], $MachinePrecision]], N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision], N[(N[(l * J), $MachinePrecision] * N[(2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -0.00265 \lor \neg \left(\ell \leq 0.00048\right):\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\ell \cdot J, 2 \cdot \cos \left(K \cdot 0.5\right), U\right)\\
\end{array}
\end{array}
if l < -0.00265000000000000001 or 4.80000000000000012e-4 < l Initial program 100.0%
Taylor expanded in K around 0 72.1%
if -0.00265000000000000001 < l < 4.80000000000000012e-4Initial program 72.2%
Taylor expanded in l around 0 99.9%
+-commutative99.9%
*-commutative99.9%
associate-*r*99.9%
associate-*l*99.9%
fma-def99.9%
*-commutative99.9%
*-commutative99.9%
Simplified99.9%
Final simplification86.7%
(FPCore (J l K U) :precision binary64 (if (or (<= l -1.9e+16) (not (<= l 2.6e+66))) (+ U (* (pow l 3.0) (* J 0.3333333333333333))) (+ U (* 2.0 (* J (* l (cos (* K 0.5))))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -1.9e+16) || !(l <= 2.6e+66)) {
tmp = U + (pow(l, 3.0) * (J * 0.3333333333333333));
} else {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if ((l <= (-1.9d+16)) .or. (.not. (l <= 2.6d+66))) then
tmp = u + ((l ** 3.0d0) * (j * 0.3333333333333333d0))
else
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -1.9e+16) || !(l <= 2.6e+66)) {
tmp = U + (Math.pow(l, 3.0) * (J * 0.3333333333333333));
} else {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -1.9e+16) or not (l <= 2.6e+66): tmp = U + (math.pow(l, 3.0) * (J * 0.3333333333333333)) else: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -1.9e+16) || !(l <= 2.6e+66)) tmp = Float64(U + Float64((l ^ 3.0) * Float64(J * 0.3333333333333333))); else tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -1.9e+16) || ~((l <= 2.6e+66))) tmp = U + ((l ^ 3.0) * (J * 0.3333333333333333)); else tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -1.9e+16], N[Not[LessEqual[l, 2.6e+66]], $MachinePrecision]], N[(U + N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.9 \cdot 10^{+16} \lor \neg \left(\ell \leq 2.6 \cdot 10^{+66}\right):\\
\;\;\;\;U + {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if l < -1.9e16 or 2.60000000000000012e66 < l Initial program 100.0%
Taylor expanded in l around 0 90.7%
Taylor expanded in K around 0 63.7%
Taylor expanded in l around inf 63.7%
associate-*r*63.7%
Simplified63.7%
if -1.9e16 < l < 2.60000000000000012e66Initial program 75.5%
Taylor expanded in l around 0 91.2%
Final simplification80.0%
(FPCore (J l K U) :precision binary64 (if (or (<= l -2.1e+17) (not (<= l 1.08e+67))) (+ U (* (pow l 3.0) (* J 0.3333333333333333))) (+ U (* (cos (/ K 2.0)) (* J (* l 2.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -2.1e+17) || !(l <= 1.08e+67)) {
tmp = U + (pow(l, 3.0) * (J * 0.3333333333333333));
} else {
tmp = U + (cos((K / 2.0)) * (J * (l * 2.0)));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if ((l <= (-2.1d+17)) .or. (.not. (l <= 1.08d+67))) then
tmp = u + ((l ** 3.0d0) * (j * 0.3333333333333333d0))
else
tmp = u + (cos((k / 2.0d0)) * (j * (l * 2.0d0)))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -2.1e+17) || !(l <= 1.08e+67)) {
tmp = U + (Math.pow(l, 3.0) * (J * 0.3333333333333333));
} else {
tmp = U + (Math.cos((K / 2.0)) * (J * (l * 2.0)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -2.1e+17) or not (l <= 1.08e+67): tmp = U + (math.pow(l, 3.0) * (J * 0.3333333333333333)) else: tmp = U + (math.cos((K / 2.0)) * (J * (l * 2.0))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -2.1e+17) || !(l <= 1.08e+67)) tmp = Float64(U + Float64((l ^ 3.0) * Float64(J * 0.3333333333333333))); else tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * 2.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -2.1e+17) || ~((l <= 1.08e+67))) tmp = U + ((l ^ 3.0) * (J * 0.3333333333333333)); else tmp = U + (cos((K / 2.0)) * (J * (l * 2.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -2.1e+17], N[Not[LessEqual[l, 1.08e+67]], $MachinePrecision]], N[(U + N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.1 \cdot 10^{+17} \lor \neg \left(\ell \leq 1.08 \cdot 10^{+67}\right):\\
\;\;\;\;U + {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\
\mathbf{else}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\
\end{array}
\end{array}
if l < -2.1e17 or 1.08e67 < l Initial program 100.0%
Taylor expanded in l around 0 90.7%
Taylor expanded in K around 0 63.7%
Taylor expanded in l around inf 63.7%
associate-*r*63.7%
Simplified63.7%
if -2.1e17 < l < 1.08e67Initial program 75.5%
Taylor expanded in l around 0 91.2%
Final simplification80.0%
(FPCore (J l K U) :precision binary64 (if (or (<= l -460000000000.0) (not (<= l 0.00048))) (+ U (* (pow l 3.0) (* J 0.3333333333333333))) (fma l (* J 2.0) U)))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -460000000000.0) || !(l <= 0.00048)) {
tmp = U + (pow(l, 3.0) * (J * 0.3333333333333333));
} else {
tmp = fma(l, (J * 2.0), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if ((l <= -460000000000.0) || !(l <= 0.00048)) tmp = Float64(U + Float64((l ^ 3.0) * Float64(J * 0.3333333333333333))); else tmp = fma(l, Float64(J * 2.0), U); end return tmp end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -460000000000.0], N[Not[LessEqual[l, 0.00048]], $MachinePrecision]], N[(U + N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(l * N[(J * 2.0), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -460000000000 \lor \neg \left(\ell \leq 0.00048\right):\\
\;\;\;\;U + {\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\ell, J \cdot 2, U\right)\\
\end{array}
\end{array}
if l < -4.6e11 or 4.80000000000000012e-4 < l Initial program 100.0%
Taylor expanded in l around 0 84.6%
Taylor expanded in K around 0 59.4%
Taylor expanded in l around inf 59.4%
associate-*r*59.4%
Simplified59.4%
if -4.6e11 < l < 4.80000000000000012e-4Initial program 72.8%
Taylor expanded in l around 0 98.0%
Taylor expanded in K around 0 86.2%
Taylor expanded in l around 0 86.2%
+-commutative86.2%
associate-*r*86.2%
*-commutative86.2%
fma-def86.2%
*-commutative86.2%
Simplified86.2%
Final simplification73.7%
(FPCore (J l K U) :precision binary64 (if (or (<= l -1.05e+30) (not (<= l 240000000000.0))) (* U U) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -1.05e+30) || !(l <= 240000000000.0)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if ((l <= (-1.05d+30)) .or. (.not. (l <= 240000000000.0d0))) then
tmp = u * u
else
tmp = u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -1.05e+30) || !(l <= 240000000000.0)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -1.05e+30) or not (l <= 240000000000.0): tmp = U * U else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -1.05e+30) || !(l <= 240000000000.0)) tmp = Float64(U * U); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -1.05e+30) || ~((l <= 240000000000.0))) tmp = U * U; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -1.05e+30], N[Not[LessEqual[l, 240000000000.0]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.05 \cdot 10^{+30} \lor \neg \left(\ell \leq 240000000000\right):\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -1.05e30 or 2.4e11 < l Initial program 100.0%
Applied egg-rr14.6%
if -1.05e30 < l < 2.4e11Initial program 73.8%
Taylor expanded in J around 0 68.8%
Final simplification44.7%
(FPCore (J l K U) :precision binary64 (+ U (* J (* l 2.0))))
double code(double J, double l, double K, double U) {
return U + (J * (l * 2.0));
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u + (j * (l * 2.0d0))
end function
public static double code(double J, double l, double K, double U) {
return U + (J * (l * 2.0));
}
def code(J, l, K, U): return U + (J * (l * 2.0))
function code(J, l, K, U) return Float64(U + Float64(J * Float64(l * 2.0))) end
function tmp = code(J, l, K, U) tmp = U + (J * (l * 2.0)); end
code[J_, l_, K_, U_] := N[(U + N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + J \cdot \left(\ell \cdot 2\right)
\end{array}
Initial program 85.5%
Taylor expanded in l around 0 91.8%
Taylor expanded in K around 0 73.7%
Taylor expanded in l around 0 58.7%
*-commutative58.7%
associate-*r*59.0%
*-commutative59.0%
Simplified59.0%
Final simplification59.0%
(FPCore (J l K U) :precision binary64 U)
double code(double J, double l, double K, double U) {
return U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u
end function
public static double code(double J, double l, double K, double U) {
return U;
}
def code(J, l, K, U): return U
function code(J, l, K, U) return U end
function tmp = code(J, l, K, U) tmp = U; end
code[J_, l_, K_, U_] := U
\begin{array}{l}
\\
U
\end{array}
Initial program 85.5%
Taylor expanded in J around 0 39.1%
Final simplification39.1%
herbie shell --seed 2023305
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))