
(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]
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
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]
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
(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]
\mathsf{fma}\left(\left(J + J\right) \cdot \sinh \ell, \cos \left(0.5 \cdot K\right), U\right)
Initial program 86.7%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites99.9%
Applied rewrites99.9%
(FPCore (J l K U)
:precision binary64
(if (<= l -4.0)
(fma (* (cos (* -0.5 K)) (- 1.0 (exp (- l)))) J U)
(if (<= l 22.0)
(fma (cos (* 0.5 K)) (* l (+ J J)) U)
(fma (* (+ J J) (sinh l)) (fma (* K K) -0.125 1.0) U))))double code(double J, double l, double K, double U) {
double tmp;
if (l <= -4.0) {
tmp = fma((cos((-0.5 * K)) * (1.0 - exp(-l))), J, U);
} else if (l <= 22.0) {
tmp = fma(cos((0.5 * K)), (l * (J + J)), U);
} else {
tmp = fma(((J + J) * sinh(l)), fma((K * K), -0.125, 1.0), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (l <= -4.0) tmp = fma(Float64(cos(Float64(-0.5 * K)) * Float64(1.0 - exp(Float64(-l)))), J, U); elseif (l <= 22.0) tmp = fma(cos(Float64(0.5 * K)), Float64(l * Float64(J + J)), U); else tmp = fma(Float64(Float64(J + J) * sinh(l)), fma(Float64(K * K), -0.125, 1.0), U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[l, -4.0], N[(N[(N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], If[LessEqual[l, 22.0], N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * N[(l * N[(J + J), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] + U), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;\ell \leq -4:\\
\;\;\;\;\mathsf{fma}\left(\cos \left(-0.5 \cdot K\right) \cdot \left(1 - e^{-\ell}\right), J, U\right)\\
\mathbf{elif}\;\ell \leq 22:\\
\;\;\;\;\mathsf{fma}\left(\cos \left(0.5 \cdot K\right), \ell \cdot \left(J + J\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(J + J\right) \cdot \sinh \ell, \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right)\\
\end{array}
if l < -4Initial program 86.7%
Taylor expanded in l around 0
Applied rewrites62.3%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites62.3%
if -4 < l < 22Initial program 86.7%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites99.9%
Taylor expanded in l around 0
Applied rewrites63.4%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites63.4%
lift-fma.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-rgt-identityN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites63.3%
if 22 < l Initial program 86.7%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6464.8%
Applied rewrites64.8%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6464.8%
Applied rewrites69.7%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* J (- (exp l) (exp (- l))))) (t_1 (* t_0 (cos (/ K 2.0)))))
(if (<= t_1 -1e+182)
(+ U t_0)
(if (<= t_1 2e+112)
(fma (cos (* 0.5 K)) (* l (+ J J)) U)
(fma (* (+ J J) (sinh l)) (fma (* K K) -0.125 1.0) U)))))double code(double J, double l, double K, double U) {
double t_0 = J * (exp(l) - exp(-l));
double t_1 = t_0 * cos((K / 2.0));
double tmp;
if (t_1 <= -1e+182) {
tmp = U + t_0;
} else if (t_1 <= 2e+112) {
tmp = fma(cos((0.5 * K)), (l * (J + J)), U);
} else {
tmp = fma(((J + J) * sinh(l)), fma((K * K), -0.125, 1.0), U);
}
return tmp;
}
function code(J, l, K, U) t_0 = Float64(J * Float64(exp(l) - exp(Float64(-l)))) t_1 = Float64(t_0 * cos(Float64(K / 2.0))) tmp = 0.0 if (t_1 <= -1e+182) tmp = Float64(U + t_0); elseif (t_1 <= 2e+112) tmp = fma(cos(Float64(0.5 * K)), Float64(l * Float64(J + J)), U); else tmp = fma(Float64(Float64(J + J) * sinh(l)), fma(Float64(K * K), -0.125, 1.0), U); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+182], N[(U + t$95$0), $MachinePrecision], If[LessEqual[t$95$1, 2e+112], N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * N[(l * N[(J + J), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] + U), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := J \cdot \left(e^{\ell} - e^{-\ell}\right)\\
t_1 := t\_0 \cdot \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+182}:\\
\;\;\;\;U + t\_0\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+112}:\\
\;\;\;\;\mathsf{fma}\left(\cos \left(0.5 \cdot K\right), \ell \cdot \left(J + J\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(J + J\right) \cdot \sinh \ell, \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right)\\
\end{array}
if (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) < -1.0000000000000001e182Initial program 86.7%
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.2%
Applied rewrites73.2%
if -1.0000000000000001e182 < (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) < 1.9999999999999999e112Initial program 86.7%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites99.9%
Taylor expanded in l around 0
Applied rewrites63.4%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites63.4%
lift-fma.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-rgt-identityN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites63.3%
if 1.9999999999999999e112 < (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) Initial program 86.7%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6464.8%
Applied rewrites64.8%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6464.8%
Applied rewrites69.7%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (fma (* K K) -0.125 1.0)) (t_1 (cos (/ K 2.0))))
(if (<= t_1 -0.2)
(fma (- (* (exp l) J) (* (exp (- l)) J)) t_0 U)
(if (<= t_1 0.9998)
(+ U (fma -1.0 (/ J (exp l)) (* J (exp l))))
(fma (* (+ J J) (sinh l)) t_0 U)))))double code(double J, double l, double K, double U) {
double t_0 = fma((K * K), -0.125, 1.0);
double t_1 = cos((K / 2.0));
double tmp;
if (t_1 <= -0.2) {
tmp = fma(((exp(l) * J) - (exp(-l) * J)), t_0, U);
} else if (t_1 <= 0.9998) {
tmp = U + fma(-1.0, (J / exp(l)), (J * exp(l)));
} else {
tmp = fma(((J + J) * sinh(l)), t_0, U);
}
return tmp;
}
function code(J, l, K, U) t_0 = fma(Float64(K * K), -0.125, 1.0) t_1 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_1 <= -0.2) tmp = fma(Float64(Float64(exp(l) * J) - Float64(exp(Float64(-l)) * J)), t_0, U); elseif (t_1 <= 0.9998) tmp = Float64(U + fma(-1.0, Float64(J / exp(l)), Float64(J * exp(l)))); else tmp = fma(Float64(Float64(J + J) * sinh(l)), t_0, U); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, -0.2], N[(N[(N[(N[Exp[l], $MachinePrecision] * J), $MachinePrecision] - N[(N[Exp[(-l)], $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision] * t$95$0 + U), $MachinePrecision], If[LessEqual[t$95$1, 0.9998], N[(U + N[(-1.0 * N[(J / N[Exp[l], $MachinePrecision]), $MachinePrecision] + N[(J * N[Exp[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * t$95$0 + U), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \mathsf{fma}\left(K \cdot K, -0.125, 1\right)\\
t_1 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_1 \leq -0.2:\\
\;\;\;\;\mathsf{fma}\left(e^{\ell} \cdot J - e^{-\ell} \cdot J, t\_0, U\right)\\
\mathbf{elif}\;t\_1 \leq 0.9998:\\
\;\;\;\;U + \mathsf{fma}\left(-1, \frac{J}{e^{\ell}}, J \cdot e^{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(J + J\right) \cdot \sinh \ell, t\_0, U\right)\\
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.20000000000000001Initial program 86.7%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6464.8%
Applied rewrites64.8%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6464.8%
Applied rewrites69.7%
lift-*.f64N/A
lift-+.f64N/A
count-2N/A
*-commutativeN/A
associate-*r*N/A
lift-sinh.f64N/A
sinh-undefN/A
lift-neg.f64N/A
lift-exp.f64N/A
sub-flipN/A
distribute-rgt-inN/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
Applied rewrites64.8%
if -0.20000000000000001 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.99980000000000002Initial program 86.7%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6464.8%
Applied rewrites64.8%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6464.8%
Applied rewrites69.7%
lift-*.f64N/A
lift-+.f64N/A
count-2N/A
*-commutativeN/A
associate-*r*N/A
lift-sinh.f64N/A
sinh-undefN/A
lift-neg.f64N/A
lift-exp.f64N/A
sub-flipN/A
distribute-lft-inN/A
lower-fma.f64N/A
lower-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
distribute-neg-frac2N/A
mult-flip-revN/A
lower-/.f64N/A
lower-neg.f64N/A
lower-exp.f6464.8%
Applied rewrites64.8%
Taylor expanded in K around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-exp.f6473.2%
Applied rewrites73.2%
if 0.99980000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 86.7%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6464.8%
Applied rewrites64.8%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6464.8%
Applied rewrites69.7%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (fma (* K K) -0.125 1.0)) (t_1 (cos (/ K 2.0))))
(if (<= t_1 -0.2)
(fma (fma J (exp l) (/ J (- (exp l)))) t_0 U)
(if (<= t_1 0.9998)
(+ U (fma -1.0 (/ J (exp l)) (* J (exp l))))
(fma (* (+ J J) (sinh l)) t_0 U)))))double code(double J, double l, double K, double U) {
double t_0 = fma((K * K), -0.125, 1.0);
double t_1 = cos((K / 2.0));
double tmp;
if (t_1 <= -0.2) {
tmp = fma(fma(J, exp(l), (J / -exp(l))), t_0, U);
} else if (t_1 <= 0.9998) {
tmp = U + fma(-1.0, (J / exp(l)), (J * exp(l)));
} else {
tmp = fma(((J + J) * sinh(l)), t_0, U);
}
return tmp;
}
function code(J, l, K, U) t_0 = fma(Float64(K * K), -0.125, 1.0) t_1 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_1 <= -0.2) tmp = fma(fma(J, exp(l), Float64(J / Float64(-exp(l)))), t_0, U); elseif (t_1 <= 0.9998) tmp = Float64(U + fma(-1.0, Float64(J / exp(l)), Float64(J * exp(l)))); else tmp = fma(Float64(Float64(J + J) * sinh(l)), t_0, U); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, -0.2], N[(N[(J * N[Exp[l], $MachinePrecision] + N[(J / (-N[Exp[l], $MachinePrecision])), $MachinePrecision]), $MachinePrecision] * t$95$0 + U), $MachinePrecision], If[LessEqual[t$95$1, 0.9998], N[(U + N[(-1.0 * N[(J / N[Exp[l], $MachinePrecision]), $MachinePrecision] + N[(J * N[Exp[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * t$95$0 + U), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \mathsf{fma}\left(K \cdot K, -0.125, 1\right)\\
t_1 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_1 \leq -0.2:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(J, e^{\ell}, \frac{J}{-e^{\ell}}\right), t\_0, U\right)\\
\mathbf{elif}\;t\_1 \leq 0.9998:\\
\;\;\;\;U + \mathsf{fma}\left(-1, \frac{J}{e^{\ell}}, J \cdot e^{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(J + J\right) \cdot \sinh \ell, t\_0, U\right)\\
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.20000000000000001Initial program 86.7%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6464.8%
Applied rewrites64.8%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6464.8%
Applied rewrites69.7%
lift-*.f64N/A
lift-+.f64N/A
count-2N/A
*-commutativeN/A
associate-*r*N/A
lift-sinh.f64N/A
sinh-undefN/A
lift-neg.f64N/A
lift-exp.f64N/A
sub-flipN/A
distribute-lft-inN/A
lower-fma.f64N/A
lower-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
distribute-neg-frac2N/A
mult-flip-revN/A
lower-/.f64N/A
lower-neg.f64N/A
lower-exp.f6464.8%
Applied rewrites64.8%
if -0.20000000000000001 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.99980000000000002Initial program 86.7%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6464.8%
Applied rewrites64.8%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6464.8%
Applied rewrites69.7%
lift-*.f64N/A
lift-+.f64N/A
count-2N/A
*-commutativeN/A
associate-*r*N/A
lift-sinh.f64N/A
sinh-undefN/A
lift-neg.f64N/A
lift-exp.f64N/A
sub-flipN/A
distribute-lft-inN/A
lower-fma.f64N/A
lower-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
distribute-neg-frac2N/A
mult-flip-revN/A
lower-/.f64N/A
lower-neg.f64N/A
lower-exp.f6464.8%
Applied rewrites64.8%
Taylor expanded in K around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-exp.f6473.2%
Applied rewrites73.2%
if 0.99980000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 86.7%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6464.8%
Applied rewrites64.8%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6464.8%
Applied rewrites69.7%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 -0.02)
(+ (/ (* J (* l (+ 2.0 (* 2.0 l)))) (exp l)) U)
(if (<= t_0 0.9998)
(+ U (fma -1.0 (/ J (exp l)) (* J (exp l))))
(fma (* (+ J J) (sinh l)) (fma (* K K) -0.125 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.02) {
tmp = ((J * (l * (2.0 + (2.0 * l)))) / exp(l)) + U;
} else if (t_0 <= 0.9998) {
tmp = U + fma(-1.0, (J / exp(l)), (J * exp(l)));
} else {
tmp = fma(((J + J) * sinh(l)), fma((K * K), -0.125, 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.02) tmp = Float64(Float64(Float64(J * Float64(l * Float64(2.0 + Float64(2.0 * l)))) / exp(l)) + U); elseif (t_0 <= 0.9998) tmp = Float64(U + fma(-1.0, Float64(J / exp(l)), Float64(J * exp(l)))); else tmp = fma(Float64(Float64(J + J) * sinh(l)), fma(Float64(K * K), -0.125, 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.02], N[(N[(N[(J * N[(l * N[(2.0 + N[(2.0 * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[t$95$0, 0.9998], N[(U + N[(-1.0 * N[(J / N[Exp[l], $MachinePrecision]), $MachinePrecision] + N[(J * N[Exp[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] + U), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq -0.02:\\
\;\;\;\;\frac{J \cdot \left(\ell \cdot \left(2 + 2 \cdot \ell\right)\right)}{e^{\ell}} + U\\
\mathbf{elif}\;t\_0 \leq 0.9998:\\
\;\;\;\;U + \mathsf{fma}\left(-1, \frac{J}{e^{\ell}}, J \cdot e^{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(J + J\right) \cdot \sinh \ell, \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right)\\
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0200000000000000004Initial program 86.7%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift--.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.f64N/A
sub-to-fractionN/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites75.2%
Taylor expanded in K around 0
lower-*.f64N/A
lower-expm1.f64N/A
lower-*.f6462.5%
Applied rewrites62.5%
Taylor expanded in l around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.4%
Applied rewrites50.4%
if -0.0200000000000000004 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.99980000000000002Initial program 86.7%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6464.8%
Applied rewrites64.8%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6464.8%
Applied rewrites69.7%
lift-*.f64N/A
lift-+.f64N/A
count-2N/A
*-commutativeN/A
associate-*r*N/A
lift-sinh.f64N/A
sinh-undefN/A
lift-neg.f64N/A
lift-exp.f64N/A
sub-flipN/A
distribute-lft-inN/A
lower-fma.f64N/A
lower-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
distribute-neg-frac2N/A
mult-flip-revN/A
lower-/.f64N/A
lower-neg.f64N/A
lower-exp.f6464.8%
Applied rewrites64.8%
Taylor expanded in K around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-exp.f6473.2%
Applied rewrites73.2%
if 0.99980000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 86.7%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6464.8%
Applied rewrites64.8%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6464.8%
Applied rewrites69.7%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 -0.02)
(+ (/ (* J (* l (+ 2.0 (* 2.0 l)))) (exp l)) U)
(if (<= t_0 0.9998)
(+ U (* J (- (exp l) (/ 1.0 (exp l)))))
(fma (* (+ J J) (sinh l)) (fma (* K K) -0.125 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.02) {
tmp = ((J * (l * (2.0 + (2.0 * l)))) / exp(l)) + U;
} else if (t_0 <= 0.9998) {
tmp = U + (J * (exp(l) - (1.0 / exp(l))));
} else {
tmp = fma(((J + J) * sinh(l)), fma((K * K), -0.125, 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.02) tmp = Float64(Float64(Float64(J * Float64(l * Float64(2.0 + Float64(2.0 * l)))) / exp(l)) + U); elseif (t_0 <= 0.9998) tmp = Float64(U + Float64(J * Float64(exp(l) - Float64(1.0 / exp(l))))); else tmp = fma(Float64(Float64(J + J) * sinh(l)), fma(Float64(K * K), -0.125, 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.02], N[(N[(N[(J * N[(l * N[(2.0 + N[(2.0 * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[t$95$0, 0.9998], N[(U + N[(J * N[(N[Exp[l], $MachinePrecision] - N[(1.0 / N[Exp[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] + U), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq -0.02:\\
\;\;\;\;\frac{J \cdot \left(\ell \cdot \left(2 + 2 \cdot \ell\right)\right)}{e^{\ell}} + U\\
\mathbf{elif}\;t\_0 \leq 0.9998:\\
\;\;\;\;U + J \cdot \left(e^{\ell} - \frac{1}{e^{\ell}}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(J + J\right) \cdot \sinh \ell, \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right)\\
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0200000000000000004Initial program 86.7%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift--.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.f64N/A
sub-to-fractionN/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites75.2%
Taylor expanded in K around 0
lower-*.f64N/A
lower-expm1.f64N/A
lower-*.f6462.5%
Applied rewrites62.5%
Taylor expanded in l around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.4%
Applied rewrites50.4%
if -0.0200000000000000004 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.99980000000000002Initial program 86.7%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites99.9%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower-exp.f6473.2%
Applied rewrites73.2%
if 0.99980000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 86.7%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6464.8%
Applied rewrites64.8%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6464.8%
Applied rewrites69.7%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 -0.02)
(+ (/ (* J (* l (+ 2.0 (* 2.0 l)))) (exp l)) U)
(if (<= t_0 0.9998)
(+ U (* J (- (exp l) (exp (- l)))))
(fma (* (+ J J) (sinh l)) (fma (* K K) -0.125 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.02) {
tmp = ((J * (l * (2.0 + (2.0 * l)))) / exp(l)) + U;
} else if (t_0 <= 0.9998) {
tmp = U + (J * (exp(l) - exp(-l)));
} else {
tmp = fma(((J + J) * sinh(l)), fma((K * K), -0.125, 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.02) tmp = Float64(Float64(Float64(J * Float64(l * Float64(2.0 + Float64(2.0 * l)))) / exp(l)) + U); elseif (t_0 <= 0.9998) tmp = Float64(U + Float64(J * Float64(exp(l) - exp(Float64(-l))))); else tmp = fma(Float64(Float64(J + J) * sinh(l)), fma(Float64(K * K), -0.125, 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.02], N[(N[(N[(J * N[(l * N[(2.0 + N[(2.0 * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[t$95$0, 0.9998], N[(U + N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] + U), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq -0.02:\\
\;\;\;\;\frac{J \cdot \left(\ell \cdot \left(2 + 2 \cdot \ell\right)\right)}{e^{\ell}} + U\\
\mathbf{elif}\;t\_0 \leq 0.9998:\\
\;\;\;\;U + J \cdot \left(e^{\ell} - e^{-\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(J + J\right) \cdot \sinh \ell, \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right)\\
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0200000000000000004Initial program 86.7%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift--.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.f64N/A
sub-to-fractionN/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites75.2%
Taylor expanded in K around 0
lower-*.f64N/A
lower-expm1.f64N/A
lower-*.f6462.5%
Applied rewrites62.5%
Taylor expanded in l around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.4%
Applied rewrites50.4%
if -0.0200000000000000004 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.99980000000000002Initial program 86.7%
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.2%
Applied rewrites73.2%
if 0.99980000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 86.7%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6464.8%
Applied rewrites64.8%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6464.8%
Applied rewrites69.7%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.02) (+ (/ (* J (* l (+ 2.0 (* 2.0 l)))) (exp l)) U) (+ U (* J (- (exp l) (exp (- l)))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.02) {
tmp = ((J * (l * (2.0 + (2.0 * l)))) / exp(l)) + U;
} 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.02d0)) then
tmp = ((j * (l * (2.0d0 + (2.0d0 * l)))) / exp(l)) + u
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.02) {
tmp = ((J * (l * (2.0 + (2.0 * l)))) / Math.exp(l)) + U;
} 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.02: tmp = ((J * (l * (2.0 + (2.0 * l)))) / math.exp(l)) + U 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.02) tmp = Float64(Float64(Float64(J * Float64(l * Float64(2.0 + Float64(2.0 * l)))) / exp(l)) + U); 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.02) tmp = ((J * (l * (2.0 + (2.0 * l)))) / exp(l)) + U; 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.02], N[(N[(N[(J * N[(l * N[(2.0 + N[(2.0 * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\
\;\;\;\;\frac{J \cdot \left(\ell \cdot \left(2 + 2 \cdot \ell\right)\right)}{e^{\ell}} + U\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(e^{\ell} - e^{-\ell}\right)\\
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0200000000000000004Initial program 86.7%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift--.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.f64N/A
sub-to-fractionN/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites75.2%
Taylor expanded in K around 0
lower-*.f64N/A
lower-expm1.f64N/A
lower-*.f6462.5%
Applied rewrites62.5%
Taylor expanded in l around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.4%
Applied rewrites50.4%
if -0.0200000000000000004 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 86.7%
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.2%
Applied rewrites73.2%
(FPCore (J l K U) :precision binary64 (if (<= l 500.0) (+ (/ (* (expm1 (+ l l)) J) (exp l)) U) (+ (/ (* J (expm1 (* 2.0 l))) (+ 1.0 l)) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= 500.0) {
tmp = ((expm1((l + l)) * J) / exp(l)) + U;
} else {
tmp = ((J * expm1((2.0 * l))) / (1.0 + l)) + U;
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= 500.0) {
tmp = ((Math.expm1((l + l)) * J) / Math.exp(l)) + U;
} else {
tmp = ((J * Math.expm1((2.0 * l))) / (1.0 + l)) + U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= 500.0: tmp = ((math.expm1((l + l)) * J) / math.exp(l)) + U else: tmp = ((J * math.expm1((2.0 * l))) / (1.0 + l)) + U return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= 500.0) tmp = Float64(Float64(Float64(expm1(Float64(l + l)) * J) / exp(l)) + U); else tmp = Float64(Float64(Float64(J * expm1(Float64(2.0 * l))) / Float64(1.0 + l)) + U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[l, 500.0], N[(N[(N[(N[(Exp[N[(l + l), $MachinePrecision]] - 1), $MachinePrecision] * J), $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(J * N[(Exp[N[(2.0 * l), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision] / N[(1.0 + l), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\ell \leq 500:\\
\;\;\;\;\frac{\mathsf{expm1}\left(\ell + \ell\right) \cdot J}{e^{\ell}} + U\\
\mathbf{else}:\\
\;\;\;\;\frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{1 + \ell} + U\\
\end{array}
if l < 500Initial program 86.7%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift--.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.f64N/A
sub-to-fractionN/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites75.2%
Taylor expanded in K around 0
lower-*.f64N/A
lower-expm1.f64N/A
lower-*.f6462.5%
Applied rewrites62.5%
Applied rewrites62.5%
if 500 < l Initial program 86.7%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift--.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.f64N/A
sub-to-fractionN/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites75.2%
Taylor expanded in K around 0
lower-*.f64N/A
lower-expm1.f64N/A
lower-*.f6462.5%
Applied rewrites62.5%
Taylor expanded in l around 0
lower-+.f6462.4%
Applied rewrites62.4%
(FPCore (J l K U) :precision binary64 (if (<= l 500.0) (fma (exp (- l)) (* (expm1 (+ l l)) J) U) (+ (/ (* J (expm1 (* 2.0 l))) (+ 1.0 l)) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= 500.0) {
tmp = fma(exp(-l), (expm1((l + l)) * J), U);
} else {
tmp = ((J * expm1((2.0 * l))) / (1.0 + l)) + U;
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (l <= 500.0) tmp = fma(exp(Float64(-l)), Float64(expm1(Float64(l + l)) * J), U); else tmp = Float64(Float64(Float64(J * expm1(Float64(2.0 * l))) / Float64(1.0 + l)) + U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[l, 500.0], N[(N[Exp[(-l)], $MachinePrecision] * N[(N[(Exp[N[(l + l), $MachinePrecision]] - 1), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(J * N[(Exp[N[(2.0 * l), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision] / N[(1.0 + l), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\ell \leq 500:\\
\;\;\;\;\mathsf{fma}\left(e^{-\ell}, \mathsf{expm1}\left(\ell + \ell\right) \cdot J, U\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{1 + \ell} + U\\
\end{array}
if l < 500Initial program 86.7%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift--.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.f64N/A
sub-to-fractionN/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites75.2%
Taylor expanded in K around 0
lower-*.f64N/A
lower-expm1.f64N/A
lower-*.f6462.5%
Applied rewrites62.5%
lift-+.f64N/A
lift-/.f64N/A
mult-flipN/A
lift-exp.f64N/A
exp-negN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites62.5%
if 500 < l Initial program 86.7%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift--.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.f64N/A
sub-to-fractionN/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites75.2%
Taylor expanded in K around 0
lower-*.f64N/A
lower-expm1.f64N/A
lower-*.f6462.5%
Applied rewrites62.5%
Taylor expanded in l around 0
lower-+.f6462.4%
Applied rewrites62.4%
(FPCore (J l K U) :precision binary64 (if (<= l -0.24) (+ (/ (* J (* 2.0 l)) (exp l)) U) (+ (/ (* J (expm1 (* 2.0 l))) (+ 1.0 l)) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -0.24) {
tmp = ((J * (2.0 * l)) / exp(l)) + U;
} else {
tmp = ((J * expm1((2.0 * l))) / (1.0 + l)) + U;
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -0.24) {
tmp = ((J * (2.0 * l)) / Math.exp(l)) + U;
} else {
tmp = ((J * Math.expm1((2.0 * l))) / (1.0 + l)) + U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -0.24: tmp = ((J * (2.0 * l)) / math.exp(l)) + U else: tmp = ((J * math.expm1((2.0 * l))) / (1.0 + l)) + U return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -0.24) tmp = Float64(Float64(Float64(J * Float64(2.0 * l)) / exp(l)) + U); else tmp = Float64(Float64(Float64(J * expm1(Float64(2.0 * l))) / Float64(1.0 + l)) + U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[l, -0.24], N[(N[(N[(J * N[(2.0 * l), $MachinePrecision]), $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(J * N[(Exp[N[(2.0 * l), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision] / N[(1.0 + l), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\ell \leq -0.24:\\
\;\;\;\;\frac{J \cdot \left(2 \cdot \ell\right)}{e^{\ell}} + U\\
\mathbf{else}:\\
\;\;\;\;\frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{1 + \ell} + U\\
\end{array}
if l < -0.23999999999999999Initial program 86.7%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift--.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.f64N/A
sub-to-fractionN/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites75.2%
Taylor expanded in K around 0
lower-*.f64N/A
lower-expm1.f64N/A
lower-*.f6462.5%
Applied rewrites62.5%
Taylor expanded in l around 0
lower-*.f6462.6%
Applied rewrites62.6%
if -0.23999999999999999 < l Initial program 86.7%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift--.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.f64N/A
sub-to-fractionN/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites75.2%
Taylor expanded in K around 0
lower-*.f64N/A
lower-expm1.f64N/A
lower-*.f6462.5%
Applied rewrites62.5%
Taylor expanded in l around 0
lower-+.f6462.4%
Applied rewrites62.4%
(FPCore (J l K U) :precision binary64 (if (<= l -8.0) (fma (* 2.0 (* J l)) (fma (* K K) -0.125 1.0) U) (+ (/ (* J (expm1 (* 2.0 l))) (+ 1.0 l)) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -8.0) {
tmp = fma((2.0 * (J * l)), fma((K * K), -0.125, 1.0), U);
} else {
tmp = ((J * expm1((2.0 * l))) / (1.0 + l)) + U;
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (l <= -8.0) tmp = fma(Float64(2.0 * Float64(J * l)), fma(Float64(K * K), -0.125, 1.0), U); else tmp = Float64(Float64(Float64(J * expm1(Float64(2.0 * l))) / Float64(1.0 + l)) + U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[l, -8.0], N[(N[(2.0 * N[(J * l), $MachinePrecision]), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(J * N[(Exp[N[(2.0 * l), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision] / N[(1.0 + l), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\ell \leq -8:\\
\;\;\;\;\mathsf{fma}\left(2 \cdot \left(J \cdot \ell\right), \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{J \cdot \mathsf{expm1}\left(2 \cdot \ell\right)}{1 + \ell} + U\\
\end{array}
if l < -8Initial program 86.7%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6464.8%
Applied rewrites64.8%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6464.8%
Applied rewrites69.7%
Taylor expanded in l around 0
lower-*.f64N/A
lower-*.f6448.8%
Applied rewrites48.8%
if -8 < l Initial program 86.7%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift--.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.f64N/A
sub-to-fractionN/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites75.2%
Taylor expanded in K around 0
lower-*.f64N/A
lower-expm1.f64N/A
lower-*.f6462.5%
Applied rewrites62.5%
Taylor expanded in l around 0
lower-+.f6462.4%
Applied rewrites62.4%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* 2.0 (* J l))))
(if (<= l -11.5)
(fma t_0 (fma (* K K) -0.125 1.0) U)
(if (<= l 1.1e+25) (+ t_0 U) (/ (* (+ (* (* l J) 2.0) U) U) U)))))double code(double J, double l, double K, double U) {
double t_0 = 2.0 * (J * l);
double tmp;
if (l <= -11.5) {
tmp = fma(t_0, fma((K * K), -0.125, 1.0), U);
} else if (l <= 1.1e+25) {
tmp = t_0 + U;
} else {
tmp = ((((l * J) * 2.0) + U) * U) / U;
}
return tmp;
}
function code(J, l, K, U) t_0 = Float64(2.0 * Float64(J * l)) tmp = 0.0 if (l <= -11.5) tmp = fma(t_0, fma(Float64(K * K), -0.125, 1.0), U); elseif (l <= 1.1e+25) tmp = Float64(t_0 + U); else tmp = Float64(Float64(Float64(Float64(Float64(l * J) * 2.0) + U) * U) / U); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(2.0 * N[(J * l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -11.5], N[(t$95$0 * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 1.1e+25], N[(t$95$0 + U), $MachinePrecision], N[(N[(N[(N[(N[(l * J), $MachinePrecision] * 2.0), $MachinePrecision] + U), $MachinePrecision] * U), $MachinePrecision] / U), $MachinePrecision]]]]
\begin{array}{l}
t_0 := 2 \cdot \left(J \cdot \ell\right)\\
\mathbf{if}\;\ell \leq -11.5:\\
\;\;\;\;\mathsf{fma}\left(t\_0, \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right)\\
\mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+25}:\\
\;\;\;\;t\_0 + U\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\left(\ell \cdot J\right) \cdot 2 + U\right) \cdot U}{U}\\
\end{array}
if l < -11.5Initial program 86.7%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6464.8%
Applied rewrites64.8%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6464.8%
Applied rewrites69.7%
Taylor expanded in l around 0
lower-*.f64N/A
lower-*.f6448.8%
Applied rewrites48.8%
if -11.5 < l < 1.1e25Initial program 86.7%
Taylor expanded in l around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6463.4%
Applied rewrites63.4%
Taylor expanded in K around 0
lower-*.f6453.7%
Applied rewrites53.7%
if 1.1e25 < l Initial program 86.7%
Taylor expanded in l around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6463.4%
Applied rewrites63.4%
Taylor expanded in K around 0
lower-*.f6453.7%
Applied rewrites53.7%
lift-+.f64N/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
Applied rewrites57.2%
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites41.9%
(FPCore (J l K U) :precision binary64 (let* ((t_0 (* (* l J) 2.0))) (if (<= l 1.16e+25) (fma (/ t_0 U) U U) (/ (* (+ t_0 U) U) U))))
double code(double J, double l, double K, double U) {
double t_0 = (l * J) * 2.0;
double tmp;
if (l <= 1.16e+25) {
tmp = fma((t_0 / U), U, U);
} else {
tmp = ((t_0 + U) * U) / U;
}
return tmp;
}
function code(J, l, K, U) t_0 = Float64(Float64(l * J) * 2.0) tmp = 0.0 if (l <= 1.16e+25) tmp = fma(Float64(t_0 / U), U, U); else tmp = Float64(Float64(Float64(t_0 + U) * U) / U); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(l * J), $MachinePrecision] * 2.0), $MachinePrecision]}, If[LessEqual[l, 1.16e+25], N[(N[(t$95$0 / U), $MachinePrecision] * U + U), $MachinePrecision], N[(N[(N[(t$95$0 + U), $MachinePrecision] * U), $MachinePrecision] / U), $MachinePrecision]]]
\begin{array}{l}
t_0 := \left(\ell \cdot J\right) \cdot 2\\
\mathbf{if}\;\ell \leq 1.16 \cdot 10^{+25}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t\_0}{U}, U, U\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(t\_0 + U\right) \cdot U}{U}\\
\end{array}
if l < 1.15999999999999992e25Initial program 86.7%
Taylor expanded in l around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6463.4%
Applied rewrites63.4%
Taylor expanded in K around 0
lower-*.f6453.7%
Applied rewrites53.7%
lift-+.f64N/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
Applied rewrites57.2%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6457.2%
Applied rewrites57.2%
if 1.15999999999999992e25 < l Initial program 86.7%
Taylor expanded in l around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6463.4%
Applied rewrites63.4%
Taylor expanded in K around 0
lower-*.f6453.7%
Applied rewrites53.7%
lift-+.f64N/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
Applied rewrites57.2%
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites41.9%
(FPCore (J l K U) :precision binary64 (fma (/ (* (* l J) 2.0) U) U U))
double code(double J, double l, double K, double U) {
return fma((((l * J) * 2.0) / U), U, U);
}
function code(J, l, K, U) return fma(Float64(Float64(Float64(l * J) * 2.0) / U), U, U) end
code[J_, l_, K_, U_] := N[(N[(N[(N[(l * J), $MachinePrecision] * 2.0), $MachinePrecision] / U), $MachinePrecision] * U + U), $MachinePrecision]
\mathsf{fma}\left(\frac{\left(\ell \cdot J\right) \cdot 2}{U}, U, U\right)
Initial program 86.7%
Taylor expanded in l around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6463.4%
Applied rewrites63.4%
Taylor expanded in K around 0
lower-*.f6453.7%
Applied rewrites53.7%
lift-+.f64N/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
Applied rewrites57.2%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6457.2%
Applied rewrites57.2%
(FPCore (J l K U) :precision binary64 (+ (* 2.0 (* J l)) U))
double code(double J, double l, double K, double U) {
return (2.0 * (J * l)) + 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 = (2.0d0 * (j * l)) + u
end function
public static double code(double J, double l, double K, double U) {
return (2.0 * (J * l)) + U;
}
def code(J, l, K, U): return (2.0 * (J * l)) + U
function code(J, l, K, U) return Float64(Float64(2.0 * Float64(J * l)) + U) end
function tmp = code(J, l, K, U) tmp = (2.0 * (J * l)) + U; end
code[J_, l_, K_, U_] := N[(N[(2.0 * N[(J * l), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
2 \cdot \left(J \cdot \ell\right) + U
Initial program 86.7%
Taylor expanded in l around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6463.4%
Applied rewrites63.4%
Taylor expanded in K around 0
lower-*.f6453.7%
Applied rewrites53.7%
(FPCore (J l K U) :precision binary64 U)
double code(double J, double l, double K, double U) {
return U;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(j, l, k, u)
use fmin_fmax_functions
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u
end function
public static double code(double J, double l, double K, double U) {
return U;
}
def code(J, l, K, U): return U
function code(J, l, K, U) return U end
function tmp = code(J, l, K, U) tmp = U; end
code[J_, l_, K_, U_] := U
U
Initial program 86.7%
Taylor expanded in J around 0
Applied rewrites37.2%
herbie shell --seed 2025189
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))