
(FPCore (x y z t a b c i) :precision binary64 (+ (+ (+ (+ (+ (* x (log y)) z) t) a) (* (- b 0.5) (log c))) (* y i)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i);
}
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(x, y, z, t, a, b, c, i)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
code = (((((x * log(y)) + z) + t) + a) + ((b - 0.5d0) * log(c))) + (y * i)
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((((x * Math.log(y)) + z) + t) + a) + ((b - 0.5) * Math.log(c))) + (y * i);
}
def code(x, y, z, t, a, b, c, i): return (((((x * math.log(y)) + z) + t) + a) + ((b - 0.5) * math.log(c))) + (y * i)
function code(x, y, z, t, a, b, c, i) return Float64(Float64(Float64(Float64(Float64(Float64(x * log(y)) + z) + t) + a) + Float64(Float64(b - 0.5) * log(c))) + Float64(y * i)) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i); end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision] + t), $MachinePrecision] + a), $MachinePrecision] + N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * i), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right) + y \cdot i
\end{array}
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b c i) :precision binary64 (+ (+ (+ (+ (+ (* x (log y)) z) t) a) (* (- b 0.5) (log c))) (* y i)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i);
}
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(x, y, z, t, a, b, c, i)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
code = (((((x * log(y)) + z) + t) + a) + ((b - 0.5d0) * log(c))) + (y * i)
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((((x * Math.log(y)) + z) + t) + a) + ((b - 0.5) * Math.log(c))) + (y * i);
}
def code(x, y, z, t, a, b, c, i): return (((((x * math.log(y)) + z) + t) + a) + ((b - 0.5) * math.log(c))) + (y * i)
function code(x, y, z, t, a, b, c, i) return Float64(Float64(Float64(Float64(Float64(Float64(x * log(y)) + z) + t) + a) + Float64(Float64(b - 0.5) * log(c))) + Float64(y * i)) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i); end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision] + t), $MachinePrecision] + a), $MachinePrecision] + N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * i), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right) + y \cdot i
\end{array}
(FPCore (x y z t a b c i) :precision binary64 (fma y i (+ (+ (fma (log c) (- b 0.5) (fma (log y) x z)) a) t)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return fma(y, i, ((fma(log(c), (b - 0.5), fma(log(y), x, z)) + a) + t));
}
function code(x, y, z, t, a, b, c, i) return fma(y, i, Float64(Float64(fma(log(c), Float64(b - 0.5), fma(log(y), x, z)) + a) + t)) end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(y * i + N[(N[(N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision] + N[(N[Log[y], $MachinePrecision] * x + z), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, i, \left(\mathsf{fma}\left(\log c, b - 0.5, \mathsf{fma}\left(\log y, x, z\right)\right) + a\right) + t\right)
\end{array}
Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.8
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites99.8%
(FPCore (x y z t a b c i) :precision binary64 (+ a (+ z (fma i y (fma x (log y) (* (log c) (- b 0.5)))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return a + (z + fma(i, y, fma(x, log(y), (log(c) * (b - 0.5)))));
}
function code(x, y, z, t, a, b, c, i) return Float64(a + Float64(z + fma(i, y, fma(x, log(y), Float64(log(c) * Float64(b - 0.5)))))) end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(a + N[(z + N[(i * y + N[(x * N[Log[y], $MachinePrecision] + N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a + \left(z + \mathsf{fma}\left(i, y, \mathsf{fma}\left(x, \log y, \log c \cdot \left(b - 0.5\right)\right)\right)\right)
\end{array}
Initial program 99.8%
Taylor expanded in t around 0
lower-+.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6484.3
Applied rewrites84.3%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma y i (+ (+ (fma (log c) -0.5 (fma (log y) x z)) a) t))))
(if (<= x -9e+101)
t_1
(if (<= x 2.1e+33) (fma y i (+ (+ (fma (log c) (- b 0.5) z) a) t)) t_1))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(y, i, ((fma(log(c), -0.5, fma(log(y), x, z)) + a) + t));
double tmp;
if (x <= -9e+101) {
tmp = t_1;
} else if (x <= 2.1e+33) {
tmp = fma(y, i, ((fma(log(c), (b - 0.5), z) + a) + t));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(y, i, Float64(Float64(fma(log(c), -0.5, fma(log(y), x, z)) + a) + t)) tmp = 0.0 if (x <= -9e+101) tmp = t_1; elseif (x <= 2.1e+33) tmp = fma(y, i, Float64(Float64(fma(log(c), Float64(b - 0.5), z) + a) + t)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(y * i + N[(N[(N[(N[Log[c], $MachinePrecision] * -0.5 + N[(N[Log[y], $MachinePrecision] * x + z), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -9e+101], t$95$1, If[LessEqual[x, 2.1e+33], N[(y * i + N[(N[(N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision] + z), $MachinePrecision] + a), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y, i, \left(\mathsf{fma}\left(\log c, -0.5, \mathsf{fma}\left(\log y, x, z\right)\right) + a\right) + t\right)\\
\mathbf{if}\;x \leq -9 \cdot 10^{+101}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{+33}:\\
\;\;\;\;\mathsf{fma}\left(y, i, \left(\mathsf{fma}\left(\log c, b - 0.5, z\right) + a\right) + t\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -9.0000000000000004e101 or 2.1000000000000001e33 < x Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.8
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites99.8%
Taylor expanded in b around 0
Applied rewrites84.3%
if -9.0000000000000004e101 < x < 2.1000000000000001e33Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.8
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites84.7%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (+ a (+ z (fma i y (fma x (log y) (* (log c) -0.5)))))))
(if (<= x -1.16e+104)
t_1
(if (<= x 2.2e+69) (fma y i (+ (+ (fma (log c) (- b 0.5) z) a) t)) t_1))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = a + (z + fma(i, y, fma(x, log(y), (log(c) * -0.5))));
double tmp;
if (x <= -1.16e+104) {
tmp = t_1;
} else if (x <= 2.2e+69) {
tmp = fma(y, i, ((fma(log(c), (b - 0.5), z) + a) + t));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = Float64(a + Float64(z + fma(i, y, fma(x, log(y), Float64(log(c) * -0.5))))) tmp = 0.0 if (x <= -1.16e+104) tmp = t_1; elseif (x <= 2.2e+69) tmp = fma(y, i, Float64(Float64(fma(log(c), Float64(b - 0.5), z) + a) + t)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(a + N[(z + N[(i * y + N[(x * N[Log[y], $MachinePrecision] + N[(N[Log[c], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.16e+104], t$95$1, If[LessEqual[x, 2.2e+69], N[(y * i + N[(N[(N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision] + z), $MachinePrecision] + a), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a + \left(z + \mathsf{fma}\left(i, y, \mathsf{fma}\left(x, \log y, \log c \cdot -0.5\right)\right)\right)\\
\mathbf{if}\;x \leq -1.16 \cdot 10^{+104}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{+69}:\\
\;\;\;\;\mathsf{fma}\left(y, i, \left(\mathsf{fma}\left(\log c, b - 0.5, z\right) + a\right) + t\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -1.1599999999999999e104 or 2.2000000000000002e69 < x Initial program 99.8%
Taylor expanded in t around 0
lower-+.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6484.3
Applied rewrites84.3%
Taylor expanded in b around 0
Applied rewrites69.1%
if -1.1599999999999999e104 < x < 2.2000000000000002e69Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.8
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites84.7%
(FPCore (x y z t a b c i) :precision binary64 (if (<= z -3.4e+116) (fma y i (+ (+ (fma (log c) (- b 0.5) z) a) t)) (+ a (fma i y (fma x (log y) (* (log c) (- b 0.5)))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (z <= -3.4e+116) {
tmp = fma(y, i, ((fma(log(c), (b - 0.5), z) + a) + t));
} else {
tmp = a + fma(i, y, fma(x, log(y), (log(c) * (b - 0.5))));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (z <= -3.4e+116) tmp = fma(y, i, Float64(Float64(fma(log(c), Float64(b - 0.5), z) + a) + t)); else tmp = Float64(a + fma(i, y, fma(x, log(y), Float64(log(c) * Float64(b - 0.5))))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[z, -3.4e+116], N[(y * i + N[(N[(N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision] + z), $MachinePrecision] + a), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision], N[(a + N[(i * y + N[(x * N[Log[y], $MachinePrecision] + N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.4 \cdot 10^{+116}:\\
\;\;\;\;\mathsf{fma}\left(y, i, \left(\mathsf{fma}\left(\log c, b - 0.5, z\right) + a\right) + t\right)\\
\mathbf{else}:\\
\;\;\;\;a + \mathsf{fma}\left(i, y, \mathsf{fma}\left(x, \log y, \log c \cdot \left(b - 0.5\right)\right)\right)\\
\end{array}
\end{array}
if z < -3.40000000000000023e116Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.8
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites84.7%
if -3.40000000000000023e116 < z Initial program 99.8%
Taylor expanded in t around 0
lower-+.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6484.3
Applied rewrites84.3%
Taylor expanded in z around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6469.1
Applied rewrites69.1%
(FPCore (x y z t a b c i) :precision binary64 (if (<= y 7.2e+91) (+ a (+ z (fma x (log y) (* (log c) (- b 0.5))))) (+ a (+ z (fma i y (* b (log c)))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (y <= 7.2e+91) {
tmp = a + (z + fma(x, log(y), (log(c) * (b - 0.5))));
} else {
tmp = a + (z + fma(i, y, (b * log(c))));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (y <= 7.2e+91) tmp = Float64(a + Float64(z + fma(x, log(y), Float64(log(c) * Float64(b - 0.5))))); else tmp = Float64(a + Float64(z + fma(i, y, Float64(b * log(c))))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[y, 7.2e+91], N[(a + N[(z + N[(x * N[Log[y], $MachinePrecision] + N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a + N[(z + N[(i * y + N[(b * N[Log[c], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.2 \cdot 10^{+91}:\\
\;\;\;\;a + \left(z + \mathsf{fma}\left(x, \log y, \log c \cdot \left(b - 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;a + \left(z + \mathsf{fma}\left(i, y, b \cdot \log c\right)\right)\\
\end{array}
\end{array}
if y < 7.2e91Initial program 99.8%
Taylor expanded in t around 0
lower-+.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6484.3
Applied rewrites84.3%
Taylor expanded in b around inf
lower-*.f64N/A
lower-+.f64N/A
lower-log.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-log.f6473.8
Applied rewrites73.8%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6473.8
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-/.f64N/A
div-add-revN/A
lower-/.f64N/A
lower-fma.f6473.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6473.8
Applied rewrites73.8%
Taylor expanded in y around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6462.0
Applied rewrites62.0%
if 7.2e91 < y Initial program 99.8%
Taylor expanded in t around 0
lower-+.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6484.3
Applied rewrites84.3%
Taylor expanded in b around inf
lower-*.f64N/A
lower-+.f64N/A
lower-log.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-log.f6473.8
Applied rewrites73.8%
Taylor expanded in b around inf
lower-log.f6467.9
Applied rewrites67.9%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* x (log y))))
(if (<= x -7e+154)
t_1
(if (<= x 2.8e+221) (+ a (+ z (fma i y (* (log c) (- b 0.5))))) t_1))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = x * log(y);
double tmp;
if (x <= -7e+154) {
tmp = t_1;
} else if (x <= 2.8e+221) {
tmp = a + (z + fma(i, y, (log(c) * (b - 0.5))));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = Float64(x * log(y)) tmp = 0.0 if (x <= -7e+154) tmp = t_1; elseif (x <= 2.8e+221) tmp = Float64(a + Float64(z + fma(i, y, Float64(log(c) * Float64(b - 0.5))))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -7e+154], t$95$1, If[LessEqual[x, 2.8e+221], N[(a + N[(z + N[(i * y + N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \log y\\
\mathbf{if}\;x \leq -7 \cdot 10^{+154}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{+221}:\\
\;\;\;\;a + \left(z + \mathsf{fma}\left(i, y, \log c \cdot \left(b - 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -7.00000000000000041e154 or 2.79999999999999989e221 < x Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.8
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites99.8%
Taylor expanded in x around inf
lower-*.f64N/A
lower-log.f6416.0
Applied rewrites16.0%
if -7.00000000000000041e154 < x < 2.79999999999999989e221Initial program 99.8%
Taylor expanded in t around 0
lower-+.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6484.3
Applied rewrites84.3%
Taylor expanded in x around 0
lower-*.f64N/A
lower-log.f64N/A
lower--.f6469.5
Applied rewrites69.5%
(FPCore (x y z t a b c i) :precision binary64 (if (<= x 2.8e+221) (fma y i (+ (+ (fma (log c) (- b 0.5) z) a) t)) (* x (log y))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (x <= 2.8e+221) {
tmp = fma(y, i, ((fma(log(c), (b - 0.5), z) + a) + t));
} else {
tmp = x * log(y);
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (x <= 2.8e+221) tmp = fma(y, i, Float64(Float64(fma(log(c), Float64(b - 0.5), z) + a) + t)); else tmp = Float64(x * log(y)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[x, 2.8e+221], N[(y * i + N[(N[(N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision] + z), $MachinePrecision] + a), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision], N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.8 \cdot 10^{+221}:\\
\;\;\;\;\mathsf{fma}\left(y, i, \left(\mathsf{fma}\left(\log c, b - 0.5, z\right) + a\right) + t\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log y\\
\end{array}
\end{array}
if x < 2.79999999999999989e221Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.8
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites84.7%
if 2.79999999999999989e221 < x Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.8
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites99.8%
Taylor expanded in x around inf
lower-*.f64N/A
lower-log.f6416.0
Applied rewrites16.0%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* x (log y))))
(if (<= x -7e+154)
t_1
(if (<= x 2.8e+221) (+ a (+ z (fma i y (* b (log c))))) t_1))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = x * log(y);
double tmp;
if (x <= -7e+154) {
tmp = t_1;
} else if (x <= 2.8e+221) {
tmp = a + (z + fma(i, y, (b * log(c))));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = Float64(x * log(y)) tmp = 0.0 if (x <= -7e+154) tmp = t_1; elseif (x <= 2.8e+221) tmp = Float64(a + Float64(z + fma(i, y, Float64(b * log(c))))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -7e+154], t$95$1, If[LessEqual[x, 2.8e+221], N[(a + N[(z + N[(i * y + N[(b * N[Log[c], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \log y\\
\mathbf{if}\;x \leq -7 \cdot 10^{+154}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{+221}:\\
\;\;\;\;a + \left(z + \mathsf{fma}\left(i, y, b \cdot \log c\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -7.00000000000000041e154 or 2.79999999999999989e221 < x Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.8
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites99.8%
Taylor expanded in x around inf
lower-*.f64N/A
lower-log.f6416.0
Applied rewrites16.0%
if -7.00000000000000041e154 < x < 2.79999999999999989e221Initial program 99.8%
Taylor expanded in t around 0
lower-+.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6484.3
Applied rewrites84.3%
Taylor expanded in b around inf
lower-*.f64N/A
lower-+.f64N/A
lower-log.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-log.f6473.8
Applied rewrites73.8%
Taylor expanded in b around inf
lower-log.f6467.9
Applied rewrites67.9%
(FPCore (x y z t a b c i)
:precision binary64
(if (<=
(+ (+ (+ (+ (+ (* x (log y)) z) t) a) (* (- b 0.5) (log c))) (* y i))
-50.0)
(fma y i (* (/ z a) a))
(fma y i (* 1.0 a))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i)) <= -50.0) {
tmp = fma(y, i, ((z / a) * a));
} else {
tmp = fma(y, i, (1.0 * a));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(Float64(Float64(Float64(Float64(Float64(x * log(y)) + z) + t) + a) + Float64(Float64(b - 0.5) * log(c))) + Float64(y * i)) <= -50.0) tmp = fma(y, i, Float64(Float64(z / a) * a)); else tmp = fma(y, i, Float64(1.0 * a)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(N[(N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision] + t), $MachinePrecision] + a), $MachinePrecision] + N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * i), $MachinePrecision]), $MachinePrecision], -50.0], N[(y * i + N[(N[(z / a), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision], N[(y * i + N[(1.0 * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right) + y \cdot i \leq -50:\\
\;\;\;\;\mathsf{fma}\left(y, i, \frac{z}{a} \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, i, 1 \cdot a\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c))) (*.f64 y i)) < -50Initial program 99.8%
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
sum-to-multN/A
lower-unsound-*.f64N/A
Applied rewrites73.0%
Taylor expanded in a around inf
Applied rewrites38.4%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6438.4
Applied rewrites38.4%
Taylor expanded in z around inf
lower-/.f6431.4
Applied rewrites31.4%
if -50 < (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c))) (*.f64 y i)) Initial program 99.8%
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
sum-to-multN/A
lower-unsound-*.f64N/A
Applied rewrites73.0%
Taylor expanded in a around inf
Applied rewrites38.4%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6438.4
Applied rewrites38.4%
(FPCore (x y z t a b c i) :precision binary64 (let* ((t_1 (* x (log y)))) (if (<= x -5.1e+154) t_1 (if (<= x 5.4e+165) (fma y i (* 1.0 a)) t_1))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = x * log(y);
double tmp;
if (x <= -5.1e+154) {
tmp = t_1;
} else if (x <= 5.4e+165) {
tmp = fma(y, i, (1.0 * a));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = Float64(x * log(y)) tmp = 0.0 if (x <= -5.1e+154) tmp = t_1; elseif (x <= 5.4e+165) tmp = fma(y, i, Float64(1.0 * a)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -5.1e+154], t$95$1, If[LessEqual[x, 5.4e+165], N[(y * i + N[(1.0 * a), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \log y\\
\mathbf{if}\;x \leq -5.1 \cdot 10^{+154}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 5.4 \cdot 10^{+165}:\\
\;\;\;\;\mathsf{fma}\left(y, i, 1 \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -5.0999999999999999e154 or 5.3999999999999999e165 < x Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.8
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites99.8%
Taylor expanded in x around inf
lower-*.f64N/A
lower-log.f6416.0
Applied rewrites16.0%
if -5.0999999999999999e154 < x < 5.3999999999999999e165Initial program 99.8%
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
sum-to-multN/A
lower-unsound-*.f64N/A
Applied rewrites73.0%
Taylor expanded in a around inf
Applied rewrites38.4%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6438.4
Applied rewrites38.4%
(FPCore (x y z t a b c i) :precision binary64 (fma y i (* 1.0 a)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return fma(y, i, (1.0 * a));
}
function code(x, y, z, t, a, b, c, i) return fma(y, i, Float64(1.0 * a)) end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(y * i + N[(1.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, i, 1 \cdot a\right)
\end{array}
Initial program 99.8%
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
sum-to-multN/A
lower-unsound-*.f64N/A
Applied rewrites73.0%
Taylor expanded in a around inf
Applied rewrites38.4%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6438.4
Applied rewrites38.4%
(FPCore (x y z t a b c i) :precision binary64 t)
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return t;
}
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(x, y, z, t, a, b, c, i)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: i
code = t
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return t;
}
def code(x, y, z, t, a, b, c, i): return t
function code(x, y, z, t, a, b, c, i) return t end
function tmp = code(x, y, z, t, a, b, c, i) tmp = t; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := t
\begin{array}{l}
\\
t
\end{array}
Initial program 99.8%
Taylor expanded in t around 0
lower-+.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6484.3
Applied rewrites84.3%
Taylor expanded in b around inf
lower-*.f64N/A
lower-+.f64N/A
lower-log.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-log.f6473.8
Applied rewrites73.8%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6473.8
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-/.f64N/A
div-add-revN/A
lower-/.f64N/A
lower-fma.f6473.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6473.8
Applied rewrites73.8%
Taylor expanded in t around inf
Applied rewrites16.5%
herbie shell --seed 2025155
(FPCore (x y z t a b c i)
:name "Numeric.SpecFunctions:logBeta from math-functions-0.1.5.2, B"
:precision binary64
(+ (+ (+ (+ (+ (* x (log y)) z) t) a) (* (- b 0.5) (log c))) (* y i)))