
(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 19 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 (fma (* (* 2.0 (sinh l)) (cos (* K 0.5))) J U))
double code(double J, double l, double K, double U) {
return fma(((2.0 * sinh(l)) * cos((K * 0.5))), J, U);
}
function code(J, l, K, U) return fma(Float64(Float64(2.0 * sinh(l)) * cos(Float64(K * 0.5))), J, U) end
code[J_, l_, K_, U_] := N[(N[(N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \cos \left(K \cdot 0.5\right), J, U\right)
\end{array}
Initial program 85.7%
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
flip--N/A
associate-*r/N/A
lift-/.f64N/A
lift-cos.f64N/A
associate-*r/N/A
flip--N/A
lift--.f64N/A
associate-*l*N/A
Applied rewrites99.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 0.995)
(+ U (* t_0 (* J (* l (fma l (* l 0.3333333333333333) 2.0)))))
(fma (* (sinh l) J) 2.0 U))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double tmp;
if (t_0 <= 0.995) {
tmp = U + (t_0 * (J * (l * fma(l, (l * 0.3333333333333333), 2.0))));
} else {
tmp = fma((sinh(l) * J), 2.0, U);
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= 0.995) tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * fma(l, Float64(l * 0.3333333333333333), 2.0))))); else tmp = fma(Float64(sinh(l) * J), 2.0, U); end return 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.995], N[(U + N[(t$95$0 * N[(J * N[(l * N[(l * N[(l * 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sinh[l], $MachinePrecision] * J), $MachinePrecision] * 2.0 + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq 0.995:\\
\;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sinh \ell \cdot J, 2, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.994999999999999996Initial program 80.4%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6491.9
Applied rewrites91.9%
if 0.994999999999999996 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 89.9%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6489.9
Applied rewrites89.9%
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
lift-sinh.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6499.1
Applied rewrites99.1%
Final simplification96.0%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.995) (fma l (* (fma l (* l 0.3333333333333333) 2.0) (* J (cos (* K 0.5)))) U) (fma (* (sinh l) J) 2.0 U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.995) {
tmp = fma(l, (fma(l, (l * 0.3333333333333333), 2.0) * (J * cos((K * 0.5)))), U);
} else {
tmp = fma((sinh(l) * J), 2.0, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.995) tmp = fma(l, Float64(fma(l, Float64(l * 0.3333333333333333), 2.0) * Float64(J * cos(Float64(K * 0.5)))), U); else tmp = fma(Float64(sinh(l) * J), 2.0, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.995], N[(l * N[(N[(l * N[(l * 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision] * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[Sinh[l], $MachinePrecision] * J), $MachinePrecision] * 2.0 + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.995:\\
\;\;\;\;\mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right) \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sinh \ell \cdot J, 2, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.994999999999999996Initial program 80.4%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites89.3%
if 0.994999999999999996 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 89.9%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6489.9
Applied rewrites89.9%
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
lift-sinh.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6499.1
Applied rewrites99.1%
Final simplification94.8%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.01) (fma (cos (* K 0.5)) (* J (* 2.0 l)) U) (fma (* (sinh l) J) 2.0 U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.01) {
tmp = fma(cos((K * 0.5)), (J * (2.0 * l)), U);
} else {
tmp = fma((sinh(l) * J), 2.0, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.01) tmp = fma(cos(Float64(K * 0.5)), Float64(J * Float64(2.0 * l)), U); else tmp = fma(Float64(sinh(l) * J), 2.0, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.01], N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(J * N[(2.0 * l), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[Sinh[l], $MachinePrecision] * J), $MachinePrecision] * 2.0 + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\
\;\;\;\;\mathsf{fma}\left(\cos \left(K \cdot 0.5\right), J \cdot \left(2 \cdot \ell\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sinh \ell \cdot J, 2, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002Initial program 74.2%
Taylor expanded in l around 0
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6474.3
Applied rewrites74.3%
if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 88.5%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6488.1
Applied rewrites88.1%
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
lift-sinh.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6495.2
Applied rewrites95.2%
Final simplification91.2%
(FPCore (J l K U) :precision binary64 (if (<= (* J (- (exp l) (exp (- l)))) (- INFINITY)) (* J (* l (fma -0.25 (* K K) 2.0))) (fma J (* 2.0 l) U)))
double code(double J, double l, double K, double U) {
double tmp;
if ((J * (exp(l) - exp(-l))) <= -((double) INFINITY)) {
tmp = J * (l * fma(-0.25, (K * K), 2.0));
} else {
tmp = fma(J, (2.0 * l), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (Float64(J * Float64(exp(l) - exp(Float64(-l)))) <= Float64(-Inf)) tmp = Float64(J * Float64(l * fma(-0.25, Float64(K * K), 2.0))); else tmp = fma(J, Float64(2.0 * l), U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-Infinity)], N[(J * N[(l * N[(-0.25 * N[(K * K), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(J * N[(2.0 * l), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;J \cdot \left(e^{\ell} - e^{-\ell}\right) \leq -\infty:\\
\;\;\;\;J \cdot \left(\ell \cdot \mathsf{fma}\left(-0.25, K \cdot K, 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J, 2 \cdot \ell, U\right)\\
\end{array}
\end{array}
if (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < -inf.0Initial program 100.0%
Taylor expanded in l around 0
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6424.3
Applied rewrites24.3%
Taylor expanded in J around inf
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6424.7
Applied rewrites24.7%
Taylor expanded in K around 0
associate-*r*N/A
+-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites32.7%
Taylor expanded in J around 0
lower-*.f64N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6432.7
Applied rewrites32.7%
if -inf.0 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) Initial program 82.0%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6477.2
Applied rewrites77.2%
Taylor expanded in l around 0
lower-*.f6463.1
Applied rewrites63.1%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) -0.01)
(fma
J
(*
(* K K)
(* (fma 0.3333333333333333 (* l l) 2.0) (fma l -0.125 (/ l (* K K)))))
U)
(fma (* (sinh l) J) 2.0 U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.01) {
tmp = fma(J, ((K * K) * (fma(0.3333333333333333, (l * l), 2.0) * fma(l, -0.125, (l / (K * K))))), U);
} else {
tmp = fma((sinh(l) * J), 2.0, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.01) tmp = fma(J, Float64(Float64(K * K) * Float64(fma(0.3333333333333333, Float64(l * l), 2.0) * fma(l, -0.125, Float64(l / Float64(K * K))))), U); else tmp = fma(Float64(sinh(l) * J), 2.0, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.01], N[(J * N[(N[(K * K), $MachinePrecision] * N[(N[(0.3333333333333333 * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * N[(l * -0.125 + N[(l / N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[Sinh[l], $MachinePrecision] * J), $MachinePrecision] * 2.0 + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\
\;\;\;\;\mathsf{fma}\left(J, \left(K \cdot K\right) \cdot \left(\mathsf{fma}\left(0.3333333333333333, \ell \cdot \ell, 2\right) \cdot \mathsf{fma}\left(\ell, -0.125, \frac{\ell}{K \cdot K}\right)\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sinh \ell \cdot J, 2, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002Initial program 74.2%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6488.1
Applied rewrites88.1%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-outN/A
lower-fma.f64N/A
Applied rewrites26.1%
Taylor expanded in K around inf
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-outN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6452.6
Applied rewrites52.6%
if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 88.5%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6488.1
Applied rewrites88.1%
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
lift-sinh.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6495.2
Applied rewrites95.2%
Final simplification87.0%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) -0.01)
(fma
J
(*
(* K K)
(* (fma 0.3333333333333333 (* l l) 2.0) (fma l -0.125 (/ l (* K K)))))
U)
(*
(fma
(- J)
(/
(*
l
(fma
(* l l)
(fma
(* l l)
(fma (* l l) 0.0003968253968253968 0.016666666666666666)
0.3333333333333333)
2.0))
U)
-1.0)
(- U))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.01) {
tmp = fma(J, ((K * K) * (fma(0.3333333333333333, (l * l), 2.0) * fma(l, -0.125, (l / (K * K))))), U);
} else {
tmp = fma(-J, ((l * fma((l * l), fma((l * l), fma((l * l), 0.0003968253968253968, 0.016666666666666666), 0.3333333333333333), 2.0)) / U), -1.0) * -U;
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.01) tmp = fma(J, Float64(Float64(K * K) * Float64(fma(0.3333333333333333, Float64(l * l), 2.0) * fma(l, -0.125, Float64(l / Float64(K * K))))), U); else tmp = Float64(fma(Float64(-J), Float64(Float64(l * fma(Float64(l * l), fma(Float64(l * l), fma(Float64(l * l), 0.0003968253968253968, 0.016666666666666666), 0.3333333333333333), 2.0)) / U), -1.0) * Float64(-U)); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.01], N[(J * N[(N[(K * K), $MachinePrecision] * N[(N[(0.3333333333333333 * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * N[(l * -0.125 + N[(l / N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[((-J) * N[(N[(l * N[(N[(l * l), $MachinePrecision] * N[(N[(l * l), $MachinePrecision] * N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968 + 0.016666666666666666), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] / U), $MachinePrecision] + -1.0), $MachinePrecision] * (-U)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\
\;\;\;\;\mathsf{fma}\left(J, \left(K \cdot K\right) \cdot \left(\mathsf{fma}\left(0.3333333333333333, \ell \cdot \ell, 2\right) \cdot \mathsf{fma}\left(\ell, -0.125, \frac{\ell}{K \cdot K}\right)\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-J, \frac{\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 2\right)}{U}, -1\right) \cdot \left(-U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002Initial program 74.2%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6488.1
Applied rewrites88.1%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-outN/A
lower-fma.f64N/A
Applied rewrites26.1%
Taylor expanded in K around inf
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-outN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6452.6
Applied rewrites52.6%
if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 88.5%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6488.1
Applied rewrites88.1%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f6492.4
Applied rewrites92.4%
Taylor expanded in U around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
sub-negN/A
associate-/l*N/A
associate-*r*N/A
metadata-evalN/A
lower-fma.f64N/A
Applied rewrites92.7%
Final simplification85.0%
(FPCore (J l K U)
:precision binary64
(if (<= (/ K 2.0) 1e-115)
(fma (* (sinh l) J) 2.0 U)
(+
U
(*
(*
J
(*
l
(fma
(* l l)
(fma
l
(* l (fma (* l l) 0.0003968253968253968 0.016666666666666666))
0.3333333333333333)
2.0)))
(cos (/ K 2.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((K / 2.0) <= 1e-115) {
tmp = fma((sinh(l) * J), 2.0, U);
} else {
tmp = U + ((J * (l * fma((l * l), fma(l, (l * fma((l * l), 0.0003968253968253968, 0.016666666666666666)), 0.3333333333333333), 2.0))) * cos((K / 2.0)));
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (Float64(K / 2.0) <= 1e-115) tmp = fma(Float64(sinh(l) * J), 2.0, U); else tmp = Float64(U + Float64(Float64(J * Float64(l * fma(Float64(l * l), fma(l, Float64(l * fma(Float64(l * l), 0.0003968253968253968, 0.016666666666666666)), 0.3333333333333333), 2.0))) * cos(Float64(K / 2.0)))); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[(K / 2.0), $MachinePrecision], 1e-115], N[(N[(N[Sinh[l], $MachinePrecision] * J), $MachinePrecision] * 2.0 + U), $MachinePrecision], N[(U + N[(N[(J * N[(l * N[(N[(l * l), $MachinePrecision] * N[(l * N[(l * N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968 + 0.016666666666666666), $MachinePrecision]), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{K}{2} \leq 10^{-115}:\\
\;\;\;\;\mathsf{fma}\left(\sinh \ell \cdot J, 2, U\right)\\
\mathbf{else}:\\
\;\;\;\;U + \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 2\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right)\\
\end{array}
\end{array}
if (/.f64 K #s(literal 2 binary64)) < 1.0000000000000001e-115Initial program 85.9%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6481.2
Applied rewrites81.2%
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
lift-sinh.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6488.1
Applied rewrites88.1%
if 1.0000000000000001e-115 < (/.f64 K #s(literal 2 binary64)) Initial program 85.4%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6496.8
Applied rewrites96.8%
Final simplification91.3%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) -0.01)
(fma
J
(*
(* K K)
(* (fma 0.3333333333333333 (* l l) 2.0) (fma l -0.125 (/ l (* K K)))))
U)
(fma
J
(*
l
(fma
l
(*
l
(fma
(* l l)
(fma l (* l 0.0003968253968253968) 0.016666666666666666)
0.3333333333333333))
2.0))
U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.01) {
tmp = fma(J, ((K * K) * (fma(0.3333333333333333, (l * l), 2.0) * fma(l, -0.125, (l / (K * K))))), U);
} else {
tmp = fma(J, (l * fma(l, (l * fma((l * l), fma(l, (l * 0.0003968253968253968), 0.016666666666666666), 0.3333333333333333)), 2.0)), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.01) tmp = fma(J, Float64(Float64(K * K) * Float64(fma(0.3333333333333333, Float64(l * l), 2.0) * fma(l, -0.125, Float64(l / Float64(K * K))))), U); else tmp = fma(J, Float64(l * fma(l, Float64(l * fma(Float64(l * l), fma(l, Float64(l * 0.0003968253968253968), 0.016666666666666666), 0.3333333333333333)), 2.0)), U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.01], N[(J * N[(N[(K * K), $MachinePrecision] * N[(N[(0.3333333333333333 * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * N[(l * -0.125 + N[(l / N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(J * N[(l * N[(l * N[(l * N[(N[(l * l), $MachinePrecision] * N[(l * N[(l * 0.0003968253968253968), $MachinePrecision] + 0.016666666666666666), $MachinePrecision] + 0.3333333333333333), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\
\;\;\;\;\mathsf{fma}\left(J, \left(K \cdot K\right) \cdot \left(\mathsf{fma}\left(0.3333333333333333, \ell \cdot \ell, 2\right) \cdot \mathsf{fma}\left(\ell, -0.125, \frac{\ell}{K \cdot K}\right)\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 2\right), U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002Initial program 74.2%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6488.1
Applied rewrites88.1%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-outN/A
lower-fma.f64N/A
Applied rewrites26.1%
Taylor expanded in K around inf
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-outN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6452.6
Applied rewrites52.6%
if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 88.5%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6488.1
Applied rewrites88.1%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f6492.4
Applied rewrites92.4%
(FPCore (J l K U)
:precision binary64
(if (<= (/ K 2.0) 1e-13)
(fma (* (sinh l) J) 2.0 U)
(+
U
(*
(cos (/ K 2.0))
(*
J
(*
l
(fma
(* l l)
(fma (* l l) 0.016666666666666666 0.3333333333333333)
2.0)))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((K / 2.0) <= 1e-13) {
tmp = fma((sinh(l) * J), 2.0, U);
} else {
tmp = U + (cos((K / 2.0)) * (J * (l * fma((l * l), fma((l * l), 0.016666666666666666, 0.3333333333333333), 2.0))));
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (Float64(K / 2.0) <= 1e-13) tmp = fma(Float64(sinh(l) * J), 2.0, U); else tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * fma(Float64(l * l), fma(Float64(l * l), 0.016666666666666666, 0.3333333333333333), 2.0))))); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[(K / 2.0), $MachinePrecision], 1e-13], N[(N[(N[Sinh[l], $MachinePrecision] * J), $MachinePrecision] * 2.0 + U), $MachinePrecision], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * N[(N[(l * l), $MachinePrecision] * N[(N[(l * l), $MachinePrecision] * 0.016666666666666666 + 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{K}{2} \leq 10^{-13}:\\
\;\;\;\;\mathsf{fma}\left(\sinh \ell \cdot J, 2, U\right)\\
\mathbf{else}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, 0.016666666666666666, 0.3333333333333333\right), 2\right)\right)\right)\\
\end{array}
\end{array}
if (/.f64 K #s(literal 2 binary64)) < 1e-13Initial program 86.4%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6482.3
Applied rewrites82.3%
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
lift-sinh.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6489.7
Applied rewrites89.7%
if 1e-13 < (/.f64 K #s(literal 2 binary64)) Initial program 83.8%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6494.3
Applied rewrites94.3%
Final simplification90.9%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) -0.01)
(fma
(fma -0.125 (* K K) 1.0)
(*
J
(*
l
(fma l (* l (fma (* l l) 0.016666666666666666 0.3333333333333333)) 2.0)))
U)
(fma
J
(*
l
(fma
l
(*
l
(fma
(* l l)
(fma l (* l 0.0003968253968253968) 0.016666666666666666)
0.3333333333333333))
2.0))
U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.01) {
tmp = fma(fma(-0.125, (K * K), 1.0), (J * (l * fma(l, (l * fma((l * l), 0.016666666666666666, 0.3333333333333333)), 2.0))), U);
} else {
tmp = fma(J, (l * fma(l, (l * fma((l * l), fma(l, (l * 0.0003968253968253968), 0.016666666666666666), 0.3333333333333333)), 2.0)), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.01) tmp = fma(fma(-0.125, Float64(K * K), 1.0), Float64(J * Float64(l * fma(l, Float64(l * fma(Float64(l * l), 0.016666666666666666, 0.3333333333333333)), 2.0))), U); else tmp = fma(J, Float64(l * fma(l, Float64(l * fma(Float64(l * l), fma(l, Float64(l * 0.0003968253968253968), 0.016666666666666666), 0.3333333333333333)), 2.0)), U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.01], N[(N[(-0.125 * N[(K * K), $MachinePrecision] + 1.0), $MachinePrecision] * N[(J * N[(l * N[(l * N[(l * N[(N[(l * l), $MachinePrecision] * 0.016666666666666666 + 0.3333333333333333), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(J * N[(l * N[(l * N[(l * N[(N[(l * l), $MachinePrecision] * N[(l * N[(l * 0.0003968253968253968), $MachinePrecision] + 0.016666666666666666), $MachinePrecision] + 0.3333333333333333), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.125, K \cdot K, 1\right), J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.016666666666666666, 0.3333333333333333\right), 2\right)\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 2\right), U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002Initial program 74.2%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites90.3%
Taylor expanded in K around 0
+-commutativeN/A
associate-*r*N/A
distribute-lft1-inN/A
+-commutativeN/A
lower-fma.f64N/A
Applied rewrites52.6%
if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 88.5%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6488.1
Applied rewrites88.1%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f6492.4
Applied rewrites92.4%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) -0.01)
(fma
J
(* (* l l) (* l (fma (* K K) -0.041666666666666664 0.3333333333333333)))
U)
(fma
J
(*
l
(fma
l
(*
l
(fma
(* l l)
(fma l (* l 0.0003968253968253968) 0.016666666666666666)
0.3333333333333333))
2.0))
U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.01) {
tmp = fma(J, ((l * l) * (l * fma((K * K), -0.041666666666666664, 0.3333333333333333))), U);
} else {
tmp = fma(J, (l * fma(l, (l * fma((l * l), fma(l, (l * 0.0003968253968253968), 0.016666666666666666), 0.3333333333333333)), 2.0)), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.01) tmp = fma(J, Float64(Float64(l * l) * Float64(l * fma(Float64(K * K), -0.041666666666666664, 0.3333333333333333))), U); else tmp = fma(J, Float64(l * fma(l, Float64(l * fma(Float64(l * l), fma(l, Float64(l * 0.0003968253968253968), 0.016666666666666666), 0.3333333333333333)), 2.0)), U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.01], N[(J * N[(N[(l * l), $MachinePrecision] * N[(l * N[(N[(K * K), $MachinePrecision] * -0.041666666666666664 + 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(J * N[(l * N[(l * N[(l * N[(N[(l * l), $MachinePrecision] * N[(l * N[(l * 0.0003968253968253968), $MachinePrecision] + 0.016666666666666666), $MachinePrecision] + 0.3333333333333333), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\
\;\;\;\;\mathsf{fma}\left(J, \left(\ell \cdot \ell\right) \cdot \left(\ell \cdot \mathsf{fma}\left(K \cdot K, -0.041666666666666664, 0.3333333333333333\right)\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 2\right), U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002Initial program 74.2%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6488.1
Applied rewrites88.1%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-outN/A
lower-fma.f64N/A
Applied rewrites26.1%
Taylor expanded in l around inf
unpow3N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6452.2
Applied rewrites52.2%
if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 88.5%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6488.1
Applied rewrites88.1%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f6492.4
Applied rewrites92.4%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (fma (* (sinh l) J) 2.0 U))
(t_1 (cos (* K 0.5)))
(t_2 (* (* l J) (* t_1 (fma 0.3333333333333333 (* l l) 2.0)))))
(if (<= l -2.4e+124)
t_2
(if (<= l -0.0072)
t_0
(if (<= l 0.0092)
(fma (* t_1 (* 2.0 l)) J U)
(if (<= l 1.3e+92) t_0 t_2))))))
double code(double J, double l, double K, double U) {
double t_0 = fma((sinh(l) * J), 2.0, U);
double t_1 = cos((K * 0.5));
double t_2 = (l * J) * (t_1 * fma(0.3333333333333333, (l * l), 2.0));
double tmp;
if (l <= -2.4e+124) {
tmp = t_2;
} else if (l <= -0.0072) {
tmp = t_0;
} else if (l <= 0.0092) {
tmp = fma((t_1 * (2.0 * l)), J, U);
} else if (l <= 1.3e+92) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
function code(J, l, K, U) t_0 = fma(Float64(sinh(l) * J), 2.0, U) t_1 = cos(Float64(K * 0.5)) t_2 = Float64(Float64(l * J) * Float64(t_1 * fma(0.3333333333333333, Float64(l * l), 2.0))) tmp = 0.0 if (l <= -2.4e+124) tmp = t_2; elseif (l <= -0.0072) tmp = t_0; elseif (l <= 0.0092) tmp = fma(Float64(t_1 * Float64(2.0 * l)), J, U); elseif (l <= 1.3e+92) tmp = t_0; else tmp = t_2; end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(N[Sinh[l], $MachinePrecision] * J), $MachinePrecision] * 2.0 + U), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(l * J), $MachinePrecision] * N[(t$95$1 * N[(0.3333333333333333 * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2.4e+124], t$95$2, If[LessEqual[l, -0.0072], t$95$0, If[LessEqual[l, 0.0092], N[(N[(t$95$1 * N[(2.0 * l), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], If[LessEqual[l, 1.3e+92], t$95$0, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\sinh \ell \cdot J, 2, U\right)\\
t_1 := \cos \left(K \cdot 0.5\right)\\
t_2 := \left(\ell \cdot J\right) \cdot \left(t\_1 \cdot \mathsf{fma}\left(0.3333333333333333, \ell \cdot \ell, 2\right)\right)\\
\mathbf{if}\;\ell \leq -2.4 \cdot 10^{+124}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\ell \leq -0.0072:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq 0.0092:\\
\;\;\;\;\mathsf{fma}\left(t\_1 \cdot \left(2 \cdot \ell\right), J, U\right)\\
\mathbf{elif}\;\ell \leq 1.3 \cdot 10^{+92}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if l < -2.40000000000000006e124 or 1.2999999999999999e92 < l Initial program 100.0%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in J around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6496.4
Applied rewrites96.4%
if -2.40000000000000006e124 < l < -0.0071999999999999998 or 0.0091999999999999998 < l < 1.2999999999999999e92Initial program 100.0%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6486.7
Applied rewrites86.7%
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
lift-sinh.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6486.7
Applied rewrites86.7%
if -0.0071999999999999998 < l < 0.0091999999999999998Initial program 72.3%
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
flip--N/A
associate-*r/N/A
lift-/.f64N/A
lift-cos.f64N/A
associate-*r/N/A
flip--N/A
lift--.f64N/A
associate-*l*N/A
Applied rewrites99.9%
Taylor expanded in l around 0
lower-*.f6499.5
Applied rewrites99.5%
Final simplification96.3%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) -0.01)
(fma
J
(* (* l l) (* l (fma (* K K) -0.041666666666666664 0.3333333333333333)))
U)
(fma
J
(*
l
(fma l (* l (fma (* l l) 0.016666666666666666 0.3333333333333333)) 2.0))
U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.01) {
tmp = fma(J, ((l * l) * (l * fma((K * K), -0.041666666666666664, 0.3333333333333333))), U);
} else {
tmp = fma(J, (l * fma(l, (l * fma((l * l), 0.016666666666666666, 0.3333333333333333)), 2.0)), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.01) tmp = fma(J, Float64(Float64(l * l) * Float64(l * fma(Float64(K * K), -0.041666666666666664, 0.3333333333333333))), U); else tmp = fma(J, Float64(l * fma(l, Float64(l * fma(Float64(l * l), 0.016666666666666666, 0.3333333333333333)), 2.0)), U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.01], N[(J * N[(N[(l * l), $MachinePrecision] * N[(l * N[(N[(K * K), $MachinePrecision] * -0.041666666666666664 + 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(J * N[(l * N[(l * N[(l * N[(N[(l * l), $MachinePrecision] * 0.016666666666666666 + 0.3333333333333333), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\
\;\;\;\;\mathsf{fma}\left(J, \left(\ell \cdot \ell\right) \cdot \left(\ell \cdot \mathsf{fma}\left(K \cdot K, -0.041666666666666664, 0.3333333333333333\right)\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.016666666666666666, 0.3333333333333333\right), 2\right), U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002Initial program 74.2%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6488.1
Applied rewrites88.1%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-outN/A
lower-fma.f64N/A
Applied rewrites26.1%
Taylor expanded in l around inf
unpow3N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6452.2
Applied rewrites52.2%
if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 88.5%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites91.2%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
distribute-rgt-inN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites89.7%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) -0.01)
(fma
J
(* (* l l) (* l (fma (* K K) -0.041666666666666664 0.3333333333333333)))
U)
(fma J (* l (fma 0.3333333333333333 (* l l) 2.0)) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.01) {
tmp = fma(J, ((l * l) * (l * fma((K * K), -0.041666666666666664, 0.3333333333333333))), U);
} else {
tmp = fma(J, (l * fma(0.3333333333333333, (l * l), 2.0)), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.01) tmp = fma(J, Float64(Float64(l * l) * Float64(l * fma(Float64(K * K), -0.041666666666666664, 0.3333333333333333))), U); else tmp = fma(J, Float64(l * fma(0.3333333333333333, Float64(l * l), 2.0)), U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.01], N[(J * N[(N[(l * l), $MachinePrecision] * N[(l * N[(N[(K * K), $MachinePrecision] * -0.041666666666666664 + 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(J * N[(l * N[(0.3333333333333333 * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\
\;\;\;\;\mathsf{fma}\left(J, \left(\ell \cdot \ell\right) \cdot \left(\ell \cdot \mathsf{fma}\left(K \cdot K, -0.041666666666666664, 0.3333333333333333\right)\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(0.3333333333333333, \ell \cdot \ell, 2\right), U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002Initial program 74.2%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6488.1
Applied rewrites88.1%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-outN/A
lower-fma.f64N/A
Applied rewrites26.1%
Taylor expanded in l around inf
unpow3N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6452.2
Applied rewrites52.2%
if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 88.5%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6487.7
Applied rewrites87.7%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6483.1
Applied rewrites83.1%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.01) (fma (* l J) (fma -0.25 (* K K) 2.0) U) (fma J (* l (fma 0.3333333333333333 (* l l) 2.0)) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.01) {
tmp = fma((l * J), fma(-0.25, (K * K), 2.0), U);
} else {
tmp = fma(J, (l * fma(0.3333333333333333, (l * l), 2.0)), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.01) tmp = fma(Float64(l * J), fma(-0.25, Float64(K * K), 2.0), U); else tmp = fma(J, Float64(l * fma(0.3333333333333333, Float64(l * l), 2.0)), U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.01], N[(N[(l * J), $MachinePrecision] * N[(-0.25 * N[(K * K), $MachinePrecision] + 2.0), $MachinePrecision] + U), $MachinePrecision], N[(J * N[(l * N[(0.3333333333333333 * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\
\;\;\;\;\mathsf{fma}\left(\ell \cdot J, \mathsf{fma}\left(-0.25, K \cdot K, 2\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(0.3333333333333333, \ell \cdot \ell, 2\right), U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002Initial program 74.2%
Taylor expanded in l around 0
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6474.3
Applied rewrites74.3%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
distribute-lft-outN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6448.6
Applied rewrites48.6%
if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 88.5%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6487.7
Applied rewrites87.7%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6483.1
Applied rewrites83.1%
Final simplification76.5%
(FPCore (J l K U) :precision binary64 (fma J (* l (fma 0.3333333333333333 (* l l) 2.0)) U))
double code(double J, double l, double K, double U) {
return fma(J, (l * fma(0.3333333333333333, (l * l), 2.0)), U);
}
function code(J, l, K, U) return fma(J, Float64(l * fma(0.3333333333333333, Float64(l * l), 2.0)), U) end
code[J_, l_, K_, U_] := N[(J * N[(l * N[(0.3333333333333333 * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(J, \ell \cdot \mathsf{fma}\left(0.3333333333333333, \ell \cdot \ell, 2\right), U\right)
\end{array}
Initial program 85.7%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6487.8
Applied rewrites87.8%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6473.9
Applied rewrites73.9%
(FPCore (J l K U) :precision binary64 (fma J (* 2.0 l) U))
double code(double J, double l, double K, double U) {
return fma(J, (2.0 * l), U);
}
function code(J, l, K, U) return fma(J, Float64(2.0 * l), U) end
code[J_, l_, K_, U_] := N[(J * N[(2.0 * l), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(J, 2 \cdot \ell, U\right)
\end{array}
Initial program 85.7%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6478.0
Applied rewrites78.0%
Taylor expanded in l around 0
lower-*.f6454.2
Applied rewrites54.2%
(FPCore (J l K U) :precision binary64 (* J (* 2.0 l)))
double code(double J, double l, double K, double U) {
return J * (2.0 * l);
}
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 * (2.0d0 * l)
end function
public static double code(double J, double l, double K, double U) {
return J * (2.0 * l);
}
def code(J, l, K, U): return J * (2.0 * l)
function code(J, l, K, U) return Float64(J * Float64(2.0 * l)) end
function tmp = code(J, l, K, U) tmp = J * (2.0 * l); end
code[J_, l_, K_, U_] := N[(J * N[(2.0 * l), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
J \cdot \left(2 \cdot \ell\right)
\end{array}
Initial program 85.7%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6478.0
Applied rewrites78.0%
Taylor expanded in l around 0
lower-*.f6454.2
Applied rewrites54.2%
Taylor expanded in J around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6418.9
Applied rewrites18.9%
Final simplification18.9%
herbie shell --seed 2024219
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))