
(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 18 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (J l K U) :precision binary64 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U): return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) end
function tmp = code(J, l, K, U) tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
(FPCore (J l K U) :precision binary64 (fma (* (* 2.0 (sinh l)) (cos (* -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 87.3%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
Final simplification100.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (+ (* (* (- (exp l) (exp (- l))) J) (cos (/ K 2.0))) U))
(t_1 (fma (* (* (* l l) J) 0.3333333333333333) l U)))
(if (<= t_0 (- INFINITY)) t_1 (if (<= t_0 1e+78) (fma (* 2.0 J) l U) t_1))))
double code(double J, double l, double K, double U) {
double t_0 = (((exp(l) - exp(-l)) * J) * cos((K / 2.0))) + U;
double t_1 = fma((((l * l) * J) * 0.3333333333333333), l, U);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_0 <= 1e+78) {
tmp = fma((2.0 * J), l, U);
} else {
tmp = t_1;
}
return tmp;
}
function code(J, l, K, U) t_0 = Float64(Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) * cos(Float64(K / 2.0))) + U) t_1 = fma(Float64(Float64(Float64(l * l) * J) * 0.3333333333333333), l, U) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = t_1; elseif (t_0 <= 1e+78) tmp = fma(Float64(2.0 * J), l, U); else tmp = t_1; end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[(l * l), $MachinePrecision] * J), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] * l + U), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], t$95$1, If[LessEqual[t$95$0, 1e+78], N[(N[(2.0 * J), $MachinePrecision] * l + U), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(e^{\ell} - e^{-\ell}\right) \cdot J\right) \cdot \cos \left(\frac{K}{2}\right) + U\\
t_1 := \mathsf{fma}\left(\left(\left(\ell \cdot \ell\right) \cdot J\right) \cdot 0.3333333333333333, \ell, U\right)\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 10^{+78}:\\
\;\;\;\;\mathsf{fma}\left(2 \cdot J, \ell, U\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\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.0 or 1.00000000000000001e78 < (+.f64 (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) U) Initial program 98.8%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites75.1%
Taylor expanded in K around 0
Applied rewrites59.6%
Taylor expanded in l around inf
Applied rewrites59.6%
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) < 1.00000000000000001e78Initial program 67.2%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites99.9%
Taylor expanded in K around 0
Applied rewrites84.9%
Taylor expanded in l around 0
Applied rewrites84.9%
Final simplification68.8%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* 2.0 (sinh l))))
(if (<= (cos (/ K 2.0)) -0.215)
(fma (* (fma (* K K) -0.125 1.0) t_0) J U)
(fma (* 1.0 t_0) J U))))
double code(double J, double l, double K, double U) {
double t_0 = 2.0 * sinh(l);
double tmp;
if (cos((K / 2.0)) <= -0.215) {
tmp = fma((fma((K * K), -0.125, 1.0) * t_0), J, U);
} else {
tmp = fma((1.0 * t_0), J, U);
}
return tmp;
}
function code(J, l, K, U) t_0 = Float64(2.0 * sinh(l)) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.215) tmp = fma(Float64(fma(Float64(K * K), -0.125, 1.0) * t_0), J, U); else tmp = fma(Float64(1.0 * t_0), J, U); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.215], N[(N[(N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision] * J + U), $MachinePrecision], N[(N[(1.0 * t$95$0), $MachinePrecision] * J + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 2 \cdot \sinh \ell\\
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.215:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right) \cdot t\_0, J, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot t\_0, J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.214999999999999997Initial program 90.8%
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-*.f6481.8
Applied rewrites81.8%
if -0.214999999999999997 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 86.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 rewrites92.7%
Final simplification90.2%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) -0.215)
(fma
(*
(*
(fma
(fma
(fma 0.0003968253968253968 (* l l) 0.016666666666666666)
(* l l)
0.3333333333333333)
(* l l)
2.0)
l)
(fma (* K K) -0.125 1.0))
J
U)
(fma (* 1.0 (* 2.0 (sinh l))) J U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.215) {
tmp = fma(((fma(fma(fma(0.0003968253968253968, (l * l), 0.016666666666666666), (l * l), 0.3333333333333333), (l * l), 2.0) * l) * fma((K * K), -0.125, 1.0)), J, U);
} else {
tmp = fma((1.0 * (2.0 * sinh(l))), J, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.215) 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) * fma(Float64(K * K), -0.125, 1.0)), J, U); else tmp = fma(Float64(1.0 * Float64(2.0 * sinh(l))), J, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.215], 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] * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], N[(N[(1.0 * N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.215:\\
\;\;\;\;\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 \mathsf{fma}\left(K \cdot K, -0.125, 1\right), J, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot \left(2 \cdot \sinh \ell\right), J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.214999999999999997Initial program 90.8%
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 rewrites30.2%
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-*.f6430.5
Applied rewrites30.5%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6478.5
Applied rewrites78.5%
if -0.214999999999999997 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 86.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 rewrites92.7%
Final simplification89.5%
(FPCore (J l K U)
:precision binary64
(if (<= (/ K 2.0) 4e-19)
(fma (* 1.0 (* 2.0 (sinh l))) J U)
(+
(*
(cos (/ K 2.0))
(*
(*
(fma
(fma
(fma 0.0003968253968253968 (* l l) 0.016666666666666666)
(* l l)
0.3333333333333333)
(* l l)
2.0)
l)
J))
U)))
double code(double J, double l, double K, double U) {
double tmp;
if ((K / 2.0) <= 4e-19) {
tmp = fma((1.0 * (2.0 * sinh(l))), J, U);
} else {
tmp = (cos((K / 2.0)) * ((fma(fma(fma(0.0003968253968253968, (l * l), 0.016666666666666666), (l * l), 0.3333333333333333), (l * l), 2.0) * l) * J)) + U;
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (Float64(K / 2.0) <= 4e-19) tmp = fma(Float64(1.0 * Float64(2.0 * sinh(l))), J, U); else tmp = Float64(Float64(cos(Float64(K / 2.0)) * Float64(Float64(fma(fma(fma(0.0003968253968253968, Float64(l * l), 0.016666666666666666), Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l) * J)) + U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[(K / 2.0), $MachinePrecision], 4e-19], N[(N[(1.0 * N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], N[(N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * 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]), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{K}{2} \leq 4 \cdot 10^{-19}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot \left(2 \cdot \sinh \ell\right), J, U\right)\\
\mathbf{else}:\\
\;\;\;\;\cos \left(\frac{K}{2}\right) \cdot \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\right) + U\\
\end{array}
\end{array}
if (/.f64 K #s(literal 2 binary64)) < 3.9999999999999999e-19Initial program 86.7%
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 rewrites85.6%
if 3.9999999999999999e-19 < (/.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
+-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-*.f6491.3
Applied rewrites91.3%
Final simplification87.1%
(FPCore (J l K U)
:precision binary64
(let* ((t_0
(*
(fma
(fma
(fma 0.0003968253968253968 (* l l) 0.016666666666666666)
(* l l)
0.3333333333333333)
(* l l)
2.0)
l)))
(if (<= (cos (/ K 2.0)) -0.215)
(fma (* t_0 (fma (* K K) -0.125 1.0)) J U)
(fma (* t_0 1.0) J U))))
double code(double J, double l, double K, double U) {
double t_0 = fma(fma(fma(0.0003968253968253968, (l * l), 0.016666666666666666), (l * l), 0.3333333333333333), (l * l), 2.0) * l;
double tmp;
if (cos((K / 2.0)) <= -0.215) {
tmp = fma((t_0 * fma((K * K), -0.125, 1.0)), J, U);
} else {
tmp = fma((t_0 * 1.0), J, U);
}
return tmp;
}
function code(J, l, K, U) t_0 = Float64(fma(fma(fma(0.0003968253968253968, Float64(l * l), 0.016666666666666666), Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.215) tmp = fma(Float64(t_0 * fma(Float64(K * K), -0.125, 1.0)), J, U); else tmp = fma(Float64(t_0 * 1.0), J, U); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = 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]}, If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.215], N[(N[(t$95$0 * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], N[(N[(t$95$0 * 1.0), $MachinePrecision] * J + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \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\\
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.215:\\
\;\;\;\;\mathsf{fma}\left(t\_0 \cdot \mathsf{fma}\left(K \cdot K, -0.125, 1\right), J, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_0 \cdot 1, J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.214999999999999997Initial program 90.8%
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 rewrites30.2%
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-*.f6430.5
Applied rewrites30.5%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6478.5
Applied rewrites78.5%
if -0.214999999999999997 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 86.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 rewrites92.7%
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-*.f6486.3
Applied rewrites86.3%
Final simplification84.5%
(FPCore (J l K U)
:precision binary64
(if (<= (/ K 2.0) 4e-19)
(fma (* 1.0 (* 2.0 (sinh l))) J U)
(+
(*
(*
(*
(fma (fma 0.016666666666666666 (* l l) 0.3333333333333333) (* l l) 2.0)
l)
J)
(cos (/ K 2.0)))
U)))
double code(double J, double l, double K, double U) {
double tmp;
if ((K / 2.0) <= 4e-19) {
tmp = fma((1.0 * (2.0 * sinh(l))), J, U);
} else {
tmp = (((fma(fma(0.016666666666666666, (l * l), 0.3333333333333333), (l * l), 2.0) * l) * J) * cos((K / 2.0))) + U;
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (Float64(K / 2.0) <= 4e-19) tmp = fma(Float64(1.0 * Float64(2.0 * sinh(l))), J, U); else tmp = Float64(Float64(Float64(Float64(fma(fma(0.016666666666666666, Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l) * J) * cos(Float64(K / 2.0))) + U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[(K / 2.0), $MachinePrecision], 4e-19], N[(N[(1.0 * N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], N[(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[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{K}{2} \leq 4 \cdot 10^{-19}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot \left(2 \cdot \sinh \ell\right), J, U\right)\\
\mathbf{else}:\\
\;\;\;\;\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\right) \cdot \cos \left(\frac{K}{2}\right) + U\\
\end{array}
\end{array}
if (/.f64 K #s(literal 2 binary64)) < 3.9999999999999999e-19Initial program 86.7%
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 rewrites85.6%
if 3.9999999999999999e-19 < (/.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
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6487.2
Applied rewrites87.2%
Final simplification86.0%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) -0.05)
(fma
(fma (* K K) -0.125 1.0)
(* (* (fma (* l l) 0.3333333333333333 2.0) l) J)
U)
(fma
(*
(*
(fma
(fma
(fma 0.0003968253968253968 (* l l) 0.016666666666666666)
(* l l)
0.3333333333333333)
(* l l)
2.0)
l)
1.0)
J
U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.05) {
tmp = fma(fma((K * K), -0.125, 1.0), ((fma((l * l), 0.3333333333333333, 2.0) * l) * J), U);
} else {
tmp = fma(((fma(fma(fma(0.0003968253968253968, (l * l), 0.016666666666666666), (l * l), 0.3333333333333333), (l * l), 2.0) * l) * 1.0), J, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.05) tmp = fma(fma(Float64(K * K), -0.125, 1.0), Float64(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l) * J), 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) * 1.0), J, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.05], N[(N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] * N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] + 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] * 1.0), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.05:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right), \left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J, 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 1, J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.050000000000000003Initial program 89.6%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites77.8%
Taylor expanded in K around 0
Applied rewrites67.1%
if -0.050000000000000003 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 86.5%
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 rewrites95.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-*.f6488.6
Applied rewrites88.6%
Final simplification82.8%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) -0.05)
(fma
(fma (* K K) -0.125 1.0)
(* (* (fma (* l l) 0.3333333333333333 2.0) l) J)
U)
(fma
(*
(*
(fma
(fma (* (* l l) 0.0003968253968253968) (* l l) 0.3333333333333333)
(* l l)
2.0)
l)
1.0)
J
U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.05) {
tmp = fma(fma((K * K), -0.125, 1.0), ((fma((l * l), 0.3333333333333333, 2.0) * l) * J), U);
} else {
tmp = fma(((fma(fma(((l * l) * 0.0003968253968253968), (l * l), 0.3333333333333333), (l * l), 2.0) * l) * 1.0), J, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.05) tmp = fma(fma(Float64(K * K), -0.125, 1.0), Float64(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l) * J), U); else tmp = fma(Float64(Float64(fma(fma(Float64(Float64(l * l) * 0.0003968253968253968), Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l) * 1.0), J, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.05], N[(N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] * N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(N[(N[(N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968), $MachinePrecision] * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision] * 1.0), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.05:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right), \left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(\left(\ell \cdot \ell\right) \cdot 0.0003968253968253968, \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right) \cdot 1, J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.050000000000000003Initial program 89.6%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites77.8%
Taylor expanded in K around 0
Applied rewrites67.1%
if -0.050000000000000003 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 86.5%
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 rewrites95.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-*.f6488.6
Applied rewrites88.6%
Taylor expanded in l around inf
Applied rewrites88.6%
Final simplification82.8%
(FPCore (J l K U)
:precision binary64
(let* ((t_0
(+
(* (* (* (fma (* l l) 0.3333333333333333 2.0) l) J) (cos (/ K 2.0)))
U))
(t_1 (* 2.0 (sinh l))))
(if (<= l -3.2e+93)
t_0
(if (<= l -5.5)
(fma (* (fma (* K K) -0.125 1.0) t_1) J U)
(if (<= l 2.2e-9)
(fma (* (* 2.0 J) (cos (* 0.5 K))) l U)
(if (<= l 8.2e+102) (fma (* 1.0 t_1) J U) t_0))))))
double code(double J, double l, double K, double U) {
double t_0 = (((fma((l * l), 0.3333333333333333, 2.0) * l) * J) * cos((K / 2.0))) + U;
double t_1 = 2.0 * sinh(l);
double tmp;
if (l <= -3.2e+93) {
tmp = t_0;
} else if (l <= -5.5) {
tmp = fma((fma((K * K), -0.125, 1.0) * t_1), J, U);
} else if (l <= 2.2e-9) {
tmp = fma(((2.0 * J) * cos((0.5 * K))), l, U);
} else if (l <= 8.2e+102) {
tmp = fma((1.0 * t_1), J, U);
} else {
tmp = t_0;
}
return tmp;
}
function code(J, l, K, U) t_0 = Float64(Float64(Float64(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l) * J) * cos(Float64(K / 2.0))) + U) t_1 = Float64(2.0 * sinh(l)) tmp = 0.0 if (l <= -3.2e+93) tmp = t_0; elseif (l <= -5.5) tmp = fma(Float64(fma(Float64(K * K), -0.125, 1.0) * t_1), J, U); elseif (l <= 2.2e-9) tmp = fma(Float64(Float64(2.0 * J) * cos(Float64(0.5 * K))), l, U); elseif (l <= 8.2e+102) tmp = fma(Float64(1.0 * t_1), J, U); else tmp = t_0; end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -3.2e+93], t$95$0, If[LessEqual[l, -5.5], N[(N[(N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] * t$95$1), $MachinePrecision] * J + U), $MachinePrecision], If[LessEqual[l, 2.2e-9], N[(N[(N[(2.0 * J), $MachinePrecision] * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * l + U), $MachinePrecision], If[LessEqual[l, 8.2e+102], N[(N[(1.0 * t$95$1), $MachinePrecision] * J + U), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\right) \cdot \cos \left(\frac{K}{2}\right) + U\\
t_1 := 2 \cdot \sinh \ell\\
\mathbf{if}\;\ell \leq -3.2 \cdot 10^{+93}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq -5.5:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right) \cdot t\_1, J, U\right)\\
\mathbf{elif}\;\ell \leq 2.2 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(\left(2 \cdot J\right) \cdot \cos \left(0.5 \cdot K\right), \ell, U\right)\\
\mathbf{elif}\;\ell \leq 8.2 \cdot 10^{+102}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot t\_1, J, U\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if l < -3.2000000000000001e93 or 8.1999999999999999e102 < l Initial program 100.0%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
if -3.2000000000000001e93 < l < -5.5Initial 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-*.f6487.5
Applied rewrites87.5%
if -5.5 < l < 2.1999999999999998e-9Initial program 73.3%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in l around 0
Applied rewrites100.0%
if 2.1999999999999998e-9 < l < 8.1999999999999999e102Initial program 98.8%
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 rewrites82.8%
Final simplification96.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (* 0.5 K)))
(t_1 (fma (* (* (fma (* l l) 0.3333333333333333 2.0) J) t_0) l U))
(t_2 (* 2.0 (sinh l))))
(if (<= l -3.2e+93)
t_1
(if (<= l -5.5)
(fma (* (fma (* K K) -0.125 1.0) t_2) J U)
(if (<= l 2.2e-9)
(fma (* (* 2.0 J) t_0) l U)
(if (<= l 1.32e+115) (fma (* 1.0 t_2) J U) t_1))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((0.5 * K));
double t_1 = fma(((fma((l * l), 0.3333333333333333, 2.0) * J) * t_0), l, U);
double t_2 = 2.0 * sinh(l);
double tmp;
if (l <= -3.2e+93) {
tmp = t_1;
} else if (l <= -5.5) {
tmp = fma((fma((K * K), -0.125, 1.0) * t_2), J, U);
} else if (l <= 2.2e-9) {
tmp = fma(((2.0 * J) * t_0), l, U);
} else if (l <= 1.32e+115) {
tmp = fma((1.0 * t_2), J, U);
} else {
tmp = t_1;
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(0.5 * K)) t_1 = fma(Float64(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * J) * t_0), l, U) t_2 = Float64(2.0 * sinh(l)) tmp = 0.0 if (l <= -3.2e+93) tmp = t_1; elseif (l <= -5.5) tmp = fma(Float64(fma(Float64(K * K), -0.125, 1.0) * t_2), J, U); elseif (l <= 2.2e-9) tmp = fma(Float64(Float64(2.0 * J) * t_0), l, U); elseif (l <= 1.32e+115) tmp = fma(Float64(1.0 * t_2), J, U); else tmp = t_1; end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * J), $MachinePrecision] * t$95$0), $MachinePrecision] * l + U), $MachinePrecision]}, Block[{t$95$2 = N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -3.2e+93], t$95$1, If[LessEqual[l, -5.5], N[(N[(N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] * t$95$2), $MachinePrecision] * J + U), $MachinePrecision], If[LessEqual[l, 2.2e-9], N[(N[(N[(2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision] * l + U), $MachinePrecision], If[LessEqual[l, 1.32e+115], N[(N[(1.0 * t$95$2), $MachinePrecision] * J + U), $MachinePrecision], t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(0.5 \cdot K\right)\\
t_1 := \mathsf{fma}\left(\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot J\right) \cdot t\_0, \ell, U\right)\\
t_2 := 2 \cdot \sinh \ell\\
\mathbf{if}\;\ell \leq -3.2 \cdot 10^{+93}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\ell \leq -5.5:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right) \cdot t\_2, J, U\right)\\
\mathbf{elif}\;\ell \leq 2.2 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(\left(2 \cdot J\right) \cdot t\_0, \ell, U\right)\\
\mathbf{elif}\;\ell \leq 1.32 \cdot 10^{+115}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot t\_2, J, U\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if l < -3.2000000000000001e93 or 1.32e115 < l Initial program 100.0%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites96.5%
if -3.2000000000000001e93 < l < -5.5Initial 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-*.f6487.5
Applied rewrites87.5%
if -5.5 < l < 2.1999999999999998e-9Initial program 73.3%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in l around 0
Applied rewrites100.0%
if 2.1999999999999998e-9 < l < 1.32e115Initial program 98.9%
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 rewrites83.3%
Final simplification95.7%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) -0.05)
(fma
(fma (* K K) -0.125 1.0)
(* (* (fma (* l l) 0.3333333333333333 2.0) l) J)
U)
(fma
(*
(*
(fma (fma 0.016666666666666666 (* l l) 0.3333333333333333) (* l l) 2.0)
l)
1.0)
J
U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.05) {
tmp = fma(fma((K * K), -0.125, 1.0), ((fma((l * l), 0.3333333333333333, 2.0) * l) * J), U);
} else {
tmp = fma(((fma(fma(0.016666666666666666, (l * l), 0.3333333333333333), (l * l), 2.0) * l) * 1.0), J, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.05) tmp = fma(fma(Float64(K * K), -0.125, 1.0), Float64(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l) * J), U); else tmp = fma(Float64(Float64(fma(fma(0.016666666666666666, Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l) * 1.0), J, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.05], N[(N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] * N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] + 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] * 1.0), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.05:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right), \left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J, 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 1, J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.050000000000000003Initial program 89.6%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites77.8%
Taylor expanded in K around 0
Applied rewrites67.1%
if -0.050000000000000003 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 86.5%
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 rewrites95.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-*.f6487.1
Applied rewrites87.1%
Final simplification81.6%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* (fma (* l l) 0.3333333333333333 2.0) l)))
(if (<= (cos (/ K 2.0)) -0.05)
(fma (fma (* K K) -0.125 1.0) (* t_0 J) U)
(fma t_0 J U))))
double code(double J, double l, double K, double U) {
double t_0 = fma((l * l), 0.3333333333333333, 2.0) * l;
double tmp;
if (cos((K / 2.0)) <= -0.05) {
tmp = fma(fma((K * K), -0.125, 1.0), (t_0 * J), U);
} else {
tmp = fma(t_0, J, U);
}
return tmp;
}
function code(J, l, K, U) t_0 = Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.05) tmp = fma(fma(Float64(K * K), -0.125, 1.0), Float64(t_0 * J), U); else tmp = fma(t_0, J, U); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision]}, If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.05], N[(N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] * N[(t$95$0 * J), $MachinePrecision] + U), $MachinePrecision], N[(t$95$0 * J + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\\
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.05:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right), t\_0 \cdot J, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_0, J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.050000000000000003Initial program 89.6%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites77.8%
Taylor expanded in K around 0
Applied rewrites67.1%
if -0.050000000000000003 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 86.5%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites86.5%
Taylor expanded in K around 0
Applied rewrites82.9%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.225) (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.225) {
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.225) 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.225], 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.225:\\
\;\;\;\;\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.225000000000000006Initial program 90.6%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f6457.0
Applied rewrites57.0%
Taylor expanded in K around 0
Applied rewrites67.4%
if -0.225000000000000006 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 86.4%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites86.4%
Taylor expanded in K around 0
Applied rewrites80.6%
Final simplification77.7%
(FPCore (J l K U) :precision binary64 (fma (* (fma (* l l) 0.3333333333333333 2.0) l) J U))
double code(double J, double l, double K, double U) {
return fma((fma((l * l), 0.3333333333333333, 2.0) * l), J, U);
}
function code(J, l, K, U) return fma(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l), J, U) end
code[J_, l_, K_, U_] := N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * J + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell, J, U\right)
\end{array}
Initial program 87.3%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites84.1%
Taylor expanded in K around 0
Applied rewrites69.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 87.3%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites84.1%
Taylor expanded in K around 0
Applied rewrites68.8%
Taylor expanded in l around 0
Applied rewrites52.5%
(FPCore (J l K U) :precision binary64 (fma (* J l) 2.0 U))
double code(double J, double l, double K, double U) {
return fma((J * l), 2.0, U);
}
function code(J, l, K, U) return fma(Float64(J * l), 2.0, U) end
code[J_, l_, K_, U_] := N[(N[(J * l), $MachinePrecision] * 2.0 + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(J \cdot \ell, 2, U\right)
\end{array}
Initial program 87.3%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f6462.9
Applied rewrites62.9%
Taylor expanded in K around 0
Applied rewrites52.5%
Final simplification52.5%
(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 87.3%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f6462.9
Applied rewrites62.9%
Taylor expanded in K around 0
Applied rewrites52.5%
Taylor expanded in U around 0
Applied rewrites18.5%
Final simplification18.5%
herbie shell --seed 2024268
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))