
(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 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]
\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.5%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
associate-*l*N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites100.0%
lift-fma.f64N/A
lift-*.f64N/A
associate-*r*N/A
Applied rewrites100.0%
(FPCore (J l K U) :precision binary64 (fma (* (cos (* -0.5 K)) (+ J J)) (sinh l) U))
double code(double J, double l, double K, double U) {
return fma((cos((-0.5 * K)) * (J + J)), sinh(l), U);
}
function code(J, l, K, U) return fma(Float64(cos(Float64(-0.5 * K)) * Float64(J + J)), sinh(l), U) end
code[J_, l_, K_, U_] := N[(N[(N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision] * N[(J + J), $MachinePrecision]), $MachinePrecision] * N[Sinh[l], $MachinePrecision] + U), $MachinePrecision]
\mathsf{fma}\left(\cos \left(-0.5 \cdot K\right) \cdot \left(J + J\right), \sinh \ell, U\right)
Initial program 86.5%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
associate-*l*N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites100.0%
lift-fma.f64N/A
lift-*.f64N/A
associate-*r*N/A
Applied rewrites100.0%
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
metadata-evalN/A
distribute-lft-neg-inN/A
lift-*.f64N/A
cos-neg-revN/A
lift-cos.f64N/A
lower-*.f64100.0%
Applied rewrites100.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 -0.56)
(+ (* (* J (- (exp l) (exp (- l)))) (+ 1.0 (* -0.125 (pow K 2.0)))) U)
(if (<= t_0 0.02)
(fma l (* (cos (* -0.5 K)) (+ J J)) U)
(fma (+ J J) (sinh l) U)))))double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double tmp;
if (t_0 <= -0.56) {
tmp = ((J * (exp(l) - exp(-l))) * (1.0 + (-0.125 * pow(K, 2.0)))) + U;
} else if (t_0 <= 0.02) {
tmp = fma(l, (cos((-0.5 * K)) * (J + J)), U);
} else {
tmp = fma((J + J), sinh(l), U);
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= -0.56) tmp = Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * Float64(1.0 + Float64(-0.125 * (K ^ 2.0)))) + U); elseif (t_0 <= 0.02) tmp = fma(l, Float64(cos(Float64(-0.5 * K)) * Float64(J + J)), U); else tmp = fma(Float64(J + J), sinh(l), 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.56], N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.125 * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[t$95$0, 0.02], N[(l * N[(N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision] * N[(J + J), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision] + U), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq -0.56:\\
\;\;\;\;\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \left(1 + -0.125 \cdot {K}^{2}\right) + U\\
\mathbf{elif}\;t\_0 \leq 0.02:\\
\;\;\;\;\mathsf{fma}\left(\ell, \cos \left(-0.5 \cdot K\right) \cdot \left(J + J\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J + J, \sinh \ell, U\right)\\
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.56000000000000005Initial program 86.5%
Taylor expanded in K around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6464.8%
Applied rewrites64.8%
if -0.56000000000000005 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.0200000000000000004Initial program 86.5%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
associate-*l*N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in l around 0
Applied rewrites63.5%
lift-fma.f64N/A
add-flipN/A
sub-flipN/A
Applied rewrites63.5%
if 0.0200000000000000004 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 86.5%
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.f6472.9%
Applied rewrites72.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
lift-sinh.f64N/A
associate-*r*N/A
*-commutativeN/A
count-2N/A
lift-+.f64N/A
lower-fma.f6480.2%
Applied rewrites80.2%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U)))
(if (<= t_0 (- INFINITY))
(fma (* (+ J J) (sinh l)) (fma (* K K) -0.125 1.0) U)
(if (<= t_0 2e+111)
(fma (* l (+ J J)) (cos (* -0.5 K)) U)
(fma (+ J J) (sinh l) U)))))double code(double J, double l, double K, double U) {
double t_0 = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = fma(((J + J) * sinh(l)), fma((K * K), -0.125, 1.0), U);
} else if (t_0 <= 2e+111) {
tmp = fma((l * (J + J)), cos((-0.5 * K)), U);
} else {
tmp = fma((J + J), sinh(l), U);
}
return tmp;
}
function code(J, l, K, U) t_0 = Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = fma(Float64(Float64(J + J) * sinh(l)), fma(Float64(K * K), -0.125, 1.0), U); elseif (t_0 <= 2e+111) tmp = fma(Float64(l * Float64(J + J)), cos(Float64(-0.5 * K)), U); else tmp = fma(Float64(J + J), sinh(l), U); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = 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]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[t$95$0, 2e+111], N[(N[(l * N[(J + J), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision] + U), $MachinePrecision], N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision] + U), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(\left(J + J\right) \cdot \sinh \ell, \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right)\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+111}:\\
\;\;\;\;\mathsf{fma}\left(\ell \cdot \left(J + J\right), \cos \left(-0.5 \cdot K\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J + J, \sinh \ell, U\right)\\
\end{array}
if (+.f64 (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) U) < -inf.0Initial program 86.5%
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.5%
if -inf.0 < (+.f64 (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) U) < 1.99999999999999991e111Initial program 86.5%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
associate-*l*N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in l around 0
Applied rewrites63.5%
lift-fma.f64N/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f64N/A
count-2-revN/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
lift-+.f64N/A
lower-*.f6463.5%
Applied rewrites63.5%
if 1.99999999999999991e111 < (+.f64 (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) U) Initial program 86.5%
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.f6472.9%
Applied rewrites72.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
lift-sinh.f64N/A
associate-*r*N/A
*-commutativeN/A
count-2N/A
lift-+.f64N/A
lower-fma.f6480.2%
Applied rewrites80.2%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U)))
(if (<= t_0 (- INFINITY))
(fma (* (+ J J) (sinh l)) (fma (* K K) -0.125 1.0) U)
(if (<= t_0 2e+111)
(fma l (* (cos (* -0.5 K)) (+ J J)) U)
(fma (+ J J) (sinh l) U)))))double code(double J, double l, double K, double U) {
double t_0 = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = fma(((J + J) * sinh(l)), fma((K * K), -0.125, 1.0), U);
} else if (t_0 <= 2e+111) {
tmp = fma(l, (cos((-0.5 * K)) * (J + J)), U);
} else {
tmp = fma((J + J), sinh(l), U);
}
return tmp;
}
function code(J, l, K, U) t_0 = Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = fma(Float64(Float64(J + J) * sinh(l)), fma(Float64(K * K), -0.125, 1.0), U); elseif (t_0 <= 2e+111) tmp = fma(l, Float64(cos(Float64(-0.5 * K)) * Float64(J + J)), U); else tmp = fma(Float64(J + J), sinh(l), U); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = 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]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[t$95$0, 2e+111], N[(l * N[(N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision] * N[(J + J), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision] + U), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(\left(J + J\right) \cdot \sinh \ell, \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right)\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+111}:\\
\;\;\;\;\mathsf{fma}\left(\ell, \cos \left(-0.5 \cdot K\right) \cdot \left(J + J\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J + J, \sinh \ell, U\right)\\
\end{array}
if (+.f64 (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) U) < -inf.0Initial program 86.5%
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.5%
if -inf.0 < (+.f64 (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) U) < 1.99999999999999991e111Initial program 86.5%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
associate-*l*N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in l around 0
Applied rewrites63.5%
lift-fma.f64N/A
add-flipN/A
sub-flipN/A
Applied rewrites63.5%
if 1.99999999999999991e111 < (+.f64 (*.f64 (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) (cos.f64 (/.f64 K #s(literal 2 binary64)))) U) Initial program 86.5%
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.f6472.9%
Applied rewrites72.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
lift-sinh.f64N/A
associate-*r*N/A
*-commutativeN/A
count-2N/A
lift-+.f64N/A
lower-fma.f6480.2%
Applied rewrites80.2%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.04) (fma (+ J J) (* (fma -0.125 (* K K) 1.0) (sinh l)) U) (fma (+ J J) (sinh l) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.04) {
tmp = fma((J + J), (fma(-0.125, (K * K), 1.0) * sinh(l)), U);
} else {
tmp = fma((J + J), sinh(l), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.04) tmp = fma(Float64(J + J), Float64(fma(-0.125, Float64(K * K), 1.0) * sinh(l)), U); else tmp = fma(Float64(J + J), sinh(l), U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.04], N[(N[(J + J), $MachinePrecision] * N[(N[(-0.125 * N[(K * K), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sinh[l], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.04:\\
\;\;\;\;\mathsf{fma}\left(J + J, \mathsf{fma}\left(-0.125, K \cdot K, 1\right) \cdot \sinh \ell, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J + J, \sinh \ell, U\right)\\
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0400000000000000008Initial program 86.5%
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.5%
lift-fma.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6469.2%
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6469.2%
Applied rewrites69.2%
if -0.0400000000000000008 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 86.5%
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.f6472.9%
Applied rewrites72.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
lift-sinh.f64N/A
associate-*r*N/A
*-commutativeN/A
count-2N/A
lift-+.f64N/A
lower-fma.f6480.2%
Applied rewrites80.2%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.04) (fma (* (+ J J) (sinh l)) (fma (* K K) -0.125 1.0) U) (fma (+ J J) (sinh l) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.04) {
tmp = fma(((J + J) * sinh(l)), fma((K * K), -0.125, 1.0), U);
} else {
tmp = fma((J + J), sinh(l), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.04) tmp = fma(Float64(Float64(J + J) * sinh(l)), fma(Float64(K * K), -0.125, 1.0), U); else tmp = fma(Float64(J + J), sinh(l), U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.04], N[(N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision]), $MachinePrecision] * N[(N[(K * K), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision] + U), $MachinePrecision], N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.04:\\
\;\;\;\;\mathsf{fma}\left(\left(J + J\right) \cdot \sinh \ell, \mathsf{fma}\left(K \cdot K, -0.125, 1\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J + J, \sinh \ell, U\right)\\
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0400000000000000008Initial program 86.5%
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.5%
if -0.0400000000000000008 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 86.5%
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.f6472.9%
Applied rewrites72.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
lift-sinh.f64N/A
associate-*r*N/A
*-commutativeN/A
count-2N/A
lift-+.f64N/A
lower-fma.f6480.2%
Applied rewrites80.2%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.04) (fma (+ J J) (* (fma -0.125 (* K K) 1.0) l) U) (fma (+ J J) (sinh l) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.04) {
tmp = fma((J + J), (fma(-0.125, (K * K), 1.0) * l), U);
} else {
tmp = fma((J + J), sinh(l), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.04) tmp = fma(Float64(J + J), Float64(fma(-0.125, Float64(K * K), 1.0) * l), U); else tmp = fma(Float64(J + J), sinh(l), U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.04], N[(N[(J + J), $MachinePrecision] * N[(N[(-0.125 * N[(K * K), $MachinePrecision] + 1.0), $MachinePrecision] * l), $MachinePrecision] + U), $MachinePrecision], N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.04:\\
\;\;\;\;\mathsf{fma}\left(J + J, \mathsf{fma}\left(-0.125, K \cdot K, 1\right) \cdot \ell, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J + J, \sinh \ell, U\right)\\
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0400000000000000008Initial program 86.5%
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.5%
lift-fma.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6469.2%
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6469.2%
Applied rewrites69.2%
Taylor expanded in l around 0
Applied rewrites48.9%
if -0.0400000000000000008 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 86.5%
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.f6472.9%
Applied rewrites72.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
lift-sinh.f64N/A
associate-*r*N/A
*-commutativeN/A
count-2N/A
lift-+.f64N/A
lower-fma.f6480.2%
Applied rewrites80.2%
(FPCore (J l K U)
:precision binary64
(if (<= l -11.0)
(+ U (* J (- 1.0 (exp (- l)))))
(if (<= l 1.34e+26)
(fma 2.0 (* J l) U)
(fma (+ J J) (* (fma -0.125 (* K K) 1.0) l) U))))double code(double J, double l, double K, double U) {
double tmp;
if (l <= -11.0) {
tmp = U + (J * (1.0 - exp(-l)));
} else if (l <= 1.34e+26) {
tmp = fma(2.0, (J * l), U);
} else {
tmp = fma((J + J), (fma(-0.125, (K * K), 1.0) * l), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (l <= -11.0) tmp = Float64(U + Float64(J * Float64(1.0 - exp(Float64(-l))))); elseif (l <= 1.34e+26) tmp = fma(2.0, Float64(J * l), U); else tmp = fma(Float64(J + J), Float64(fma(-0.125, Float64(K * K), 1.0) * l), U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[l, -11.0], N[(U + N[(J * N[(1.0 - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.34e+26], N[(2.0 * N[(J * l), $MachinePrecision] + U), $MachinePrecision], N[(N[(J + J), $MachinePrecision] * N[(N[(-0.125 * N[(K * K), $MachinePrecision] + 1.0), $MachinePrecision] * l), $MachinePrecision] + U), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;\ell \leq -11:\\
\;\;\;\;U + J \cdot \left(1 - e^{-\ell}\right)\\
\mathbf{elif}\;\ell \leq 1.34 \cdot 10^{+26}:\\
\;\;\;\;\mathsf{fma}\left(2, J \cdot \ell, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J + J, \mathsf{fma}\left(-0.125, K \cdot K, 1\right) \cdot \ell, U\right)\\
\end{array}
if l < -11Initial program 86.5%
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.f6472.9%
Applied rewrites72.9%
Taylor expanded in l around 0
Applied rewrites55.3%
if -11 < l < 1.34000000000000007e26Initial program 86.5%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
associate-*l*N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites80.2%
Taylor expanded in l around 0
lower-*.f6453.4%
Applied rewrites53.4%
if 1.34000000000000007e26 < l Initial program 86.5%
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.5%
lift-fma.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6469.2%
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6469.2%
Applied rewrites69.2%
Taylor expanded in l around 0
Applied rewrites48.9%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.04) (fma (+ J J) (* (fma -0.125 (* K K) 1.0) l) U) (* (+ 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.04) {
tmp = fma((J + J), (fma(-0.125, (K * K), 1.0) * l), U);
} 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.04) tmp = fma(Float64(J + J), Float64(fma(-0.125, Float64(K * K), 1.0) * l), U); else tmp = Float64(Float64(1.0 + Float64(Float64(Float64(l * J) * 2.0) / U)) * U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.04], N[(N[(J + J), $MachinePrecision] * N[(N[(-0.125 * N[(K * K), $MachinePrecision] + 1.0), $MachinePrecision] * l), $MachinePrecision] + U), $MachinePrecision], N[(N[(1.0 + N[(N[(N[(l * J), $MachinePrecision] * 2.0), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision] * U), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.04:\\
\;\;\;\;\mathsf{fma}\left(J + J, \mathsf{fma}\left(-0.125, K \cdot K, 1\right) \cdot \ell, U\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \frac{\left(\ell \cdot J\right) \cdot 2}{U}\right) \cdot U\\
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0400000000000000008Initial program 86.5%
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.5%
lift-fma.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6469.2%
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6469.2%
Applied rewrites69.2%
Taylor expanded in l around 0
Applied rewrites48.9%
if -0.0400000000000000008 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 86.5%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
associate-*l*N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites80.2%
Taylor expanded in l around 0
lower-*.f6453.4%
Applied rewrites53.4%
lift-fma.f64N/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
*-commutativeN/A
lower-*.f6457.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6457.2%
Applied rewrites57.2%
(FPCore (J l K U) :precision binary64 (* (+ 1.0 (/ (* (* l J) 2.0) U)) U))
double code(double J, double l, double K, double U) {
return (1.0 + (((l * J) * 2.0) / U)) * 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 = (1.0d0 + (((l * j) * 2.0d0) / u)) * u
end function
public static double code(double J, double l, double K, double U) {
return (1.0 + (((l * J) * 2.0) / U)) * U;
}
def code(J, l, K, U): return (1.0 + (((l * J) * 2.0) / U)) * U
function code(J, l, K, U) return Float64(Float64(1.0 + Float64(Float64(Float64(l * J) * 2.0) / U)) * U) end
function tmp = code(J, l, K, U) tmp = (1.0 + (((l * J) * 2.0) / U)) * U; end
code[J_, l_, K_, U_] := N[(N[(1.0 + N[(N[(N[(l * J), $MachinePrecision] * 2.0), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision] * U), $MachinePrecision]
\left(1 + \frac{\left(\ell \cdot J\right) \cdot 2}{U}\right) \cdot U
Initial program 86.5%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
associate-*l*N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites80.2%
Taylor expanded in l around 0
lower-*.f6453.4%
Applied rewrites53.4%
lift-fma.f64N/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
*-commutativeN/A
lower-*.f6457.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6457.2%
Applied rewrites57.2%
(FPCore (J l K U) :precision binary64 (fma 2.0 (* J l) U))
double code(double J, double l, double K, double U) {
return fma(2.0, (J * l), U);
}
function code(J, l, K, U) return fma(2.0, Float64(J * l), U) end
code[J_, l_, K_, U_] := N[(2.0 * N[(J * l), $MachinePrecision] + U), $MachinePrecision]
\mathsf{fma}\left(2, J \cdot \ell, U\right)
Initial program 86.5%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
associate-*l*N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in K around 0
Applied rewrites80.2%
Taylor expanded in l around 0
lower-*.f6453.4%
Applied rewrites53.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
U
Initial program 86.5%
Taylor expanded in J around 0
Applied rewrites36.3%
herbie shell --seed 2025183
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))