
(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 22 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 (* J (sinh l))) (cos (* -0.5 K)) U))
double code(double J, double l, double K, double U) {
return fma((2.0 * (J * sinh(l))), cos((-0.5 * K)), U);
}
function code(J, l, K, U) return fma(Float64(2.0 * Float64(J * sinh(l))), cos(Float64(-0.5 * K)), U) end
code[J_, l_, K_, U_] := N[(N[(2.0 * N[(J * N[Sinh[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(2 \cdot \left(J \cdot \sinh \ell\right), \cos \left(-0.5 \cdot K\right), U\right)
\end{array}
Initial program 91.1%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6491.1
Applied rewrites100.0%
Final simplification100.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))) (t_1 (* 2.0 (* J (sinh l)))))
(if (<= t_0 -0.17)
(+ (* (* (* (fma (* l l) 0.3333333333333333 2.0) l) J) t_0) U)
(if (<= t_0 -0.01)
(fma t_1 (fma (* K K) -0.125 1.0) U)
(fma t_1 1.0 U)))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = 2.0 * (J * sinh(l));
double tmp;
if (t_0 <= -0.17) {
tmp = (((fma((l * l), 0.3333333333333333, 2.0) * l) * J) * t_0) + U;
} else if (t_0 <= -0.01) {
tmp = fma(t_1, fma((K * K), -0.125, 1.0), U);
} else {
tmp = fma(t_1, 1.0, U);
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(2.0 * Float64(J * sinh(l))) tmp = 0.0 if (t_0 <= -0.17) tmp = Float64(Float64(Float64(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l) * J) * t_0) + U); elseif (t_0 <= -0.01) tmp = fma(t_1, fma(Float64(K * K), -0.125, 1.0), U); else tmp = fma(t_1, 1.0, U); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(2.0 * N[(J * N[Sinh[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.17], N[(N[(N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[t$95$0, -0.01], N[(t$95$1 * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] + U), $MachinePrecision], N[(t$95$1 * 1.0 + U), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := 2 \cdot \left(J \cdot \sinh \ell\right)\\
\mathbf{if}\;t\_0 \leq -0.17:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\right) \cdot t\_0 + U\\
\mathbf{elif}\;t\_0 \leq -0.01:\\
\;\;\;\;\mathsf{fma}\left(t\_1, \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, 1, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.170000000000000012Initial program 88.4%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6488.5
Applied rewrites88.5%
if -0.170000000000000012 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002Initial program 100.0%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 91.3%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6491.3
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites98.0%
Final simplification96.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))) (t_1 (* 2.0 (* J (sinh l)))))
(if (<= t_0 -0.17)
(fma (* (* (fma (* l l) 0.3333333333333333 2.0) J) (cos (* 0.5 K))) l U)
(if (<= t_0 -0.01)
(fma t_1 (fma (* K K) -0.125 1.0) U)
(fma t_1 1.0 U)))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = 2.0 * (J * sinh(l));
double tmp;
if (t_0 <= -0.17) {
tmp = fma(((fma((l * l), 0.3333333333333333, 2.0) * J) * cos((0.5 * K))), l, U);
} else if (t_0 <= -0.01) {
tmp = fma(t_1, fma((K * K), -0.125, 1.0), U);
} else {
tmp = fma(t_1, 1.0, U);
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(2.0 * Float64(J * sinh(l))) tmp = 0.0 if (t_0 <= -0.17) tmp = fma(Float64(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * J) * cos(Float64(0.5 * K))), l, U); elseif (t_0 <= -0.01) tmp = fma(t_1, fma(Float64(K * K), -0.125, 1.0), U); else tmp = fma(t_1, 1.0, U); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(2.0 * N[(J * N[Sinh[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.17], N[(N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * J), $MachinePrecision] * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * l + U), $MachinePrecision], If[LessEqual[t$95$0, -0.01], N[(t$95$1 * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] + U), $MachinePrecision], N[(t$95$1 * 1.0 + U), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := 2 \cdot \left(J \cdot \sinh \ell\right)\\
\mathbf{if}\;t\_0 \leq -0.17:\\
\;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot J\right) \cdot \cos \left(0.5 \cdot K\right), \ell, U\right)\\
\mathbf{elif}\;t\_0 \leq -0.01:\\
\;\;\;\;\mathsf{fma}\left(t\_1, \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, 1, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.170000000000000012Initial program 88.4%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites86.9%
if -0.170000000000000012 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002Initial program 100.0%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 91.3%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6491.3
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites98.0%
Final simplification95.6%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))) (t_1 (* 2.0 (* J (sinh l)))))
(if (<= t_0 -0.42)
(fma (* (* 2.0 J) (cos (* 0.5 K))) l U)
(if (<= t_0 -0.01)
(fma t_1 (fma (* K K) -0.125 1.0) U)
(fma t_1 1.0 U)))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = 2.0 * (J * sinh(l));
double tmp;
if (t_0 <= -0.42) {
tmp = fma(((2.0 * J) * cos((0.5 * K))), l, U);
} else if (t_0 <= -0.01) {
tmp = fma(t_1, fma((K * K), -0.125, 1.0), U);
} else {
tmp = fma(t_1, 1.0, U);
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(2.0 * Float64(J * sinh(l))) tmp = 0.0 if (t_0 <= -0.42) tmp = fma(Float64(Float64(2.0 * J) * cos(Float64(0.5 * K))), l, U); elseif (t_0 <= -0.01) tmp = fma(t_1, fma(Float64(K * K), -0.125, 1.0), U); else tmp = fma(t_1, 1.0, U); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(2.0 * N[(J * N[Sinh[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.42], N[(N[(N[(2.0 * J), $MachinePrecision] * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * l + U), $MachinePrecision], If[LessEqual[t$95$0, -0.01], N[(t$95$1 * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] + U), $MachinePrecision], N[(t$95$1 * 1.0 + U), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := 2 \cdot \left(J \cdot \sinh \ell\right)\\
\mathbf{if}\;t\_0 \leq -0.42:\\
\;\;\;\;\mathsf{fma}\left(\left(2 \cdot J\right) \cdot \cos \left(0.5 \cdot K\right), \ell, U\right)\\
\mathbf{elif}\;t\_0 \leq -0.01:\\
\;\;\;\;\mathsf{fma}\left(t\_1, \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, 1, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.419999999999999984Initial program 88.9%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites86.2%
Taylor expanded in l around 0
Applied rewrites77.6%
if -0.419999999999999984 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002Initial program 93.7%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6493.7
Applied rewrites100.0%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6482.5
Applied rewrites82.5%
if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 91.3%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6491.3
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites98.0%
Final simplification92.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 -0.42)
(fma (* (* 2.0 J) (cos (* 0.5 K))) l U)
(if (<= t_0 -0.01)
(fma
(*
(*
(fma (* (* (* (* (* l l) l) J) 0.0001984126984126984) l) (* l l) J)
l)
2.0)
(fma (* K K) -0.125 1.0)
U)
(fma (* 2.0 (* J (sinh l))) 1.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.42) {
tmp = fma(((2.0 * J) * cos((0.5 * K))), l, U);
} else if (t_0 <= -0.01) {
tmp = fma(((fma((((((l * l) * l) * J) * 0.0001984126984126984) * l), (l * l), J) * l) * 2.0), fma((K * K), -0.125, 1.0), U);
} else {
tmp = fma((2.0 * (J * sinh(l))), 1.0, U);
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= -0.42) tmp = fma(Float64(Float64(2.0 * J) * cos(Float64(0.5 * K))), l, U); elseif (t_0 <= -0.01) tmp = fma(Float64(Float64(fma(Float64(Float64(Float64(Float64(Float64(l * l) * l) * J) * 0.0001984126984126984) * l), Float64(l * l), J) * l) * 2.0), fma(Float64(K * K), -0.125, 1.0), U); else tmp = fma(Float64(2.0 * Float64(J * sinh(l))), 1.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.42], N[(N[(N[(2.0 * J), $MachinePrecision] * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * l + U), $MachinePrecision], If[LessEqual[t$95$0, -0.01], N[(N[(N[(N[(N[(N[(N[(N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] * 0.0001984126984126984), $MachinePrecision] * l), $MachinePrecision] * N[(l * l), $MachinePrecision] + J), $MachinePrecision] * l), $MachinePrecision] * 2.0), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] + U), $MachinePrecision], N[(N[(2.0 * N[(J * N[Sinh[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 1.0 + U), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq -0.42:\\
\;\;\;\;\mathsf{fma}\left(\left(2 \cdot J\right) \cdot \cos \left(0.5 \cdot K\right), \ell, U\right)\\
\mathbf{elif}\;t\_0 \leq -0.01:\\
\;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(\left(\left(\left(\left(\ell \cdot \ell\right) \cdot \ell\right) \cdot J\right) \cdot 0.0001984126984126984\right) \cdot \ell, \ell \cdot \ell, J\right) \cdot \ell\right) \cdot 2, \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(2 \cdot \left(J \cdot \sinh \ell\right), 1, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.419999999999999984Initial program 88.9%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites86.2%
Taylor expanded in l around 0
Applied rewrites77.6%
if -0.419999999999999984 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002Initial program 93.7%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6493.7
Applied rewrites100.0%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6482.5
Applied rewrites82.5%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites73.9%
Taylor expanded in l around inf
Applied rewrites73.9%
if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 91.3%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6491.3
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites98.0%
Final simplification92.2%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 -0.42)
(fma (* (* 2.0 l) (cos (* 0.5 K))) J U)
(if (<= t_0 -0.01)
(fma
(*
(*
(fma (* (* (* (* (* l l) l) J) 0.0001984126984126984) l) (* l l) J)
l)
2.0)
(fma (* K K) -0.125 1.0)
U)
(fma (* 2.0 (* J (sinh l))) 1.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.42) {
tmp = fma(((2.0 * l) * cos((0.5 * K))), J, U);
} else if (t_0 <= -0.01) {
tmp = fma(((fma((((((l * l) * l) * J) * 0.0001984126984126984) * l), (l * l), J) * l) * 2.0), fma((K * K), -0.125, 1.0), U);
} else {
tmp = fma((2.0 * (J * sinh(l))), 1.0, U);
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= -0.42) tmp = fma(Float64(Float64(2.0 * l) * cos(Float64(0.5 * K))), J, U); elseif (t_0 <= -0.01) tmp = fma(Float64(Float64(fma(Float64(Float64(Float64(Float64(Float64(l * l) * l) * J) * 0.0001984126984126984) * l), Float64(l * l), J) * l) * 2.0), fma(Float64(K * K), -0.125, 1.0), U); else tmp = fma(Float64(2.0 * Float64(J * sinh(l))), 1.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.42], N[(N[(N[(2.0 * l), $MachinePrecision] * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], If[LessEqual[t$95$0, -0.01], N[(N[(N[(N[(N[(N[(N[(N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] * 0.0001984126984126984), $MachinePrecision] * l), $MachinePrecision] * N[(l * l), $MachinePrecision] + J), $MachinePrecision] * l), $MachinePrecision] * 2.0), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] + U), $MachinePrecision], N[(N[(2.0 * N[(J * N[Sinh[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 1.0 + U), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq -0.42:\\
\;\;\;\;\mathsf{fma}\left(\left(2 \cdot \ell\right) \cdot \cos \left(0.5 \cdot K\right), J, U\right)\\
\mathbf{elif}\;t\_0 \leq -0.01:\\
\;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(\left(\left(\left(\left(\ell \cdot \ell\right) \cdot \ell\right) \cdot J\right) \cdot 0.0001984126984126984\right) \cdot \ell, \ell \cdot \ell, J\right) \cdot \ell\right) \cdot 2, \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(2 \cdot \left(J \cdot \sinh \ell\right), 1, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.419999999999999984Initial program 88.9%
Taylor expanded in l around 0
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f6477.6
Applied rewrites77.6%
Applied rewrites77.5%
if -0.419999999999999984 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002Initial program 93.7%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6493.7
Applied rewrites100.0%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6482.5
Applied rewrites82.5%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites73.9%
Taylor expanded in l around inf
Applied rewrites73.9%
if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 91.3%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6491.3
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites98.0%
Final simplification92.1%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) 0.98)
(fma
(cos (* 0.5 K))
(*
(*
(fma (fma 0.016666666666666666 (* l l) 0.3333333333333333) (* l l) 2.0)
J)
l)
U)
(fma (* 2.0 (* J (sinh l))) 1.0 U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.98) {
tmp = fma(cos((0.5 * K)), ((fma(fma(0.016666666666666666, (l * l), 0.3333333333333333), (l * l), 2.0) * J) * l), U);
} else {
tmp = fma((2.0 * (J * sinh(l))), 1.0, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.98) tmp = fma(cos(Float64(0.5 * K)), Float64(Float64(fma(fma(0.016666666666666666, Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * J) * l), U); else tmp = fma(Float64(2.0 * Float64(J * sinh(l))), 1.0, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.98], N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * N[(N[(N[(N[(0.016666666666666666 * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * J), $MachinePrecision] * l), $MachinePrecision] + U), $MachinePrecision], N[(N[(2.0 * N[(J * N[Sinh[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 1.0 + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.98:\\
\;\;\;\;\mathsf{fma}\left(\cos \left(0.5 \cdot K\right), \left(\mathsf{fma}\left(\mathsf{fma}\left(0.016666666666666666, \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot J\right) \cdot \ell, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(2 \cdot \left(J \cdot \sinh \ell\right), 1, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.97999999999999998Initial program 90.4%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites89.6%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6489.6
Applied rewrites91.3%
if 0.97999999999999998 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 91.5%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6491.5
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites99.5%
Final simplification96.1%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 -0.42)
(fma (* 2.0 J) l U)
(if (<= t_0 0.055)
(* (* (* (* K K) l) J) -0.25)
(fma (* (fma (* l l) 0.3333333333333333 2.0) l) J U)))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double tmp;
if (t_0 <= -0.42) {
tmp = fma((2.0 * J), l, U);
} else if (t_0 <= 0.055) {
tmp = (((K * K) * l) * J) * -0.25;
} else {
tmp = fma((fma((l * l), 0.3333333333333333, 2.0) * l), J, U);
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= -0.42) tmp = fma(Float64(2.0 * J), l, U); elseif (t_0 <= 0.055) tmp = Float64(Float64(Float64(Float64(K * K) * l) * J) * -0.25); else tmp = fma(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l), J, 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.42], N[(N[(2.0 * J), $MachinePrecision] * l + U), $MachinePrecision], If[LessEqual[t$95$0, 0.055], N[(N[(N[(N[(K * K), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] * -0.25), $MachinePrecision], N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * J + U), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq -0.42:\\
\;\;\;\;\mathsf{fma}\left(2 \cdot J, \ell, U\right)\\
\mathbf{elif}\;t\_0 \leq 0.055:\\
\;\;\;\;\left(\left(\left(K \cdot K\right) \cdot \ell\right) \cdot J\right) \cdot -0.25\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell, J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.419999999999999984Initial program 88.9%
Taylor expanded in l around 0
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f6477.6
Applied rewrites77.6%
Taylor expanded in K around 0
Applied rewrites51.7%
if -0.419999999999999984 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.0550000000000000003Initial program 93.9%
Taylor expanded in l around 0
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f6441.5
Applied rewrites41.5%
Taylor expanded in K around 0
Applied rewrites13.6%
Taylor expanded in K around 0
Applied rewrites54.0%
Taylor expanded in K around inf
Applied rewrites49.7%
if 0.0550000000000000003 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 91.3%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites88.1%
Taylor expanded in K around 0
Applied rewrites87.6%
Final simplification77.6%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) -0.01)
(fma
(*
(* (fma (* (* (* (* (* l l) l) J) 0.0001984126984126984) l) (* l l) J) l)
2.0)
(fma (* K K) -0.125 1.0)
U)
(fma (* 2.0 (* J (sinh l))) 1.0 U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.01) {
tmp = fma(((fma((((((l * l) * l) * J) * 0.0001984126984126984) * l), (l * l), J) * l) * 2.0), fma((K * K), -0.125, 1.0), U);
} else {
tmp = fma((2.0 * (J * sinh(l))), 1.0, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.01) tmp = fma(Float64(Float64(fma(Float64(Float64(Float64(Float64(Float64(l * l) * l) * J) * 0.0001984126984126984) * l), Float64(l * l), J) * l) * 2.0), fma(Float64(K * K), -0.125, 1.0), U); else tmp = fma(Float64(2.0 * Float64(J * sinh(l))), 1.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[(N[(N[(N[(N[(N[(N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] * 0.0001984126984126984), $MachinePrecision] * l), $MachinePrecision] * N[(l * l), $MachinePrecision] + J), $MachinePrecision] * l), $MachinePrecision] * 2.0), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] + U), $MachinePrecision], N[(N[(2.0 * N[(J * N[Sinh[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 1.0 + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\
\;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(\left(\left(\left(\left(\ell \cdot \ell\right) \cdot \ell\right) \cdot J\right) \cdot 0.0001984126984126984\right) \cdot \ell, \ell \cdot \ell, J\right) \cdot \ell\right) \cdot 2, \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(2 \cdot \left(J \cdot \sinh \ell\right), 1, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002Initial program 90.4%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6490.4
Applied rewrites99.9%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6470.5
Applied rewrites70.5%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites63.6%
Taylor expanded in l around inf
Applied rewrites63.6%
if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 91.3%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6491.3
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites98.0%
Final simplification88.7%
(FPCore (J l K U) :precision binary64 (fma (* (* 2.0 (sinh l)) (cos (* -0.5 K))) J U))
double code(double J, double l, double K, double U) {
return fma(((2.0 * sinh(l)) * cos((-0.5 * K))), J, U);
}
function code(J, l, K, U) return fma(Float64(Float64(2.0 * sinh(l)) * cos(Float64(-0.5 * K))), J, U) end
code[J_, l_, K_, U_] := N[(N[(N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\left(2 \cdot \sinh \ell\right) \cdot \cos \left(-0.5 \cdot K\right), J, U\right)
\end{array}
Initial program 91.1%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.9%
Final simplification99.9%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) -0.01)
(fma
(*
(* (fma (* (* (* (* (* l l) l) J) 0.0001984126984126984) l) (* l l) J) l)
2.0)
(fma (* K K) -0.125 1.0)
U)
(fma
(*
1.0
(*
(fma
(fma
(fma (* l l) 0.0001984126984126984 0.008333333333333333)
(* l l)
0.16666666666666666)
(* l l)
1.0)
l))
(* 2.0 J)
U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.01) {
tmp = fma(((fma((((((l * l) * l) * J) * 0.0001984126984126984) * l), (l * l), J) * l) * 2.0), fma((K * K), -0.125, 1.0), U);
} else {
tmp = fma((1.0 * (fma(fma(fma((l * l), 0.0001984126984126984, 0.008333333333333333), (l * l), 0.16666666666666666), (l * l), 1.0) * l)), (2.0 * J), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.01) tmp = fma(Float64(Float64(fma(Float64(Float64(Float64(Float64(Float64(l * l) * l) * J) * 0.0001984126984126984) * l), Float64(l * l), J) * l) * 2.0), fma(Float64(K * K), -0.125, 1.0), U); else tmp = fma(Float64(1.0 * Float64(fma(fma(fma(Float64(l * l), 0.0001984126984126984, 0.008333333333333333), Float64(l * l), 0.16666666666666666), Float64(l * l), 1.0) * l)), Float64(2.0 * J), U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.01], N[(N[(N[(N[(N[(N[(N[(N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] * 0.0001984126984126984), $MachinePrecision] * l), $MachinePrecision] * N[(l * l), $MachinePrecision] + J), $MachinePrecision] * l), $MachinePrecision] * 2.0), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] + U), $MachinePrecision], N[(N[(1.0 * N[(N[(N[(N[(N[(l * l), $MachinePrecision] * 0.0001984126984126984 + 0.008333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 0.16666666666666666), $MachinePrecision] * N[(l * l), $MachinePrecision] + 1.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * N[(2.0 * J), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\
\;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(\left(\left(\left(\left(\ell \cdot \ell\right) \cdot \ell\right) \cdot J\right) \cdot 0.0001984126984126984\right) \cdot \ell, \ell \cdot \ell, J\right) \cdot \ell\right) \cdot 2, \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.0001984126984126984, 0.008333333333333333\right), \ell \cdot \ell, 0.16666666666666666\right), \ell \cdot \ell, 1\right) \cdot \ell\right), 2 \cdot J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002Initial program 90.4%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6490.4
Applied rewrites99.9%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6470.5
Applied rewrites70.5%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites63.6%
Taylor expanded in l around inf
Applied rewrites63.6%
if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 91.3%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6491.3
Applied rewrites100.0%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6495.8
Applied rewrites95.8%
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites95.8%
Taylor expanded in K around 0
Applied rewrites93.8%
(FPCore (J l K U)
:precision binary64
(if (<= (/ K 2.0) 20000.0)
(fma (* 2.0 (* J (sinh l))) (fma (* K K) -0.125 1.0) U)
(fma
(*
(*
(*
(fma
(fma
(fma 0.0001984126984126984 (* l l) 0.008333333333333333)
(* l l)
0.16666666666666666)
(* l l)
1.0)
l)
J)
2.0)
(cos (* -0.5 K))
U)))
double code(double J, double l, double K, double U) {
double tmp;
if ((K / 2.0) <= 20000.0) {
tmp = fma((2.0 * (J * sinh(l))), fma((K * K), -0.125, 1.0), U);
} else {
tmp = fma((((fma(fma(fma(0.0001984126984126984, (l * l), 0.008333333333333333), (l * l), 0.16666666666666666), (l * l), 1.0) * l) * J) * 2.0), cos((-0.5 * K)), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (Float64(K / 2.0) <= 20000.0) tmp = fma(Float64(2.0 * Float64(J * sinh(l))), fma(Float64(K * K), -0.125, 1.0), U); else tmp = fma(Float64(Float64(Float64(fma(fma(fma(0.0001984126984126984, Float64(l * l), 0.008333333333333333), Float64(l * l), 0.16666666666666666), Float64(l * l), 1.0) * l) * J) * 2.0), cos(Float64(-0.5 * K)), U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[(K / 2.0), $MachinePrecision], 20000.0], N[(N[(2.0 * N[(J * N[Sinh[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(N[(N[(N[(N[(0.0001984126984126984 * N[(l * l), $MachinePrecision] + 0.008333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 0.16666666666666666), $MachinePrecision] * N[(l * l), $MachinePrecision] + 1.0), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] * 2.0), $MachinePrecision] * N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{K}{2} \leq 20000:\\
\;\;\;\;\mathsf{fma}\left(2 \cdot \left(J \cdot \sinh \ell\right), \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0001984126984126984, \ell \cdot \ell, 0.008333333333333333\right), \ell \cdot \ell, 0.16666666666666666\right), \ell \cdot \ell, 1\right) \cdot \ell\right) \cdot J\right) \cdot 2, \cos \left(-0.5 \cdot K\right), U\right)\\
\end{array}
\end{array}
if (/.f64 K #s(literal 2 binary64)) < 2e4Initial program 90.7%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6490.7
Applied rewrites100.0%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6486.4
Applied rewrites86.4%
if 2e4 < (/.f64 K #s(literal 2 binary64)) Initial program 92.3%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6492.3
Applied rewrites100.0%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6496.0
Applied rewrites96.0%
Final simplification88.7%
(FPCore (J l K U)
:precision binary64
(if (<= (/ K 2.0) 20000.0)
(fma (* 2.0 (* J (sinh l))) (fma (* K K) -0.125 1.0) U)
(fma
(*
(*
(fma
(fma
(fma (* l l) 0.0001984126984126984 0.008333333333333333)
(* l l)
0.16666666666666666)
(* l l)
1.0)
l)
(cos (* -0.5 K)))
(* 2.0 J)
U)))
double code(double J, double l, double K, double U) {
double tmp;
if ((K / 2.0) <= 20000.0) {
tmp = fma((2.0 * (J * sinh(l))), fma((K * K), -0.125, 1.0), U);
} else {
tmp = fma(((fma(fma(fma((l * l), 0.0001984126984126984, 0.008333333333333333), (l * l), 0.16666666666666666), (l * l), 1.0) * l) * cos((-0.5 * K))), (2.0 * J), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (Float64(K / 2.0) <= 20000.0) tmp = fma(Float64(2.0 * Float64(J * sinh(l))), fma(Float64(K * K), -0.125, 1.0), U); else tmp = fma(Float64(Float64(fma(fma(fma(Float64(l * l), 0.0001984126984126984, 0.008333333333333333), Float64(l * l), 0.16666666666666666), Float64(l * l), 1.0) * l) * cos(Float64(-0.5 * K))), Float64(2.0 * J), U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[(K / 2.0), $MachinePrecision], 20000.0], N[(N[(2.0 * N[(J * N[Sinh[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(N[(N[(N[(N[(l * l), $MachinePrecision] * 0.0001984126984126984 + 0.008333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 0.16666666666666666), $MachinePrecision] * N[(l * l), $MachinePrecision] + 1.0), $MachinePrecision] * l), $MachinePrecision] * N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(2.0 * J), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{K}{2} \leq 20000:\\
\;\;\;\;\mathsf{fma}\left(2 \cdot \left(J \cdot \sinh \ell\right), \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.0001984126984126984, 0.008333333333333333\right), \ell \cdot \ell, 0.16666666666666666\right), \ell \cdot \ell, 1\right) \cdot \ell\right) \cdot \cos \left(-0.5 \cdot K\right), 2 \cdot J, U\right)\\
\end{array}
\end{array}
if (/.f64 K #s(literal 2 binary64)) < 2e4Initial program 90.7%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6490.7
Applied rewrites100.0%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6486.4
Applied rewrites86.4%
if 2e4 < (/.f64 K #s(literal 2 binary64)) Initial program 92.3%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6492.3
Applied rewrites100.0%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6496.0
Applied rewrites96.0%
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites95.9%
Final simplification88.7%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) -0.01)
(fma
(*
(*
(*
(fma (fma 0.008333333333333333 (* l l) 0.16666666666666666) (* l l) 1.0)
l)
J)
2.0)
(fma (* K K) -0.125 1.0)
U)
(fma
(*
1.0
(*
(fma
(fma
(fma (* l l) 0.0001984126984126984 0.008333333333333333)
(* l l)
0.16666666666666666)
(* l l)
1.0)
l))
(* 2.0 J)
U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.01) {
tmp = fma((((fma(fma(0.008333333333333333, (l * l), 0.16666666666666666), (l * l), 1.0) * l) * J) * 2.0), fma((K * K), -0.125, 1.0), U);
} else {
tmp = fma((1.0 * (fma(fma(fma((l * l), 0.0001984126984126984, 0.008333333333333333), (l * l), 0.16666666666666666), (l * l), 1.0) * l)), (2.0 * J), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.01) tmp = fma(Float64(Float64(Float64(fma(fma(0.008333333333333333, Float64(l * l), 0.16666666666666666), Float64(l * l), 1.0) * l) * J) * 2.0), fma(Float64(K * K), -0.125, 1.0), U); else tmp = fma(Float64(1.0 * Float64(fma(fma(fma(Float64(l * l), 0.0001984126984126984, 0.008333333333333333), Float64(l * l), 0.16666666666666666), Float64(l * l), 1.0) * l)), Float64(2.0 * J), U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.01], N[(N[(N[(N[(N[(N[(0.008333333333333333 * N[(l * l), $MachinePrecision] + 0.16666666666666666), $MachinePrecision] * N[(l * l), $MachinePrecision] + 1.0), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] * 2.0), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] + U), $MachinePrecision], N[(N[(1.0 * N[(N[(N[(N[(N[(l * l), $MachinePrecision] * 0.0001984126984126984 + 0.008333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 0.16666666666666666), $MachinePrecision] * N[(l * l), $MachinePrecision] + 1.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * N[(2.0 * J), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(0.008333333333333333, \ell \cdot \ell, 0.16666666666666666\right), \ell \cdot \ell, 1\right) \cdot \ell\right) \cdot J\right) \cdot 2, \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.0001984126984126984, 0.008333333333333333\right), \ell \cdot \ell, 0.16666666666666666\right), \ell \cdot \ell, 1\right) \cdot \ell\right), 2 \cdot J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002Initial program 90.4%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6490.4
Applied rewrites99.9%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6470.5
Applied rewrites70.5%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6462.2
Applied rewrites62.2%
if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 91.3%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6491.3
Applied rewrites100.0%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6495.8
Applied rewrites95.8%
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites95.8%
Taylor expanded in K around 0
Applied rewrites93.8%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) -0.01)
(fma
(* (* (fma (* 0.16666666666666666 J) (* l l) J) l) 2.0)
(fma (* K K) -0.125 1.0)
U)
(fma
(*
1.0
(*
(fma
(fma
(fma (* l l) 0.0001984126984126984 0.008333333333333333)
(* l l)
0.16666666666666666)
(* l l)
1.0)
l))
(* 2.0 J)
U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.01) {
tmp = fma(((fma((0.16666666666666666 * J), (l * l), J) * l) * 2.0), fma((K * K), -0.125, 1.0), U);
} else {
tmp = fma((1.0 * (fma(fma(fma((l * l), 0.0001984126984126984, 0.008333333333333333), (l * l), 0.16666666666666666), (l * l), 1.0) * l)), (2.0 * J), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.01) tmp = fma(Float64(Float64(fma(Float64(0.16666666666666666 * J), Float64(l * l), J) * l) * 2.0), fma(Float64(K * K), -0.125, 1.0), U); else tmp = fma(Float64(1.0 * Float64(fma(fma(fma(Float64(l * l), 0.0001984126984126984, 0.008333333333333333), Float64(l * l), 0.16666666666666666), Float64(l * l), 1.0) * l)), Float64(2.0 * J), U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.01], N[(N[(N[(N[(N[(0.16666666666666666 * J), $MachinePrecision] * N[(l * l), $MachinePrecision] + J), $MachinePrecision] * l), $MachinePrecision] * 2.0), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] + U), $MachinePrecision], N[(N[(1.0 * N[(N[(N[(N[(N[(l * l), $MachinePrecision] * 0.0001984126984126984 + 0.008333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 0.16666666666666666), $MachinePrecision] * N[(l * l), $MachinePrecision] + 1.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * N[(2.0 * J), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\
\;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(0.16666666666666666 \cdot J, \ell \cdot \ell, J\right) \cdot \ell\right) \cdot 2, \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.0001984126984126984, 0.008333333333333333\right), \ell \cdot \ell, 0.16666666666666666\right), \ell \cdot \ell, 1\right) \cdot \ell\right), 2 \cdot J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002Initial program 90.4%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6490.4
Applied rewrites99.9%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6470.5
Applied rewrites70.5%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites63.6%
Taylor expanded in l around 0
Applied rewrites60.7%
if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 91.3%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6491.3
Applied rewrites100.0%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6495.8
Applied rewrites95.8%
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites95.8%
Taylor expanded in K around 0
Applied rewrites93.8%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) -0.01)
(fma
(* (* (fma (* 0.16666666666666666 J) (* l l) J) l) 2.0)
(fma (* K K) -0.125 1.0)
U)
(fma (* (fma (* l l) 0.3333333333333333 2.0) l) J U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.01) {
tmp = fma(((fma((0.16666666666666666 * J), (l * l), J) * l) * 2.0), fma((K * K), -0.125, 1.0), U);
} else {
tmp = fma((fma((l * l), 0.3333333333333333, 2.0) * l), J, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.01) tmp = fma(Float64(Float64(fma(Float64(0.16666666666666666 * J), Float64(l * l), J) * l) * 2.0), fma(Float64(K * K), -0.125, 1.0), U); else tmp = fma(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l), J, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.01], N[(N[(N[(N[(N[(0.16666666666666666 * J), $MachinePrecision] * N[(l * l), $MachinePrecision] + J), $MachinePrecision] * l), $MachinePrecision] * 2.0), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\
\;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(0.16666666666666666 \cdot J, \ell \cdot \ell, J\right) \cdot \ell\right) \cdot 2, \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell, J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002Initial program 90.4%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6490.4
Applied rewrites99.9%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6470.5
Applied rewrites70.5%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites63.6%
Taylor expanded in l around 0
Applied rewrites60.7%
if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 91.3%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites87.6%
Taylor expanded in K around 0
Applied rewrites87.1%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) 0.055)
(fma
(* (* (fma 0.16666666666666666 (* (* J l) l) J) l) 2.0)
(fma (* K K) -0.125 1.0)
U)
(fma (* (fma (* l l) 0.3333333333333333 2.0) l) J U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.055) {
tmp = fma(((fma(0.16666666666666666, ((J * l) * l), J) * l) * 2.0), fma((K * K), -0.125, 1.0), U);
} else {
tmp = fma((fma((l * l), 0.3333333333333333, 2.0) * l), J, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.055) tmp = fma(Float64(Float64(fma(0.16666666666666666, Float64(Float64(J * l) * l), J) * l) * 2.0), fma(Float64(K * K), -0.125, 1.0), U); else tmp = fma(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l), J, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.055], N[(N[(N[(N[(0.16666666666666666 * N[(N[(J * l), $MachinePrecision] * l), $MachinePrecision] + J), $MachinePrecision] * l), $MachinePrecision] * 2.0), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.055:\\
\;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(0.16666666666666666, \left(J \cdot \ell\right) \cdot \ell, J\right) \cdot \ell\right) \cdot 2, \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell, J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.0550000000000000003Initial program 90.5%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6490.5
Applied rewrites99.9%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6469.5
Applied rewrites69.5%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6458.6
Applied rewrites58.6%
if 0.0550000000000000003 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 91.3%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites88.1%
Taylor expanded in K around 0
Applied rewrites87.6%
Final simplification79.7%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (fma (* l l) 0.3333333333333333 2.0)))
(if (<= (cos (/ K 2.0)) -0.01)
(fma (* (fma (* K K) -0.125 1.0) (* t_0 J)) l U)
(fma (* t_0 l) J U))))
double code(double J, double l, double K, double U) {
double t_0 = fma((l * l), 0.3333333333333333, 2.0);
double tmp;
if (cos((K / 2.0)) <= -0.01) {
tmp = fma((fma((K * K), -0.125, 1.0) * (t_0 * J)), l, U);
} else {
tmp = fma((t_0 * l), J, U);
}
return tmp;
}
function code(J, l, K, U) t_0 = fma(Float64(l * l), 0.3333333333333333, 2.0) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.01) tmp = fma(Float64(fma(Float64(K * K), -0.125, 1.0) * Float64(t_0 * J)), l, U); else tmp = fma(Float64(t_0 * l), J, U); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision]}, If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.01], N[(N[(N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] * N[(t$95$0 * J), $MachinePrecision]), $MachinePrecision] * l + U), $MachinePrecision], N[(N[(t$95$0 * l), $MachinePrecision] * J + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\\
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right) \cdot \left(t\_0 \cdot J\right), \ell, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_0 \cdot \ell, J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002Initial program 90.4%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites80.8%
Taylor expanded in K around 0
Applied rewrites59.4%
if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 91.3%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites87.6%
Taylor expanded in K around 0
Applied rewrites87.1%
Final simplification79.6%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.055) (fma (* J l) (fma (* K K) -0.25 2.0) U) (fma (* (fma (* l l) 0.3333333333333333 2.0) l) J U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.055) {
tmp = fma((J * l), fma((K * K), -0.25, 2.0), U);
} else {
tmp = fma((fma((l * l), 0.3333333333333333, 2.0) * l), J, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.055) tmp = fma(Float64(J * l), fma(Float64(K * K), -0.25, 2.0), U); else tmp = fma(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l), J, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.055], N[(N[(J * l), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.25 + 2.0), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.055:\\
\;\;\;\;\mathsf{fma}\left(J \cdot \ell, \mathsf{fma}\left(K \cdot K, -0.25, 2\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell, J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.0550000000000000003Initial program 90.5%
Taylor expanded in l around 0
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f6465.7
Applied rewrites65.7%
Taylor expanded in K around 0
Applied rewrites51.7%
if 0.0550000000000000003 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 91.3%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites88.1%
Taylor expanded in K around 0
Applied rewrites87.6%
Final simplification77.8%
(FPCore (J l K U) :precision binary64 (if (<= l 3.6e+94) (fma (* 2.0 J) l U) (* (* (* (* K K) l) J) -0.25)))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= 3.6e+94) {
tmp = fma((2.0 * J), l, U);
} else {
tmp = (((K * K) * l) * J) * -0.25;
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (l <= 3.6e+94) tmp = fma(Float64(2.0 * J), l, U); else tmp = Float64(Float64(Float64(Float64(K * K) * l) * J) * -0.25); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[l, 3.6e+94], N[(N[(2.0 * J), $MachinePrecision] * l + U), $MachinePrecision], N[(N[(N[(N[(K * K), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] * -0.25), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 3.6 \cdot 10^{+94}:\\
\;\;\;\;\mathsf{fma}\left(2 \cdot J, \ell, U\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(K \cdot K\right) \cdot \ell\right) \cdot J\right) \cdot -0.25\\
\end{array}
\end{array}
if l < 3.59999999999999992e94Initial program 89.1%
Taylor expanded in l around 0
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f6475.4
Applied rewrites75.4%
Taylor expanded in K around 0
Applied rewrites67.8%
if 3.59999999999999992e94 < l Initial program 100.0%
Taylor expanded in l around 0
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f6429.0
Applied rewrites29.0%
Taylor expanded in K around 0
Applied rewrites15.4%
Taylor expanded in K around 0
Applied rewrites26.1%
Taylor expanded in K around inf
Applied rewrites29.2%
Final simplification60.8%
(FPCore (J l K U) :precision binary64 (fma (* 2.0 J) l U))
double code(double J, double l, double K, double U) {
return fma((2.0 * J), l, U);
}
function code(J, l, K, U) return fma(Float64(2.0 * J), l, U) end
code[J_, l_, K_, U_] := N[(N[(2.0 * J), $MachinePrecision] * l + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(2 \cdot J, \ell, U\right)
\end{array}
Initial program 91.1%
Taylor expanded in l around 0
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f6467.1
Applied rewrites67.1%
Taylor expanded in K around 0
Applied rewrites58.4%
Final simplification58.4%
(FPCore (J l K U) :precision binary64 (* (* J l) 2.0))
double code(double J, double l, double K, double U) {
return (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 = (j * l) * 2.0d0
end function
public static double code(double J, double l, double K, double U) {
return (J * l) * 2.0;
}
def code(J, l, K, U): return (J * l) * 2.0
function code(J, l, K, U) return Float64(Float64(J * l) * 2.0) end
function tmp = code(J, l, K, U) tmp = (J * l) * 2.0; end
code[J_, l_, K_, U_] := N[(N[(J * l), $MachinePrecision] * 2.0), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \ell\right) \cdot 2
\end{array}
Initial program 91.1%
Taylor expanded in l around 0
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f6467.1
Applied rewrites67.1%
Taylor expanded in K around 0
Applied rewrites58.4%
Taylor expanded in J around inf
Applied rewrites18.3%
Final simplification18.3%
herbie shell --seed 2024235
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))