
(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 15 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 (+ (* (* (cos (* K -0.5)) (* (sinh l) 2.0)) J) U))
double code(double J, double l, double K, double U) {
return ((cos((K * -0.5)) * (sinh(l) * 2.0)) * J) + 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 = ((cos((k * (-0.5d0))) * (sinh(l) * 2.0d0)) * j) + u
end function
public static double code(double J, double l, double K, double U) {
return ((Math.cos((K * -0.5)) * (Math.sinh(l) * 2.0)) * J) + U;
}
def code(J, l, K, U): return ((math.cos((K * -0.5)) * (math.sinh(l) * 2.0)) * J) + U
function code(J, l, K, U) return Float64(Float64(Float64(cos(Float64(K * -0.5)) * Float64(sinh(l) * 2.0)) * J) + U) end
function tmp = code(J, l, K, U) tmp = ((cos((K * -0.5)) * (sinh(l) * 2.0)) * J) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(N[Cos[N[(K * -0.5), $MachinePrecision]], $MachinePrecision] * N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(\cos \left(K \cdot -0.5\right) \cdot \left(\sinh \ell \cdot 2\right)\right) \cdot J + U
\end{array}
Initial program 89.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0)))))
(if (or (<= t_0 -1e+162) (not (<= t_0 2e+148)))
(+ (* (* (fma (* K K) -0.125 1.0) (* (sinh l) 2.0)) J) U)
(+ (* (* (* 2.0 l) (cos (* -0.5 K))) J) U))))
double code(double J, double l, double K, double U) {
double t_0 = (J * (exp(l) - exp(-l))) * cos((K / 2.0));
double tmp;
if ((t_0 <= -1e+162) || !(t_0 <= 2e+148)) {
tmp = ((fma((K * K), -0.125, 1.0) * (sinh(l) * 2.0)) * J) + U;
} else {
tmp = (((2.0 * l) * cos((-0.5 * K))) * J) + U;
}
return tmp;
}
function code(J, l, K, U) t_0 = Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) tmp = 0.0 if ((t_0 <= -1e+162) || !(t_0 <= 2e+148)) tmp = Float64(Float64(Float64(fma(Float64(K * K), -0.125, 1.0) * Float64(sinh(l) * 2.0)) * J) + U); else tmp = Float64(Float64(Float64(Float64(2.0 * l) * cos(Float64(-0.5 * K))) * J) + U); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -1e+162], N[Not[LessEqual[t$95$0, 2e+148]], $MachinePrecision]], N[(N[(N[(N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] * N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(N[(2.0 * l), $MachinePrecision] * N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+162} \lor \neg \left(t\_0 \leq 2 \cdot 10^{+148}\right):\\
\;\;\;\;\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right) \cdot \left(\sinh \ell \cdot 2\right)\right) \cdot J + U\\
\mathbf{else}:\\
\;\;\;\;\left(\left(2 \cdot \ell\right) \cdot \cos \left(-0.5 \cdot K\right)\right) \cdot J + U\\
\end{array}
\end{array}
if (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) < -9.9999999999999994e161 or 2.0000000000000001e148 < (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) Initial program 99.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6478.8
Applied rewrites78.8%
if -9.9999999999999994e161 < (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) < 2.0000000000000001e148Initial program 75.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in l around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6499.3
Applied rewrites99.3%
Final simplification87.6%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0)))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 0.0)))
(+ (* (* (* (* l l) J) 0.3333333333333333) l) U)
(+ (* (* 2.0 l) J) U))))
double code(double J, double l, double K, double U) {
double t_0 = (J * (exp(l) - exp(-l))) * cos((K / 2.0));
double tmp;
if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 0.0)) {
tmp = ((((l * l) * J) * 0.3333333333333333) * l) + U;
} else {
tmp = ((2.0 * l) * J) + U;
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double t_0 = (J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0));
double tmp;
if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 0.0)) {
tmp = ((((l * l) * J) * 0.3333333333333333) * l) + U;
} else {
tmp = ((2.0 * l) * J) + U;
}
return tmp;
}
def code(J, l, K, U): t_0 = (J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0)) tmp = 0 if (t_0 <= -math.inf) or not (t_0 <= 0.0): tmp = ((((l * l) * J) * 0.3333333333333333) * l) + U else: tmp = ((2.0 * l) * J) + U return tmp
function code(J, l, K, U) t_0 = Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) tmp = 0.0 if ((t_0 <= Float64(-Inf)) || !(t_0 <= 0.0)) tmp = Float64(Float64(Float64(Float64(Float64(l * l) * J) * 0.3333333333333333) * l) + U); else tmp = Float64(Float64(Float64(2.0 * l) * J) + U); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = (J * (exp(l) - exp(-l))) * cos((K / 2.0)); tmp = 0.0; if ((t_0 <= -Inf) || ~((t_0 <= 0.0))) tmp = ((((l * l) * J) * 0.3333333333333333) * l) + U; else tmp = ((2.0 * l) * J) + U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], N[(N[(N[(N[(N[(l * l), $MachinePrecision] * J), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] * l), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(2.0 * l), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq -\infty \lor \neg \left(t\_0 \leq 0\right):\\
\;\;\;\;\left(\left(\left(\ell \cdot \ell\right) \cdot J\right) \cdot 0.3333333333333333\right) \cdot \ell + U\\
\mathbf{else}:\\
\;\;\;\;\left(2 \cdot \ell\right) \cdot J + U\\
\end{array}
\end{array}
if (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) < -inf.0 or 0.0 < (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) Initial program 99.7%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6468.7
Applied rewrites68.7%
Applied rewrites68.7%
Taylor expanded in l around 0
Applied rewrites49.5%
Taylor expanded in l around inf
Applied rewrites49.5%
if -inf.0 < (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) < 0.0Initial program 75.5%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6475.5
Applied rewrites75.5%
Applied rewrites83.2%
Taylor expanded in l around 0
Applied rewrites82.7%
Final simplification63.6%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (or (<= t_0 -0.2) (not (<= t_0 0.996)))
(+
(*
(* (fma (* K K) -0.125 1.0) J)
(*
(fma
(fma
(fma (* l l) 0.0003968253968253968 0.016666666666666666)
(* l l)
0.3333333333333333)
(* l l)
2.0)
l))
U)
(+ (* (* J (fma (* 0.3333333333333333 l) l 2.0)) l) U))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double tmp;
if ((t_0 <= -0.2) || !(t_0 <= 0.996)) {
tmp = ((fma((K * K), -0.125, 1.0) * J) * (fma(fma(fma((l * l), 0.0003968253968253968, 0.016666666666666666), (l * l), 0.3333333333333333), (l * l), 2.0) * l)) + U;
} else {
tmp = ((J * fma((0.3333333333333333 * l), l, 2.0)) * l) + U;
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if ((t_0 <= -0.2) || !(t_0 <= 0.996)) tmp = Float64(Float64(Float64(fma(Float64(K * K), -0.125, 1.0) * J) * Float64(fma(fma(fma(Float64(l * l), 0.0003968253968253968, 0.016666666666666666), Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l)) + U); else tmp = Float64(Float64(Float64(J * fma(Float64(0.3333333333333333 * l), l, 2.0)) * l) + U); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[t$95$0, -0.2], N[Not[LessEqual[t$95$0, 0.996]], $MachinePrecision]], N[(N[(N[(N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] * J), $MachinePrecision] * N[(N[(N[(N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968 + 0.016666666666666666), $MachinePrecision] * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(J * N[(N[(0.3333333333333333 * l), $MachinePrecision] * l + 2.0), $MachinePrecision]), $MachinePrecision] * l), $MachinePrecision] + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq -0.2 \lor \neg \left(t\_0 \leq 0.996\right):\\
\;\;\;\;\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right) \cdot J\right) \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right) + U\\
\mathbf{else}:\\
\;\;\;\;\left(J \cdot \mathsf{fma}\left(0.3333333333333333 \cdot \ell, \ell, 2\right)\right) \cdot \ell + U\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.20000000000000001 or 0.996 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 92.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-*.f6495.9
Applied rewrites95.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
Applied rewrites96.0%
Taylor expanded in K around 0
*-commutativeN/A
associate-*r*N/A
distribute-rgt1-inN/A
+-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6482.9
Applied rewrites82.9%
if -0.20000000000000001 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.996Initial program 80.8%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6480.8
Applied rewrites80.8%
Applied rewrites84.0%
Taylor expanded in l around 0
Applied rewrites70.8%
Applied rewrites70.8%
Final simplification79.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 0.95)
(+
(*
(*
J
(*
(fma
(fma 0.016666666666666666 (* l l) 0.3333333333333333)
(* l l)
2.0)
l))
t_0)
U)
(+ (* (* (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.95) {
tmp = ((J * (fma(fma(0.016666666666666666, (l * l), 0.3333333333333333), (l * l), 2.0) * l)) * t_0) + U;
} else {
tmp = ((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.95) 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 = Float64(Float64(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.95], 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[(N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq 0.95:\\
\;\;\;\;\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}:\\
\;\;\;\;\left(\sinh \ell \cdot 2\right) \cdot J + U\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.94999999999999996Initial program 85.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-*.f6491.9
Applied rewrites91.9%
if 0.94999999999999996 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 93.9%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6493.9
Applied rewrites93.9%
Applied rewrites99.4%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) 0.95)
(+
(*
(*
(* (cos (* 0.5 K)) J)
(fma (fma 0.016666666666666666 (* l l) 0.3333333333333333) (* l l) 2.0))
l)
U)
(+ (* (* (sinh l) 2.0) J) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.95) {
tmp = (((cos((0.5 * K)) * J) * fma(fma(0.016666666666666666, (l * l), 0.3333333333333333), (l * l), 2.0)) * l) + U;
} else {
tmp = ((sinh(l) * 2.0) * J) + U;
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.95) tmp = Float64(Float64(Float64(Float64(cos(Float64(0.5 * K)) * J) * fma(fma(0.016666666666666666, Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0)) * l) + U); else tmp = Float64(Float64(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.95], N[(N[(N[(N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * J), $MachinePrecision] * N[(N[(0.016666666666666666 * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] * l), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.95:\\
\;\;\;\;\left(\left(\cos \left(0.5 \cdot K\right) \cdot J\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.016666666666666666, \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right)\right) \cdot \ell + U\\
\mathbf{else}:\\
\;\;\;\;\left(\sinh \ell \cdot 2\right) \cdot J + U\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.94999999999999996Initial program 85.3%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites91.3%
if 0.94999999999999996 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 93.9%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6493.9
Applied rewrites93.9%
Applied rewrites99.4%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 -0.953)
(+ (* (- 1.0 (fma (fma 0.5 l -1.0) l 1.0)) J) U)
(if (<= t_0 -0.2)
(+ (* (* (* (* K K) l) J) -0.25) U)
(+ (* (* J (fma (* 0.3333333333333333 l) l 2.0)) l) U)))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double tmp;
if (t_0 <= -0.953) {
tmp = ((1.0 - fma(fma(0.5, l, -1.0), l, 1.0)) * J) + U;
} else if (t_0 <= -0.2) {
tmp = ((((K * K) * l) * J) * -0.25) + U;
} else {
tmp = ((J * fma((0.3333333333333333 * l), l, 2.0)) * l) + U;
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= -0.953) tmp = Float64(Float64(Float64(1.0 - fma(fma(0.5, l, -1.0), l, 1.0)) * J) + U); elseif (t_0 <= -0.2) tmp = Float64(Float64(Float64(Float64(Float64(K * K) * l) * J) * -0.25) + U); else tmp = Float64(Float64(Float64(J * fma(Float64(0.3333333333333333 * l), l, 2.0)) * l) + 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.953], N[(N[(N[(1.0 - N[(N[(0.5 * l + -1.0), $MachinePrecision] * l + 1.0), $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[t$95$0, -0.2], N[(N[(N[(N[(N[(K * K), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] * -0.25), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(J * N[(N[(0.3333333333333333 * l), $MachinePrecision] * l + 2.0), $MachinePrecision]), $MachinePrecision] * l), $MachinePrecision] + U), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq -0.953:\\
\;\;\;\;\left(1 - \mathsf{fma}\left(\mathsf{fma}\left(0.5, \ell, -1\right), \ell, 1\right)\right) \cdot J + U\\
\mathbf{elif}\;t\_0 \leq -0.2:\\
\;\;\;\;\left(\left(\left(K \cdot K\right) \cdot \ell\right) \cdot J\right) \cdot -0.25 + U\\
\mathbf{else}:\\
\;\;\;\;\left(J \cdot \mathsf{fma}\left(0.3333333333333333 \cdot \ell, \ell, 2\right)\right) \cdot \ell + U\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.952999999999999958Initial program 81.0%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6441.0
Applied rewrites41.0%
Taylor expanded in l around 0
Applied rewrites41.4%
Taylor expanded in l around 0
Applied rewrites68.2%
if -0.952999999999999958 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.20000000000000001Initial program 91.7%
Taylor expanded in l around 0
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6455.2
Applied rewrites55.2%
Taylor expanded in K around 0
Applied rewrites55.2%
Taylor expanded in K around inf
Applied rewrites61.2%
if -0.20000000000000001 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 89.3%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6489.3
Applied rewrites89.3%
Applied rewrites94.1%
Taylor expanded in l around 0
Applied rewrites77.9%
Applied rewrites77.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 -0.953)
(+ (* (- 1.0 (fma (fma 0.5 l -1.0) l 1.0)) J) U)
(if (<= t_0 -0.2)
(+ (* (* (* (* K K) l) J) -0.25) U)
(+ (* (* (* (* l l) J) 0.3333333333333333) l) U)))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double tmp;
if (t_0 <= -0.953) {
tmp = ((1.0 - fma(fma(0.5, l, -1.0), l, 1.0)) * J) + U;
} else if (t_0 <= -0.2) {
tmp = ((((K * K) * l) * J) * -0.25) + U;
} else {
tmp = ((((l * l) * J) * 0.3333333333333333) * l) + U;
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= -0.953) tmp = Float64(Float64(Float64(1.0 - fma(fma(0.5, l, -1.0), l, 1.0)) * J) + U); elseif (t_0 <= -0.2) tmp = Float64(Float64(Float64(Float64(Float64(K * K) * l) * J) * -0.25) + U); else tmp = Float64(Float64(Float64(Float64(Float64(l * l) * J) * 0.3333333333333333) * l) + 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.953], N[(N[(N[(1.0 - N[(N[(0.5 * l + -1.0), $MachinePrecision] * l + 1.0), $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[t$95$0, -0.2], N[(N[(N[(N[(N[(K * K), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] * -0.25), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(N[(N[(l * l), $MachinePrecision] * J), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] * l), $MachinePrecision] + U), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq -0.953:\\
\;\;\;\;\left(1 - \mathsf{fma}\left(\mathsf{fma}\left(0.5, \ell, -1\right), \ell, 1\right)\right) \cdot J + U\\
\mathbf{elif}\;t\_0 \leq -0.2:\\
\;\;\;\;\left(\left(\left(K \cdot K\right) \cdot \ell\right) \cdot J\right) \cdot -0.25 + U\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(\ell \cdot \ell\right) \cdot J\right) \cdot 0.3333333333333333\right) \cdot \ell + U\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.952999999999999958Initial program 81.0%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6441.0
Applied rewrites41.0%
Taylor expanded in l around 0
Applied rewrites41.4%
Taylor expanded in l around 0
Applied rewrites68.2%
if -0.952999999999999958 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.20000000000000001Initial program 91.7%
Taylor expanded in l around 0
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6455.2
Applied rewrites55.2%
Taylor expanded in K around 0
Applied rewrites55.2%
Taylor expanded in K around inf
Applied rewrites61.2%
if -0.20000000000000001 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 89.3%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6489.3
Applied rewrites89.3%
Applied rewrites94.1%
Taylor expanded in l around 0
Applied rewrites77.9%
Taylor expanded in l around inf
Applied rewrites72.7%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 0.95)
(+ (* (* J (* (fma (* l l) 0.3333333333333333 2.0) l)) t_0) U)
(+ (* (* (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.95) {
tmp = ((J * (fma((l * l), 0.3333333333333333, 2.0) * l)) * t_0) + U;
} else {
tmp = ((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.95) tmp = Float64(Float64(Float64(J * Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l)) * t_0) + U); else tmp = Float64(Float64(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.95], N[(N[(N[(J * N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq 0.95:\\
\;\;\;\;\left(J \cdot \left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right)\right) \cdot t\_0 + U\\
\mathbf{else}:\\
\;\;\;\;\left(\sinh \ell \cdot 2\right) \cdot J + U\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.94999999999999996Initial program 85.3%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6488.2
Applied rewrites88.2%
if 0.94999999999999996 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 93.9%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6493.9
Applied rewrites93.9%
Applied rewrites99.4%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.95) (+ (* (* (* (cos (* 0.5 K)) J) (fma (* l l) 0.3333333333333333 2.0)) l) U) (+ (* (* (sinh l) 2.0) J) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.95) {
tmp = (((cos((0.5 * K)) * J) * fma((l * l), 0.3333333333333333, 2.0)) * l) + U;
} else {
tmp = ((sinh(l) * 2.0) * J) + U;
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.95) tmp = Float64(Float64(Float64(Float64(cos(Float64(0.5 * K)) * J) * fma(Float64(l * l), 0.3333333333333333, 2.0)) * l) + U); else tmp = Float64(Float64(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.95], N[(N[(N[(N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * J), $MachinePrecision] * N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision]), $MachinePrecision] * l), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.95:\\
\;\;\;\;\left(\left(\cos \left(0.5 \cdot K\right) \cdot J\right) \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\right) \cdot \ell + U\\
\mathbf{else}:\\
\;\;\;\;\left(\sinh \ell \cdot 2\right) \cdot J + U\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.94999999999999996Initial program 85.3%
Taylor expanded in l around 0
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6462.0
Applied rewrites62.0%
Taylor expanded in l around 0
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites85.4%
if 0.94999999999999996 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 93.9%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6493.9
Applied rewrites93.9%
Applied rewrites99.4%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.95) (+ (* (* (* J l) (cos (* 0.5 K))) (fma (* l l) 0.3333333333333333 2.0)) U) (+ (* (* (sinh l) 2.0) J) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.95) {
tmp = (((J * l) * cos((0.5 * K))) * fma((l * l), 0.3333333333333333, 2.0)) + U;
} else {
tmp = ((sinh(l) * 2.0) * J) + U;
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.95) tmp = Float64(Float64(Float64(Float64(J * l) * cos(Float64(0.5 * K))) * fma(Float64(l * l), 0.3333333333333333, 2.0)) + U); else tmp = Float64(Float64(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.95], N[(N[(N[(N[(J * l), $MachinePrecision] * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.95:\\
\;\;\;\;\left(\left(J \cdot \ell\right) \cdot \cos \left(0.5 \cdot K\right)\right) \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) + U\\
\mathbf{else}:\\
\;\;\;\;\left(\sinh \ell \cdot 2\right) \cdot J + U\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.94999999999999996Initial program 85.3%
Taylor expanded in l around 0
distribute-rgt-inN/A
+-commutativeN/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
Applied rewrites85.3%
if 0.94999999999999996 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 93.9%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6493.9
Applied rewrites93.9%
Applied rewrites99.4%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) -0.2)
(+
(*
(* (fma (* K K) -0.125 1.0) J)
(*
(fma
(fma
(fma (* l l) 0.0003968253968253968 0.016666666666666666)
(* l l)
0.3333333333333333)
(* l l)
2.0)
l))
U)
(+ (* (* (sinh l) 2.0) J) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.2) {
tmp = ((fma((K * K), -0.125, 1.0) * J) * (fma(fma(fma((l * l), 0.0003968253968253968, 0.016666666666666666), (l * l), 0.3333333333333333), (l * l), 2.0) * l)) + U;
} else {
tmp = ((sinh(l) * 2.0) * J) + U;
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.2) tmp = Float64(Float64(Float64(fma(Float64(K * K), -0.125, 1.0) * J) * Float64(fma(fma(fma(Float64(l * l), 0.0003968253968253968, 0.016666666666666666), Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l)) + U); else tmp = Float64(Float64(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.2], N[(N[(N[(N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] * J), $MachinePrecision] * N[(N[(N[(N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968 + 0.016666666666666666), $MachinePrecision] * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.2:\\
\;\;\;\;\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right) \cdot J\right) \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right) + U\\
\mathbf{else}:\\
\;\;\;\;\left(\sinh \ell \cdot 2\right) \cdot J + U\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.20000000000000001Initial program 89.6%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6495.0
Applied rewrites95.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
Applied rewrites95.0%
Taylor expanded in K around 0
*-commutativeN/A
associate-*r*N/A
distribute-rgt1-inN/A
+-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6463.5
Applied rewrites63.5%
if -0.20000000000000001 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 89.3%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6489.3
Applied rewrites89.3%
Applied rewrites94.1%
(FPCore (J l K U)
:precision binary64
(+
(*
(* (cos (* -0.5 K)) J)
(*
(fma
(fma
(fma (* l l) 0.0003968253968253968 0.016666666666666666)
(* l l)
0.3333333333333333)
(* l l)
2.0)
l))
U))
double code(double J, double l, double K, double U) {
return ((cos((-0.5 * K)) * J) * (fma(fma(fma((l * l), 0.0003968253968253968, 0.016666666666666666), (l * l), 0.3333333333333333), (l * l), 2.0) * l)) + U;
}
function code(J, l, K, U) return Float64(Float64(Float64(cos(Float64(-0.5 * K)) * J) * Float64(fma(fma(fma(Float64(l * l), 0.0003968253968253968, 0.016666666666666666), Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l)) + U) end
code[J_, l_, K_, U_] := N[(N[(N[(N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision] * J), $MachinePrecision] * N[(N[(N[(N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968 + 0.016666666666666666), $MachinePrecision] * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(\cos \left(-0.5 \cdot K\right) \cdot J\right) \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right) + U
\end{array}
Initial program 89.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-*.f6496.2
Applied rewrites96.2%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
Applied rewrites96.2%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.2) (+ (* (* (* (* K K) l) J) -0.25) U) (+ (* (* (* (* l l) J) 0.3333333333333333) l) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.2) {
tmp = ((((K * K) * l) * J) * -0.25) + U;
} else {
tmp = ((((l * l) * J) * 0.3333333333333333) * l) + U;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (cos((k / 2.0d0)) <= (-0.2d0)) then
tmp = ((((k * k) * l) * j) * (-0.25d0)) + u
else
tmp = ((((l * l) * j) * 0.3333333333333333d0) * l) + u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (Math.cos((K / 2.0)) <= -0.2) {
tmp = ((((K * K) * l) * J) * -0.25) + U;
} else {
tmp = ((((l * l) * J) * 0.3333333333333333) * l) + U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.2: tmp = ((((K * K) * l) * J) * -0.25) + U else: tmp = ((((l * l) * J) * 0.3333333333333333) * l) + U return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.2) tmp = Float64(Float64(Float64(Float64(Float64(K * K) * l) * J) * -0.25) + U); else tmp = Float64(Float64(Float64(Float64(Float64(l * l) * J) * 0.3333333333333333) * l) + U); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= -0.2) tmp = ((((K * K) * l) * J) * -0.25) + U; else tmp = ((((l * l) * J) * 0.3333333333333333) * l) + U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.2], N[(N[(N[(N[(N[(K * K), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] * -0.25), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(N[(N[(l * l), $MachinePrecision] * J), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] * l), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.2:\\
\;\;\;\;\left(\left(\left(K \cdot K\right) \cdot \ell\right) \cdot J\right) \cdot -0.25 + U\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(\ell \cdot \ell\right) \cdot J\right) \cdot 0.3333333333333333\right) \cdot \ell + U\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.20000000000000001Initial program 89.6%
Taylor expanded in l around 0
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6457.6
Applied rewrites57.6%
Taylor expanded in K around 0
Applied rewrites51.6%
Taylor expanded in K around inf
Applied rewrites56.5%
if -0.20000000000000001 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 89.3%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6489.3
Applied rewrites89.3%
Applied rewrites94.1%
Taylor expanded in l around 0
Applied rewrites77.9%
Taylor expanded in l around inf
Applied rewrites72.7%
(FPCore (J l K U) :precision binary64 (+ (* (* 2.0 l) J) U))
double code(double J, double l, double K, double U) {
return ((2.0 * l) * J) + 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 = ((2.0d0 * l) * j) + u
end function
public static double code(double J, double l, double K, double U) {
return ((2.0 * l) * J) + U;
}
def code(J, l, K, U): return ((2.0 * l) * J) + U
function code(J, l, K, U) return Float64(Float64(Float64(2.0 * l) * J) + U) end
function tmp = code(J, l, K, U) tmp = ((2.0 * l) * J) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(2.0 * l), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(2 \cdot \ell\right) \cdot J + U
\end{array}
Initial program 89.4%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6471.6
Applied rewrites71.6%
Applied rewrites74.9%
Taylor expanded in l around 0
Applied rewrites47.6%
herbie shell --seed 2024298
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))