
(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 20 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 (* (cos (* K -0.5)) (* (sinh l) 2.0)) J U))
double code(double J, double l, double K, double U) {
return fma((cos((K * -0.5)) * (sinh(l) * 2.0)), J, U);
}
function code(J, l, K, U) return fma(Float64(cos(Float64(K * -0.5)) * Float64(sinh(l) * 2.0)), J, U) end
code[J_, l_, K_, U_] := N[(N[(N[Cos[N[(K * -0.5), $MachinePrecision]], $MachinePrecision] * N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\cos \left(K \cdot -0.5\right) \cdot \left(\sinh \ell \cdot 2\right), J, U\right)
\end{array}
Initial program 86.7%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* (sinh l) 2.0)) (t_1 (* J (- (exp l) (exp (- l))))))
(if (<= t_1 (- INFINITY))
(fma (* 1.0 t_0) J U)
(if (<= t_1 1e+266)
(fma (* (* 2.0 l) J) (cos (* 0.5 K)) U)
(fma (* (fma (* K K) -0.125 1.0) t_0) J U)))))
double code(double J, double l, double K, double U) {
double t_0 = sinh(l) * 2.0;
double t_1 = J * (exp(l) - exp(-l));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = fma((1.0 * t_0), J, U);
} else if (t_1 <= 1e+266) {
tmp = fma(((2.0 * l) * J), cos((0.5 * K)), U);
} else {
tmp = fma((fma((K * K), -0.125, 1.0) * t_0), J, U);
}
return tmp;
}
function code(J, l, K, U) t_0 = Float64(sinh(l) * 2.0) t_1 = Float64(J * Float64(exp(l) - exp(Float64(-l)))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = fma(Float64(1.0 * t_0), J, U); elseif (t_1 <= 1e+266) tmp = fma(Float64(Float64(2.0 * l) * J), cos(Float64(0.5 * K)), U); else tmp = fma(Float64(fma(Float64(K * K), -0.125, 1.0) * t_0), J, U); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision]}, Block[{t$95$1 = N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(1.0 * t$95$0), $MachinePrecision] * J + U), $MachinePrecision], If[LessEqual[t$95$1, 1e+266], N[(N[(N[(2.0 * l), $MachinePrecision] * J), $MachinePrecision] * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision] * J + U), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sinh \ell \cdot 2\\
t_1 := J \cdot \left(e^{\ell} - e^{-\ell}\right)\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot t\_0, J, U\right)\\
\mathbf{elif}\;t\_1 \leq 10^{+266}:\\
\;\;\;\;\mathsf{fma}\left(\left(2 \cdot \ell\right) \cdot J, \cos \left(0.5 \cdot K\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right) \cdot t\_0, J, U\right)\\
\end{array}
\end{array}
if (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < -inf.0Initial program 100.0%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites88.4%
if -inf.0 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < 1e266Initial program 71.1%
Taylor expanded in l around 0
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6499.6
Applied rewrites99.6%
if 1e266 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) Initial program 100.0%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6479.7
Applied rewrites79.7%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* J (- (exp l) (exp (- l))))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 1e+266)))
(fma (* 1.0 (* (sinh l) 2.0)) J U)
(fma (* (* 2.0 l) J) (cos (* 0.5 K)) U))))
double code(double J, double l, double K, double U) {
double t_0 = J * (exp(l) - exp(-l));
double tmp;
if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 1e+266)) {
tmp = fma((1.0 * (sinh(l) * 2.0)), J, U);
} else {
tmp = fma(((2.0 * l) * J), cos((0.5 * K)), U);
}
return tmp;
}
function code(J, l, K, U) t_0 = Float64(J * Float64(exp(l) - exp(Float64(-l)))) tmp = 0.0 if ((t_0 <= Float64(-Inf)) || !(t_0 <= 1e+266)) tmp = fma(Float64(1.0 * Float64(sinh(l) * 2.0)), J, U); else tmp = fma(Float64(Float64(2.0 * l) * J), cos(Float64(0.5 * K)), U); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 1e+266]], $MachinePrecision]], N[(N[(1.0 * N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], N[(N[(N[(2.0 * l), $MachinePrecision] * J), $MachinePrecision] * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := J \cdot \left(e^{\ell} - e^{-\ell}\right)\\
\mathbf{if}\;t\_0 \leq -\infty \lor \neg \left(t\_0 \leq 10^{+266}\right):\\
\;\;\;\;\mathsf{fma}\left(1 \cdot \left(\sinh \ell \cdot 2\right), J, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(2 \cdot \ell\right) \cdot J, \cos \left(0.5 \cdot K\right), U\right)\\
\end{array}
\end{array}
if (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < -inf.0 or 1e266 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) Initial program 100.0%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites81.9%
if -inf.0 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < 1e266Initial program 71.1%
Taylor expanded in l around 0
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6499.6
Applied rewrites99.6%
Final simplification90.1%
(FPCore (J l K U) :precision binary64 (if (<= (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U) (- INFINITY)) (* (fma 2.0 l (/ U J)) J) (fma (* 2.0 J) l U)))
double code(double J, double l, double K, double U) {
double tmp;
if ((((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U) <= -((double) INFINITY)) {
tmp = fma(2.0, l, (U / J)) * J;
} else {
tmp = fma((2.0 * J), l, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) <= Float64(-Inf)) tmp = Float64(fma(2.0, l, Float64(U / J)) * J); else tmp = fma(Float64(2.0 * J), l, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[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], (-Infinity)], N[(N[(2.0 * l + N[(U / J), $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision], N[(N[(2.0 * J), $MachinePrecision] * l + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(2, \ell, \frac{U}{J}\right) \cdot J\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(2 \cdot J, \ell, U\right)\\
\end{array}
\end{array}
if (+.f64 (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) U) < -inf.0Initial program 100.0%
Taylor expanded in l around 0
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6421.8
Applied rewrites21.8%
Taylor expanded in K around 0
Applied rewrites19.0%
Taylor expanded in J around inf
Applied rewrites31.0%
if -inf.0 < (+.f64 (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) U) Initial program 80.8%
Taylor expanded in l around 0
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6479.3
Applied rewrites79.3%
Taylor expanded in K around 0
Applied rewrites67.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1 (* (* (fma 0.3333333333333333 (* l l) 2.0) l) J)))
(if (<= t_0 -0.415)
(fma t_1 (fma -0.125 (* K K) 1.0) U)
(if (<= t_0 0.9975)
(fma t_1 1.0 U)
(fma
(*
(*
(fma
(fma
(fma 0.0003968253968253968 (* l l) 0.016666666666666666)
(* l l)
0.3333333333333333)
(* l l)
2.0)
l)
J)
(fma (fma 0.0026041666666666665 (* K K) -0.125) (* K K) 1.0)
U)))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = (fma(0.3333333333333333, (l * l), 2.0) * l) * J;
double tmp;
if (t_0 <= -0.415) {
tmp = fma(t_1, fma(-0.125, (K * K), 1.0), U);
} else if (t_0 <= 0.9975) {
tmp = fma(t_1, 1.0, U);
} else {
tmp = fma(((fma(fma(fma(0.0003968253968253968, (l * l), 0.016666666666666666), (l * l), 0.3333333333333333), (l * l), 2.0) * l) * J), fma(fma(0.0026041666666666665, (K * K), -0.125), (K * K), 1.0), U);
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(Float64(fma(0.3333333333333333, Float64(l * l), 2.0) * l) * J) tmp = 0.0 if (t_0 <= -0.415) tmp = fma(t_1, fma(-0.125, Float64(K * K), 1.0), U); elseif (t_0 <= 0.9975) tmp = fma(t_1, 1.0, U); else tmp = fma(Float64(Float64(fma(fma(fma(0.0003968253968253968, Float64(l * l), 0.016666666666666666), Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l) * J), fma(fma(0.0026041666666666665, Float64(K * K), -0.125), Float64(K * K), 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[(N[(N[(0.3333333333333333 * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision]}, If[LessEqual[t$95$0, -0.415], N[(t$95$1 * N[(-0.125 * N[(K * K), $MachinePrecision] + 1.0), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[t$95$0, 0.9975], N[(t$95$1 * 1.0 + U), $MachinePrecision], N[(N[(N[(N[(N[(N[(0.0003968253968253968 * N[(l * l), $MachinePrecision] + 0.016666666666666666), $MachinePrecision] * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] * N[(N[(0.0026041666666666665 * N[(K * K), $MachinePrecision] + -0.125), $MachinePrecision] * N[(K * K), $MachinePrecision] + 1.0), $MachinePrecision] + U), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := \left(\mathsf{fma}\left(0.3333333333333333, \ell \cdot \ell, 2\right) \cdot \ell\right) \cdot J\\
\mathbf{if}\;t\_0 \leq -0.415:\\
\;\;\;\;\mathsf{fma}\left(t\_1, \mathsf{fma}\left(-0.125, K \cdot K, 1\right), U\right)\\
\mathbf{elif}\;t\_0 \leq 0.9975:\\
\;\;\;\;\mathsf{fma}\left(t\_1, 1, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, \ell \cdot \ell, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right) \cdot J, \mathsf{fma}\left(\mathsf{fma}\left(0.0026041666666666665, K \cdot K, -0.125\right), K \cdot K, 1\right), U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.41499999999999998Initial program 95.0%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6492.3
Applied rewrites92.3%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6492.3
Applied rewrites92.3%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6469.2
Applied rewrites69.2%
if -0.41499999999999998 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.99750000000000005Initial program 77.3%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6492.2
Applied rewrites92.2%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6492.2
Applied rewrites92.2%
Taylor expanded in K around 0
Applied rewrites67.2%
if 0.99750000000000005 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 89.3%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6485.5
Applied rewrites85.5%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6485.5
Applied rewrites85.5%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6485.4
Applied rewrites85.4%
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-*.f6492.7
Applied rewrites92.7%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1 (* (* (fma 0.3333333333333333 (* l l) 2.0) l) J)))
(if (<= t_0 -0.415)
(fma t_1 (fma -0.125 (* K K) 1.0) U)
(if (<= t_0 0.9975)
(fma t_1 1.0 U)
(fma
(*
(*
(fma
(fma 0.016666666666666666 (* l l) 0.3333333333333333)
(* l l)
2.0)
l)
J)
(fma (fma 0.0026041666666666665 (* K K) -0.125) (* K K) 1.0)
U)))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = (fma(0.3333333333333333, (l * l), 2.0) * l) * J;
double tmp;
if (t_0 <= -0.415) {
tmp = fma(t_1, fma(-0.125, (K * K), 1.0), U);
} else if (t_0 <= 0.9975) {
tmp = fma(t_1, 1.0, U);
} else {
tmp = fma(((fma(fma(0.016666666666666666, (l * l), 0.3333333333333333), (l * l), 2.0) * l) * J), fma(fma(0.0026041666666666665, (K * K), -0.125), (K * K), 1.0), U);
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(Float64(fma(0.3333333333333333, Float64(l * l), 2.0) * l) * J) tmp = 0.0 if (t_0 <= -0.415) tmp = fma(t_1, fma(-0.125, Float64(K * K), 1.0), U); elseif (t_0 <= 0.9975) tmp = fma(t_1, 1.0, U); else tmp = fma(Float64(Float64(fma(fma(0.016666666666666666, Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l) * J), fma(fma(0.0026041666666666665, Float64(K * K), -0.125), Float64(K * K), 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[(N[(N[(0.3333333333333333 * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision]}, If[LessEqual[t$95$0, -0.415], N[(t$95$1 * N[(-0.125 * N[(K * K), $MachinePrecision] + 1.0), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[t$95$0, 0.9975], N[(t$95$1 * 1.0 + U), $MachinePrecision], N[(N[(N[(N[(N[(0.016666666666666666 * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] * N[(N[(0.0026041666666666665 * N[(K * K), $MachinePrecision] + -0.125), $MachinePrecision] * N[(K * K), $MachinePrecision] + 1.0), $MachinePrecision] + U), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := \left(\mathsf{fma}\left(0.3333333333333333, \ell \cdot \ell, 2\right) \cdot \ell\right) \cdot J\\
\mathbf{if}\;t\_0 \leq -0.415:\\
\;\;\;\;\mathsf{fma}\left(t\_1, \mathsf{fma}\left(-0.125, K \cdot K, 1\right), U\right)\\
\mathbf{elif}\;t\_0 \leq 0.9975:\\
\;\;\;\;\mathsf{fma}\left(t\_1, 1, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(0.016666666666666666, \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right) \cdot J, \mathsf{fma}\left(\mathsf{fma}\left(0.0026041666666666665, K \cdot K, -0.125\right), K \cdot K, 1\right), U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.41499999999999998Initial program 95.0%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6492.3
Applied rewrites92.3%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6492.3
Applied rewrites92.3%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6469.2
Applied rewrites69.2%
if -0.41499999999999998 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.99750000000000005Initial program 77.3%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6492.2
Applied rewrites92.2%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6492.2
Applied rewrites92.2%
Taylor expanded in K around 0
Applied rewrites67.2%
if 0.99750000000000005 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 89.3%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6485.5
Applied rewrites85.5%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6485.5
Applied rewrites85.5%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6485.4
Applied rewrites85.4%
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-*.f6490.7
Applied rewrites90.7%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 0.9975)
(+
(*
(*
J
(*
(fma
(fma
(fma 0.0003968253968253968 (* l l) 0.016666666666666666)
(* l l)
0.3333333333333333)
(* l l)
2.0)
l))
t_0)
U)
(fma (* 1.0 (* (sinh l) 2.0)) 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.9975) {
tmp = ((J * (fma(fma(fma(0.0003968253968253968, (l * l), 0.016666666666666666), (l * l), 0.3333333333333333), (l * l), 2.0) * l)) * t_0) + U;
} else {
tmp = fma((1.0 * (sinh(l) * 2.0)), J, U);
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= 0.9975) tmp = Float64(Float64(Float64(J * Float64(fma(fma(fma(0.0003968253968253968, Float64(l * l), 0.016666666666666666), Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l)) * t_0) + U); else tmp = fma(Float64(1.0 * Float64(sinh(l) * 2.0)), 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.9975], N[(N[(N[(J * N[(N[(N[(N[(0.0003968253968253968 * N[(l * l), $MachinePrecision] + 0.016666666666666666), $MachinePrecision] * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(N[(1.0 * N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq 0.9975:\\
\;\;\;\;\left(J \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, \ell \cdot \ell, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right)\right) \cdot t\_0 + U\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot \left(\sinh \ell \cdot 2\right), J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.99750000000000005Initial program 83.3%
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-*.f6499.1
Applied rewrites99.1%
if 0.99750000000000005 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 89.3%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites99.3%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 0.94)
(+
(*
(*
J
(*
(fma
(fma 0.016666666666666666 (* l l) 0.3333333333333333)
(* l l)
2.0)
l))
t_0)
U)
(fma (* 1.0 (* (sinh l) 2.0)) 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.94) {
tmp = ((J * (fma(fma(0.016666666666666666, (l * l), 0.3333333333333333), (l * l), 2.0) * l)) * t_0) + U;
} else {
tmp = fma((1.0 * (sinh(l) * 2.0)), J, U);
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= 0.94) tmp = Float64(Float64(Float64(J * Float64(fma(fma(0.016666666666666666, Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l)) * t_0) + U); else tmp = fma(Float64(1.0 * Float64(sinh(l) * 2.0)), 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.94], N[(N[(N[(J * N[(N[(N[(0.016666666666666666 * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(N[(1.0 * N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq 0.94:\\
\;\;\;\;\left(J \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(0.016666666666666666, \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right)\right) \cdot t\_0 + U\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot \left(\sinh \ell \cdot 2\right), J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.93999999999999995Initial program 82.9%
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-*.f6499.0
Applied rewrites99.0%
if 0.93999999999999995 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 89.2%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites98.9%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.94) (fma (* (* (fma 0.3333333333333333 (* l l) 2.0) l) J) (cos (* 0.5 K)) U) (fma (* 1.0 (* (sinh l) 2.0)) J U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.94) {
tmp = fma(((fma(0.3333333333333333, (l * l), 2.0) * l) * J), cos((0.5 * K)), U);
} else {
tmp = fma((1.0 * (sinh(l) * 2.0)), J, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.94) tmp = fma(Float64(Float64(fma(0.3333333333333333, Float64(l * l), 2.0) * l) * J), cos(Float64(0.5 * K)), U); else tmp = fma(Float64(1.0 * Float64(sinh(l) * 2.0)), J, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.94], N[(N[(N[(N[(0.3333333333333333 * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] + U), $MachinePrecision], N[(N[(1.0 * N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.94:\\
\;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(0.3333333333333333, \ell \cdot \ell, 2\right) \cdot \ell\right) \cdot J, \cos \left(0.5 \cdot K\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot \left(\sinh \ell \cdot 2\right), J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.93999999999999995Initial program 82.9%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6492.6
Applied rewrites92.6%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6492.6
Applied rewrites92.6%
lift-cos.f64N/A
cos-negN/A
lift-/.f64N/A
distribute-frac-negN/A
metadata-evalN/A
frac-2negN/A
div-invN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lift-cos.f6492.6
Applied rewrites92.6%
if 0.93999999999999995 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 89.2%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites98.9%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.94) (fma (* (cos (* -0.5 K)) (* (fma (* l l) 0.3333333333333333 2.0) l)) J U) (fma (* 1.0 (* (sinh l) 2.0)) J U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.94) {
tmp = fma((cos((-0.5 * K)) * (fma((l * l), 0.3333333333333333, 2.0) * l)), J, U);
} else {
tmp = fma((1.0 * (sinh(l) * 2.0)), J, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.94) tmp = fma(Float64(cos(Float64(-0.5 * K)) * Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l)), J, U); else tmp = fma(Float64(1.0 * Float64(sinh(l) * 2.0)), J, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.94], N[(N[(N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision] * N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], N[(N[(1.0 * N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.94:\\
\;\;\;\;\mathsf{fma}\left(\cos \left(-0.5 \cdot K\right) \cdot \left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right), J, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot \left(\sinh \ell \cdot 2\right), J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.93999999999999995Initial program 82.9%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.8%
Taylor expanded in l around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
distribute-rgt-outN/A
*-commutativeN/A
distribute-lft-inN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites92.5%
if 0.93999999999999995 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 89.2%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites98.9%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.94) (fma (* (cos (* 0.5 K)) (* J (fma (* l l) 0.3333333333333333 2.0))) l U) (fma (* 1.0 (* (sinh l) 2.0)) J U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.94) {
tmp = fma((cos((0.5 * K)) * (J * fma((l * l), 0.3333333333333333, 2.0))), l, U);
} else {
tmp = fma((1.0 * (sinh(l) * 2.0)), J, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.94) tmp = fma(Float64(cos(Float64(0.5 * K)) * Float64(J * fma(Float64(l * l), 0.3333333333333333, 2.0))), l, U); else tmp = fma(Float64(1.0 * Float64(sinh(l) * 2.0)), J, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.94], N[(N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * N[(J * N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * l + U), $MachinePrecision], N[(N[(1.0 * N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.94:\\
\;\;\;\;\mathsf{fma}\left(\cos \left(0.5 \cdot K\right) \cdot \left(J \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\right), \ell, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot \left(\sinh \ell \cdot 2\right), J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.93999999999999995Initial program 82.9%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites88.9%
if 0.93999999999999995 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 89.2%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites98.9%
(FPCore (J l K U) :precision binary64 (if (<= (* J (- (exp l) (exp (- l)))) 1e+266) (fma (* 2.0 J) l U) (* (* J l) (fma (* K K) -0.25 2.0))))
double code(double J, double l, double K, double U) {
double tmp;
if ((J * (exp(l) - exp(-l))) <= 1e+266) {
tmp = fma((2.0 * J), l, U);
} else {
tmp = (J * l) * fma((K * K), -0.25, 2.0);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (Float64(J * Float64(exp(l) - exp(Float64(-l)))) <= 1e+266) tmp = fma(Float64(2.0 * J), l, U); else tmp = Float64(Float64(J * l) * fma(Float64(K * K), -0.25, 2.0)); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+266], N[(N[(2.0 * J), $MachinePrecision] * l + U), $MachinePrecision], N[(N[(J * l), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.25 + 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;J \cdot \left(e^{\ell} - e^{-\ell}\right) \leq 10^{+266}:\\
\;\;\;\;\mathsf{fma}\left(2 \cdot J, \ell, U\right)\\
\mathbf{else}:\\
\;\;\;\;\left(J \cdot \ell\right) \cdot \mathsf{fma}\left(K \cdot K, -0.25, 2\right)\\
\end{array}
\end{array}
if (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < 1e266Initial program 81.8%
Taylor expanded in l around 0
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6471.8
Applied rewrites71.8%
Taylor expanded in K around 0
Applied rewrites60.9%
if 1e266 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) Initial program 100.0%
Taylor expanded in l around 0
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6434.6
Applied rewrites34.6%
Taylor expanded in J around inf
Applied rewrites34.5%
Taylor expanded in K around 0
Applied rewrites42.2%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) -0.415)
(fma
(* (* (fma 0.3333333333333333 (* l l) 2.0) l) J)
(fma -0.125 (* K K) 1.0)
U)
(fma (* 1.0 (* (sinh l) 2.0)) J U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.415) {
tmp = fma(((fma(0.3333333333333333, (l * l), 2.0) * l) * J), fma(-0.125, (K * K), 1.0), U);
} else {
tmp = fma((1.0 * (sinh(l) * 2.0)), J, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.415) tmp = fma(Float64(Float64(fma(0.3333333333333333, Float64(l * l), 2.0) * l) * J), fma(-0.125, Float64(K * K), 1.0), U); else tmp = fma(Float64(1.0 * Float64(sinh(l) * 2.0)), J, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.415], N[(N[(N[(N[(0.3333333333333333 * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] * N[(-0.125 * N[(K * K), $MachinePrecision] + 1.0), $MachinePrecision] + U), $MachinePrecision], N[(N[(1.0 * N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.415:\\
\;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(0.3333333333333333, \ell \cdot \ell, 2\right) \cdot \ell\right) \cdot J, \mathsf{fma}\left(-0.125, K \cdot K, 1\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot \left(\sinh \ell \cdot 2\right), J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.41499999999999998Initial program 95.0%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6492.3
Applied rewrites92.3%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6492.3
Applied rewrites92.3%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6469.2
Applied rewrites69.2%
if -0.41499999999999998 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.2%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.9%
Taylor expanded in K around 0
Applied rewrites91.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* (* (fma 0.3333333333333333 (* l l) 2.0) l) J)))
(if (<= (cos (/ K 2.0)) -0.415)
(fma t_0 (fma -0.125 (* K K) 1.0) U)
(fma t_0 1.0 U))))
double code(double J, double l, double K, double U) {
double t_0 = (fma(0.3333333333333333, (l * l), 2.0) * l) * J;
double tmp;
if (cos((K / 2.0)) <= -0.415) {
tmp = fma(t_0, fma(-0.125, (K * K), 1.0), U);
} else {
tmp = fma(t_0, 1.0, U);
}
return tmp;
}
function code(J, l, K, U) t_0 = Float64(Float64(fma(0.3333333333333333, Float64(l * l), 2.0) * l) * J) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.415) tmp = fma(t_0, fma(-0.125, Float64(K * K), 1.0), U); else tmp = fma(t_0, 1.0, U); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(N[(0.3333333333333333 * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision]}, If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.415], N[(t$95$0 * N[(-0.125 * N[(K * K), $MachinePrecision] + 1.0), $MachinePrecision] + U), $MachinePrecision], N[(t$95$0 * 1.0 + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{fma}\left(0.3333333333333333, \ell \cdot \ell, 2\right) \cdot \ell\right) \cdot J\\
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.415:\\
\;\;\;\;\mathsf{fma}\left(t\_0, \mathsf{fma}\left(-0.125, K \cdot K, 1\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_0, 1, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.41499999999999998Initial program 95.0%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6492.3
Applied rewrites92.3%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6492.3
Applied rewrites92.3%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6469.2
Applied rewrites69.2%
if -0.41499999999999998 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.2%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6487.8
Applied rewrites87.8%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6487.8
Applied rewrites87.8%
Taylor expanded in K around 0
Applied rewrites78.8%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.415) (fma (* (fma -0.125 (* K K) 1.0) J) (* 2.0 l) U) (fma (* (* (fma 0.3333333333333333 (* l l) 2.0) l) J) 1.0 U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.415) {
tmp = fma((fma(-0.125, (K * K), 1.0) * J), (2.0 * l), U);
} else {
tmp = fma(((fma(0.3333333333333333, (l * l), 2.0) * l) * J), 1.0, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.415) tmp = fma(Float64(fma(-0.125, Float64(K * K), 1.0) * J), Float64(2.0 * l), U); else tmp = fma(Float64(Float64(fma(0.3333333333333333, Float64(l * l), 2.0) * l) * J), 1.0, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.415], N[(N[(N[(-0.125 * N[(K * K), $MachinePrecision] + 1.0), $MachinePrecision] * J), $MachinePrecision] * N[(2.0 * l), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(N[(0.3333333333333333 * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] * 1.0 + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.415:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.125, K \cdot K, 1\right) \cdot J, 2 \cdot \ell, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(0.3333333333333333, \ell \cdot \ell, 2\right) \cdot \ell\right) \cdot J, 1, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.41499999999999998Initial program 95.0%
Taylor expanded in l around 0
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6454.4
Applied rewrites54.4%
Applied rewrites54.4%
Taylor expanded in K around 0
Applied rewrites61.9%
if -0.41499999999999998 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.2%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6487.8
Applied rewrites87.8%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6487.8
Applied rewrites87.8%
Taylor expanded in K around 0
Applied rewrites78.8%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.415) (fma (* (fma -0.125 (* K K) 1.0) J) (* 2.0 l) U) (* (fma (* (/ l U) J) 2.0 1.0) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.415) {
tmp = fma((fma(-0.125, (K * K), 1.0) * J), (2.0 * l), U);
} else {
tmp = fma(((l / U) * J), 2.0, 1.0) * U;
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.415) tmp = fma(Float64(fma(-0.125, Float64(K * K), 1.0) * J), Float64(2.0 * l), U); else tmp = Float64(fma(Float64(Float64(l / U) * J), 2.0, 1.0) * U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.415], N[(N[(N[(-0.125 * N[(K * K), $MachinePrecision] + 1.0), $MachinePrecision] * J), $MachinePrecision] * N[(2.0 * l), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(N[(l / U), $MachinePrecision] * J), $MachinePrecision] * 2.0 + 1.0), $MachinePrecision] * U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.415:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.125, K \cdot K, 1\right) \cdot J, 2 \cdot \ell, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\ell}{U} \cdot J, 2, 1\right) \cdot U\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.41499999999999998Initial program 95.0%
Taylor expanded in l around 0
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6454.4
Applied rewrites54.4%
Applied rewrites54.4%
Taylor expanded in K around 0
Applied rewrites61.9%
if -0.41499999999999998 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.2%
Taylor expanded in l around 0
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6463.1
Applied rewrites63.1%
Taylor expanded in K around 0
Applied rewrites55.6%
Taylor expanded in U around inf
Applied rewrites61.5%
Applied rewrites64.5%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.415) (fma (* J l) (fma (* K K) -0.25 2.0) U) (* (fma (* (/ l U) J) 2.0 1.0) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.415) {
tmp = fma((J * l), fma((K * K), -0.25, 2.0), U);
} else {
tmp = fma(((l / U) * J), 2.0, 1.0) * U;
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.415) tmp = fma(Float64(J * l), fma(Float64(K * K), -0.25, 2.0), U); else tmp = Float64(fma(Float64(Float64(l / U) * J), 2.0, 1.0) * U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.415], N[(N[(J * l), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.25 + 2.0), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(N[(l / U), $MachinePrecision] * J), $MachinePrecision] * 2.0 + 1.0), $MachinePrecision] * U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.415:\\
\;\;\;\;\mathsf{fma}\left(J \cdot \ell, \mathsf{fma}\left(K \cdot K, -0.25, 2\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\ell}{U} \cdot J, 2, 1\right) \cdot U\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.41499999999999998Initial program 95.0%
Taylor expanded in l around 0
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6454.4
Applied rewrites54.4%
Taylor expanded in K around 0
Applied rewrites61.9%
if -0.41499999999999998 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.2%
Taylor expanded in l around 0
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6463.1
Applied rewrites63.1%
Taylor expanded in K around 0
Applied rewrites55.6%
Taylor expanded in U around inf
Applied rewrites61.5%
Applied rewrites64.5%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.415) (fma (* J l) (fma (* K K) -0.25 2.0) U) (* (fma (* l (/ J U)) 2.0 1.0) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.415) {
tmp = fma((J * l), fma((K * K), -0.25, 2.0), U);
} else {
tmp = fma((l * (J / U)), 2.0, 1.0) * U;
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.415) tmp = fma(Float64(J * l), fma(Float64(K * K), -0.25, 2.0), U); else tmp = Float64(fma(Float64(l * Float64(J / U)), 2.0, 1.0) * U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.415], N[(N[(J * l), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.25 + 2.0), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(l * N[(J / U), $MachinePrecision]), $MachinePrecision] * 2.0 + 1.0), $MachinePrecision] * U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.415:\\
\;\;\;\;\mathsf{fma}\left(J \cdot \ell, \mathsf{fma}\left(K \cdot K, -0.25, 2\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\ell \cdot \frac{J}{U}, 2, 1\right) \cdot U\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.41499999999999998Initial program 95.0%
Taylor expanded in l around 0
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6454.4
Applied rewrites54.4%
Taylor expanded in K around 0
Applied rewrites61.9%
if -0.41499999999999998 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.2%
Taylor expanded in l around 0
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6463.1
Applied rewrites63.1%
Taylor expanded in K around 0
Applied rewrites55.6%
Taylor expanded in U around inf
Applied rewrites61.5%
Applied rewrites58.6%
(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 86.7%
Taylor expanded in l around 0
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6461.8
Applied rewrites61.8%
Taylor expanded in K around 0
Applied rewrites53.0%
(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 86.7%
Taylor expanded in l around 0
+-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6461.8
Applied rewrites61.8%
Taylor expanded in K around 0
Applied rewrites53.0%
Applied rewrites53.0%
Taylor expanded in J around inf
Applied rewrites22.1%
Final simplification22.1%
herbie shell --seed 2024307
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))