
(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}
Sampling outcomes in binary64 precision:
Herbie found 16 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) (+ a (+ t (fma (log y) x z))))))
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), (a + (t + fma(log(y), x, z)))));
}
function code(x, y, z, t, a, b, c, i) return fma(y, i, fma(log(c), Float64(b - 0.5), Float64(a + Float64(t + fma(log(y), x, z))))) end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(y * i + N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision] + N[(a + N[(t + N[(N[Log[y], $MachinePrecision] * x + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, i, \mathsf{fma}\left(\log c, b - 0.5, a + \left(t + \mathsf{fma}\left(\log y, x, z\right)\right)\right)\right)
\end{array}
Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.9
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9
Applied rewrites99.9%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1
(+
(+ (+ (+ (+ (* x (log y)) z) t) a) (* (- b 0.5) (log c)))
(* y i))))
(if (<= t_1 -1e+305)
(* i y)
(if (<= t_1 -20.0) z (if (<= t_1 1e+307) a (* i y))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i);
double tmp;
if (t_1 <= -1e+305) {
tmp = i * y;
} else if (t_1 <= -20.0) {
tmp = z;
} else if (t_1 <= 1e+307) {
tmp = a;
} else {
tmp = i * y;
}
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(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
real(8) :: t_1
real(8) :: tmp
t_1 = (((((x * log(y)) + z) + t) + a) + ((b - 0.5d0) * log(c))) + (y * i)
if (t_1 <= (-1d+305)) then
tmp = i * y
else if (t_1 <= (-20.0d0)) then
tmp = z
else if (t_1 <= 1d+307) then
tmp = a
else
tmp = i * y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (((((x * Math.log(y)) + z) + t) + a) + ((b - 0.5) * Math.log(c))) + (y * i);
double tmp;
if (t_1 <= -1e+305) {
tmp = i * y;
} else if (t_1 <= -20.0) {
tmp = z;
} else if (t_1 <= 1e+307) {
tmp = a;
} else {
tmp = i * y;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): t_1 = (((((x * math.log(y)) + z) + t) + a) + ((b - 0.5) * math.log(c))) + (y * i) tmp = 0 if t_1 <= -1e+305: tmp = i * y elif t_1 <= -20.0: tmp = z elif t_1 <= 1e+307: tmp = a else: tmp = i * y return tmp
function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(Float64(Float64(Float64(Float64(x * log(y)) + z) + t) + a) + Float64(Float64(b - 0.5) * log(c))) + Float64(y * i)) tmp = 0.0 if (t_1 <= -1e+305) tmp = Float64(i * y); elseif (t_1 <= -20.0) tmp = z; elseif (t_1 <= 1e+307) tmp = a; else tmp = Float64(i * y); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) t_1 = (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i); tmp = 0.0; if (t_1 <= -1e+305) tmp = i * y; elseif (t_1 <= -20.0) tmp = z; elseif (t_1 <= 1e+307) tmp = a; else tmp = i * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = 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]}, If[LessEqual[t$95$1, -1e+305], N[(i * y), $MachinePrecision], If[LessEqual[t$95$1, -20.0], z, If[LessEqual[t$95$1, 1e+307], a, N[(i * y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \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\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+305}:\\
\;\;\;\;i \cdot y\\
\mathbf{elif}\;t\_1 \leq -20:\\
\;\;\;\;z\\
\mathbf{elif}\;t\_1 \leq 10^{+307}:\\
\;\;\;\;a\\
\mathbf{else}:\\
\;\;\;\;i \cdot y\\
\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)) < -9.9999999999999994e304 or 9.99999999999999986e306 < (+.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 100.0%
Taylor expanded in y around inf
lower-*.f6491.5
Applied rewrites91.5%
if -9.9999999999999994e304 < (+.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)) < -20Initial program 99.8%
Taylor expanded in z around inf
Applied rewrites15.1%
if -20 < (+.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)) < 9.99999999999999986e306Initial program 99.9%
Taylor expanded in a around inf
Applied rewrites30.1%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1
(+
(+ (+ (+ (+ (* x (log y)) z) t) a) (* (- b 0.5) (log c)))
(* y i))))
(if (<= t_1 -1e+305) (* i y) (if (<= t_1 20000000000000.0) z (fma y i a)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i);
double tmp;
if (t_1 <= -1e+305) {
tmp = i * y;
} else if (t_1 <= 20000000000000.0) {
tmp = z;
} else {
tmp = fma(y, i, a);
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(Float64(Float64(Float64(Float64(x * log(y)) + z) + t) + a) + Float64(Float64(b - 0.5) * log(c))) + Float64(y * i)) tmp = 0.0 if (t_1 <= -1e+305) tmp = Float64(i * y); elseif (t_1 <= 20000000000000.0) tmp = z; else tmp = fma(y, i, a); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = 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]}, If[LessEqual[t$95$1, -1e+305], N[(i * y), $MachinePrecision], If[LessEqual[t$95$1, 20000000000000.0], z, N[(y * i + a), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \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\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+305}:\\
\;\;\;\;i \cdot y\\
\mathbf{elif}\;t\_1 \leq 20000000000000:\\
\;\;\;\;z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, i, 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)) < -9.9999999999999994e304Initial program 100.0%
Taylor expanded in y around inf
lower-*.f6487.4
Applied rewrites87.4%
if -9.9999999999999994e304 < (+.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)) < 2e13Initial program 99.8%
Taylor expanded in z around inf
Applied rewrites14.9%
if 2e13 < (+.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.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.9
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9
Applied rewrites99.9%
Taylor expanded in a around inf
Applied rewrites44.5%
(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))
-100.0)
(fma y i (fma (- b 0.5) (log c) z))
(fma y i (fma (- b 0.5) (log c) 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)) <= -100.0) {
tmp = fma(y, i, fma((b - 0.5), log(c), z));
} else {
tmp = fma(y, i, fma((b - 0.5), log(c), 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)) <= -100.0) tmp = fma(y, i, fma(Float64(b - 0.5), log(c), z)); else tmp = fma(y, i, fma(Float64(b - 0.5), log(c), 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], -100.0], N[(y * i + N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision], N[(y * i + N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision] + 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 -100:\\
\;\;\;\;\mathsf{fma}\left(y, i, \mathsf{fma}\left(b - 0.5, \log c, z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, i, \mathsf{fma}\left(b - 0.5, \log c, a\right)\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)) < -100Initial program 99.8%
Taylor expanded in z around inf
Applied rewrites55.4%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6455.4
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6455.4
Applied rewrites55.4%
if -100 < (+.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.9%
Taylor expanded in z around inf
Applied rewrites47.4%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6447.4
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6447.4
Applied rewrites47.4%
Taylor expanded in a around inf
Applied rewrites60.2%
(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))
-5e+35)
(fma y i (fma b (log c) z))
(fma y i (fma (- b 0.5) (log c) 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)) <= -5e+35) {
tmp = fma(y, i, fma(b, log(c), z));
} else {
tmp = fma(y, i, fma((b - 0.5), log(c), 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)) <= -5e+35) tmp = fma(y, i, fma(b, log(c), z)); else tmp = fma(y, i, fma(Float64(b - 0.5), log(c), 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], -5e+35], N[(y * i + N[(b * N[Log[c], $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision], N[(y * i + N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision] + 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 -5 \cdot 10^{+35}:\\
\;\;\;\;\mathsf{fma}\left(y, i, \mathsf{fma}\left(b, \log c, z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, i, \mathsf{fma}\left(b - 0.5, \log c, a\right)\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)) < -5.00000000000000021e35Initial program 99.8%
Taylor expanded in z around inf
Applied rewrites55.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6455.3
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6455.3
Applied rewrites55.3%
Taylor expanded in b around inf
Applied rewrites55.3%
if -5.00000000000000021e35 < (+.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.9%
Taylor expanded in z around inf
Applied rewrites47.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6447.6
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6447.6
Applied rewrites47.6%
Taylor expanded in a around inf
Applied rewrites60.8%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* (- b 0.5) (log c))))
(if (or (<= t_1 -2e+190) (not (<= t_1 5e+179)))
(fma y i (fma b (log c) z))
(fma (+ (fma i y t) a) (/ z z) z))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (b - 0.5) * log(c);
double tmp;
if ((t_1 <= -2e+190) || !(t_1 <= 5e+179)) {
tmp = fma(y, i, fma(b, log(c), z));
} else {
tmp = fma((fma(i, y, t) + a), (z / z), z);
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(b - 0.5) * log(c)) tmp = 0.0 if ((t_1 <= -2e+190) || !(t_1 <= 5e+179)) tmp = fma(y, i, fma(b, log(c), z)); else tmp = fma(Float64(fma(i, y, t) + a), Float64(z / z), z); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e+190], N[Not[LessEqual[t$95$1, 5e+179]], $MachinePrecision]], N[(y * i + N[(b * N[Log[c], $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision], N[(N[(N[(i * y + t), $MachinePrecision] + a), $MachinePrecision] * N[(z / z), $MachinePrecision] + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(b - 0.5\right) \cdot \log c\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+190} \lor \neg \left(t\_1 \leq 5 \cdot 10^{+179}\right):\\
\;\;\;\;\mathsf{fma}\left(y, i, \mathsf{fma}\left(b, \log c, z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(i, y, t\right) + a, \frac{z}{z}, z\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c)) < -2.0000000000000001e190 or 5e179 < (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c)) Initial program 99.5%
Taylor expanded in z around inf
Applied rewrites84.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6484.2
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6484.2
Applied rewrites84.2%
Taylor expanded in b around inf
Applied rewrites84.2%
if -2.0000000000000001e190 < (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c)) < 5e179Initial program 99.9%
Taylor expanded in z around inf
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
lower-fma.f64N/A
Applied rewrites74.7%
Taylor expanded in t around inf
Applied rewrites60.0%
lift-fma.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6478.0
Applied rewrites78.0%
Final simplification79.4%
(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))
-20.0)
(fma y i z)
(fma y i 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)) <= -20.0) {
tmp = fma(y, i, z);
} else {
tmp = fma(y, i, 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)) <= -20.0) tmp = fma(y, i, z); else tmp = fma(y, i, 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], -20.0], N[(y * i + z), $MachinePrecision], N[(y * i + a), $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 -20:\\
\;\;\;\;\mathsf{fma}\left(y, i, z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, i, 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)) < -20Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.8
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.8
Applied rewrites99.8%
Taylor expanded in z around inf
Applied rewrites37.2%
if -20 < (+.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.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.9
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9
Applied rewrites99.9%
Taylor expanded in a around inf
Applied rewrites43.8%
(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))
-20.0)
z
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)) <= -20.0) {
tmp = z;
} else {
tmp = a;
}
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(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
real(8) :: tmp
if (((((((x * log(y)) + z) + t) + a) + ((b - 0.5d0) * log(c))) + (y * i)) <= (-20.0d0)) then
tmp = z
else
tmp = a
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((((((x * Math.log(y)) + z) + t) + a) + ((b - 0.5) * Math.log(c))) + (y * i)) <= -20.0) {
tmp = z;
} else {
tmp = a;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if ((((((x * math.log(y)) + z) + t) + a) + ((b - 0.5) * math.log(c))) + (y * i)) <= -20.0: tmp = z else: tmp = 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)) <= -20.0) tmp = z; else tmp = a; end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if (((((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i)) <= -20.0) tmp = z; else tmp = a; end tmp_2 = 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], -20.0], z, a]
\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 -20:\\
\;\;\;\;z\\
\mathbf{else}:\\
\;\;\;\;a\\
\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)) < -20Initial program 99.8%
Taylor expanded in z around inf
Applied rewrites12.8%
if -20 < (+.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.9%
Taylor expanded in a around inf
Applied rewrites27.5%
(FPCore (x y z t a b c i) :precision binary64 (+ (fma i y (fma (log y) x (fma (log c) (- b 0.5) z))) a))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return fma(i, y, fma(log(y), x, fma(log(c), (b - 0.5), z))) + a;
}
function code(x, y, z, t, a, b, c, i) return Float64(fma(i, y, fma(log(y), x, fma(log(c), Float64(b - 0.5), z))) + a) end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(i * y + N[(N[Log[y], $MachinePrecision] * x + N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(i, y, \mathsf{fma}\left(\log y, x, \mathsf{fma}\left(\log c, b - 0.5, z\right)\right)\right) + a
\end{array}
Initial program 99.8%
Taylor expanded in t around 0
+-commutativeN/A
lower-+.f64N/A
Applied rewrites86.3%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= x -9e+195) (not (<= x 3e+128))) (fma y i (* (+ (/ (+ (+ z t) a) x) (log y)) x)) (+ (+ a t) (fma (log c) (- b 0.5) (fma i y z)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((x <= -9e+195) || !(x <= 3e+128)) {
tmp = fma(y, i, (((((z + t) + a) / x) + log(y)) * x));
} else {
tmp = (a + t) + fma(log(c), (b - 0.5), fma(i, y, z));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((x <= -9e+195) || !(x <= 3e+128)) tmp = fma(y, i, Float64(Float64(Float64(Float64(Float64(z + t) + a) / x) + log(y)) * x)); else tmp = Float64(Float64(a + t) + fma(log(c), Float64(b - 0.5), fma(i, y, z))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[x, -9e+195], N[Not[LessEqual[x, 3e+128]], $MachinePrecision]], N[(y * i + N[(N[(N[(N[(N[(z + t), $MachinePrecision] + a), $MachinePrecision] / x), $MachinePrecision] + N[Log[y], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(N[(a + t), $MachinePrecision] + N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision] + N[(i * y + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9 \cdot 10^{+195} \lor \neg \left(x \leq 3 \cdot 10^{+128}\right):\\
\;\;\;\;\mathsf{fma}\left(y, i, \left(\frac{\left(z + t\right) + a}{x} + \log y\right) \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a + t\right) + \mathsf{fma}\left(\log c, b - 0.5, \mathsf{fma}\left(i, y, z\right)\right)\\
\end{array}
\end{array}
if x < -9.00000000000000018e195 or 2.9999999999999998e128 < x Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.8
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
*-commutativeN/A
div-add-revN/A
div-add-revN/A
div-addN/A
lower-*.f64N/A
Applied rewrites99.7%
Taylor expanded in z around inf
Applied rewrites94.2%
if -9.00000000000000018e195 < x < 2.9999999999999998e128Initial program 99.9%
Taylor expanded in x around 0
associate-+r+N/A
lower-+.f64N/A
lower-+.f64N/A
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f6497.1
Applied rewrites97.1%
Final simplification96.4%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= x -4e+196) (not (<= x 1.05e+153))) (fma y i (* (+ (/ a x) (log y)) x)) (+ (+ a t) (fma (log c) (- b 0.5) (fma i y z)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((x <= -4e+196) || !(x <= 1.05e+153)) {
tmp = fma(y, i, (((a / x) + log(y)) * x));
} else {
tmp = (a + t) + fma(log(c), (b - 0.5), fma(i, y, z));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((x <= -4e+196) || !(x <= 1.05e+153)) tmp = fma(y, i, Float64(Float64(Float64(a / x) + log(y)) * x)); else tmp = Float64(Float64(a + t) + fma(log(c), Float64(b - 0.5), fma(i, y, z))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[x, -4e+196], N[Not[LessEqual[x, 1.05e+153]], $MachinePrecision]], N[(y * i + N[(N[(N[(a / x), $MachinePrecision] + N[Log[y], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(N[(a + t), $MachinePrecision] + N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision] + N[(i * y + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{+196} \lor \neg \left(x \leq 1.05 \cdot 10^{+153}\right):\\
\;\;\;\;\mathsf{fma}\left(y, i, \left(\frac{a}{x} + \log y\right) \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a + t\right) + \mathsf{fma}\left(\log c, b - 0.5, \mathsf{fma}\left(i, y, z\right)\right)\\
\end{array}
\end{array}
if x < -3.9999999999999998e196 or 1.05000000000000008e153 < x Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.8
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.8
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
*-commutativeN/A
div-add-revN/A
div-add-revN/A
div-addN/A
lower-*.f64N/A
Applied rewrites99.7%
Taylor expanded in a around inf
Applied rewrites80.7%
if -3.9999999999999998e196 < x < 1.05000000000000008e153Initial program 99.9%
Taylor expanded in x around 0
associate-+r+N/A
lower-+.f64N/A
lower-+.f64N/A
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f6497.2
Applied rewrites97.2%
Final simplification93.3%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= x -1.15e+199) (not (<= x 2.55e+206))) (fma y i (* (log y) x)) (+ (+ a t) (fma (log c) (- b 0.5) (fma i y z)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((x <= -1.15e+199) || !(x <= 2.55e+206)) {
tmp = fma(y, i, (log(y) * x));
} else {
tmp = (a + t) + fma(log(c), (b - 0.5), fma(i, y, z));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((x <= -1.15e+199) || !(x <= 2.55e+206)) tmp = fma(y, i, Float64(log(y) * x)); else tmp = Float64(Float64(a + t) + fma(log(c), Float64(b - 0.5), fma(i, y, z))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[x, -1.15e+199], N[Not[LessEqual[x, 2.55e+206]], $MachinePrecision]], N[(y * i + N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(N[(a + t), $MachinePrecision] + N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision] + N[(i * y + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.15 \cdot 10^{+199} \lor \neg \left(x \leq 2.55 \cdot 10^{+206}\right):\\
\;\;\;\;\mathsf{fma}\left(y, i, \log y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a + t\right) + \mathsf{fma}\left(\log c, b - 0.5, \mathsf{fma}\left(i, y, z\right)\right)\\
\end{array}
\end{array}
if x < -1.14999999999999997e199 or 2.5500000000000002e206 < x Initial program 99.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.7
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.7
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.7
Applied rewrites99.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6480.7
Applied rewrites80.7%
if -1.14999999999999997e199 < x < 2.5500000000000002e206Initial program 99.9%
Taylor expanded in x around 0
associate-+r+N/A
lower-+.f64N/A
lower-+.f64N/A
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f6495.6
Applied rewrites95.6%
Final simplification92.8%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= b -2.8e+184) (not (<= b 8.2e+176))) (fma y i (* (log c) b)) (fma (+ (fma i y t) a) (/ z z) z)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((b <= -2.8e+184) || !(b <= 8.2e+176)) {
tmp = fma(y, i, (log(c) * b));
} else {
tmp = fma((fma(i, y, t) + a), (z / z), z);
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((b <= -2.8e+184) || !(b <= 8.2e+176)) tmp = fma(y, i, Float64(log(c) * b)); else tmp = fma(Float64(fma(i, y, t) + a), Float64(z / z), z); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[b, -2.8e+184], N[Not[LessEqual[b, 8.2e+176]], $MachinePrecision]], N[(y * i + N[(N[Log[c], $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision], N[(N[(N[(i * y + t), $MachinePrecision] + a), $MachinePrecision] * N[(z / z), $MachinePrecision] + z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.8 \cdot 10^{+184} \lor \neg \left(b \leq 8.2 \cdot 10^{+176}\right):\\
\;\;\;\;\mathsf{fma}\left(y, i, \log c \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(i, y, t\right) + a, \frac{z}{z}, z\right)\\
\end{array}
\end{array}
if b < -2.7999999999999999e184 or 8.1999999999999998e176 < b Initial program 99.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.6
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.6
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.6
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.6
Applied rewrites99.6%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6483.5
Applied rewrites83.5%
if -2.7999999999999999e184 < b < 8.1999999999999998e176Initial program 99.9%
Taylor expanded in z around inf
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
lower-fma.f64N/A
Applied rewrites74.5%
Taylor expanded in t around inf
Applied rewrites59.5%
lift-fma.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6477.8
Applied rewrites77.8%
Final simplification79.1%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= b -8.5e+219) (not (<= b 3.6e+225))) (* (log c) b) (fma (+ (fma i y t) a) (/ z z) z)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((b <= -8.5e+219) || !(b <= 3.6e+225)) {
tmp = log(c) * b;
} else {
tmp = fma((fma(i, y, t) + a), (z / z), z);
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((b <= -8.5e+219) || !(b <= 3.6e+225)) tmp = Float64(log(c) * b); else tmp = fma(Float64(fma(i, y, t) + a), Float64(z / z), z); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[b, -8.5e+219], N[Not[LessEqual[b, 3.6e+225]], $MachinePrecision]], N[(N[Log[c], $MachinePrecision] * b), $MachinePrecision], N[(N[(N[(i * y + t), $MachinePrecision] + a), $MachinePrecision] * N[(z / z), $MachinePrecision] + z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -8.5 \cdot 10^{+219} \lor \neg \left(b \leq 3.6 \cdot 10^{+225}\right):\\
\;\;\;\;\log c \cdot b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(i, y, t\right) + a, \frac{z}{z}, z\right)\\
\end{array}
\end{array}
if b < -8.5000000000000001e219 or 3.5999999999999998e225 < b Initial program 99.6%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
lower-log.f6481.8
Applied rewrites81.8%
if -8.5000000000000001e219 < b < 3.5999999999999998e225Initial program 99.9%
Taylor expanded in z around inf
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
lower-fma.f64N/A
Applied rewrites74.5%
Taylor expanded in t around inf
Applied rewrites57.8%
lift-fma.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6475.0
Applied rewrites75.0%
Final simplification76.1%
(FPCore (x y z t a b c i) :precision binary64 (fma (+ (fma i y t) a) (/ z z) z))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return fma((fma(i, y, t) + a), (z / z), z);
}
function code(x, y, z, t, a, b, c, i) return fma(Float64(fma(i, y, t) + a), Float64(z / z), z) end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(i * y + t), $MachinePrecision] + a), $MachinePrecision] * N[(z / z), $MachinePrecision] + z), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(i, y, t\right) + a, \frac{z}{z}, z\right)
\end{array}
Initial program 99.8%
Taylor expanded in z around inf
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
lower-fma.f64N/A
Applied rewrites72.5%
Taylor expanded in t around inf
Applied rewrites51.2%
lift-fma.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6466.3
Applied rewrites66.3%
(FPCore (x y z t a b c i) :precision binary64 a)
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return a;
}
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 = a
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return a;
}
def code(x, y, z, t, a, b, c, i): return a
function code(x, y, z, t, a, b, c, i) return a end
function tmp = code(x, y, z, t, a, b, c, i) tmp = a; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := a
\begin{array}{l}
\\
a
\end{array}
Initial program 99.8%
Taylor expanded in a around inf
Applied rewrites21.6%
herbie shell --seed 2025026
(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)))