
(FPCore (J l K U) :precision binary64 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U): return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) end
function tmp = code(J, l, K, U) tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 19 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (J l K U) :precision binary64 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U): return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) end
function tmp = code(J, l, K, U) tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))) (t_1 (- (exp l) (exp (- l)))))
(if (<= t_1 (- INFINITY))
(+ (* (* t_1 J) t_0) U)
(+
U
(*
t_0
(*
J
(*
l
(fma
l
(*
l
(fma
(* l l)
(fma (* l l) 0.0003968253968253968 0.016666666666666666)
0.3333333333333333))
2.0))))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = exp(l) - exp(-l);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * (J * (l * fma(l, (l * fma((l * l), fma((l * l), 0.0003968253968253968, 0.016666666666666666), 0.3333333333333333)), 2.0))));
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(exp(l) - exp(Float64(-l))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(Float64(Float64(t_1 * J) * t_0) + U); else tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * fma(l, Float64(l * fma(Float64(l * l), fma(Float64(l * l), 0.0003968253968253968, 0.016666666666666666), 0.3333333333333333)), 2.0))))); 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[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(N[(t$95$1 * J), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(t$95$0 * N[(J * N[(l * N[(l * N[(l * N[(N[(l * l), $MachinePrecision] * N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968 + 0.016666666666666666), $MachinePrecision] + 0.3333333333333333), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\left(t\_1 \cdot J\right) \cdot t\_0 + U\\
\mathbf{else}:\\
\;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 2\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0Initial program 100.0%
if -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 78.1%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6497.8
Simplified97.8%
Final simplification98.5%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 -0.405)
(* J (fma (cos (* K 0.5)) (* l 2.0) (/ U J)))
(if (<= t_0 -0.01)
(fma
l
(*
(fma
(* l l)
(fma l (* l 0.016666666666666666) 0.3333333333333333)
2.0)
(fma (* K K) (* J -0.125) J))
U)
(fma
(* l (fma l (* l (* 0.0003968253968253968 (* (* l l) (* l 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.405) {
tmp = J * fma(cos((K * 0.5)), (l * 2.0), (U / J));
} else if (t_0 <= -0.01) {
tmp = fma(l, (fma((l * l), fma(l, (l * 0.016666666666666666), 0.3333333333333333), 2.0) * fma((K * K), (J * -0.125), J)), U);
} else {
tmp = fma((l * fma(l, (l * (0.0003968253968253968 * ((l * l) * (l * 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.405) tmp = Float64(J * fma(cos(Float64(K * 0.5)), Float64(l * 2.0), Float64(U / J))); elseif (t_0 <= -0.01) tmp = fma(l, Float64(fma(Float64(l * l), fma(l, Float64(l * 0.016666666666666666), 0.3333333333333333), 2.0) * fma(Float64(K * K), Float64(J * -0.125), J)), U); else tmp = fma(Float64(l * fma(l, Float64(l * Float64(0.0003968253968253968 * Float64(Float64(l * l) * Float64(l * 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.405], N[(J * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(l * 2.0), $MachinePrecision] + N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -0.01], N[(l * N[(N[(N[(l * l), $MachinePrecision] * N[(l * N[(l * 0.016666666666666666), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * N[(J * -0.125), $MachinePrecision] + J), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(l * N[(l * N[(l * N[(0.0003968253968253968 * N[(N[(l * l), $MachinePrecision] * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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.405:\\
\;\;\;\;J \cdot \mathsf{fma}\left(\cos \left(K \cdot 0.5\right), \ell \cdot 2, \frac{U}{J}\right)\\
\mathbf{elif}\;t\_0 \leq -0.01:\\
\;\;\;\;\mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.016666666666666666, 0.3333333333333333\right), 2\right) \cdot \mathsf{fma}\left(K \cdot K, J \cdot -0.125, J\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \left(0.0003968253968253968 \cdot \left(\left(\ell \cdot \ell\right) \cdot \left(\ell \cdot \ell\right)\right)\right), 2\right), J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.40500000000000003Initial program 82.5%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6465.7
Simplified65.7%
Taylor expanded in J around inf
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6467.6
Simplified67.6%
if -0.40500000000000003 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002Initial program 88.3%
Taylor expanded in l around 0
+-commutativeN/A
lower-fma.f64N/A
Simplified95.6%
Taylor expanded in K around 0
associate-*r*N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6473.5
Simplified73.5%
if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.4%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6485.4
Simplified85.4%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
Simplified91.9%
Taylor expanded in l around inf
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6491.9
Simplified91.9%
Taylor expanded in l around inf
metadata-evalN/A
pow-plusN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
metadata-evalN/A
pow-sqrN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6491.9
Simplified91.9%
Final simplification85.7%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) -0.01)
(+
U
(*
(fma
l
(*
l
(fma
l
(* l (fma (* l l) 0.0003968253968253968 0.016666666666666666))
0.3333333333333333))
2.0)
(* J (fma -0.125 (* l (* K K)) l))))
(fma
(* l (fma l (* l (* 0.0003968253968253968 (* (* l l) (* l l)))) 2.0))
J
U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.01) {
tmp = U + (fma(l, (l * fma(l, (l * fma((l * l), 0.0003968253968253968, 0.016666666666666666)), 0.3333333333333333)), 2.0) * (J * fma(-0.125, (l * (K * K)), l)));
} else {
tmp = fma((l * fma(l, (l * (0.0003968253968253968 * ((l * l) * (l * l)))), 2.0)), J, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.01) tmp = Float64(U + Float64(fma(l, Float64(l * fma(l, Float64(l * fma(Float64(l * l), 0.0003968253968253968, 0.016666666666666666)), 0.3333333333333333)), 2.0) * Float64(J * fma(-0.125, Float64(l * Float64(K * K)), l)))); else tmp = fma(Float64(l * fma(l, Float64(l * Float64(0.0003968253968253968 * Float64(Float64(l * l) * Float64(l * 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.01], N[(U + N[(N[(l * N[(l * N[(l * N[(l * N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968 + 0.016666666666666666), $MachinePrecision]), $MachinePrecision] + 0.3333333333333333), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision] * N[(J * N[(-0.125 * N[(l * N[(K * K), $MachinePrecision]), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(l * N[(l * N[(l * N[(0.0003968253968253968 * N[(N[(l * l), $MachinePrecision] * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\
\;\;\;\;U + \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 2\right) \cdot \left(J \cdot \mathsf{fma}\left(-0.125, \ell \cdot \left(K \cdot K\right), \ell\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \left(0.0003968253968253968 \cdot \left(\left(\ell \cdot \ell\right) \cdot \left(\ell \cdot \ell\right)\right)\right), 2\right), J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002Initial program 84.3%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6494.5
Simplified94.5%
Taylor expanded in K around 0
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
Simplified61.6%
if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.4%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6485.4
Simplified85.4%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
Simplified91.9%
Taylor expanded in l around inf
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6491.9
Simplified91.9%
Taylor expanded in l around inf
metadata-evalN/A
pow-plusN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
metadata-evalN/A
pow-sqrN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6491.9
Simplified91.9%
Final simplification83.6%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) -0.01)
(fma
l
(*
(fma (* l l) (fma l (* l 0.016666666666666666) 0.3333333333333333) 2.0)
(fma (* K K) (* J -0.125) J))
U)
(fma
(* l (fma l (* l (* 0.0003968253968253968 (* (* l l) (* l l)))) 2.0))
J
U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.01) {
tmp = fma(l, (fma((l * l), fma(l, (l * 0.016666666666666666), 0.3333333333333333), 2.0) * fma((K * K), (J * -0.125), J)), U);
} else {
tmp = fma((l * fma(l, (l * (0.0003968253968253968 * ((l * l) * (l * l)))), 2.0)), J, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.01) tmp = fma(l, Float64(fma(Float64(l * l), fma(l, Float64(l * 0.016666666666666666), 0.3333333333333333), 2.0) * fma(Float64(K * K), Float64(J * -0.125), J)), U); else tmp = fma(Float64(l * fma(l, Float64(l * Float64(0.0003968253968253968 * Float64(Float64(l * l) * Float64(l * 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.01], N[(l * N[(N[(N[(l * l), $MachinePrecision] * N[(l * N[(l * 0.016666666666666666), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * N[(J * -0.125), $MachinePrecision] + J), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(l * N[(l * N[(l * N[(0.0003968253968253968 * N[(N[(l * l), $MachinePrecision] * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\
\;\;\;\;\mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.016666666666666666, 0.3333333333333333\right), 2\right) \cdot \mathsf{fma}\left(K \cdot K, J \cdot -0.125, J\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \left(0.0003968253968253968 \cdot \left(\left(\ell \cdot \ell\right) \cdot \left(\ell \cdot \ell\right)\right)\right), 2\right), J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002Initial program 84.3%
Taylor expanded in l around 0
+-commutativeN/A
lower-fma.f64N/A
Simplified93.1%
Taylor expanded in K around 0
associate-*r*N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6460.1
Simplified60.1%
if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.4%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6485.4
Simplified85.4%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
Simplified91.9%
Taylor expanded in l around inf
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6491.9
Simplified91.9%
Taylor expanded in l around inf
metadata-evalN/A
pow-plusN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
metadata-evalN/A
pow-sqrN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6491.9
Simplified91.9%
Final simplification83.2%
(FPCore (J l K U)
:precision binary64
(+
U
(*
(cos (/ K 2.0))
(*
J
(*
l
(fma
l
(*
l
(fma
(* l l)
(fma (* l l) 0.0003968253968253968 0.016666666666666666)
0.3333333333333333))
2.0))))))
double code(double J, double l, double K, double U) {
return U + (cos((K / 2.0)) * (J * (l * fma(l, (l * fma((l * l), fma((l * l), 0.0003968253968253968, 0.016666666666666666), 0.3333333333333333)), 2.0))));
}
function code(J, l, K, U) return Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * fma(l, Float64(l * fma(Float64(l * l), fma(Float64(l * l), 0.0003968253968253968, 0.016666666666666666), 0.3333333333333333)), 2.0))))) end
code[J_, l_, K_, U_] := N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * N[(l * N[(l * N[(N[(l * l), $MachinePrecision] * N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968 + 0.016666666666666666), $MachinePrecision] + 0.3333333333333333), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 2\right)\right)\right)
\end{array}
Initial program 85.1%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6495.9
Simplified95.9%
Final simplification95.9%
(FPCore (J l K U)
:precision binary64
(if (<= (/ K 2.0) 2e+14)
(+
U
(*
(fma
l
(*
l
(fma
l
(* l (fma (* l l) 0.0003968253968253968 0.016666666666666666))
0.3333333333333333))
2.0)
(* J (fma -0.125 (* l (* K K)) l))))
(fma
l
(*
(fma (* l l) (fma l (* l 0.016666666666666666) 0.3333333333333333) 2.0)
(* J (cos (* K 0.5))))
U)))
double code(double J, double l, double K, double U) {
double tmp;
if ((K / 2.0) <= 2e+14) {
tmp = U + (fma(l, (l * fma(l, (l * fma((l * l), 0.0003968253968253968, 0.016666666666666666)), 0.3333333333333333)), 2.0) * (J * fma(-0.125, (l * (K * K)), l)));
} else {
tmp = fma(l, (fma((l * l), fma(l, (l * 0.016666666666666666), 0.3333333333333333), 2.0) * (J * cos((K * 0.5)))), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (Float64(K / 2.0) <= 2e+14) tmp = Float64(U + Float64(fma(l, Float64(l * fma(l, Float64(l * fma(Float64(l * l), 0.0003968253968253968, 0.016666666666666666)), 0.3333333333333333)), 2.0) * Float64(J * fma(-0.125, Float64(l * Float64(K * K)), l)))); else tmp = fma(l, Float64(fma(Float64(l * l), fma(l, Float64(l * 0.016666666666666666), 0.3333333333333333), 2.0) * Float64(J * cos(Float64(K * 0.5)))), U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[(K / 2.0), $MachinePrecision], 2e+14], N[(U + N[(N[(l * N[(l * N[(l * N[(l * N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968 + 0.016666666666666666), $MachinePrecision]), $MachinePrecision] + 0.3333333333333333), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision] * N[(J * N[(-0.125 * N[(l * N[(K * K), $MachinePrecision]), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(l * N[(N[(N[(l * l), $MachinePrecision] * N[(l * N[(l * 0.016666666666666666), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision] * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{K}{2} \leq 2 \cdot 10^{+14}:\\
\;\;\;\;U + \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 2\right) \cdot \left(J \cdot \mathsf{fma}\left(-0.125, \ell \cdot \left(K \cdot K\right), \ell\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.016666666666666666, 0.3333333333333333\right), 2\right) \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right), U\right)\\
\end{array}
\end{array}
if (/.f64 K #s(literal 2 binary64)) < 2e14Initial program 86.7%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6495.7
Simplified95.7%
Taylor expanded in K around 0
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
Simplified78.0%
if 2e14 < (/.f64 K #s(literal 2 binary64)) Initial program 81.5%
Taylor expanded in l around 0
+-commutativeN/A
lower-fma.f64N/A
Simplified94.1%
Final simplification82.9%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) 0.114)
(fma (fma l (* l 0.5) l) J U)
(fma
(* l (fma l (* l (* 0.0003968253968253968 (* (* l l) (* l l)))) 2.0))
J
U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.114) {
tmp = fma(fma(l, (l * 0.5), l), J, U);
} else {
tmp = fma((l * fma(l, (l * (0.0003968253968253968 * ((l * l) * (l * l)))), 2.0)), J, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.114) tmp = fma(fma(l, Float64(l * 0.5), l), J, U); else tmp = fma(Float64(l * fma(l, Float64(l * Float64(0.0003968253968253968 * Float64(Float64(l * l) * Float64(l * 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.114], N[(N[(l * N[(l * 0.5), $MachinePrecision] + l), $MachinePrecision] * J + U), $MachinePrecision], N[(N[(l * N[(l * N[(l * N[(0.0003968253968253968 * N[(N[(l * l), $MachinePrecision] * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.114:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\ell, \ell \cdot 0.5, \ell\right), J, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \left(0.0003968253968253968 \cdot \left(\left(\ell \cdot \ell\right) \cdot \left(\ell \cdot \ell\right)\right)\right), 2\right), J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.114000000000000004Initial program 83.4%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6430.6
Simplified30.6%
Taylor expanded in l around 0
Simplified31.3%
Taylor expanded in l around 0
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6460.0
Simplified60.0%
if 0.114000000000000004 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.8%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6485.7
Simplified85.7%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
Simplified92.2%
Taylor expanded in l around inf
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6492.2
Simplified92.2%
Taylor expanded in l around inf
metadata-evalN/A
pow-plusN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
metadata-evalN/A
pow-sqrN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6492.2
Simplified92.2%
(FPCore (J l K U)
:precision binary64
(if (<= (/ K 2.0) 2e+14)
(+
U
(*
(fma
l
(*
l
(fma
l
(* l (fma (* l l) 0.0003968253968253968 0.016666666666666666))
0.3333333333333333))
2.0)
(* J (fma -0.125 (* l (* K K)) l))))
(+ U (* (cos (/ K 2.0)) (* J (* l (fma l (* l 0.3333333333333333) 2.0)))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((K / 2.0) <= 2e+14) {
tmp = U + (fma(l, (l * fma(l, (l * fma((l * l), 0.0003968253968253968, 0.016666666666666666)), 0.3333333333333333)), 2.0) * (J * fma(-0.125, (l * (K * K)), l)));
} else {
tmp = U + (cos((K / 2.0)) * (J * (l * fma(l, (l * 0.3333333333333333), 2.0))));
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (Float64(K / 2.0) <= 2e+14) tmp = Float64(U + Float64(fma(l, Float64(l * fma(l, Float64(l * fma(Float64(l * l), 0.0003968253968253968, 0.016666666666666666)), 0.3333333333333333)), 2.0) * Float64(J * fma(-0.125, Float64(l * Float64(K * K)), l)))); else tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * fma(l, Float64(l * 0.3333333333333333), 2.0))))); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[(K / 2.0), $MachinePrecision], 2e+14], N[(U + N[(N[(l * N[(l * N[(l * N[(l * N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968 + 0.016666666666666666), $MachinePrecision]), $MachinePrecision] + 0.3333333333333333), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision] * N[(J * N[(-0.125 * N[(l * N[(K * K), $MachinePrecision]), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * N[(l * N[(l * 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{K}{2} \leq 2 \cdot 10^{+14}:\\
\;\;\;\;U + \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 2\right) \cdot \left(J \cdot \mathsf{fma}\left(-0.125, \ell \cdot \left(K \cdot K\right), \ell\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right)\right)\right)\\
\end{array}
\end{array}
if (/.f64 K #s(literal 2 binary64)) < 2e14Initial program 86.7%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6495.7
Simplified95.7%
Taylor expanded in K around 0
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
Simplified78.0%
if 2e14 < (/.f64 K #s(literal 2 binary64)) Initial program 81.5%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f6491.5
Simplified91.5%
Final simplification82.2%
(FPCore (J l K U)
:precision binary64
(+
U
(*
(cos (/ K 2.0))
(*
J
(*
l
(fma
(* l l)
(fma l (* l 0.016666666666666666) 0.3333333333333333)
2.0))))))
double code(double J, double l, double K, double U) {
return U + (cos((K / 2.0)) * (J * (l * fma((l * l), fma(l, (l * 0.016666666666666666), 0.3333333333333333), 2.0))));
}
function code(J, l, K, U) return Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * fma(Float64(l * l), fma(l, Float64(l * 0.016666666666666666), 0.3333333333333333), 2.0))))) end
code[J_, l_, K_, U_] := N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * N[(N[(l * l), $MachinePrecision] * N[(l * N[(l * 0.016666666666666666), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \mathsf{fma}\left(\ell \cdot \ell, \mathsf{fma}\left(\ell, \ell \cdot 0.016666666666666666, 0.3333333333333333\right), 2\right)\right)\right)
\end{array}
Initial program 85.1%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f6494.0
Simplified94.0%
Final simplification94.0%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) 0.114)
(fma (fma l (* l 0.5) l) J U)
(fma
(*
l
(fma l (* l (fma l (* l 0.016666666666666666) 0.3333333333333333)) 2.0))
J
U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.114) {
tmp = fma(fma(l, (l * 0.5), l), J, U);
} else {
tmp = fma((l * fma(l, (l * fma(l, (l * 0.016666666666666666), 0.3333333333333333)), 2.0)), J, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.114) tmp = fma(fma(l, Float64(l * 0.5), l), J, U); else tmp = fma(Float64(l * fma(l, Float64(l * fma(l, Float64(l * 0.016666666666666666), 0.3333333333333333)), 2.0)), J, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.114], N[(N[(l * N[(l * 0.5), $MachinePrecision] + l), $MachinePrecision] * J + U), $MachinePrecision], N[(N[(l * N[(l * N[(l * N[(l * N[(l * 0.016666666666666666), $MachinePrecision] + 0.3333333333333333), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.114:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\ell, \ell \cdot 0.5, \ell\right), J, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.016666666666666666, 0.3333333333333333\right), 2\right), J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.114000000000000004Initial program 83.4%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6430.6
Simplified30.6%
Taylor expanded in l around 0
Simplified31.3%
Taylor expanded in l around 0
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6460.0
Simplified60.0%
if 0.114000000000000004 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.8%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6485.7
Simplified85.7%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
Simplified92.2%
Taylor expanded in l around 0
Simplified90.2%
(FPCore (J l K U)
:precision binary64
(if (<= (/ K 2.0) 1e+28)
(+
U
(*
(fma
l
(*
l
(fma
l
(* l (fma (* l l) 0.0003968253968253968 0.016666666666666666))
0.3333333333333333))
2.0)
(* J (fma -0.125 (* l (* K K)) l))))
(fma (* (cos (* K 0.5)) (* l J)) (fma l (* l 0.3333333333333333) 2.0) U)))
double code(double J, double l, double K, double U) {
double tmp;
if ((K / 2.0) <= 1e+28) {
tmp = U + (fma(l, (l * fma(l, (l * fma((l * l), 0.0003968253968253968, 0.016666666666666666)), 0.3333333333333333)), 2.0) * (J * fma(-0.125, (l * (K * K)), l)));
} else {
tmp = fma((cos((K * 0.5)) * (l * J)), fma(l, (l * 0.3333333333333333), 2.0), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (Float64(K / 2.0) <= 1e+28) tmp = Float64(U + Float64(fma(l, Float64(l * fma(l, Float64(l * fma(Float64(l * l), 0.0003968253968253968, 0.016666666666666666)), 0.3333333333333333)), 2.0) * Float64(J * fma(-0.125, Float64(l * Float64(K * K)), l)))); else tmp = fma(Float64(cos(Float64(K * 0.5)) * Float64(l * J)), fma(l, Float64(l * 0.3333333333333333), 2.0), U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[(K / 2.0), $MachinePrecision], 1e+28], N[(U + N[(N[(l * N[(l * N[(l * N[(l * N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968 + 0.016666666666666666), $MachinePrecision]), $MachinePrecision] + 0.3333333333333333), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision] * N[(J * N[(-0.125 * N[(l * N[(K * K), $MachinePrecision]), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(l * J), $MachinePrecision]), $MachinePrecision] * N[(l * N[(l * 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{K}{2} \leq 10^{+28}:\\
\;\;\;\;U + \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell, \ell \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), 0.3333333333333333\right), 2\right) \cdot \left(J \cdot \mathsf{fma}\left(-0.125, \ell \cdot \left(K \cdot K\right), \ell\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos \left(K \cdot 0.5\right) \cdot \left(\ell \cdot J\right), \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right), U\right)\\
\end{array}
\end{array}
if (/.f64 K #s(literal 2 binary64)) < 9.99999999999999958e27Initial program 86.4%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6495.7
Simplified95.7%
Taylor expanded in K around 0
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
Simplified77.8%
if 9.99999999999999958e27 < (/.f64 K #s(literal 2 binary64)) Initial program 82.0%
Taylor expanded in l around 0
+-commutativeN/A
Simplified86.3%
Final simplification80.3%
(FPCore (J l K U)
:precision binary64
(if (<= l -2e+209)
(fma
(* J (fma -0.125 (* l (* K K)) l))
(fma l (* l 0.3333333333333333) 2.0)
U)
(if (<= l -1.9)
(fma (- 1.0 (exp (- l))) J U)
(if (<= l 85.0)
(fma l (* (cos (* K 0.5)) (* J 2.0)) U)
(* J (expm1 l))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -2e+209) {
tmp = fma((J * fma(-0.125, (l * (K * K)), l)), fma(l, (l * 0.3333333333333333), 2.0), U);
} else if (l <= -1.9) {
tmp = fma((1.0 - exp(-l)), J, U);
} else if (l <= 85.0) {
tmp = fma(l, (cos((K * 0.5)) * (J * 2.0)), U);
} else {
tmp = J * expm1(l);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (l <= -2e+209) tmp = fma(Float64(J * fma(-0.125, Float64(l * Float64(K * K)), l)), fma(l, Float64(l * 0.3333333333333333), 2.0), U); elseif (l <= -1.9) tmp = fma(Float64(1.0 - exp(Float64(-l))), J, U); elseif (l <= 85.0) tmp = fma(l, Float64(cos(Float64(K * 0.5)) * Float64(J * 2.0)), U); else tmp = Float64(J * expm1(l)); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[l, -2e+209], N[(N[(J * N[(-0.125 * N[(l * N[(K * K), $MachinePrecision]), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision] * N[(l * N[(l * 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, -1.9], N[(N[(1.0 - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], If[LessEqual[l, 85.0], N[(l * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(J * 2.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(J * N[(Exp[l] - 1), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2 \cdot 10^{+209}:\\
\;\;\;\;\mathsf{fma}\left(J \cdot \mathsf{fma}\left(-0.125, \ell \cdot \left(K \cdot K\right), \ell\right), \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right), U\right)\\
\mathbf{elif}\;\ell \leq -1.9:\\
\;\;\;\;\mathsf{fma}\left(1 - e^{-\ell}, J, U\right)\\
\mathbf{elif}\;\ell \leq 85:\\
\;\;\;\;\mathsf{fma}\left(\ell, \cos \left(K \cdot 0.5\right) \cdot \left(J \cdot 2\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;J \cdot \mathsf{expm1}\left(\ell\right)\\
\end{array}
\end{array}
if l < -2.0000000000000001e209Initial program 100.0%
Taylor expanded in l around 0
+-commutativeN/A
Simplified100.0%
Taylor expanded in K around 0
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-outN/A
lower-*.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6478.8
Simplified78.8%
if -2.0000000000000001e209 < l < -1.8999999999999999Initial program 100.0%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6475.5
Simplified75.5%
Taylor expanded in l around 0
Simplified75.5%
if -1.8999999999999999 < l < 85Initial program 68.5%
Taylor expanded in l around 0
+-commutativeN/A
lower-fma.f64N/A
Simplified100.0%
Taylor expanded in l around 0
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64100.0
Simplified100.0%
if 85 < l Initial program 100.0%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6473.6
Simplified73.6%
Taylor expanded in l around 0
Simplified73.6%
Taylor expanded in J around inf
lower-*.f64N/A
lower-expm1.f6473.6
Simplified73.6%
Final simplification87.1%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.114) (fma (fma l (* l 0.5) l) J U) (fma (* l (fma l (* l 0.3333333333333333) 2.0)) J U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.114) {
tmp = fma(fma(l, (l * 0.5), l), J, U);
} else {
tmp = fma((l * fma(l, (l * 0.3333333333333333), 2.0)), J, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.114) tmp = fma(fma(l, Float64(l * 0.5), l), J, U); else tmp = fma(Float64(l * fma(l, Float64(l * 0.3333333333333333), 2.0)), J, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.114], N[(N[(l * N[(l * 0.5), $MachinePrecision] + l), $MachinePrecision] * J + U), $MachinePrecision], N[(N[(l * N[(l * N[(l * 0.3333333333333333), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.114:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\ell, \ell \cdot 0.5, \ell\right), J, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\ell \cdot \mathsf{fma}\left(\ell, \ell \cdot 0.3333333333333333, 2\right), J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.114000000000000004Initial program 83.4%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6430.6
Simplified30.6%
Taylor expanded in l around 0
Simplified31.3%
Taylor expanded in l around 0
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6460.0
Simplified60.0%
if 0.114000000000000004 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.8%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6485.7
Simplified85.7%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
Simplified92.2%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f6486.0
Simplified86.0%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.114) (fma (fma l (* l 0.5) l) J U) (fma l (* J (fma (* l l) 0.3333333333333333 2.0)) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.114) {
tmp = fma(fma(l, (l * 0.5), l), J, U);
} else {
tmp = fma(l, (J * fma((l * l), 0.3333333333333333, 2.0)), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.114) tmp = fma(fma(l, Float64(l * 0.5), l), J, U); else tmp = fma(l, Float64(J * fma(Float64(l * l), 0.3333333333333333, 2.0)), U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.114], N[(N[(l * N[(l * 0.5), $MachinePrecision] + l), $MachinePrecision] * J + U), $MachinePrecision], N[(l * N[(J * N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.114:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\ell, \ell \cdot 0.5, \ell\right), J, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\ell, J \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right), U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.114000000000000004Initial program 83.4%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6430.6
Simplified30.6%
Taylor expanded in l around 0
Simplified31.3%
Taylor expanded in l around 0
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6460.0
Simplified60.0%
if 0.114000000000000004 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.8%
Taylor expanded in l around 0
+-commutativeN/A
Simplified85.5%
Taylor expanded in K around 0
+-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
+-commutativeN/A
distribute-lft-outN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Simplified81.4%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.478) (fma (fma l (* l 0.5) l) J U) (fma (* l 2.0) J U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.478) {
tmp = fma(fma(l, (l * 0.5), l), J, U);
} else {
tmp = fma((l * 2.0), J, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.478) tmp = fma(fma(l, Float64(l * 0.5), l), J, U); else tmp = fma(Float64(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.478], N[(N[(l * N[(l * 0.5), $MachinePrecision] + l), $MachinePrecision] * J + U), $MachinePrecision], N[(N[(l * 2.0), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.478:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\ell, \ell \cdot 0.5, \ell\right), J, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\ell \cdot 2, J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.47799999999999998Initial program 84.0%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6441.3
Simplified41.3%
Taylor expanded in l around 0
Simplified39.8%
Taylor expanded in l around 0
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6461.1
Simplified61.1%
if 0.47799999999999998 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.7%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6485.7
Simplified85.7%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f6461.1
Simplified61.1%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.478) (fma l (fma (* l J) 0.5 J) U) (fma (* l 2.0) J U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.478) {
tmp = fma(l, fma((l * J), 0.5, J), U);
} else {
tmp = fma((l * 2.0), J, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.478) tmp = fma(l, fma(Float64(l * J), 0.5, J), U); else tmp = fma(Float64(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.478], N[(l * N[(N[(l * J), $MachinePrecision] * 0.5 + J), $MachinePrecision] + U), $MachinePrecision], N[(N[(l * 2.0), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.478:\\
\;\;\;\;\mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell \cdot J, 0.5, J\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\ell \cdot 2, J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.47799999999999998Initial program 84.0%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6441.3
Simplified41.3%
Taylor expanded in l around 0
Simplified39.8%
Taylor expanded in l around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6450.7
Simplified50.7%
if 0.47799999999999998 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.7%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6485.7
Simplified85.7%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f6461.1
Simplified61.1%
Final simplification57.4%
(FPCore (J l K U) :precision binary64 (fma (* l 2.0) J U))
double code(double J, double l, double K, double U) {
return fma((l * 2.0), J, U);
}
function code(J, l, K, U) return fma(Float64(l * 2.0), J, U) end
code[J_, l_, K_, U_] := N[(N[(l * 2.0), $MachinePrecision] * J + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\ell \cdot 2, J, U\right)
\end{array}
Initial program 85.1%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6470.2
Simplified70.2%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f6451.8
Simplified51.8%
(FPCore (J l K U) :precision binary64 (fma 2.0 (* l J) U))
double code(double J, double l, double K, double U) {
return fma(2.0, (l * J), U);
}
function code(J, l, K, U) return fma(2.0, Float64(l * J), U) end
code[J_, l_, K_, U_] := N[(2.0 * N[(l * J), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(2, \ell \cdot J, U\right)
\end{array}
Initial program 85.1%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6470.2
Simplified70.2%
Taylor expanded in l around 0
lower-*.f64N/A
+-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
Simplified74.9%
Taylor expanded in l around 0
+-commutativeN/A
lower-fma.f64N/A
lower-*.f6451.8
Simplified51.8%
Final simplification51.8%
(FPCore (J l K U) :precision binary64 (fma J l U))
double code(double J, double l, double K, double U) {
return fma(J, l, U);
}
function code(J, l, K, U) return fma(J, l, U) end
code[J_, l_, K_, U_] := N[(J * l + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(J, \ell, U\right)
\end{array}
Initial program 85.1%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6470.2
Simplified70.2%
Taylor expanded in l around 0
Simplified48.7%
Taylor expanded in l around 0
+-commutativeN/A
lower-fma.f6446.0
Simplified46.0%
herbie shell --seed 2024215
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))