
(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 8 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 (* -0.5 K)) J) 2.0) (sinh l) U))
double code(double J, double l, double K, double U) {
return fma(((cos((-0.5 * K)) * J) * 2.0), sinh(l), U);
}
function code(J, l, K, U) return fma(Float64(Float64(cos(Float64(-0.5 * K)) * J) * 2.0), sinh(l), U) end
code[J_, l_, K_, U_] := N[(N[(N[(N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision] * J), $MachinePrecision] * 2.0), $MachinePrecision] * N[Sinh[l], $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\left(\cos \left(-0.5 \cdot K\right) \cdot J\right) \cdot 2, \sinh \ell, U\right)
\end{array}
Initial program 86.1%
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
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites99.9%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.01) (fma (* (cos (* 0.5 K)) J) (+ l 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.01) {
tmp = fma((cos((0.5 * K)) * J), (l + 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.01) tmp = fma(Float64(cos(Float64(0.5 * K)) * J), Float64(l + 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.01], N[(N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * J), $MachinePrecision] * N[(l + l), $MachinePrecision] + U), $MachinePrecision], N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\
\;\;\;\;\mathsf{fma}\left(\cos \left(0.5 \cdot K\right) \cdot J, \ell + \ell, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J + J, \sinh \ell, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002Initial program 86.1%
Taylor expanded in l around 0
lower-*.f6464.1
Applied rewrites64.1%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-cos.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
metadata-evalN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lift-*.f64N/A
cos-neg-revN/A
lift-cos.f64N/A
lift-*.f64N/A
Applied rewrites64.1%
if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 86.1%
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%
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
lower-fma.f64N/A
count-2-revN/A
lower-+.f6481.0
Applied rewrites81.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 -0.82)
(+ U (* J (- 1.0 (+ 1.0 (* l (- (* 0.5 l) 1.0))))))
(if (<= t_0 -0.15)
(fma (sinh l) (fma (* (* K K) J) -0.25 (+ 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.82) {
tmp = U + (J * (1.0 - (1.0 + (l * ((0.5 * l) - 1.0)))));
} else if (t_0 <= -0.15) {
tmp = fma(sinh(l), fma(((K * K) * J), -0.25, (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.82) tmp = Float64(U + Float64(J * Float64(1.0 - Float64(1.0 + Float64(l * Float64(Float64(0.5 * l) - 1.0)))))); elseif (t_0 <= -0.15) tmp = fma(sinh(l), fma(Float64(Float64(K * K) * J), -0.25, 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.82], N[(U + N[(J * N[(1.0 - N[(1.0 + N[(l * N[(N[(0.5 * l), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -0.15], N[(N[Sinh[l], $MachinePrecision] * N[(N[(N[(K * K), $MachinePrecision] * J), $MachinePrecision] * -0.25 + N[(J + J), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision] + U), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq -0.82:\\
\;\;\;\;U + J \cdot \left(1 - \left(1 + \ell \cdot \left(0.5 \cdot \ell - 1\right)\right)\right)\\
\mathbf{elif}\;t\_0 \leq -0.15:\\
\;\;\;\;\mathsf{fma}\left(\sinh \ell, \mathsf{fma}\left(\left(K \cdot K\right) \cdot J, -0.25, J + J\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J + J, \sinh \ell, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.819999999999999951Initial program 86.1%
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%
Taylor expanded in l around 0
Applied rewrites55.4%
Taylor expanded in l around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6452.1
Applied rewrites52.1%
if -0.819999999999999951 < (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.149999999999999994Initial program 86.1%
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
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites99.9%
Taylor expanded in K around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-*.f6468.5
Applied rewrites68.5%
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6468.5
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6468.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6468.5
lift-pow.f64N/A
unpow2N/A
lower-*.f6468.5
lift-*.f64N/A
count-2-revN/A
lift-+.f6468.5
Applied rewrites68.5%
if -0.149999999999999994 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 86.1%
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%
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
lower-fma.f64N/A
count-2-revN/A
lower-+.f6481.0
Applied rewrites81.0%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 9e-261) (+ U (* J (- 1.0 (+ 1.0 (* l (- (* 0.5 l) 1.0)))))) (fma (+ J J) (sinh l) U)))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 9e-261) {
tmp = U + (J * (1.0 - (1.0 + (l * ((0.5 * l) - 1.0)))));
} 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)) <= 9e-261) tmp = Float64(U + Float64(J * Float64(1.0 - Float64(1.0 + Float64(l * Float64(Float64(0.5 * l) - 1.0)))))); 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], 9e-261], N[(U + N[(J * N[(1.0 - N[(1.0 + N[(l * N[(N[(0.5 * l), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(J + J), $MachinePrecision] * N[Sinh[l], $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 9 \cdot 10^{-261}:\\
\;\;\;\;U + J \cdot \left(1 - \left(1 + \ell \cdot \left(0.5 \cdot \ell - 1\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J + J, \sinh \ell, U\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 9.0000000000000002e-261Initial program 86.1%
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%
Taylor expanded in l around 0
Applied rewrites55.4%
Taylor expanded in l around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6452.1
Applied rewrites52.1%
if 9.0000000000000002e-261 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 86.1%
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%
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
lower-fma.f64N/A
count-2-revN/A
lower-+.f6481.0
Applied rewrites81.0%
(FPCore (J l K U) :precision binary64 (if (<= l -36000000.0) (fma (- 1.0 (exp (- l))) J U) (if (<= l 8e-25) (fma (+ J J) l U) (fma (* (/ l U) (+ J J)) U U))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -36000000.0) {
tmp = fma((1.0 - exp(-l)), J, U);
} else if (l <= 8e-25) {
tmp = fma((J + J), l, U);
} else {
tmp = fma(((l / U) * (J + J)), U, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (l <= -36000000.0) tmp = fma(Float64(1.0 - exp(Float64(-l))), J, U); elseif (l <= 8e-25) tmp = fma(Float64(J + J), l, U); else tmp = fma(Float64(Float64(l / U) * Float64(J + J)), U, U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[l, -36000000.0], N[(N[(1.0 - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision], If[LessEqual[l, 8e-25], N[(N[(J + J), $MachinePrecision] * l + U), $MachinePrecision], N[(N[(N[(l / U), $MachinePrecision] * N[(J + J), $MachinePrecision]), $MachinePrecision] * U + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -36000000:\\
\;\;\;\;\mathsf{fma}\left(1 - e^{-\ell}, J, U\right)\\
\mathbf{elif}\;\ell \leq 8 \cdot 10^{-25}:\\
\;\;\;\;\mathsf{fma}\left(J + J, \ell, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\ell}{U} \cdot \left(J + J\right), U, U\right)\\
\end{array}
\end{array}
if l < -3.6e7Initial program 86.1%
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%
Taylor expanded in l around 0
Applied rewrites55.4%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6455.4
Applied rewrites55.4%
if -3.6e7 < l < 8.00000000000000031e-25Initial program 86.1%
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%
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
lower-fma.f64N/A
count-2-revN/A
lower-+.f6481.0
Applied rewrites81.0%
Taylor expanded in l around 0
Applied rewrites54.3%
if 8.00000000000000031e-25 < l Initial program 86.1%
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%
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
lower-fma.f64N/A
count-2-revN/A
lower-+.f6481.0
Applied rewrites81.0%
lift-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
sum-to-mult-revN/A
lift-/.f64N/A
lift-+.f64N/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6479.9
Applied rewrites79.9%
Taylor expanded in l around 0
lower-/.f6460.3
Applied rewrites60.3%
(FPCore (J l K U) :precision binary64 (fma (* (/ l U) (+ J J)) U U))
double code(double J, double l, double K, double U) {
return fma(((l / U) * (J + J)), U, U);
}
function code(J, l, K, U) return fma(Float64(Float64(l / U) * Float64(J + J)), U, U) end
code[J_, l_, K_, U_] := N[(N[(N[(l / U), $MachinePrecision] * N[(J + J), $MachinePrecision]), $MachinePrecision] * U + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{\ell}{U} \cdot \left(J + J\right), U, U\right)
\end{array}
Initial program 86.1%
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%
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
lower-fma.f64N/A
count-2-revN/A
lower-+.f6481.0
Applied rewrites81.0%
lift-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
sum-to-mult-revN/A
lift-/.f64N/A
lift-+.f64N/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6479.9
Applied rewrites79.9%
Taylor expanded in l around 0
lower-/.f6460.3
Applied rewrites60.3%
(FPCore (J l K U) :precision binary64 (fma (+ J J) l U))
double code(double J, double l, double K, double U) {
return fma((J + J), l, U);
}
function code(J, l, K, U) return fma(Float64(J + J), l, U) end
code[J_, l_, K_, U_] := N[(N[(J + J), $MachinePrecision] * l + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(J + J, \ell, U\right)
\end{array}
Initial program 86.1%
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%
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
lower-fma.f64N/A
count-2-revN/A
lower-+.f6481.0
Applied rewrites81.0%
Taylor expanded in l around 0
Applied rewrites54.3%
(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 86.1%
Taylor expanded in J around 0
Applied rewrites36.6%
herbie shell --seed 2025154
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))