
(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}
Herbie found 13 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 (* (cos (* K -0.5)) (* (sinh l) 2.0)) J U))
double code(double J, double l, double K, double U) {
return fma((cos((K * -0.5)) * (sinh(l) * 2.0)), J, U);
}
function code(J, l, K, U) return fma(Float64(cos(Float64(K * -0.5)) * Float64(sinh(l) * 2.0)), J, U) end
code[J_, l_, K_, U_] := N[(N[(N[Cos[N[(K * -0.5), $MachinePrecision]], $MachinePrecision] * N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\cos \left(K \cdot -0.5\right) \cdot \left(\sinh \ell \cdot 2\right), J, U\right)
\end{array}
Initial program 85.8%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.9%
(FPCore (J l K U) :precision binary64 (fma (* (cos (* K -0.5)) J) (* (sinh l) 2.0) U))
double code(double J, double l, double K, double U) {
return fma((cos((K * -0.5)) * J), (sinh(l) * 2.0), U);
}
function code(J, l, K, U) return fma(Float64(cos(Float64(K * -0.5)) * J), Float64(sinh(l) * 2.0), U) end
code[J_, l_, K_, U_] := N[(N[(N[Cos[N[(K * -0.5), $MachinePrecision]], $MachinePrecision] * J), $MachinePrecision] * N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\cos \left(K \cdot -0.5\right) \cdot J, \sinh \ell \cdot 2, U\right)
\end{array}
Initial program 85.8%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites99.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 -0.08)
(+ U (* J (* l (- (* l (- (* -4.333333333333333 l) 4.0)) 2.0))))
(if (<= t_0 0.9995)
(+ U (* J (- (exp l) (exp (- l)))))
(fma (* (+ 1.0 (* -0.125 (pow K 2.0))) (* (sinh l) 2.0)) J U)))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double tmp;
if (t_0 <= -0.08) {
tmp = U + (J * (l * ((l * ((-4.333333333333333 * l) - 4.0)) - 2.0)));
} else if (t_0 <= 0.9995) {
tmp = U + (J * (exp(l) - exp(-l)));
} else {
tmp = fma(((1.0 + (-0.125 * pow(K, 2.0))) * (sinh(l) * 2.0)), J, U);
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= -0.08) tmp = Float64(U + Float64(J * Float64(l * Float64(Float64(l * Float64(Float64(-4.333333333333333 * l) - 4.0)) - 2.0)))); elseif (t_0 <= 0.9995) tmp = Float64(U + Float64(J * Float64(exp(l) - exp(Float64(-l))))); else tmp = fma(Float64(Float64(1.0 + Float64(-0.125 * (K ^ 2.0))) * Float64(sinh(l) * 2.0)), J, U); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, -0.08], N[(U + N[(J * N[(l * N[(N[(l * N[(N[(-4.333333333333333 * l), $MachinePrecision] - 4.0), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.9995], N[(U + N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 + N[(-0.125 * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sinh[l], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq -0.08:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(\ell \cdot \left(-4.333333333333333 \cdot \ell - 4\right) - 2\right)\right)\\
\mathbf{elif}\;t\_0 \leq 0.9995:\\
\;\;\;\;U + J \cdot \left(e^{\ell} - e^{-\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(1 + -0.125 \cdot {K}^{2}\right) \cdot \left(\sinh \ell \cdot 2\right), J, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0800000000000000017Initial program 85.8%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-to-multN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites75.8%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f6454.9
Applied rewrites54.9%
lift-neg.f64N/A
lift-*.f64N/A
count-2-revN/A
distribute-neg-outN/A
flip-+N/A
sqr-neg-revN/A
sqr-neg-revN/A
sqr-neg-revN/A
add-flipN/A
+-commutativeN/A
flip--N/A
add-flip-revN/A
lower-+.f6443.1
Applied rewrites43.1%
Taylor expanded in l around 0
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6445.8
Applied rewrites45.8%
if -0.0800000000000000017 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.99950000000000006Initial program 85.8%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6473.4
Applied rewrites73.4%
if 0.99950000000000006 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.8%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.9%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6468.5
Applied rewrites68.5%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.08) (+ U (* J (* l (- (* l (- (* -4.333333333333333 l) 4.0)) 2.0)))) (+ U (* J (- (exp l) (exp (- l)))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.08) {
tmp = U + (J * (l * ((l * ((-4.333333333333333 * l) - 4.0)) - 2.0)));
} else {
tmp = U + (J * (exp(l) - exp(-l)));
}
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) :: tmp
if (cos((k / 2.0d0)) <= (-0.08d0)) then
tmp = u + (j * (l * ((l * (((-4.333333333333333d0) * l) - 4.0d0)) - 2.0d0)))
else
tmp = u + (j * (exp(l) - exp(-l)))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (Math.cos((K / 2.0)) <= -0.08) {
tmp = U + (J * (l * ((l * ((-4.333333333333333 * l) - 4.0)) - 2.0)));
} else {
tmp = U + (J * (Math.exp(l) - Math.exp(-l)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.08: tmp = U + (J * (l * ((l * ((-4.333333333333333 * l) - 4.0)) - 2.0))) else: tmp = U + (J * (math.exp(l) - math.exp(-l))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.08) tmp = Float64(U + Float64(J * Float64(l * Float64(Float64(l * Float64(Float64(-4.333333333333333 * l) - 4.0)) - 2.0)))); else tmp = Float64(U + Float64(J * Float64(exp(l) - exp(Float64(-l))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= -0.08) tmp = U + (J * (l * ((l * ((-4.333333333333333 * l) - 4.0)) - 2.0))); else tmp = U + (J * (exp(l) - exp(-l))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.08], N[(U + N[(J * N[(l * N[(N[(l * N[(N[(-4.333333333333333 * l), $MachinePrecision] - 4.0), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.08:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(\ell \cdot \left(-4.333333333333333 \cdot \ell - 4\right) - 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(e^{\ell} - e^{-\ell}\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0800000000000000017Initial program 85.8%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-to-multN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites75.8%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f6454.9
Applied rewrites54.9%
lift-neg.f64N/A
lift-*.f64N/A
count-2-revN/A
distribute-neg-outN/A
flip-+N/A
sqr-neg-revN/A
sqr-neg-revN/A
sqr-neg-revN/A
add-flipN/A
+-commutativeN/A
flip--N/A
add-flip-revN/A
lower-+.f6443.1
Applied rewrites43.1%
Taylor expanded in l around 0
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6445.8
Applied rewrites45.8%
if -0.0800000000000000017 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.8%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6473.4
Applied rewrites73.4%
(FPCore (J l K U) :precision binary64 (if (<= l -1.7) (+ U (* J (* 1.0 (- 1.0 (exp (- (* 2.0 l))))))) (+ U (* J (* (exp l) (* l 2.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -1.7) {
tmp = U + (J * (1.0 * (1.0 - exp(-(2.0 * l)))));
} else {
tmp = U + (J * (exp(l) * (l * 2.0)));
}
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) :: tmp
if (l <= (-1.7d0)) then
tmp = u + (j * (1.0d0 * (1.0d0 - exp(-(2.0d0 * l)))))
else
tmp = u + (j * (exp(l) * (l * 2.0d0)))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -1.7) {
tmp = U + (J * (1.0 * (1.0 - Math.exp(-(2.0 * l)))));
} else {
tmp = U + (J * (Math.exp(l) * (l * 2.0)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -1.7: tmp = U + (J * (1.0 * (1.0 - math.exp(-(2.0 * l))))) else: tmp = U + (J * (math.exp(l) * (l * 2.0))) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -1.7) tmp = Float64(U + Float64(J * Float64(1.0 * Float64(1.0 - exp(Float64(-Float64(2.0 * l))))))); else tmp = Float64(U + Float64(J * Float64(exp(l) * Float64(l * 2.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -1.7) tmp = U + (J * (1.0 * (1.0 - exp(-(2.0 * l))))); else tmp = U + (J * (exp(l) * (l * 2.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -1.7], N[(U + N[(J * N[(1.0 * N[(1.0 - N[Exp[(-N[(2.0 * l), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(N[Exp[l], $MachinePrecision] * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.7:\\
\;\;\;\;U + J \cdot \left(1 \cdot \left(1 - e^{-2 \cdot \ell}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(e^{\ell} \cdot \left(\ell \cdot 2\right)\right)\\
\end{array}
\end{array}
if l < -1.69999999999999996Initial program 85.8%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-to-multN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites75.8%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f6454.9
Applied rewrites54.9%
Taylor expanded in l around 0
Applied rewrites55.9%
if -1.69999999999999996 < l Initial program 85.8%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-to-multN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites75.8%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f6454.9
Applied rewrites54.9%
Taylor expanded in l around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.8
Applied rewrites50.8%
Taylor expanded in l around 0
Applied rewrites62.8%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.08) (+ U (* J (* l (- (* l (- (* -4.333333333333333 l) 4.0)) 2.0)))) (+ U (* J (* (exp l) (* l 2.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.08) {
tmp = U + (J * (l * ((l * ((-4.333333333333333 * l) - 4.0)) - 2.0)));
} else {
tmp = U + (J * (exp(l) * (l * 2.0)));
}
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) :: tmp
if (cos((k / 2.0d0)) <= (-0.08d0)) then
tmp = u + (j * (l * ((l * (((-4.333333333333333d0) * l) - 4.0d0)) - 2.0d0)))
else
tmp = u + (j * (exp(l) * (l * 2.0d0)))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (Math.cos((K / 2.0)) <= -0.08) {
tmp = U + (J * (l * ((l * ((-4.333333333333333 * l) - 4.0)) - 2.0)));
} else {
tmp = U + (J * (Math.exp(l) * (l * 2.0)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.08: tmp = U + (J * (l * ((l * ((-4.333333333333333 * l) - 4.0)) - 2.0))) else: tmp = U + (J * (math.exp(l) * (l * 2.0))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.08) tmp = Float64(U + Float64(J * Float64(l * Float64(Float64(l * Float64(Float64(-4.333333333333333 * l) - 4.0)) - 2.0)))); else tmp = Float64(U + Float64(J * Float64(exp(l) * Float64(l * 2.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= -0.08) tmp = U + (J * (l * ((l * ((-4.333333333333333 * l) - 4.0)) - 2.0))); else tmp = U + (J * (exp(l) * (l * 2.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.08], N[(U + N[(J * N[(l * N[(N[(l * N[(N[(-4.333333333333333 * l), $MachinePrecision] - 4.0), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(N[Exp[l], $MachinePrecision] * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.08:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(\ell \cdot \left(-4.333333333333333 \cdot \ell - 4\right) - 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(e^{\ell} \cdot \left(\ell \cdot 2\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0800000000000000017Initial program 85.8%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-to-multN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites75.8%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f6454.9
Applied rewrites54.9%
lift-neg.f64N/A
lift-*.f64N/A
count-2-revN/A
distribute-neg-outN/A
flip-+N/A
sqr-neg-revN/A
sqr-neg-revN/A
sqr-neg-revN/A
add-flipN/A
+-commutativeN/A
flip--N/A
add-flip-revN/A
lower-+.f6443.1
Applied rewrites43.1%
Taylor expanded in l around 0
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6445.8
Applied rewrites45.8%
if -0.0800000000000000017 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.8%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-to-multN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites75.8%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f6454.9
Applied rewrites54.9%
Taylor expanded in l around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.8
Applied rewrites50.8%
Taylor expanded in l around 0
Applied rewrites62.8%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.08) (+ U (* J (* l (- (* l (- (* -4.333333333333333 l) 4.0)) 2.0)))) (* (+ 1.0 (/ (* (* l J) 2.0) U)) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.08) {
tmp = U + (J * (l * ((l * ((-4.333333333333333 * l) - 4.0)) - 2.0)));
} else {
tmp = (1.0 + (((l * J) * 2.0) / U)) * 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) :: tmp
if (cos((k / 2.0d0)) <= (-0.08d0)) then
tmp = u + (j * (l * ((l * (((-4.333333333333333d0) * l) - 4.0d0)) - 2.0d0)))
else
tmp = (1.0d0 + (((l * j) * 2.0d0) / u)) * u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (Math.cos((K / 2.0)) <= -0.08) {
tmp = U + (J * (l * ((l * ((-4.333333333333333 * l) - 4.0)) - 2.0)));
} else {
tmp = (1.0 + (((l * J) * 2.0) / U)) * U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.08: tmp = U + (J * (l * ((l * ((-4.333333333333333 * l) - 4.0)) - 2.0))) else: tmp = (1.0 + (((l * J) * 2.0) / U)) * U return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.08) tmp = Float64(U + Float64(J * Float64(l * Float64(Float64(l * Float64(Float64(-4.333333333333333 * l) - 4.0)) - 2.0)))); else tmp = Float64(Float64(1.0 + Float64(Float64(Float64(l * J) * 2.0) / U)) * U); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= -0.08) tmp = U + (J * (l * ((l * ((-4.333333333333333 * l) - 4.0)) - 2.0))); else tmp = (1.0 + (((l * J) * 2.0) / U)) * U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.08], N[(U + N[(J * N[(l * N[(N[(l * N[(N[(-4.333333333333333 * l), $MachinePrecision] - 4.0), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(N[(N[(l * J), $MachinePrecision] * 2.0), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision] * U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.08:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(\ell \cdot \left(-4.333333333333333 \cdot \ell - 4\right) - 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \frac{\left(\ell \cdot J\right) \cdot 2}{U}\right) \cdot U\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0800000000000000017Initial program 85.8%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-to-multN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites75.8%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f6454.9
Applied rewrites54.9%
lift-neg.f64N/A
lift-*.f64N/A
count-2-revN/A
distribute-neg-outN/A
flip-+N/A
sqr-neg-revN/A
sqr-neg-revN/A
sqr-neg-revN/A
add-flipN/A
+-commutativeN/A
flip--N/A
add-flip-revN/A
lower-+.f6443.1
Applied rewrites43.1%
Taylor expanded in l around 0
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6445.8
Applied rewrites45.8%
if -0.0800000000000000017 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.8%
Taylor expanded in l around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6464.4
Applied rewrites64.4%
Taylor expanded in K around 0
lower-*.f6454.6
Applied rewrites54.6%
lift-+.f64N/A
+-commutativeN/A
sum-to-multN/A
lower-*.f64N/A
Applied rewrites58.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 -0.3)
(+ (* (+ J J) (fma (* (* K K) l) -0.125 l)) U)
(if (<= t_0 0.05)
(+ U (* J (* l (- (* -4.0 l) 2.0))))
(* (+ 1.0 (/ (* (* l J) 2.0) U)) U)))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double tmp;
if (t_0 <= -0.3) {
tmp = ((J + J) * fma(((K * K) * l), -0.125, l)) + U;
} else if (t_0 <= 0.05) {
tmp = U + (J * (l * ((-4.0 * l) - 2.0)));
} else {
tmp = (1.0 + (((l * J) * 2.0) / U)) * U;
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= -0.3) tmp = Float64(Float64(Float64(J + J) * fma(Float64(Float64(K * K) * l), -0.125, l)) + U); elseif (t_0 <= 0.05) tmp = Float64(U + Float64(J * Float64(l * Float64(Float64(-4.0 * l) - 2.0)))); else tmp = Float64(Float64(1.0 + Float64(Float64(Float64(l * J) * 2.0) / U)) * 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.3], N[(N[(N[(J + J), $MachinePrecision] * N[(N[(N[(K * K), $MachinePrecision] * l), $MachinePrecision] * -0.125 + l), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[t$95$0, 0.05], N[(U + N[(J * N[(l * N[(N[(-4.0 * l), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(N[(N[(l * J), $MachinePrecision] * 2.0), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision] * U), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq -0.3:\\
\;\;\;\;\left(J + J\right) \cdot \mathsf{fma}\left(\left(K \cdot K\right) \cdot \ell, -0.125, \ell\right) + U\\
\mathbf{elif}\;t\_0 \leq 0.05:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(-4 \cdot \ell - 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \frac{\left(\ell \cdot J\right) \cdot 2}{U}\right) \cdot U\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.299999999999999989Initial program 85.8%
Taylor expanded in l around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6464.4
Applied rewrites64.4%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6448.9
Applied rewrites48.9%
Applied rewrites48.9%
if -0.299999999999999989 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.050000000000000003Initial program 85.8%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-to-multN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites75.8%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f6454.9
Applied rewrites54.9%
lift-neg.f64N/A
lift-*.f64N/A
count-2-revN/A
distribute-neg-outN/A
flip-+N/A
sqr-neg-revN/A
sqr-neg-revN/A
sqr-neg-revN/A
add-flipN/A
+-commutativeN/A
flip--N/A
add-flip-revN/A
lower-+.f6443.1
Applied rewrites43.1%
Taylor expanded in l around 0
lower-*.f64N/A
lower--.f64N/A
lower-*.f6452.6
Applied rewrites52.6%
if 0.050000000000000003 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.8%
Taylor expanded in l around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6464.4
Applied rewrites64.4%
Taylor expanded in K around 0
lower-*.f6454.6
Applied rewrites54.6%
lift-+.f64N/A
+-commutativeN/A
sum-to-multN/A
lower-*.f64N/A
Applied rewrites58.0%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.05) (+ U (* J (* l (- (* -4.0 l) 2.0)))) (* (+ 1.0 (/ (* (* l J) 2.0) U)) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.05) {
tmp = U + (J * (l * ((-4.0 * l) - 2.0)));
} else {
tmp = (1.0 + (((l * J) * 2.0) / U)) * 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) :: tmp
if (cos((k / 2.0d0)) <= 0.05d0) then
tmp = u + (j * (l * (((-4.0d0) * l) - 2.0d0)))
else
tmp = (1.0d0 + (((l * j) * 2.0d0) / u)) * u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (Math.cos((K / 2.0)) <= 0.05) {
tmp = U + (J * (l * ((-4.0 * l) - 2.0)));
} else {
tmp = (1.0 + (((l * J) * 2.0) / U)) * U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= 0.05: tmp = U + (J * (l * ((-4.0 * l) - 2.0))) else: tmp = (1.0 + (((l * J) * 2.0) / U)) * U return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.05) tmp = Float64(U + Float64(J * Float64(l * Float64(Float64(-4.0 * l) - 2.0)))); else tmp = Float64(Float64(1.0 + Float64(Float64(Float64(l * J) * 2.0) / U)) * U); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= 0.05) tmp = U + (J * (l * ((-4.0 * l) - 2.0))); else tmp = (1.0 + (((l * J) * 2.0) / U)) * U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.05], N[(U + N[(J * N[(l * N[(N[(-4.0 * l), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(N[(N[(l * J), $MachinePrecision] * 2.0), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision] * U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.05:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(-4 \cdot \ell - 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \frac{\left(\ell \cdot J\right) \cdot 2}{U}\right) \cdot U\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.050000000000000003Initial program 85.8%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-to-multN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites75.8%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f6454.9
Applied rewrites54.9%
lift-neg.f64N/A
lift-*.f64N/A
count-2-revN/A
distribute-neg-outN/A
flip-+N/A
sqr-neg-revN/A
sqr-neg-revN/A
sqr-neg-revN/A
add-flipN/A
+-commutativeN/A
flip--N/A
add-flip-revN/A
lower-+.f6443.1
Applied rewrites43.1%
Taylor expanded in l around 0
lower-*.f64N/A
lower--.f64N/A
lower-*.f6452.6
Applied rewrites52.6%
if 0.050000000000000003 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.8%
Taylor expanded in l around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6464.4
Applied rewrites64.4%
Taylor expanded in K around 0
lower-*.f6454.6
Applied rewrites54.6%
lift-+.f64N/A
+-commutativeN/A
sum-to-multN/A
lower-*.f64N/A
Applied rewrites58.0%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.85) (+ U (* J (* l (- (* -4.0 l) 2.0)))) (+ (* 2.0 (* J l)) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.85) {
tmp = U + (J * (l * ((-4.0 * l) - 2.0)));
} else {
tmp = (2.0 * (J * l)) + 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) :: tmp
if (cos((k / 2.0d0)) <= 0.85d0) then
tmp = u + (j * (l * (((-4.0d0) * l) - 2.0d0)))
else
tmp = (2.0d0 * (j * l)) + u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (Math.cos((K / 2.0)) <= 0.85) {
tmp = U + (J * (l * ((-4.0 * l) - 2.0)));
} else {
tmp = (2.0 * (J * l)) + U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= 0.85: tmp = U + (J * (l * ((-4.0 * l) - 2.0))) else: tmp = (2.0 * (J * l)) + U return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.85) tmp = Float64(U + Float64(J * Float64(l * Float64(Float64(-4.0 * l) - 2.0)))); else tmp = Float64(Float64(2.0 * Float64(J * l)) + U); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= 0.85) tmp = U + (J * (l * ((-4.0 * l) - 2.0))); else tmp = (2.0 * (J * l)) + U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.85], N[(U + N[(J * N[(l * N[(N[(-4.0 * l), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * N[(J * l), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.85:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(-4 \cdot \ell - 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(J \cdot \ell\right) + U\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.849999999999999978Initial program 85.8%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-to-multN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites75.8%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f6454.9
Applied rewrites54.9%
lift-neg.f64N/A
lift-*.f64N/A
count-2-revN/A
distribute-neg-outN/A
flip-+N/A
sqr-neg-revN/A
sqr-neg-revN/A
sqr-neg-revN/A
add-flipN/A
+-commutativeN/A
flip--N/A
add-flip-revN/A
lower-+.f6443.1
Applied rewrites43.1%
Taylor expanded in l around 0
lower-*.f64N/A
lower--.f64N/A
lower-*.f6452.6
Applied rewrites52.6%
if 0.849999999999999978 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.8%
Taylor expanded in l around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6464.4
Applied rewrites64.4%
Taylor expanded in K around 0
lower-*.f6454.6
Applied rewrites54.6%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.072) (+ U (* -2.0 (* J l))) (+ (* 2.0 (* J l)) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.072) {
tmp = U + (-2.0 * (J * l));
} else {
tmp = (2.0 * (J * l)) + 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) :: tmp
if (cos((k / 2.0d0)) <= (-0.072d0)) then
tmp = u + ((-2.0d0) * (j * l))
else
tmp = (2.0d0 * (j * l)) + u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (Math.cos((K / 2.0)) <= -0.072) {
tmp = U + (-2.0 * (J * l));
} else {
tmp = (2.0 * (J * l)) + U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.072: tmp = U + (-2.0 * (J * l)) else: tmp = (2.0 * (J * l)) + U return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.072) tmp = Float64(U + Float64(-2.0 * Float64(J * l))); else tmp = Float64(Float64(2.0 * Float64(J * l)) + U); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= -0.072) tmp = U + (-2.0 * (J * l)); else tmp = (2.0 * (J * l)) + U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.072], N[(U + N[(-2.0 * N[(J * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * N[(J * l), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.072:\\
\;\;\;\;U + -2 \cdot \left(J \cdot \ell\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(J \cdot \ell\right) + U\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0719999999999999946Initial program 85.8%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-to-multN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites75.8%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f6454.9
Applied rewrites54.9%
lift-neg.f64N/A
lift-*.f64N/A
count-2-revN/A
distribute-neg-outN/A
flip-+N/A
sqr-neg-revN/A
sqr-neg-revN/A
sqr-neg-revN/A
add-flipN/A
+-commutativeN/A
flip--N/A
add-flip-revN/A
lower-+.f6443.1
Applied rewrites43.1%
Taylor expanded in l around 0
lower-*.f64N/A
lower-*.f6440.4
Applied rewrites40.4%
if -0.0719999999999999946 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.8%
Taylor expanded in l around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6464.4
Applied rewrites64.4%
Taylor expanded in K around 0
lower-*.f6454.6
Applied rewrites54.6%
(FPCore (J l K U) :precision binary64 (+ U (* -2.0 (* J l))))
double code(double J, double l, double K, double U) {
return U + (-2.0 * (J * l));
}
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 + ((-2.0d0) * (j * l))
end function
public static double code(double J, double l, double K, double U) {
return U + (-2.0 * (J * l));
}
def code(J, l, K, U): return U + (-2.0 * (J * l))
function code(J, l, K, U) return Float64(U + Float64(-2.0 * Float64(J * l))) end
function tmp = code(J, l, K, U) tmp = U + (-2.0 * (J * l)); end
code[J_, l_, K_, U_] := N[(U + N[(-2.0 * N[(J * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + -2 \cdot \left(J \cdot \ell\right)
\end{array}
Initial program 85.8%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-to-multN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites75.8%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f6454.9
Applied rewrites54.9%
lift-neg.f64N/A
lift-*.f64N/A
count-2-revN/A
distribute-neg-outN/A
flip-+N/A
sqr-neg-revN/A
sqr-neg-revN/A
sqr-neg-revN/A
add-flipN/A
+-commutativeN/A
flip--N/A
add-flip-revN/A
lower-+.f6443.1
Applied rewrites43.1%
Taylor expanded in l around 0
lower-*.f64N/A
lower-*.f6440.4
Applied rewrites40.4%
(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 85.8%
Taylor expanded in J around 0
Applied rewrites37.4%
herbie shell --seed 2025151
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))