
(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 16 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
(if (<= l 0.00112)
(fma
J
(*
(*
(fma
(fma (* (* l l) 0.0003968253968253968) (* l l) 0.3333333333333333)
(* l l)
2.0)
l)
(cos (* 0.5 K)))
U)
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= 0.00112) {
tmp = fma(J, ((fma(fma(((l * l) * 0.0003968253968253968), (l * l), 0.3333333333333333), (l * l), 2.0) * l) * cos((0.5 * K))), U);
} else {
tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (l <= 0.00112) tmp = fma(J, Float64(Float64(fma(fma(Float64(Float64(l * l) * 0.0003968253968253968), Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l) * cos(Float64(0.5 * K))), U); else tmp = Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[l, 0.00112], N[(J * N[(N[(N[(N[(N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968), $MachinePrecision] * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision] * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], 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}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 0.00112:\\
\;\;\;\;\mathsf{fma}\left(J, \left(\mathsf{fma}\left(\mathsf{fma}\left(\left(\ell \cdot \ell\right) \cdot 0.0003968253968253968, \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right) \cdot \cos \left(0.5 \cdot K\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U\\
\end{array}
\end{array}
if l < 0.0011199999999999999Initial program 84.3%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.3%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-cos.f64N/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites98.4%
Taylor expanded in K around inf
lift-cos.f64N/A
lift-*.f6498.4
Applied rewrites98.4%
Taylor expanded in l around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6498.4
Applied rewrites98.4%
if 0.0011199999999999999 < l Initial program 100.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0)))))
(if (<= t_0 -500000.0)
(* (* (* l J) (fma (* K K) -0.125 1.0)) 2.0)
(if (<= t_0 20000.0) (fma (+ J J) l U) (* (fma 2.0 l (/ U J)) J)))))
double code(double J, double l, double K, double U) {
double t_0 = (J * (exp(l) - exp(-l))) * cos((K / 2.0));
double tmp;
if (t_0 <= -500000.0) {
tmp = ((l * J) * fma((K * K), -0.125, 1.0)) * 2.0;
} else if (t_0 <= 20000.0) {
tmp = fma((J + J), l, U);
} else {
tmp = fma(2.0, l, (U / J)) * J;
}
return tmp;
}
function code(J, l, K, U) t_0 = Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) tmp = 0.0 if (t_0 <= -500000.0) tmp = Float64(Float64(Float64(l * J) * fma(Float64(K * K), -0.125, 1.0)) * 2.0); elseif (t_0 <= 20000.0) tmp = fma(Float64(J + J), l, U); else tmp = Float64(fma(2.0, l, Float64(U / J)) * J); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -500000.0], N[(N[(N[(l * J), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision], If[LessEqual[t$95$0, 20000.0], N[(N[(J + J), $MachinePrecision] * l + U), $MachinePrecision], N[(N[(2.0 * l + N[(U / J), $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq -500000:\\
\;\;\;\;\left(\left(\ell \cdot J\right) \cdot \mathsf{fma}\left(K \cdot K, -0.125, 1\right)\right) \cdot 2\\
\mathbf{elif}\;t\_0 \leq 20000:\\
\;\;\;\;\mathsf{fma}\left(J + J, \ell, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(2, \ell, \frac{U}{J}\right) \cdot J\\
\end{array}
\end{array}
if (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) < -5e5Initial program 99.4%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6421.8
Applied rewrites21.8%
Taylor expanded in J around inf
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f6422.1
Applied rewrites22.1%
Taylor expanded in K around 0
*-commutativeN/A
pow2N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f6430.0
Applied rewrites30.0%
if -5e5 < (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) < 2e4Initial program 76.2%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6499.2
Applied rewrites99.2%
Taylor expanded in K around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lift-*.f6489.5
Applied rewrites89.5%
lift-*.f64N/A
count-2-revN/A
lower-+.f6489.5
Applied rewrites89.5%
if 2e4 < (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) Initial program 98.1%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6432.7
Applied rewrites32.7%
Taylor expanded in K around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lift-*.f6422.8
Applied rewrites22.8%
Taylor expanded in J around inf
*-commutativeN/A
lower-*.f64N/A
lower-fma.f64N/A
lower-/.f6437.9
Applied rewrites37.9%
(FPCore (J l K U) :precision binary64 (if (<= (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) 0.0) (fma (+ J J) l U) (* (fma 2.0 l (/ U J)) J)))
double code(double J, double l, double K, double U) {
double tmp;
if (((J * (exp(l) - exp(-l))) * cos((K / 2.0))) <= 0.0) {
tmp = fma((J + J), l, U);
} else {
tmp = fma(2.0, l, (U / J)) * J;
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) <= 0.0) tmp = fma(Float64(J + J), l, U); else tmp = Float64(fma(2.0, l, Float64(U / J)) * J); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 0.0], N[(N[(J + J), $MachinePrecision] * l + U), $MachinePrecision], N[(N[(2.0 * l + N[(U / J), $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) \leq 0:\\
\;\;\;\;\mathsf{fma}\left(J + J, \ell, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(2, \ell, \frac{U}{J}\right) \cdot J\\
\end{array}
\end{array}
if (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) < 0.0Initial program 85.3%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6468.9
Applied rewrites68.9%
Taylor expanded in K around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lift-*.f6460.9
Applied rewrites60.9%
lift-*.f64N/A
count-2-revN/A
lower-+.f6460.9
Applied rewrites60.9%
if 0.0 < (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) Initial program 98.1%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6432.5
Applied rewrites32.5%
Taylor expanded in K around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lift-*.f6422.7
Applied rewrites22.7%
Taylor expanded in J around inf
*-commutativeN/A
lower-*.f64N/A
lower-fma.f64N/A
lower-/.f6437.7
Applied rewrites37.7%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) 0.9372)
(fma
J
(*
(*
(fma (fma (* l l) 0.016666666666666666 0.3333333333333333) (* l l) 2.0)
l)
(cos (* 0.5 K)))
U)
(fma (* 2.0 (sinh l)) J U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.9372) {
tmp = fma(J, ((fma(fma((l * l), 0.016666666666666666, 0.3333333333333333), (l * l), 2.0) * l) * cos((0.5 * K))), U);
} else {
tmp = fma((2.0 * sinh(l)), J, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.9372) tmp = fma(J, Float64(Float64(fma(fma(Float64(l * l), 0.016666666666666666, 0.3333333333333333), Float64(l * l), 2.0) * l) * cos(Float64(0.5 * K))), U); else tmp = fma(Float64(2.0 * sinh(l)), J, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.9372], N[(J * N[(N[(N[(N[(N[(l * l), $MachinePrecision] * 0.016666666666666666 + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision] * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.9372:\\
\;\;\;\;\mathsf{fma}\left(J, \left(\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.016666666666666666, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right) \cdot \cos \left(0.5 \cdot K\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(2 \cdot \sinh \ell, J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.93720000000000003Initial program 89.7%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites92.7%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-cos.f64N/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites92.8%
Taylor expanded in K around inf
lift-cos.f64N/A
lift-*.f6492.8
Applied rewrites92.8%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6492.0
Applied rewrites92.0%
if 0.93720000000000003 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 88.5%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sinh-undefN/A
lower-*.f64N/A
lower-sinh.f64100.0
Applied rewrites100.0%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.302) (fma J (* (* (fma (* l l) 0.3333333333333333 2.0) l) (cos (* 0.5 K))) U) (fma (* 2.0 (sinh l)) J U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.302) {
tmp = fma(J, ((fma((l * l), 0.3333333333333333, 2.0) * l) * cos((0.5 * K))), U);
} else {
tmp = fma((2.0 * sinh(l)), J, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.302) tmp = fma(J, Float64(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l) * cos(Float64(0.5 * K))), U); else tmp = fma(Float64(2.0 * sinh(l)), J, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.302], N[(J * N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.302:\\
\;\;\;\;\mathsf{fma}\left(J, \left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot \cos \left(0.5 \cdot K\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(2 \cdot \sinh \ell, J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.301999999999999991Initial program 88.3%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites91.6%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-cos.f64N/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites91.7%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6484.5
Applied rewrites84.5%
Taylor expanded in K around 0
lift-*.f6484.5
Applied rewrites84.5%
if 0.301999999999999991 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 89.4%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sinh-undefN/A
lower-*.f64N/A
lower-sinh.f6498.7
Applied rewrites98.7%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) -0.005)
(+
(* (* (* (* 0.3333333333333333 J) (* l l)) l) (fma (* K K) -0.125 1.0))
U)
(fma (* 2.0 (sinh l)) J U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.005) {
tmp = ((((0.3333333333333333 * J) * (l * l)) * l) * fma((K * K), -0.125, 1.0)) + U;
} else {
tmp = fma((2.0 * sinh(l)), J, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.005) tmp = Float64(Float64(Float64(Float64(Float64(0.3333333333333333 * J) * Float64(l * l)) * l) * fma(Float64(K * K), -0.125, 1.0)) + U); else tmp = fma(Float64(2.0 * sinh(l)), J, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.005], N[(N[(N[(N[(N[(0.3333333333333333 * J), $MachinePrecision] * N[(l * l), $MachinePrecision]), $MachinePrecision] * l), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.005:\\
\;\;\;\;\left(\left(\left(0.3333333333333333 \cdot J\right) \cdot \left(\ell \cdot \ell\right)\right) \cdot \ell\right) \cdot \mathsf{fma}\left(K \cdot K, -0.125, 1\right) + U\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(2 \cdot \sinh \ell, J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0050000000000000001Initial program 90.1%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6479.4
Applied rewrites79.4%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6463.0
Applied rewrites63.0%
Taylor expanded in l around inf
associate-*r*N/A
lower-*.f64N/A
lift-*.f64N/A
pow2N/A
lift-*.f6470.1
Applied rewrites70.1%
if -0.0050000000000000001 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 88.7%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sinh-undefN/A
lower-*.f64N/A
lower-sinh.f6497.5
Applied rewrites97.5%
Final simplification90.5%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (* 0.5 K))))
(if (<= l 1.7e-27)
(fma
J
(*
(*
(fma
(fma (* (* l l) 0.0003968253968253968) (* l l) 0.3333333333333333)
(* l l)
2.0)
l)
t_0)
U)
(* (* t_0 J) (* 2.0 (sinh l))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((0.5 * K));
double tmp;
if (l <= 1.7e-27) {
tmp = fma(J, ((fma(fma(((l * l) * 0.0003968253968253968), (l * l), 0.3333333333333333), (l * l), 2.0) * l) * t_0), U);
} else {
tmp = (t_0 * J) * (2.0 * sinh(l));
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(0.5 * K)) tmp = 0.0 if (l <= 1.7e-27) tmp = fma(J, Float64(Float64(fma(fma(Float64(Float64(l * l) * 0.0003968253968253968), Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l) * t_0), U); else tmp = Float64(Float64(t_0 * J) * Float64(2.0 * sinh(l))); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, 1.7e-27], N[(J * N[(N[(N[(N[(N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968), $MachinePrecision] * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(N[(t$95$0 * J), $MachinePrecision] * N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(0.5 \cdot K\right)\\
\mathbf{if}\;\ell \leq 1.7 \cdot 10^{-27}:\\
\;\;\;\;\mathsf{fma}\left(J, \left(\mathsf{fma}\left(\mathsf{fma}\left(\left(\ell \cdot \ell\right) \cdot 0.0003968253968253968, \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right) \cdot t\_0, U\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t\_0 \cdot J\right) \cdot \left(2 \cdot \sinh \ell\right)\\
\end{array}
\end{array}
if l < 1.69999999999999985e-27Initial program 85.3%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.3%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-cos.f64N/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites98.3%
Taylor expanded in K around inf
lift-cos.f64N/A
lift-*.f6498.3
Applied rewrites98.3%
Taylor expanded in l around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6498.3
Applied rewrites98.3%
if 1.69999999999999985e-27 < l Initial program 97.2%
Taylor expanded in J around inf
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
sinh-undefN/A
lower-*.f64N/A
lower-sinh.f6498.7
Applied rewrites98.7%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) -0.005)
(+
(* (* (* (* 0.3333333333333333 J) (* l l)) l) (fma (* K K) -0.125 1.0))
U)
(fma
J
(*
(*
(fma
(fma
(fma (* l l) 0.0003968253968253968 0.016666666666666666)
(* l l)
0.3333333333333333)
(* l l)
2.0)
l)
1.0)
U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.005) {
tmp = ((((0.3333333333333333 * J) * (l * l)) * l) * fma((K * K), -0.125, 1.0)) + U;
} else {
tmp = fma(J, ((fma(fma(fma((l * l), 0.0003968253968253968, 0.016666666666666666), (l * l), 0.3333333333333333), (l * l), 2.0) * l) * 1.0), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.005) tmp = Float64(Float64(Float64(Float64(Float64(0.3333333333333333 * J) * Float64(l * l)) * l) * fma(Float64(K * K), -0.125, 1.0)) + U); else tmp = fma(J, Float64(Float64(fma(fma(fma(Float64(l * l), 0.0003968253968253968, 0.016666666666666666), Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l) * 1.0), U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.005], N[(N[(N[(N[(N[(0.3333333333333333 * J), $MachinePrecision] * N[(l * l), $MachinePrecision]), $MachinePrecision] * l), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(J * N[(N[(N[(N[(N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968 + 0.016666666666666666), $MachinePrecision] * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision] * 1.0), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.005:\\
\;\;\;\;\left(\left(\left(0.3333333333333333 \cdot J\right) \cdot \left(\ell \cdot \ell\right)\right) \cdot \ell\right) \cdot \mathsf{fma}\left(K \cdot K, -0.125, 1\right) + U\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J, \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right) \cdot 1, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0050000000000000001Initial program 90.1%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6479.4
Applied rewrites79.4%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6463.0
Applied rewrites63.0%
Taylor expanded in l around inf
associate-*r*N/A
lower-*.f64N/A
lift-*.f64N/A
pow2N/A
lift-*.f6470.1
Applied rewrites70.1%
if -0.0050000000000000001 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 88.7%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites95.1%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-cos.f64N/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites95.1%
Taylor expanded in K around 0
Applied rewrites92.6%
Final simplification86.9%
(FPCore (J l K U)
:precision binary64
(if (<= K 5.5e-8)
(fma (* 2.0 (sinh l)) J U)
(fma
J
(*
(*
(fma
(fma
(fma (* l l) 0.0003968253968253968 0.016666666666666666)
(* l l)
0.3333333333333333)
(* l l)
2.0)
l)
(cos (* 0.5 K)))
U)))
double code(double J, double l, double K, double U) {
double tmp;
if (K <= 5.5e-8) {
tmp = fma((2.0 * sinh(l)), J, U);
} else {
tmp = fma(J, ((fma(fma(fma((l * l), 0.0003968253968253968, 0.016666666666666666), (l * l), 0.3333333333333333), (l * l), 2.0) * l) * cos((0.5 * K))), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (K <= 5.5e-8) tmp = fma(Float64(2.0 * sinh(l)), J, U); else tmp = fma(J, Float64(Float64(fma(fma(fma(Float64(l * l), 0.0003968253968253968, 0.016666666666666666), Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l) * cos(Float64(0.5 * K))), U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[K, 5.5e-8], N[(N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], N[(J * N[(N[(N[(N[(N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968 + 0.016666666666666666), $MachinePrecision] * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision] * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;K \leq 5.5 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(2 \cdot \sinh \ell, J, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J, \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right) \cdot \cos \left(0.5 \cdot K\right), U\right)\\
\end{array}
\end{array}
if K < 5.5000000000000003e-8Initial program 89.2%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sinh-undefN/A
lower-*.f64N/A
lower-sinh.f6491.3
Applied rewrites91.3%
if 5.5000000000000003e-8 < K Initial program 88.6%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites90.9%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-cos.f64N/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites90.9%
Taylor expanded in K around inf
lift-cos.f64N/A
lift-*.f6490.9
Applied rewrites90.9%
(FPCore (J l K U)
:precision binary64
(if (<= K 5.5e-8)
(fma (* 2.0 (sinh l)) J U)
(fma
J
(*
(*
(fma
(fma (* (* l l) 0.0003968253968253968) (* l l) 0.3333333333333333)
(* l l)
2.0)
l)
(cos (* 0.5 K)))
U)))
double code(double J, double l, double K, double U) {
double tmp;
if (K <= 5.5e-8) {
tmp = fma((2.0 * sinh(l)), J, U);
} else {
tmp = fma(J, ((fma(fma(((l * l) * 0.0003968253968253968), (l * l), 0.3333333333333333), (l * l), 2.0) * l) * cos((0.5 * K))), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (K <= 5.5e-8) tmp = fma(Float64(2.0 * sinh(l)), J, U); else tmp = fma(J, Float64(Float64(fma(fma(Float64(Float64(l * l) * 0.0003968253968253968), Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l) * cos(Float64(0.5 * K))), U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[K, 5.5e-8], N[(N[(2.0 * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], N[(J * N[(N[(N[(N[(N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968), $MachinePrecision] * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision] * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;K \leq 5.5 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(2 \cdot \sinh \ell, J, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J, \left(\mathsf{fma}\left(\mathsf{fma}\left(\left(\ell \cdot \ell\right) \cdot 0.0003968253968253968, \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right) \cdot \cos \left(0.5 \cdot K\right), U\right)\\
\end{array}
\end{array}
if K < 5.5000000000000003e-8Initial program 89.2%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sinh-undefN/A
lower-*.f64N/A
lower-sinh.f6491.3
Applied rewrites91.3%
if 5.5000000000000003e-8 < K Initial program 88.6%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites90.9%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-cos.f64N/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites90.9%
Taylor expanded in K around inf
lift-cos.f64N/A
lift-*.f6490.9
Applied rewrites90.9%
Taylor expanded in l around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6490.9
Applied rewrites90.9%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) -0.005)
(+
(* (* (* (* 0.3333333333333333 J) (* l l)) l) (fma (* K K) -0.125 1.0))
U)
(+ (* (* (* (fma (* l l) 0.3333333333333333 2.0) l) J) 1.0) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.005) {
tmp = ((((0.3333333333333333 * J) * (l * l)) * l) * fma((K * K), -0.125, 1.0)) + U;
} else {
tmp = (((fma((l * l), 0.3333333333333333, 2.0) * l) * J) * 1.0) + U;
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.005) tmp = Float64(Float64(Float64(Float64(Float64(0.3333333333333333 * J) * Float64(l * l)) * l) * fma(Float64(K * K), -0.125, 1.0)) + U); else tmp = Float64(Float64(Float64(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l) * J) * 1.0) + U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.005], N[(N[(N[(N[(N[(0.3333333333333333 * J), $MachinePrecision] * N[(l * l), $MachinePrecision]), $MachinePrecision] * l), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] * 1.0), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.005:\\
\;\;\;\;\left(\left(\left(0.3333333333333333 \cdot J\right) \cdot \left(\ell \cdot \ell\right)\right) \cdot \ell\right) \cdot \mathsf{fma}\left(K \cdot K, -0.125, 1\right) + U\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\right) \cdot 1 + U\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0050000000000000001Initial program 90.1%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6479.4
Applied rewrites79.4%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6463.0
Applied rewrites63.0%
Taylor expanded in l around inf
associate-*r*N/A
lower-*.f64N/A
lift-*.f64N/A
pow2N/A
lift-*.f6470.1
Applied rewrites70.1%
if -0.0050000000000000001 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 88.7%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6483.0
Applied rewrites83.0%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6456.8
Applied rewrites56.8%
Taylor expanded in K around 0
Applied rewrites80.5%
Taylor expanded in J around 0
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
Applied rewrites84.9%
Final simplification81.2%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.005) (fma (* (* l J) (fma (* K K) -0.125 1.0)) 2.0 U) (+ (* (* (* (fma (* l l) 0.3333333333333333 2.0) l) J) 1.0) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.005) {
tmp = fma(((l * J) * fma((K * K), -0.125, 1.0)), 2.0, U);
} else {
tmp = (((fma((l * l), 0.3333333333333333, 2.0) * l) * J) * 1.0) + U;
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.005) tmp = fma(Float64(Float64(l * J) * fma(Float64(K * K), -0.125, 1.0)), 2.0, U); else tmp = Float64(Float64(Float64(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l) * J) * 1.0) + U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.005], N[(N[(N[(l * J), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision]), $MachinePrecision] * 2.0 + U), $MachinePrecision], N[(N[(N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] * 1.0), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.005:\\
\;\;\;\;\mathsf{fma}\left(\left(\ell \cdot J\right) \cdot \mathsf{fma}\left(K \cdot K, -0.125, 1\right), 2, U\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\right) \cdot 1 + U\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0050000000000000001Initial program 90.1%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6456.3
Applied rewrites56.3%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6451.5
Applied rewrites51.5%
if -0.0050000000000000001 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 88.7%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6483.0
Applied rewrites83.0%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6456.8
Applied rewrites56.8%
Taylor expanded in K around 0
Applied rewrites80.5%
Taylor expanded in J around 0
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
Applied rewrites84.9%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.005) (fma (* (* l J) (fma (* K K) -0.125 1.0)) 2.0 U) (* (fma (/ (* l J) U) 2.0 1.0) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.005) {
tmp = fma(((l * J) * fma((K * K), -0.125, 1.0)), 2.0, U);
} else {
tmp = fma(((l * J) / U), 2.0, 1.0) * U;
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.005) tmp = fma(Float64(Float64(l * J) * fma(Float64(K * K), -0.125, 1.0)), 2.0, U); else tmp = Float64(fma(Float64(Float64(l * J) / U), 2.0, 1.0) * U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.005], N[(N[(N[(l * J), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision]), $MachinePrecision] * 2.0 + U), $MachinePrecision], N[(N[(N[(N[(l * J), $MachinePrecision] / U), $MachinePrecision] * 2.0 + 1.0), $MachinePrecision] * U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.005:\\
\;\;\;\;\mathsf{fma}\left(\left(\ell \cdot J\right) \cdot \mathsf{fma}\left(K \cdot K, -0.125, 1\right), 2, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\ell \cdot J}{U}, 2, 1\right) \cdot U\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0050000000000000001Initial program 90.1%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6456.3
Applied rewrites56.3%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6451.5
Applied rewrites51.5%
if -0.0050000000000000001 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 88.7%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6458.9
Applied rewrites58.9%
Taylor expanded in K around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lift-*.f6456.4
Applied rewrites56.4%
Taylor expanded in U around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lift-*.f6459.2
Applied rewrites59.2%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (+ (* (* (* (* (* l l) J) 0.3333333333333333) l) 1.0) U)))
(if (<= l -1.2e+15)
t_0
(if (<= l 1150000000000.0)
(fma (+ J J) l U)
(if (<= l 7.8e+77) (* (* (* l J) (fma (* K K) -0.125 1.0)) 2.0) t_0)))))
double code(double J, double l, double K, double U) {
double t_0 = (((((l * l) * J) * 0.3333333333333333) * l) * 1.0) + U;
double tmp;
if (l <= -1.2e+15) {
tmp = t_0;
} else if (l <= 1150000000000.0) {
tmp = fma((J + J), l, U);
} else if (l <= 7.8e+77) {
tmp = ((l * J) * fma((K * K), -0.125, 1.0)) * 2.0;
} else {
tmp = t_0;
}
return tmp;
}
function code(J, l, K, U) t_0 = Float64(Float64(Float64(Float64(Float64(Float64(l * l) * J) * 0.3333333333333333) * l) * 1.0) + U) tmp = 0.0 if (l <= -1.2e+15) tmp = t_0; elseif (l <= 1150000000000.0) tmp = fma(Float64(J + J), l, U); elseif (l <= 7.8e+77) tmp = Float64(Float64(Float64(l * J) * fma(Float64(K * K), -0.125, 1.0)) * 2.0); else tmp = t_0; end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(N[(N[(N[(N[(l * l), $MachinePrecision] * J), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] * l), $MachinePrecision] * 1.0), $MachinePrecision] + U), $MachinePrecision]}, If[LessEqual[l, -1.2e+15], t$95$0, If[LessEqual[l, 1150000000000.0], N[(N[(J + J), $MachinePrecision] * l + U), $MachinePrecision], If[LessEqual[l, 7.8e+77], N[(N[(N[(l * J), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(\left(\left(\ell \cdot \ell\right) \cdot J\right) \cdot 0.3333333333333333\right) \cdot \ell\right) \cdot 1 + U\\
\mathbf{if}\;\ell \leq -1.2 \cdot 10^{+15}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq 1150000000000:\\
\;\;\;\;\mathsf{fma}\left(J + J, \ell, U\right)\\
\mathbf{elif}\;\ell \leq 7.8 \cdot 10^{+77}:\\
\;\;\;\;\left(\left(\ell \cdot J\right) \cdot \mathsf{fma}\left(K \cdot K, -0.125, 1\right)\right) \cdot 2\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if l < -1.2e15 or 7.7999999999999995e77 < l Initial program 100.0%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6480.4
Applied rewrites80.4%
Taylor expanded in K around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6457.3
Applied rewrites57.3%
Taylor expanded in K around 0
Applied rewrites59.6%
Taylor expanded in l around inf
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
pow2N/A
lift-*.f64N/A
lift-*.f6459.6
Applied rewrites59.6%
if -1.2e15 < l < 1.15e12Initial program 77.0%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6492.9
Applied rewrites92.9%
Taylor expanded in K around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lift-*.f6483.3
Applied rewrites83.3%
lift-*.f64N/A
count-2-revN/A
lower-+.f6483.3
Applied rewrites83.3%
if 1.15e12 < l < 7.7999999999999995e77Initial program 100.0%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6413.5
Applied rewrites13.5%
Taylor expanded in J around inf
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f6414.1
Applied rewrites14.1%
Taylor expanded in K around 0
*-commutativeN/A
pow2N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f6435.5
Applied rewrites35.5%
(FPCore (J l K U) :precision binary64 (fma (+ J J) l U))
double code(double J, double l, double K, double U) {
return fma((J + J), l, U);
}
function code(J, l, K, U) return fma(Float64(J + J), l, U) end
code[J_, l_, K_, U_] := N[(N[(J + J), $MachinePrecision] * l + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(J + J, \ell, U\right)
\end{array}
Initial program 89.0%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6458.2
Applied rewrites58.2%
Taylor expanded in K around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lift-*.f6449.7
Applied rewrites49.7%
lift-*.f64N/A
count-2-revN/A
lower-+.f6449.7
Applied rewrites49.7%
(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 89.0%
Taylor expanded in J around 0
Applied rewrites33.7%
herbie shell --seed 2025051
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))