
(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;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(j, l, k, u)
use fmin_fmax_functions
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 24 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;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(j, l, k, u)
use fmin_fmax_functions
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)))) (fma (/ (* (pow t_0 2.0) (* (sinh l) 2.0)) t_0) J U)))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / -2.0));
return fma(((pow(t_0, 2.0) * (sinh(l) * 2.0)) / t_0), J, U);
}
function code(J, l, K, U) t_0 = cos(Float64(K / -2.0)) return fma(Float64(Float64((t_0 ^ 2.0) * Float64(sinh(l) * 2.0)) / t_0), J, U) end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / -2.0), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(N[Power[t$95$0, 2.0], $MachinePrecision] * N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{-2}\right)\\
\mathsf{fma}\left(\frac{{t\_0}^{2} \cdot \left(\sinh \ell \cdot 2\right)}{t\_0}, J, U\right)
\end{array}
\end{array}
Initial program 84.6%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
lift-cos.f64N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lift-/.f64N/A
distribute-frac-neg2N/A
metadata-evalN/A
lift-/.f64N/A
sin-sumN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-PI.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-PI.f6499.9
Applied rewrites99.9%
Applied rewrites100.0%
Final simplification100.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))) (t_1 (* (sinh l) 2.0)))
(if (<= t_0 -0.92)
(fma (* (* 2.0 l) J) (cos (* -0.5 K)) U)
(if (<= t_0 -0.001)
(fma (* (fma (* K K) -0.125 1.0) t_1) J U)
(fma (* 1.0 t_1) J U)))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = sinh(l) * 2.0;
double tmp;
if (t_0 <= -0.92) {
tmp = fma(((2.0 * l) * J), cos((-0.5 * K)), U);
} else if (t_0 <= -0.001) {
tmp = fma((fma((K * K), -0.125, 1.0) * t_1), J, U);
} else {
tmp = fma((1.0 * t_1), J, U);
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(sinh(l) * 2.0) tmp = 0.0 if (t_0 <= -0.92) tmp = fma(Float64(Float64(2.0 * l) * J), cos(Float64(-0.5 * K)), U); elseif (t_0 <= -0.001) tmp = fma(Float64(fma(Float64(K * K), -0.125, 1.0) * t_1), J, U); else tmp = fma(Float64(1.0 * t_1), J, U); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision]}, If[LessEqual[t$95$0, -0.92], N[(N[(N[(2.0 * l), $MachinePrecision] * J), $MachinePrecision] * N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision] + U), $MachinePrecision], If[LessEqual[t$95$0, -0.001], N[(N[(N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] * t$95$1), $MachinePrecision] * J + U), $MachinePrecision], N[(N[(1.0 * t$95$1), $MachinePrecision] * J + U), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := \sinh \ell \cdot 2\\
\mathbf{if}\;t\_0 \leq -0.92:\\
\;\;\;\;\mathsf{fma}\left(\left(2 \cdot \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right)\\
\mathbf{elif}\;t\_0 \leq -0.001:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right) \cdot t\_1, J, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot t\_1, J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.92000000000000004Initial program 74.3%
Taylor expanded in l around 0
Applied rewrites80.0%
if -0.92000000000000004 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < -1e-3Initial program 90.9%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.9%
Taylor expanded in K around 0
Applied rewrites73.0%
if -1e-3 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 84.2%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites96.2%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 -0.92)
(fma (* (* 2.0 l) J) (cos (* -0.5 K)) U)
(if (<= t_0 -0.001)
(fma
(*
(fma (* K K) -0.125 1.0)
(*
(fma
(fma (* 0.0003968253968253968 (* l l)) (* l l) 0.3333333333333333)
(* l l)
2.0)
l))
J
U)
(fma (* 1.0 (* (sinh l) 2.0)) J U)))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double tmp;
if (t_0 <= -0.92) {
tmp = fma(((2.0 * l) * J), cos((-0.5 * K)), U);
} else if (t_0 <= -0.001) {
tmp = fma((fma((K * K), -0.125, 1.0) * (fma(fma((0.0003968253968253968 * (l * l)), (l * l), 0.3333333333333333), (l * l), 2.0) * l)), J, U);
} else {
tmp = fma((1.0 * (sinh(l) * 2.0)), J, U);
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= -0.92) tmp = fma(Float64(Float64(2.0 * l) * J), cos(Float64(-0.5 * K)), U); elseif (t_0 <= -0.001) tmp = fma(Float64(fma(Float64(K * K), -0.125, 1.0) * Float64(fma(fma(Float64(0.0003968253968253968 * Float64(l * l)), Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l)), J, U); else tmp = fma(Float64(1.0 * Float64(sinh(l) * 2.0)), J, U); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, -0.92], N[(N[(N[(2.0 * l), $MachinePrecision] * J), $MachinePrecision] * N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision] + U), $MachinePrecision], If[LessEqual[t$95$0, -0.001], N[(N[(N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] * N[(N[(N[(N[(0.0003968253968253968 * N[(l * l), $MachinePrecision]), $MachinePrecision] * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], N[(N[(1.0 * N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq -0.92:\\
\;\;\;\;\mathsf{fma}\left(\left(2 \cdot \ell\right) \cdot J, \cos \left(-0.5 \cdot K\right), U\right)\\
\mathbf{elif}\;t\_0 \leq -0.001:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right) \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968 \cdot \left(\ell \cdot \ell\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right), J, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot \left(\sinh \ell \cdot 2\right), J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.92000000000000004Initial program 74.3%
Taylor expanded in l around 0
Applied rewrites80.0%
if -0.92000000000000004 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < -1e-3Initial program 90.9%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.9%
Taylor expanded in K around 0
Applied rewrites73.0%
Taylor expanded in l around 0
Applied rewrites70.7%
Taylor expanded in l around inf
Applied rewrites70.7%
if -1e-3 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 84.2%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites96.2%
Final simplification90.7%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 0.82)
(+
(*
(*
J
(*
(fma
(fma
(fma 0.0003968253968253968 (* l l) 0.016666666666666666)
(* l l)
0.3333333333333333)
(* l l)
2.0)
l))
t_0)
U)
(fma (* 1.0 (* (sinh l) 2.0)) J U))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double tmp;
if (t_0 <= 0.82) {
tmp = ((J * (fma(fma(fma(0.0003968253968253968, (l * l), 0.016666666666666666), (l * l), 0.3333333333333333), (l * l), 2.0) * l)) * t_0) + U;
} else {
tmp = fma((1.0 * (sinh(l) * 2.0)), J, U);
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= 0.82) tmp = Float64(Float64(Float64(J * Float64(fma(fma(fma(0.0003968253968253968, Float64(l * l), 0.016666666666666666), Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l)) * t_0) + U); else tmp = fma(Float64(1.0 * Float64(sinh(l) * 2.0)), J, U); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 0.82], N[(N[(N[(J * N[(N[(N[(N[(0.0003968253968253968 * N[(l * l), $MachinePrecision] + 0.016666666666666666), $MachinePrecision] * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(N[(1.0 * N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq 0.82:\\
\;\;\;\;\left(J \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, \ell \cdot \ell, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right)\right) \cdot t\_0 + U\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot \left(\sinh \ell \cdot 2\right), J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.819999999999999951Initial program 85.7%
Taylor expanded in l around 0
Applied rewrites96.2%
if 0.819999999999999951 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 83.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 rewrites98.8%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 0.82)
(+
(*
(*
J
(*
(fma
(fma 0.016666666666666666 (* l l) 0.3333333333333333)
(* l l)
2.0)
l))
t_0)
U)
(fma (* 1.0 (* (sinh l) 2.0)) J U))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double tmp;
if (t_0 <= 0.82) {
tmp = ((J * (fma(fma(0.016666666666666666, (l * l), 0.3333333333333333), (l * l), 2.0) * l)) * t_0) + U;
} else {
tmp = fma((1.0 * (sinh(l) * 2.0)), J, U);
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= 0.82) tmp = Float64(Float64(Float64(J * Float64(fma(fma(0.016666666666666666, Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l)) * t_0) + U); else tmp = fma(Float64(1.0 * Float64(sinh(l) * 2.0)), J, U); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 0.82], N[(N[(N[(J * N[(N[(N[(0.016666666666666666 * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(N[(1.0 * N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq 0.82:\\
\;\;\;\;\left(J \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(0.016666666666666666, \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right)\right) \cdot t\_0 + U\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot \left(\sinh \ell \cdot 2\right), J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.819999999999999951Initial program 85.7%
Taylor expanded in l around 0
Applied rewrites94.4%
if 0.819999999999999951 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 83.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 rewrites98.8%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.56) (fma (* (* (fma (* l l) 0.3333333333333333 2.0) l) (cos (* 0.5 K))) J U) (fma (* 1.0 (* (sinh l) 2.0)) J U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.56) {
tmp = fma(((fma((l * l), 0.3333333333333333, 2.0) * l) * cos((0.5 * K))), J, U);
} else {
tmp = fma((1.0 * (sinh(l) * 2.0)), J, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.56) tmp = fma(Float64(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l) * cos(Float64(0.5 * K))), J, U); else tmp = fma(Float64(1.0 * Float64(sinh(l) * 2.0)), J, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.56], N[(N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], N[(N[(1.0 * N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.56:\\
\;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot \cos \left(0.5 \cdot K\right), J, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot \left(\sinh \ell \cdot 2\right), J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.56000000000000005Initial program 85.6%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.9%
Taylor expanded in l around 0
Applied rewrites93.1%
if 0.56000000000000005 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 84.1%
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 rewrites97.6%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.56) (fma (* (cos (* -0.5 K)) (* J (fma (* l l) 0.3333333333333333 2.0))) l U) (fma (* 1.0 (* (sinh l) 2.0)) J U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.56) {
tmp = fma((cos((-0.5 * K)) * (J * fma((l * l), 0.3333333333333333, 2.0))), l, U);
} else {
tmp = fma((1.0 * (sinh(l) * 2.0)), J, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.56) tmp = fma(Float64(cos(Float64(-0.5 * K)) * Float64(J * fma(Float64(l * l), 0.3333333333333333, 2.0))), l, U); else tmp = fma(Float64(1.0 * Float64(sinh(l) * 2.0)), J, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.56], N[(N[(N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision] * N[(J * N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * l + U), $MachinePrecision], N[(N[(1.0 * N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.56:\\
\;\;\;\;\mathsf{fma}\left(\cos \left(-0.5 \cdot K\right) \cdot \left(J \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\right), \ell, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot \left(\sinh \ell \cdot 2\right), J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.56000000000000005Initial program 85.6%
Taylor expanded in l around 0
Applied rewrites93.0%
if 0.56000000000000005 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 84.1%
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 rewrites97.6%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) -0.001)
(fma
(*
(fma (* K K) -0.125 1.0)
(*
(fma
(fma (* 0.0003968253968253968 (* l l)) (* l l) 0.3333333333333333)
(* l l)
2.0)
l))
J
U)
(fma (* 1.0 (* (sinh l) 2.0)) J U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.001) {
tmp = fma((fma((K * K), -0.125, 1.0) * (fma(fma((0.0003968253968253968 * (l * l)), (l * l), 0.3333333333333333), (l * l), 2.0) * l)), J, U);
} else {
tmp = fma((1.0 * (sinh(l) * 2.0)), J, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.001) tmp = fma(Float64(fma(Float64(K * K), -0.125, 1.0) * Float64(fma(fma(Float64(0.0003968253968253968 * Float64(l * l)), Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l)), J, U); else tmp = fma(Float64(1.0 * Float64(sinh(l) * 2.0)), J, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.001], N[(N[(N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] * N[(N[(N[(N[(0.0003968253968253968 * N[(l * l), $MachinePrecision]), $MachinePrecision] * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], N[(N[(1.0 * N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.001:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right) \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968 \cdot \left(\ell \cdot \ell\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right), J, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot \left(\sinh \ell \cdot 2\right), J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -1e-3Initial program 85.8%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.9%
Taylor expanded in K around 0
Applied rewrites65.7%
Taylor expanded in l around 0
Applied rewrites64.2%
Taylor expanded in l around inf
Applied rewrites64.2%
if -1e-3 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 84.2%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites96.2%
Final simplification88.4%
(FPCore (J l K U) :precision binary64 (fma (* (cos (/ K -2.0)) (* (sinh l) 2.0)) J U))
double code(double J, double l, double K, double U) {
return fma((cos((K / -2.0)) * (sinh(l) * 2.0)), J, U);
}
function code(J, l, K, U) return fma(Float64(cos(Float64(K / -2.0)) * Float64(sinh(l) * 2.0)), J, U) end
code[J_, l_, K_, U_] := N[(N[(N[Cos[N[(K / -2.0), $MachinePrecision]], $MachinePrecision] * N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\cos \left(\frac{K}{-2}\right) \cdot \left(\sinh \ell \cdot 2\right), J, U\right)
\end{array}
Initial program 84.6%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) -0.001)
(fma
(*
(fma (* K K) -0.125 1.0)
(*
(fma
(fma (* 0.0003968253968253968 (* l l)) (* l l) 0.3333333333333333)
(* l l)
2.0)
l))
J
U)
(fma
(*
1.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 (cos((K / 2.0)) <= -0.001) {
tmp = fma((fma((K * K), -0.125, 1.0) * (fma(fma((0.0003968253968253968 * (l * l)), (l * l), 0.3333333333333333), (l * l), 2.0) * l)), J, U);
} else {
tmp = fma((1.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 (cos(Float64(K / 2.0)) <= -0.001) tmp = fma(Float64(fma(Float64(K * K), -0.125, 1.0) * Float64(fma(fma(Float64(0.0003968253968253968 * Float64(l * l)), Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l)), J, U); else tmp = fma(Float64(1.0 * 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[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.001], N[(N[(N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] * N[(N[(N[(N[(0.0003968253968253968 * N[(l * l), $MachinePrecision]), $MachinePrecision] * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], N[(N[(1.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]), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.001:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right) \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968 \cdot \left(\ell \cdot \ell\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right), J, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, \ell \cdot \ell, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right), J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -1e-3Initial program 85.8%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.9%
Taylor expanded in K around 0
Applied rewrites65.7%
Taylor expanded in l around 0
Applied rewrites64.2%
Taylor expanded in l around inf
Applied rewrites64.2%
if -1e-3 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 84.2%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites96.2%
Taylor expanded in l around 0
Applied rewrites90.4%
Final simplification84.0%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) -0.001)
(fma
(*
(fma (* K K) -0.125 1.0)
(*
(fma (fma 0.016666666666666666 (* l l) 0.3333333333333333) (* l l) 2.0)
l))
J
U)
(fma
(*
1.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 (cos((K / 2.0)) <= -0.001) {
tmp = fma((fma((K * K), -0.125, 1.0) * (fma(fma(0.016666666666666666, (l * l), 0.3333333333333333), (l * l), 2.0) * l)), J, U);
} else {
tmp = fma((1.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 (cos(Float64(K / 2.0)) <= -0.001) tmp = fma(Float64(fma(Float64(K * K), -0.125, 1.0) * Float64(fma(fma(0.016666666666666666, Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l)), J, U); else tmp = fma(Float64(1.0 * 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[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.001], N[(N[(N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] * N[(N[(N[(0.016666666666666666 * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], N[(N[(1.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]), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.001:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right) \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(0.016666666666666666, \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right), J, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, \ell \cdot \ell, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right), J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -1e-3Initial program 85.8%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.9%
Taylor expanded in K around 0
Applied rewrites65.7%
Taylor expanded in l around 0
Applied rewrites64.2%
if -1e-3 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 84.2%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites96.2%
Taylor expanded in l around 0
Applied rewrites90.4%
Final simplification84.0%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) -0.001)
(fma (* (* -0.125 J) (* (* K K) (fma (* l l) 0.3333333333333333 2.0))) l U)
(fma
(*
1.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 (cos((K / 2.0)) <= -0.001) {
tmp = fma(((-0.125 * J) * ((K * K) * fma((l * l), 0.3333333333333333, 2.0))), l, U);
} else {
tmp = fma((1.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 (cos(Float64(K / 2.0)) <= -0.001) tmp = fma(Float64(Float64(-0.125 * J) * Float64(Float64(K * K) * fma(Float64(l * l), 0.3333333333333333, 2.0))), l, U); else tmp = fma(Float64(1.0 * 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[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.001], N[(N[(N[(-0.125 * J), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * l + U), $MachinePrecision], N[(N[(1.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]), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.001:\\
\;\;\;\;\mathsf{fma}\left(\left(-0.125 \cdot J\right) \cdot \left(\left(K \cdot K\right) \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\right), \ell, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, \ell \cdot \ell, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right), J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -1e-3Initial program 85.8%
Taylor expanded in l around 0
Applied rewrites92.2%
Taylor expanded in K around 0
Applied rewrites19.2%
Taylor expanded in K around inf
Applied rewrites61.1%
if -1e-3 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 84.2%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites96.2%
Taylor expanded in l around 0
Applied rewrites90.4%
Final simplification83.3%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (* 0.5 K)))
(t_1 (* (* (* (fma (* l l) 0.3333333333333333 2.0) l) J) t_0)))
(if (<= l -1.02e+117)
t_1
(if (<= l -2.2e+33)
(fma
(*
1.0
(*
(fma
(fma
(fma 0.0003968253968253968 (* l l) 0.016666666666666666)
(* l l)
0.3333333333333333)
(* l l)
2.0)
l))
J
U)
(if (<= l 0.0048)
(fma (* (* 2.0 l) t_0) J U)
(if (<= l 8.2e+98) (fma (* 1.0 (* (sinh l) 2.0)) 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((l * l), 0.3333333333333333, 2.0) * l) * J) * t_0;
double tmp;
if (l <= -1.02e+117) {
tmp = t_1;
} else if (l <= -2.2e+33) {
tmp = fma((1.0 * (fma(fma(fma(0.0003968253968253968, (l * l), 0.016666666666666666), (l * l), 0.3333333333333333), (l * l), 2.0) * l)), J, U);
} else if (l <= 0.0048) {
tmp = fma(((2.0 * l) * t_0), J, U);
} else if (l <= 8.2e+98) {
tmp = fma((1.0 * (sinh(l) * 2.0)), J, U);
} else {
tmp = t_1;
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(0.5 * K)) t_1 = Float64(Float64(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l) * J) * t_0) tmp = 0.0 if (l <= -1.02e+117) tmp = t_1; elseif (l <= -2.2e+33) tmp = fma(Float64(1.0 * Float64(fma(fma(fma(0.0003968253968253968, Float64(l * l), 0.016666666666666666), Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l)), J, U); elseif (l <= 0.0048) tmp = fma(Float64(Float64(2.0 * l) * t_0), J, U); elseif (l <= 8.2e+98) tmp = fma(Float64(1.0 * Float64(sinh(l) * 2.0)), 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] * l), $MachinePrecision] * J), $MachinePrecision] * t$95$0), $MachinePrecision]}, If[LessEqual[l, -1.02e+117], t$95$1, If[LessEqual[l, -2.2e+33], N[(N[(1.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]), $MachinePrecision] * J + U), $MachinePrecision], If[LessEqual[l, 0.0048], N[(N[(N[(2.0 * l), $MachinePrecision] * t$95$0), $MachinePrecision] * J + U), $MachinePrecision], If[LessEqual[l, 8.2e+98], N[(N[(1.0 * N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(0.5 \cdot K\right)\\
t_1 := \left(\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\right) \cdot t\_0\\
\mathbf{if}\;\ell \leq -1.02 \cdot 10^{+117}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\ell \leq -2.2 \cdot 10^{+33}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, \ell \cdot \ell, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right), J, U\right)\\
\mathbf{elif}\;\ell \leq 0.0048:\\
\;\;\;\;\mathsf{fma}\left(\left(2 \cdot \ell\right) \cdot t\_0, J, U\right)\\
\mathbf{elif}\;\ell \leq 8.2 \cdot 10^{+98}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot \left(\sinh \ell \cdot 2\right), J, U\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if l < -1.02e117 or 8.2000000000000001e98 < l Initial program 100.0%
Taylor expanded in l around 0
Applied rewrites95.9%
Taylor expanded in J around inf
Applied rewrites100.0%
if -1.02e117 < l < -2.19999999999999994e33Initial program 100.0%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites100.0%
Taylor expanded in l around 0
Applied rewrites100.0%
if -2.19999999999999994e33 < l < 0.00479999999999999958Initial program 68.9%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.9%
Taylor expanded in l around 0
Applied rewrites98.3%
if 0.00479999999999999958 < l < 8.2000000000000001e98Initial program 100.0%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites84.0%
Final simplification97.6%
(FPCore (J l K U)
:precision binary64
(let* ((t_0
(*
(* J l)
(* (fma (* l l) 0.3333333333333333 2.0) (cos (* -0.5 K))))))
(if (<= l -1.4e+149)
t_0
(if (<= l -2.2e+33)
(fma
(*
1.0
(*
(fma
(fma
(fma 0.0003968253968253968 (* l l) 0.016666666666666666)
(* l l)
0.3333333333333333)
(* l l)
2.0)
l))
J
U)
(if (<= l 0.0048)
(fma (* (* 2.0 l) (cos (* 0.5 K))) J U)
(if (<= l 8.2e+98) (fma (* 1.0 (* (sinh l) 2.0)) J U) t_0))))))
double code(double J, double l, double K, double U) {
double t_0 = (J * l) * (fma((l * l), 0.3333333333333333, 2.0) * cos((-0.5 * K)));
double tmp;
if (l <= -1.4e+149) {
tmp = t_0;
} else if (l <= -2.2e+33) {
tmp = fma((1.0 * (fma(fma(fma(0.0003968253968253968, (l * l), 0.016666666666666666), (l * l), 0.3333333333333333), (l * l), 2.0) * l)), J, U);
} else if (l <= 0.0048) {
tmp = fma(((2.0 * l) * cos((0.5 * K))), J, U);
} else if (l <= 8.2e+98) {
tmp = fma((1.0 * (sinh(l) * 2.0)), J, U);
} else {
tmp = t_0;
}
return tmp;
}
function code(J, l, K, U) t_0 = Float64(Float64(J * l) * Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * cos(Float64(-0.5 * K)))) tmp = 0.0 if (l <= -1.4e+149) tmp = t_0; elseif (l <= -2.2e+33) tmp = fma(Float64(1.0 * Float64(fma(fma(fma(0.0003968253968253968, Float64(l * l), 0.016666666666666666), Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l)), J, U); elseif (l <= 0.0048) tmp = fma(Float64(Float64(2.0 * l) * cos(Float64(0.5 * K))), J, U); elseif (l <= 8.2e+98) tmp = fma(Float64(1.0 * Float64(sinh(l) * 2.0)), J, U); else tmp = t_0; end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(J * l), $MachinePrecision] * N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1.4e+149], t$95$0, If[LessEqual[l, -2.2e+33], N[(N[(1.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]), $MachinePrecision] * J + U), $MachinePrecision], If[LessEqual[l, 0.0048], N[(N[(N[(2.0 * l), $MachinePrecision] * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], If[LessEqual[l, 8.2e+98], N[(N[(1.0 * N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(J \cdot \ell\right) \cdot \left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \cos \left(-0.5 \cdot K\right)\right)\\
\mathbf{if}\;\ell \leq -1.4 \cdot 10^{+149}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq -2.2 \cdot 10^{+33}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, \ell \cdot \ell, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right), J, U\right)\\
\mathbf{elif}\;\ell \leq 0.0048:\\
\;\;\;\;\mathsf{fma}\left(\left(2 \cdot \ell\right) \cdot \cos \left(0.5 \cdot K\right), J, U\right)\\
\mathbf{elif}\;\ell \leq 8.2 \cdot 10^{+98}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot \left(\sinh \ell \cdot 2\right), J, U\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if l < -1.4e149 or 8.2000000000000001e98 < l Initial program 100.0%
Taylor expanded in l around 0
Applied rewrites97.8%
Taylor expanded in K around 0
Applied rewrites66.8%
Taylor expanded in J around inf
Applied rewrites97.8%
if -1.4e149 < l < -2.19999999999999994e33Initial program 100.0%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites94.1%
Taylor expanded in l around 0
Applied rewrites94.1%
if -2.19999999999999994e33 < l < 0.00479999999999999958Initial program 68.9%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.9%
Taylor expanded in l around 0
Applied rewrites98.3%
if 0.00479999999999999958 < l < 8.2000000000000001e98Initial program 100.0%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites84.0%
Final simplification96.4%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) -0.001)
(fma (* (* -0.125 J) (* (* K K) (fma (* l l) 0.3333333333333333 2.0))) l U)
(fma
(*
1.0
(*
(fma (fma 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 (cos((K / 2.0)) <= -0.001) {
tmp = fma(((-0.125 * J) * ((K * K) * fma((l * l), 0.3333333333333333, 2.0))), l, U);
} else {
tmp = fma((1.0 * (fma(fma(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 (cos(Float64(K / 2.0)) <= -0.001) tmp = fma(Float64(Float64(-0.125 * J) * Float64(Float64(K * K) * fma(Float64(l * l), 0.3333333333333333, 2.0))), l, U); else tmp = fma(Float64(1.0 * Float64(fma(fma(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[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.001], N[(N[(N[(-0.125 * J), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * l + U), $MachinePrecision], N[(N[(1.0 * N[(N[(N[(0.016666666666666666 * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.001:\\
\;\;\;\;\mathsf{fma}\left(\left(-0.125 \cdot J\right) \cdot \left(\left(K \cdot K\right) \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\right), \ell, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(0.016666666666666666, \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right), J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -1e-3Initial program 85.8%
Taylor expanded in l around 0
Applied rewrites92.2%
Taylor expanded in K around 0
Applied rewrites19.2%
Taylor expanded in K around inf
Applied rewrites61.1%
if -1e-3 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 84.2%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites96.2%
Taylor expanded in l around 0
Applied rewrites88.3%
Final simplification81.8%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.001) (fma (* (* -0.125 J) (* (* K K) (fma (* l l) 0.3333333333333333 2.0))) l U) (fma (* J (/ (* (fma (* 0.3333333333333333 l) l 2.0) l) U)) U U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.001) {
tmp = fma(((-0.125 * J) * ((K * K) * fma((l * l), 0.3333333333333333, 2.0))), l, U);
} else {
tmp = fma((J * ((fma((0.3333333333333333 * l), l, 2.0) * l) / U)), U, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.001) tmp = fma(Float64(Float64(-0.125 * J) * Float64(Float64(K * K) * fma(Float64(l * l), 0.3333333333333333, 2.0))), l, U); else tmp = fma(Float64(J * Float64(Float64(fma(Float64(0.3333333333333333 * l), l, 2.0) * l) / U)), U, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.001], N[(N[(N[(-0.125 * J), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * l + U), $MachinePrecision], N[(N[(J * N[(N[(N[(N[(0.3333333333333333 * l), $MachinePrecision] * l + 2.0), $MachinePrecision] * l), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision] * U + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.001:\\
\;\;\;\;\mathsf{fma}\left(\left(-0.125 \cdot J\right) \cdot \left(\left(K \cdot K\right) \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\right), \ell, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J \cdot \frac{\mathsf{fma}\left(0.3333333333333333 \cdot \ell, \ell, 2\right) \cdot \ell}{U}, U, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -1e-3Initial program 85.8%
Taylor expanded in l around 0
Applied rewrites92.2%
Taylor expanded in K around 0
Applied rewrites19.2%
Taylor expanded in K around inf
Applied rewrites61.1%
if -1e-3 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 84.2%
Taylor expanded in l around 0
Applied rewrites84.2%
Taylor expanded in K around 0
Applied rewrites80.5%
Taylor expanded in U around inf
Applied rewrites84.2%
Applied rewrites86.7%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (fma (* l l) 0.3333333333333333 2.0)))
(if (<= (cos (/ K 2.0)) -0.001)
(fma (* (* -0.125 J) (* (* K K) t_0)) l U)
(fma (* t_0 J) l U))))
double code(double J, double l, double K, double U) {
double t_0 = fma((l * l), 0.3333333333333333, 2.0);
double tmp;
if (cos((K / 2.0)) <= -0.001) {
tmp = fma(((-0.125 * J) * ((K * K) * t_0)), l, U);
} else {
tmp = fma((t_0 * J), l, U);
}
return tmp;
}
function code(J, l, K, U) t_0 = fma(Float64(l * l), 0.3333333333333333, 2.0) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.001) tmp = fma(Float64(Float64(-0.125 * J) * Float64(Float64(K * K) * t_0)), l, U); else tmp = fma(Float64(t_0 * J), l, U); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision]}, If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.001], N[(N[(N[(-0.125 * J), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] * l + U), $MachinePrecision], N[(N[(t$95$0 * J), $MachinePrecision] * l + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\\
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.001:\\
\;\;\;\;\mathsf{fma}\left(\left(-0.125 \cdot J\right) \cdot \left(\left(K \cdot K\right) \cdot t\_0\right), \ell, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_0 \cdot J, \ell, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -1e-3Initial program 85.8%
Taylor expanded in l around 0
Applied rewrites92.2%
Taylor expanded in K around 0
Applied rewrites19.2%
Taylor expanded in K around inf
Applied rewrites61.1%
if -1e-3 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 84.2%
Taylor expanded in l around 0
Applied rewrites84.2%
Taylor expanded in K around 0
Applied rewrites80.5%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.06) (fma (* (fma (* K K) -0.125 1.0) (* l 2.0)) J U) (fma (* (fma (* l l) 0.3333333333333333 2.0) J) l U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.06) {
tmp = fma((fma((K * K), -0.125, 1.0) * (l * 2.0)), J, U);
} else {
tmp = fma((fma((l * l), 0.3333333333333333, 2.0) * J), l, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.06) tmp = fma(Float64(fma(Float64(K * K), -0.125, 1.0) * Float64(l * 2.0)), J, U); else tmp = fma(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * J), l, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.06], N[(N[(N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] * N[(l * 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * J), $MachinePrecision] * l + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.06:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right) \cdot \left(\ell \cdot 2\right), J, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot J, \ell, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.059999999999999998Initial program 84.5%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.9%
Taylor expanded in K around 0
Applied rewrites66.2%
Taylor expanded in l around 0
Applied rewrites57.7%
if -0.059999999999999998 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 84.6%
Taylor expanded in l around 0
Applied rewrites84.6%
Taylor expanded in K around 0
Applied rewrites80.0%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.56) (fma (* (* (* K K) J) -0.25) l U) (fma (* (fma (* l l) 0.3333333333333333 2.0) J) l U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.56) {
tmp = fma((((K * K) * J) * -0.25), l, U);
} else {
tmp = fma((fma((l * l), 0.3333333333333333, 2.0) * J), l, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.56) tmp = fma(Float64(Float64(Float64(K * K) * J) * -0.25), l, U); else tmp = fma(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * J), l, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.56], N[(N[(N[(N[(K * K), $MachinePrecision] * J), $MachinePrecision] * -0.25), $MachinePrecision] * l + U), $MachinePrecision], N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * J), $MachinePrecision] * l + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.56:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(K \cdot K\right) \cdot J\right) \cdot -0.25, \ell, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot J, \ell, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.56000000000000005Initial program 83.7%
Taylor expanded in l around 0
Applied rewrites88.5%
Taylor expanded in K around 0
Applied rewrites23.1%
Taylor expanded in l around 0
Applied rewrites58.8%
Taylor expanded in K around inf
Applied rewrites61.2%
if -0.56000000000000005 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 84.8%
Taylor expanded in l around 0
Applied rewrites85.7%
Taylor expanded in K around 0
Applied rewrites77.2%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.56) (fma (* (* (* K K) J) -0.25) l U) (fma (* J l) (fma (* 0.3333333333333333 l) l 2.0) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.56) {
tmp = fma((((K * K) * J) * -0.25), l, U);
} else {
tmp = fma((J * l), fma((0.3333333333333333 * l), l, 2.0), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.56) tmp = fma(Float64(Float64(Float64(K * K) * J) * -0.25), l, U); else tmp = fma(Float64(J * l), fma(Float64(0.3333333333333333 * l), l, 2.0), U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.56], N[(N[(N[(N[(K * K), $MachinePrecision] * J), $MachinePrecision] * -0.25), $MachinePrecision] * l + U), $MachinePrecision], N[(N[(J * l), $MachinePrecision] * N[(N[(0.3333333333333333 * l), $MachinePrecision] * l + 2.0), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.56:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(K \cdot K\right) \cdot J\right) \cdot -0.25, \ell, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J \cdot \ell, \mathsf{fma}\left(0.3333333333333333 \cdot \ell, \ell, 2\right), U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.56000000000000005Initial program 83.7%
Taylor expanded in l around 0
Applied rewrites88.5%
Taylor expanded in K around 0
Applied rewrites23.1%
Taylor expanded in l around 0
Applied rewrites58.8%
Taylor expanded in K around inf
Applied rewrites61.2%
if -0.56000000000000005 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 84.8%
Taylor expanded in l around 0
Applied rewrites85.7%
Taylor expanded in K around 0
Applied rewrites77.2%
Applied rewrites77.2%
(FPCore (J l K U) :precision binary64 (if (or (<= l -2.3e+33) (not (<= l 1.5))) (* (* (fma (* l l) 0.3333333333333333 2.0) l) J) (fma (* 2.0 J) l U)))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -2.3e+33) || !(l <= 1.5)) {
tmp = (fma((l * l), 0.3333333333333333, 2.0) * l) * J;
} else {
tmp = fma((2.0 * J), l, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if ((l <= -2.3e+33) || !(l <= 1.5)) tmp = Float64(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l) * J); else tmp = fma(Float64(2.0 * J), l, U); end return tmp end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -2.3e+33], N[Not[LessEqual[l, 1.5]], $MachinePrecision]], N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision], N[(N[(2.0 * J), $MachinePrecision] * l + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.3 \cdot 10^{+33} \lor \neg \left(\ell \leq 1.5\right):\\
\;\;\;\;\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(2 \cdot J, \ell, U\right)\\
\end{array}
\end{array}
if l < -2.30000000000000011e33 or 1.5 < l Initial program 100.0%
Taylor expanded in l around 0
Applied rewrites73.4%
Taylor expanded in K around 0
Applied rewrites51.6%
Taylor expanded in J around inf
Applied rewrites55.4%
if -2.30000000000000011e33 < l < 1.5Initial program 68.9%
Taylor expanded in l around 0
Applied rewrites99.1%
Taylor expanded in K around 0
Applied rewrites64.2%
Taylor expanded in l around 0
Applied rewrites63.4%
Taylor expanded in K around 0
Applied rewrites85.6%
Final simplification70.4%
(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 84.6%
Taylor expanded in l around 0
Applied rewrites86.2%
Taylor expanded in K around 0
Applied rewrites35.5%
Taylor expanded in l around 0
Applied rewrites47.0%
Taylor expanded in K around 0
Applied rewrites51.3%
(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 84.6%
Taylor expanded in l around 0
Applied rewrites86.2%
Taylor expanded in K around 0
Applied rewrites68.4%
Taylor expanded in l around 0
Applied rewrites51.3%
(FPCore (J l K U) :precision binary64 U)
double code(double J, double l, double K, double U) {
return U;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(j, l, k, u)
use fmin_fmax_functions
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u
end function
public static double code(double J, double l, double K, double U) {
return U;
}
def code(J, l, K, U): return U
function code(J, l, K, U) return U end
function tmp = code(J, l, K, U) tmp = U; end
code[J_, l_, K_, U_] := U
\begin{array}{l}
\\
U
\end{array}
Initial program 84.6%
Taylor expanded in J around 0
Applied rewrites33.5%
herbie shell --seed 2025018
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))