
(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 18 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (J l K U) :precision binary64 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
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 (fma (* (+ J J) (sinh l)) (cos (* -0.5 K)) U))
double code(double J, double l, double K, double U) {
return fma(((J + J) * sinh(l)), cos((-0.5 * K)), U);
}
function code(J, l, K, U) return fma(Float64(Float64(J + J) * sinh(l)), cos(Float64(-0.5 * K)), U) end
code[J_, l_, K_, U_] := N[(N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\left(J + J\right) \cdot \sinh \ell, \cos \left(-0.5 \cdot K\right), U\right)
\end{array}
Initial program 87.1%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6487.1
lift-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sinh.f64100.0
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lower-/.f64N/A
metadata-eval100.0
Applied rewrites100.0%
Taylor expanded in K around inf
Applied rewrites100.0%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64100.0
Applied rewrites100.0%
(FPCore (J l K U) :precision binary64 (let* ((t_0 (* J (- (exp l) (exp (- l)))))) (if (or (<= t_0 -2e+21) (not (<= t_0 1e+79))) (* (* l J) 2.0) U)))
double code(double J, double l, double K, double U) {
double t_0 = J * (exp(l) - exp(-l));
double tmp;
if ((t_0 <= -2e+21) || !(t_0 <= 1e+79)) {
tmp = (l * J) * 2.0;
} else {
tmp = U;
}
return tmp;
}
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
real(8) :: t_0
real(8) :: tmp
t_0 = j * (exp(l) - exp(-l))
if ((t_0 <= (-2d+21)) .or. (.not. (t_0 <= 1d+79))) then
tmp = (l * j) * 2.0d0
else
tmp = u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = J * (Math.exp(l) - Math.exp(-l));
double tmp;
if ((t_0 <= -2e+21) || !(t_0 <= 1e+79)) {
tmp = (l * J) * 2.0;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): t_0 = J * (math.exp(l) - math.exp(-l)) tmp = 0 if (t_0 <= -2e+21) or not (t_0 <= 1e+79): tmp = (l * J) * 2.0 else: tmp = U return tmp
function code(J, l, K, U) t_0 = Float64(J * Float64(exp(l) - exp(Float64(-l)))) tmp = 0.0 if ((t_0 <= -2e+21) || !(t_0 <= 1e+79)) tmp = Float64(Float64(l * J) * 2.0); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = J * (exp(l) - exp(-l)); tmp = 0.0; if ((t_0 <= -2e+21) || ~((t_0 <= 1e+79))) tmp = (l * J) * 2.0; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -2e+21], N[Not[LessEqual[t$95$0, 1e+79]], $MachinePrecision]], N[(N[(l * J), $MachinePrecision] * 2.0), $MachinePrecision], U]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := J \cdot \left(e^{\ell} - e^{-\ell}\right)\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{+21} \lor \neg \left(t\_0 \leq 10^{+79}\right):\\
\;\;\;\;\left(\ell \cdot J\right) \cdot 2\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < -2e21 or 9.99999999999999967e78 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) Initial program 98.8%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6498.8
lift-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sinh.f64100.0
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lower-/.f64N/A
metadata-eval100.0
Applied rewrites100.0%
Taylor expanded in l around 0
Applied rewrites32.2%
Taylor expanded in K around 0
Applied rewrites23.4%
Taylor expanded in J around inf
Applied rewrites23.3%
if -2e21 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < 9.99999999999999967e78Initial program 75.0%
Taylor expanded in J around 0
Applied rewrites74.3%
Final simplification48.4%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 -0.84)
(fma (* (* J 2.0) (sinh l)) (fma (* K K) -0.125 1.0) U)
(if (<= t_0 -0.03)
(fma (* (+ J J) l) (cos (* -0.5 K)) U)
(fma (* (+ J J) (sinh l)) 1.0 U)))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double tmp;
if (t_0 <= -0.84) {
tmp = fma(((J * 2.0) * sinh(l)), fma((K * K), -0.125, 1.0), U);
} else if (t_0 <= -0.03) {
tmp = fma(((J + J) * l), cos((-0.5 * K)), U);
} else {
tmp = fma(((J + J) * sinh(l)), 1.0, U);
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= -0.84) tmp = fma(Float64(Float64(J * 2.0) * sinh(l)), fma(Float64(K * K), -0.125, 1.0), U); elseif (t_0 <= -0.03) tmp = fma(Float64(Float64(J + J) * l), cos(Float64(-0.5 * K)), U); else tmp = fma(Float64(Float64(J + J) * sinh(l)), 1.0, 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.84], N[(N[(N[(J * 2.0), $MachinePrecision] * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[t$95$0, -0.03], N[(N[(N[(J + J), $MachinePrecision] * l), $MachinePrecision] * N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * 1.0 + U), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq -0.84:\\
\;\;\;\;\mathsf{fma}\left(\left(J \cdot 2\right) \cdot \sinh \ell, \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right)\\
\mathbf{elif}\;t\_0 \leq -0.03:\\
\;\;\;\;\mathsf{fma}\left(\left(J + J\right) \cdot \ell, \cos \left(-0.5 \cdot K\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(J + J\right) \cdot \sinh \ell, 1, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.839999999999999969Initial program 96.6%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6496.6
lift-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sinh.f64100.0
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lower-/.f64N/A
metadata-eval100.0
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites71.9%
if -0.839999999999999969 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.029999999999999999Initial program 86.9%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6486.9
lift-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sinh.f6499.9
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lower-/.f64N/A
metadata-eval99.9
Applied rewrites99.9%
Taylor expanded in K around inf
Applied rewrites99.9%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in l around 0
Applied rewrites72.4%
if -0.029999999999999999 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.8%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6485.8
lift-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sinh.f64100.0
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lower-/.f64N/A
metadata-eval100.0
Applied rewrites100.0%
Taylor expanded in K around inf
Applied rewrites100.0%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64100.0
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.845)
(+
(*
(*
J
(*
(fma
(fma 0.016666666666666666 (* l l) 0.3333333333333333)
(* l l)
2.0)
l))
t_0)
U)
(fma (* (+ J J) (sinh l)) 1.0 U))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double tmp;
if (t_0 <= 0.845) {
tmp = ((J * (fma(fma(0.016666666666666666, (l * l), 0.3333333333333333), (l * l), 2.0) * l)) * t_0) + U;
} else {
tmp = fma(((J + J) * sinh(l)), 1.0, U);
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= 0.845) 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(Float64(J + J) * sinh(l)), 1.0, 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.845], N[(N[(N[(J * N[(N[(N[(0.016666666666666666 * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * 1.0 + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq 0.845:\\
\;\;\;\;\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(\left(J + J\right) \cdot \sinh \ell, 1, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.84499999999999997Initial program 89.4%
Taylor expanded in l around 0
Applied rewrites93.6%
if 0.84499999999999997 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.7%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6485.7
lift-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sinh.f64100.0
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lower-/.f64N/A
metadata-eval100.0
Applied rewrites100.0%
Taylor expanded in K around inf
Applied rewrites100.0%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites98.4%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) 0.845)
(fma
(*
(+ J J)
(*
(fma (fma 0.008333333333333333 (* l l) 0.16666666666666666) (* l l) 1.0)
l))
(cos (* -0.5 K))
U)
(fma (* (+ J J) (sinh l)) 1.0 U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.845) {
tmp = fma(((J + J) * (fma(fma(0.008333333333333333, (l * l), 0.16666666666666666), (l * l), 1.0) * l)), cos((-0.5 * K)), U);
} else {
tmp = fma(((J + J) * sinh(l)), 1.0, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.845) tmp = fma(Float64(Float64(J + J) * Float64(fma(fma(0.008333333333333333, Float64(l * l), 0.16666666666666666), Float64(l * l), 1.0) * l)), cos(Float64(-0.5 * K)), U); else tmp = fma(Float64(Float64(J + J) * sinh(l)), 1.0, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.845], N[(N[(N[(J + J), $MachinePrecision] * N[(N[(N[(0.008333333333333333 * N[(l * l), $MachinePrecision] + 0.16666666666666666), $MachinePrecision] * N[(l * l), $MachinePrecision] + 1.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * 1.0 + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.845:\\
\;\;\;\;\mathsf{fma}\left(\left(J + J\right) \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(0.008333333333333333, \ell \cdot \ell, 0.16666666666666666\right), \ell \cdot \ell, 1\right) \cdot \ell\right), \cos \left(-0.5 \cdot K\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(J + J\right) \cdot \sinh \ell, 1, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.84499999999999997Initial program 89.4%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6489.4
lift-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sinh.f6499.9
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lower-/.f64N/A
metadata-eval99.9
Applied rewrites99.9%
Taylor expanded in K around inf
Applied rewrites99.9%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in l around 0
Applied rewrites93.6%
if 0.84499999999999997 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.7%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6485.7
lift-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sinh.f64100.0
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lower-/.f64N/A
metadata-eval100.0
Applied rewrites100.0%
Taylor expanded in K around inf
Applied rewrites100.0%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites98.4%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 0.48)
(+ (* (* J (* (fma (* l l) 0.3333333333333333 2.0) l)) t_0) U)
(fma (* (+ J J) (sinh l)) 1.0 U))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double tmp;
if (t_0 <= 0.48) {
tmp = ((J * (fma((l * l), 0.3333333333333333, 2.0) * l)) * t_0) + U;
} else {
tmp = fma(((J + J) * sinh(l)), 1.0, U);
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= 0.48) tmp = Float64(Float64(Float64(J * Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l)) * t_0) + U); else tmp = fma(Float64(Float64(J + J) * sinh(l)), 1.0, 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.48], N[(N[(N[(J * N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * 1.0 + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq 0.48:\\
\;\;\;\;\left(J \cdot \left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right)\right) \cdot t\_0 + U\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(J + J\right) \cdot \sinh \ell, 1, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.47999999999999998Initial program 89.5%
Taylor expanded in l around 0
Applied rewrites92.2%
if 0.47999999999999998 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 86.0%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6486.0
lift-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sinh.f64100.0
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lower-/.f64N/A
metadata-eval100.0
Applied rewrites100.0%
Taylor expanded in K around inf
Applied rewrites100.0%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites97.7%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.48) (fma (* (cos (* -0.5 K)) (* J (fma (* l l) 0.3333333333333333 2.0))) l U) (fma (* (+ J J) (sinh l)) 1.0 U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.48) {
tmp = fma((cos((-0.5 * K)) * (J * fma((l * l), 0.3333333333333333, 2.0))), l, U);
} else {
tmp = fma(((J + J) * sinh(l)), 1.0, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.48) tmp = fma(Float64(cos(Float64(-0.5 * K)) * Float64(J * fma(Float64(l * l), 0.3333333333333333, 2.0))), l, U); else tmp = fma(Float64(Float64(J + J) * sinh(l)), 1.0, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.48], 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[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * 1.0 + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.48:\\
\;\;\;\;\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(\left(J + J\right) \cdot \sinh \ell, 1, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.47999999999999998Initial program 89.5%
Taylor expanded in l around 0
Applied rewrites91.0%
if 0.47999999999999998 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 86.0%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6486.0
lift-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sinh.f64100.0
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lower-/.f64N/A
metadata-eval100.0
Applied rewrites100.0%
Taylor expanded in K around inf
Applied rewrites100.0%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites97.7%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.03) (fma (* (+ J J) l) (cos (* -0.5 K)) U) (fma (* (+ J J) (sinh l)) 1.0 U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.03) {
tmp = fma(((J + J) * l), cos((-0.5 * K)), U);
} else {
tmp = fma(((J + J) * sinh(l)), 1.0, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.03) tmp = fma(Float64(Float64(J + J) * l), cos(Float64(-0.5 * K)), U); else tmp = fma(Float64(Float64(J + J) * sinh(l)), 1.0, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.03], N[(N[(N[(J + J), $MachinePrecision] * l), $MachinePrecision] * N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * 1.0 + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.03:\\
\;\;\;\;\mathsf{fma}\left(\left(J + J\right) \cdot \ell, \cos \left(-0.5 \cdot K\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(J + J\right) \cdot \sinh \ell, 1, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.029999999999999999Initial program 91.3%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6491.3
lift-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sinh.f6499.9
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lower-/.f64N/A
metadata-eval99.9
Applied rewrites99.9%
Taylor expanded in K around inf
Applied rewrites99.9%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in l around 0
Applied rewrites64.9%
if -0.029999999999999999 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.8%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6485.8
lift-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sinh.f64100.0
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lower-/.f64N/A
metadata-eval100.0
Applied rewrites100.0%
Taylor expanded in K around inf
Applied rewrites100.0%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites96.2%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) -0.03)
(fma
(* (fma (* K K) -0.125 1.0) (* J (fma (* l l) 0.3333333333333333 2.0)))
l
U)
(fma (* (+ J J) (sinh l)) 1.0 U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.03) {
tmp = fma((fma((K * K), -0.125, 1.0) * (J * fma((l * l), 0.3333333333333333, 2.0))), l, U);
} else {
tmp = fma(((J + J) * sinh(l)), 1.0, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.03) tmp = fma(Float64(fma(Float64(K * K), -0.125, 1.0) * Float64(J * fma(Float64(l * l), 0.3333333333333333, 2.0))), l, U); else tmp = fma(Float64(Float64(J + J) * sinh(l)), 1.0, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.03], N[(N[(N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] * N[(J * N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * l + U), $MachinePrecision], N[(N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * 1.0 + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.03:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right) \cdot \left(J \cdot \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\right), \ell, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(J + J\right) \cdot \sinh \ell, 1, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.029999999999999999Initial program 91.3%
Taylor expanded in l around 0
Applied rewrites91.2%
Taylor expanded in K around 0
Applied rewrites64.1%
if -0.029999999999999999 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.8%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6485.8
lift-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sinh.f64100.0
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lower-/.f64N/A
metadata-eval100.0
Applied rewrites100.0%
Taylor expanded in K around inf
Applied rewrites100.0%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites96.2%
(FPCore (J l K U)
:precision binary64
(+
(*
(*
J
(*
(fma
(fma
(fma 0.0003968253968253968 (* l l) 0.016666666666666666)
(* l l)
0.3333333333333333)
(* l l)
2.0)
l))
(cos (/ K 2.0)))
U))
double code(double J, double l, double K, double U) {
return ((J * (fma(fma(fma(0.0003968253968253968, (l * l), 0.016666666666666666), (l * l), 0.3333333333333333), (l * l), 2.0) * l)) * cos((K / 2.0))) + U;
}
function code(J, l, K, U) return 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)) * cos(Float64(K / 2.0))) + U) end
code[J_, l_, K_, U_] := 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] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\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 \cos \left(\frac{K}{2}\right) + U
\end{array}
Initial program 87.1%
Taylor expanded in l around 0
Applied rewrites96.9%
(FPCore (J l K U)
:precision binary64
(fma
(*
(+ J J)
(*
(fma
(fma
(fma 0.0001984126984126984 (* l l) 0.008333333333333333)
(* l l)
0.16666666666666666)
(* l l)
1.0)
l))
(cos (* -0.5 K))
U))
double code(double J, double l, double K, double U) {
return fma(((J + J) * (fma(fma(fma(0.0001984126984126984, (l * l), 0.008333333333333333), (l * l), 0.16666666666666666), (l * l), 1.0) * l)), cos((-0.5 * K)), U);
}
function code(J, l, K, U) return fma(Float64(Float64(J + J) * Float64(fma(fma(fma(0.0001984126984126984, Float64(l * l), 0.008333333333333333), Float64(l * l), 0.16666666666666666), Float64(l * l), 1.0) * l)), cos(Float64(-0.5 * K)), U) end
code[J_, l_, K_, U_] := N[(N[(N[(J + J), $MachinePrecision] * N[(N[(N[(N[(0.0001984126984126984 * N[(l * l), $MachinePrecision] + 0.008333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 0.16666666666666666), $MachinePrecision] * N[(l * l), $MachinePrecision] + 1.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\left(J + J\right) \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0001984126984126984, \ell \cdot \ell, 0.008333333333333333\right), \ell \cdot \ell, 0.16666666666666666\right), \ell \cdot \ell, 1\right) \cdot \ell\right), \cos \left(-0.5 \cdot K\right), U\right)
\end{array}
Initial program 87.1%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6487.1
lift-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sinh.f64100.0
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lower-/.f64N/A
metadata-eval100.0
Applied rewrites100.0%
Taylor expanded in K around inf
Applied rewrites100.0%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in l around 0
Applied rewrites96.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (fma (* l l) 0.3333333333333333 2.0)))
(if (<= (cos (/ K 2.0)) -0.03)
(fma (* (fma (* K K) -0.125 1.0) (* J t_0)) l U)
(fma (* t_0 l) J 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.03) {
tmp = fma((fma((K * K), -0.125, 1.0) * (J * t_0)), l, U);
} else {
tmp = fma((t_0 * l), J, 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.03) tmp = fma(Float64(fma(Float64(K * K), -0.125, 1.0) * Float64(J * t_0)), l, U); else tmp = fma(Float64(t_0 * l), J, 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.03], N[(N[(N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] * N[(J * t$95$0), $MachinePrecision]), $MachinePrecision] * l + U), $MachinePrecision], N[(N[(t$95$0 * l), $MachinePrecision] * J + 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.03:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(K \cdot K, -0.125, 1\right) \cdot \left(J \cdot t\_0\right), \ell, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_0 \cdot \ell, J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.029999999999999999Initial program 91.3%
Taylor expanded in l around 0
Applied rewrites91.2%
Taylor expanded in K around 0
Applied rewrites64.1%
if -0.029999999999999999 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.8%
Taylor expanded in l around 0
Applied rewrites84.4%
Taylor expanded in K around 0
Applied rewrites87.1%
(FPCore (J l K U)
:precision binary64
(let* ((t_0
(* (* (* (fma (* l l) 0.3333333333333333 2.0) l) J) (cos (* 0.5 K)))))
(if (<= l -780.0)
t_0
(if (<= l 0.00035)
(+ (* (* (* 2.0 J) l) (cos (* -0.5 K))) U)
(if (<= l 3.8e+78) (fma (* (+ J J) (sinh l)) 1.0 U) t_0)))))
double code(double J, double l, double K, double U) {
double t_0 = ((fma((l * l), 0.3333333333333333, 2.0) * l) * J) * cos((0.5 * K));
double tmp;
if (l <= -780.0) {
tmp = t_0;
} else if (l <= 0.00035) {
tmp = (((2.0 * J) * l) * cos((-0.5 * K))) + U;
} else if (l <= 3.8e+78) {
tmp = fma(((J + J) * sinh(l)), 1.0, U);
} else {
tmp = t_0;
}
return tmp;
}
function code(J, l, K, U) t_0 = Float64(Float64(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l) * J) * cos(Float64(0.5 * K))) tmp = 0.0 if (l <= -780.0) tmp = t_0; elseif (l <= 0.00035) tmp = Float64(Float64(Float64(Float64(2.0 * J) * l) * cos(Float64(-0.5 * K))) + U); elseif (l <= 3.8e+78) tmp = fma(Float64(Float64(J + J) * sinh(l)), 1.0, U); else tmp = t_0; end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -780.0], t$95$0, If[LessEqual[l, 0.00035], N[(N[(N[(N[(2.0 * J), $MachinePrecision] * l), $MachinePrecision] * N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 3.8e+78], N[(N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * 1.0 + U), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\right) \cdot \cos \left(0.5 \cdot K\right)\\
\mathbf{if}\;\ell \leq -780:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq 0.00035:\\
\;\;\;\;\left(\left(2 \cdot J\right) \cdot \ell\right) \cdot \cos \left(-0.5 \cdot K\right) + U\\
\mathbf{elif}\;\ell \leq 3.8 \cdot 10^{+78}:\\
\;\;\;\;\mathsf{fma}\left(\left(J + J\right) \cdot \sinh \ell, 1, U\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if l < -780 or 3.7999999999999999e78 < l Initial program 100.0%
Taylor expanded in l around 0
Applied rewrites80.6%
Taylor expanded in J around inf
Applied rewrites93.0%
if -780 < l < 3.49999999999999996e-4Initial program 74.1%
Taylor expanded in l around 0
Applied rewrites99.9%
if 3.49999999999999996e-4 < l < 3.7999999999999999e78Initial program 99.7%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6499.7
lift-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sinh.f6499.9
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lower-/.f64N/A
metadata-eval99.9
Applied rewrites99.9%
Taylor expanded in K around inf
Applied rewrites99.9%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in K around 0
Applied rewrites85.0%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.03) (+ (* (* (* (* K K) l) J) -0.25) U) (fma (* (fma (* l l) 0.3333333333333333 2.0) l) J U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.03) {
tmp = ((((K * K) * l) * J) * -0.25) + U;
} else {
tmp = fma((fma((l * l), 0.3333333333333333, 2.0) * l), J, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.03) tmp = Float64(Float64(Float64(Float64(Float64(K * K) * l) * J) * -0.25) + U); else tmp = fma(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l), J, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.03], N[(N[(N[(N[(N[(K * K), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] * -0.25), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.03:\\
\;\;\;\;\left(\left(\left(K \cdot K\right) \cdot \ell\right) \cdot J\right) \cdot -0.25 + U\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell, J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.029999999999999999Initial program 91.3%
Taylor expanded in l around 0
Applied rewrites64.9%
Taylor expanded in K around 0
Applied rewrites43.4%
Taylor expanded in K around inf
Applied rewrites57.9%
if -0.029999999999999999 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.8%
Taylor expanded in l around 0
Applied rewrites84.4%
Taylor expanded in K around 0
Applied rewrites87.1%
(FPCore (J l K U) :precision binary64 (if (or (<= l -205000000000.0) (not (<= l 0.0265))) (* (* (fma (* l l) 0.3333333333333333 2.0) l) J) (fma (* 2.0 l) J U)))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -205000000000.0) || !(l <= 0.0265)) {
tmp = (fma((l * l), 0.3333333333333333, 2.0) * l) * J;
} else {
tmp = fma((2.0 * l), J, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if ((l <= -205000000000.0) || !(l <= 0.0265)) tmp = Float64(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l) * J); else tmp = fma(Float64(2.0 * l), J, U); end return tmp end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -205000000000.0], N[Not[LessEqual[l, 0.0265]], $MachinePrecision]], N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision], N[(N[(2.0 * l), $MachinePrecision] * J + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -205000000000 \lor \neg \left(\ell \leq 0.0265\right):\\
\;\;\;\;\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(2 \cdot \ell, J, U\right)\\
\end{array}
\end{array}
if l < -2.05e11 or 0.0264999999999999993 < l Initial program 99.9%
Taylor expanded in l around 0
Applied rewrites72.7%
Taylor expanded in J around inf
Applied rewrites83.3%
Taylor expanded in K around 0
Applied rewrites61.7%
if -2.05e11 < l < 0.0264999999999999993Initial program 74.5%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6474.5
lift-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sinh.f6499.9
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lower-/.f64N/A
metadata-eval99.9
Applied rewrites99.9%
Taylor expanded in l around 0
Applied rewrites99.2%
Taylor expanded in K around 0
Applied rewrites89.3%
Applied rewrites89.3%
Final simplification75.6%
(FPCore (J l K U) :precision binary64 (fma (* (fma (* l l) 0.3333333333333333 2.0) l) J U))
double code(double J, double l, double K, double U) {
return fma((fma((l * l), 0.3333333333333333, 2.0) * l), J, U);
}
function code(J, l, K, U) return fma(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l), J, U) end
code[J_, l_, K_, U_] := N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * J + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell, J, U\right)
\end{array}
Initial program 87.1%
Taylor expanded in l around 0
Applied rewrites86.1%
Taylor expanded in K around 0
Applied rewrites75.6%
(FPCore (J l K U) :precision binary64 (fma (* 2.0 l) J U))
double code(double J, double l, double K, double U) {
return fma((2.0 * l), J, U);
}
function code(J, l, K, U) return fma(Float64(2.0 * l), J, U) end
code[J_, l_, K_, U_] := N[(N[(2.0 * l), $MachinePrecision] * J + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(2 \cdot \ell, J, U\right)
\end{array}
Initial program 87.1%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6487.1
lift-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sinh.f64100.0
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lower-/.f64N/A
metadata-eval100.0
Applied rewrites100.0%
Taylor expanded in l around 0
Applied rewrites65.3%
Taylor expanded in K around 0
Applied rewrites56.5%
Applied rewrites56.5%
(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 87.1%
Taylor expanded in J around 0
Applied rewrites37.6%
herbie shell --seed 2025021
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))