
(FPCore (x y z t a b) :precision binary64 (+ (- (+ (+ x y) z) (* z (log t))) (* (- a 0.5) b)))
double code(double x, double y, double z, double t, double a, double b) {
return (((x + y) + z) - (z * log(t))) + ((a - 0.5) * b);
}
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)
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
code = (((x + y) + z) - (z * log(t))) + ((a - 0.5d0) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (((x + y) + z) - (z * Math.log(t))) + ((a - 0.5) * b);
}
def code(x, y, z, t, a, b): return (((x + y) + z) - (z * math.log(t))) + ((a - 0.5) * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(Float64(x + y) + z) - Float64(z * log(t))) + Float64(Float64(a - 0.5) * b)) end
function tmp = code(x, y, z, t, a, b) tmp = (((x + y) + z) - (z * log(t))) + ((a - 0.5) * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision] - N[(z * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b
\end{array}
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b) :precision binary64 (+ (- (+ (+ x y) z) (* z (log t))) (* (- a 0.5) b)))
double code(double x, double y, double z, double t, double a, double b) {
return (((x + y) + z) - (z * log(t))) + ((a - 0.5) * b);
}
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)
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
code = (((x + y) + z) - (z * log(t))) + ((a - 0.5d0) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (((x + y) + z) - (z * Math.log(t))) + ((a - 0.5) * b);
}
def code(x, y, z, t, a, b): return (((x + y) + z) - (z * math.log(t))) + ((a - 0.5) * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(Float64(x + y) + z) - Float64(z * log(t))) + Float64(Float64(a - 0.5) * b)) end
function tmp = code(x, y, z, t, a, b) tmp = (((x + y) + z) - (z * log(t))) + ((a - 0.5) * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision] - N[(z * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b
\end{array}
(FPCore (x y z t a b) :precision binary64 (+ (+ (fma (- 1.0 (log t)) z (* (- a 0.5) b)) y) x))
double code(double x, double y, double z, double t, double a, double b) {
return (fma((1.0 - log(t)), z, ((a - 0.5) * b)) + y) + x;
}
function code(x, y, z, t, a, b) return Float64(Float64(fma(Float64(1.0 - log(t)), z, Float64(Float64(a - 0.5) * b)) + y) + x) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\left(\mathsf{fma}\left(1 - \log t, z, \left(a - 0.5\right) \cdot b\right) + y\right) + x
\end{array}
Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lift-log.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f6499.9
Applied rewrites99.9%
(FPCore (x y z t a b) :precision binary64 (if (<= (- (+ (+ x y) z) (* z (log t))) -400000.0) (+ x (- (fma (- a 0.5) b z) (* (log t) z))) (fma (- 1.0 (log t)) z (fma b (- a 0.5) y))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((((x + y) + z) - (z * log(t))) <= -400000.0) {
tmp = x + (fma((a - 0.5), b, z) - (log(t) * z));
} else {
tmp = fma((1.0 - log(t)), z, fma(b, (a - 0.5), y));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(Float64(Float64(x + y) + z) - Float64(z * log(t))) <= -400000.0) tmp = Float64(x + Float64(fma(Float64(a - 0.5), b, z) - Float64(log(t) * z))); else tmp = fma(Float64(1.0 - log(t)), z, fma(b, Float64(a - 0.5), y)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision] - N[(z * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -400000.0], N[(x + N[(N[(N[(a - 0.5), $MachinePrecision] * b + z), $MachinePrecision] - N[(N[Log[t], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + N[(b * N[(a - 0.5), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(\left(x + y\right) + z\right) - z \cdot \log t \leq -400000:\\
\;\;\;\;x + \left(\mathsf{fma}\left(a - 0.5, b, z\right) - \log t \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 - \log t, z, \mathsf{fma}\left(b, a - 0.5, y\right)\right)\\
\end{array}
\end{array}
if (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) < -4e5Initial program 99.8%
Taylor expanded in y around 0
associate--l+N/A
lower-+.f64N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f6479.3
Applied rewrites79.3%
if -4e5 < (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lift-log.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f6499.9
Applied rewrites99.9%
Taylor expanded in x around 0
+-commutativeN/A
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
associate-+l+N/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6479.5
Applied rewrites79.5%
(FPCore (x y z t a b) :precision binary64 (if (<= x -2.75e+75) (+ (fma (- a 0.5) b y) x) (fma (- 1.0 (log t)) z (fma b (- a 0.5) y))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (x <= -2.75e+75) {
tmp = fma((a - 0.5), b, y) + x;
} else {
tmp = fma((1.0 - log(t)), z, fma(b, (a - 0.5), y));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (x <= -2.75e+75) tmp = Float64(fma(Float64(a - 0.5), b, y) + x); else tmp = fma(Float64(1.0 - log(t)), z, fma(b, Float64(a - 0.5), y)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[x, -2.75e+75], N[(N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision] + x), $MachinePrecision], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + N[(b * N[(a - 0.5), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.75 \cdot 10^{+75}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y\right) + x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 - \log t, z, \mathsf{fma}\left(b, a - 0.5, y\right)\right)\\
\end{array}
\end{array}
if x < -2.75e75Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6478.4
Applied rewrites78.4%
if -2.75e75 < x Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lift-log.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f6499.9
Applied rewrites99.9%
Taylor expanded in x around 0
+-commutativeN/A
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
associate-+l+N/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6479.5
Applied rewrites79.5%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (fma (- a 0.5) b y) x)))
(if (<= b -3.1e+94)
t_1
(if (<= b 2.3e+27) (+ (fma (- 1.0 (log t)) z y) x) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma((a - 0.5), b, y) + x;
double tmp;
if (b <= -3.1e+94) {
tmp = t_1;
} else if (b <= 2.3e+27) {
tmp = fma((1.0 - log(t)), z, y) + x;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(fma(Float64(a - 0.5), b, y) + x) tmp = 0.0 if (b <= -3.1e+94) tmp = t_1; elseif (b <= 2.3e+27) tmp = Float64(fma(Float64(1.0 - log(t)), z, y) + x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[b, -3.1e+94], t$95$1, If[LessEqual[b, 2.3e+27], N[(N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + y), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(a - 0.5, b, y\right) + x\\
\mathbf{if}\;b \leq -3.1 \cdot 10^{+94}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq 2.3 \cdot 10^{+27}:\\
\;\;\;\;\mathsf{fma}\left(1 - \log t, z, y\right) + x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if b < -3.09999999999999991e94 or 2.3000000000000001e27 < b Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6478.4
Applied rewrites78.4%
if -3.09999999999999991e94 < b < 2.3000000000000001e27Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lift-log.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f6499.9
Applied rewrites99.9%
Taylor expanded in b around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f6462.3
Applied rewrites62.3%
(FPCore (x y z t a b) :precision binary64 (if (<= z -2.75e+127) (+ (* (- 1.0 (log t)) z) x) (if (<= z 1.45e+160) (+ (fma (- a 0.5) b y) x) (+ y (- z (* (log t) z))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -2.75e+127) {
tmp = ((1.0 - log(t)) * z) + x;
} else if (z <= 1.45e+160) {
tmp = fma((a - 0.5), b, y) + x;
} else {
tmp = y + (z - (log(t) * z));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= -2.75e+127) tmp = Float64(Float64(Float64(1.0 - log(t)) * z) + x); elseif (z <= 1.45e+160) tmp = Float64(fma(Float64(a - 0.5), b, y) + x); else tmp = Float64(y + Float64(z - Float64(log(t) * z))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -2.75e+127], N[(N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 1.45e+160], N[(N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision] + x), $MachinePrecision], N[(y + N[(z - N[(N[Log[t], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.75 \cdot 10^{+127}:\\
\;\;\;\;\left(1 - \log t\right) \cdot z + x\\
\mathbf{elif}\;z \leq 1.45 \cdot 10^{+160}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y\right) + x\\
\mathbf{else}:\\
\;\;\;\;y + \left(z - \log t \cdot z\right)\\
\end{array}
\end{array}
if z < -2.75000000000000021e127Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lift-log.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f6499.9
Applied rewrites99.9%
Taylor expanded in b around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f6462.3
Applied rewrites62.3%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6442.3
Applied rewrites42.3%
if -2.75000000000000021e127 < z < 1.45e160Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6478.4
Applied rewrites78.4%
if 1.45e160 < z Initial program 99.8%
Taylor expanded in x around 0
associate--l+N/A
lower-+.f64N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f6479.4
Applied rewrites79.4%
Taylor expanded in b around 0
lower--.f64N/A
*-commutativeN/A
lift-log.f64N/A
lift-*.f6442.4
Applied rewrites42.4%
(FPCore (x y z t a b) :precision binary64 (if (<= z -1.5e+174) (* (- 1.0 (log t)) z) (if (<= z 1.45e+160) (+ (fma (- a 0.5) b y) x) (+ y (- z (* (log t) z))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -1.5e+174) {
tmp = (1.0 - log(t)) * z;
} else if (z <= 1.45e+160) {
tmp = fma((a - 0.5), b, y) + x;
} else {
tmp = y + (z - (log(t) * z));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= -1.5e+174) tmp = Float64(Float64(1.0 - log(t)) * z); elseif (z <= 1.45e+160) tmp = Float64(fma(Float64(a - 0.5), b, y) + x); else tmp = Float64(y + Float64(z - Float64(log(t) * z))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -1.5e+174], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[z, 1.45e+160], N[(N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision] + x), $MachinePrecision], N[(y + N[(z - N[(N[Log[t], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.5 \cdot 10^{+174}:\\
\;\;\;\;\left(1 - \log t\right) \cdot z\\
\mathbf{elif}\;z \leq 1.45 \cdot 10^{+160}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y\right) + x\\
\mathbf{else}:\\
\;\;\;\;y + \left(z - \log t \cdot z\right)\\
\end{array}
\end{array}
if z < -1.5e174Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lift-log.f6422.5
Applied rewrites22.5%
if -1.5e174 < z < 1.45e160Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6478.4
Applied rewrites78.4%
if 1.45e160 < z Initial program 99.8%
Taylor expanded in x around 0
associate--l+N/A
lower-+.f64N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f6479.4
Applied rewrites79.4%
Taylor expanded in b around 0
lower--.f64N/A
*-commutativeN/A
lift-log.f64N/A
lift-*.f6442.4
Applied rewrites42.4%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (- 1.0 (log t)) z)))
(if (<= z -1.5e+174)
t_1
(if (<= z 1.45e+160) (+ (fma (- a 0.5) b y) x) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (1.0 - log(t)) * z;
double tmp;
if (z <= -1.5e+174) {
tmp = t_1;
} else if (z <= 1.45e+160) {
tmp = fma((a - 0.5), b, y) + x;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(1.0 - log(t)) * z) tmp = 0.0 if (z <= -1.5e+174) tmp = t_1; elseif (z <= 1.45e+160) tmp = Float64(fma(Float64(a - 0.5), b, y) + x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -1.5e+174], t$95$1, If[LessEqual[z, 1.45e+160], N[(N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(1 - \log t\right) \cdot z\\
\mathbf{if}\;z \leq -1.5 \cdot 10^{+174}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.45 \cdot 10^{+160}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y\right) + x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.5e174 or 1.45e160 < z Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lift-log.f6422.5
Applied rewrites22.5%
if -1.5e174 < z < 1.45e160Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6478.4
Applied rewrites78.4%
(FPCore (x y z t a b) :precision binary64 (+ (fma (- a 0.5) b y) x))
double code(double x, double y, double z, double t, double a, double b) {
return fma((a - 0.5), b, y) + x;
}
function code(x, y, z, t, a, b) return Float64(fma(Float64(a - 0.5), b, y) + x) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a - 0.5, b, y\right) + x
\end{array}
Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6478.4
Applied rewrites78.4%
(FPCore (x y z t a b) :precision binary64 (if (<= (- (+ (+ x y) z) (* z (log t))) -400000.0) (fma b (- a 0.5) x) (fma b (- a 0.5) y)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((((x + y) + z) - (z * log(t))) <= -400000.0) {
tmp = fma(b, (a - 0.5), x);
} else {
tmp = fma(b, (a - 0.5), y);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(Float64(Float64(x + y) + z) - Float64(z * log(t))) <= -400000.0) tmp = fma(b, Float64(a - 0.5), x); else tmp = fma(b, Float64(a - 0.5), y); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision] - N[(z * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -400000.0], N[(b * N[(a - 0.5), $MachinePrecision] + x), $MachinePrecision], N[(b * N[(a - 0.5), $MachinePrecision] + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(\left(x + y\right) + z\right) - z \cdot \log t \leq -400000:\\
\;\;\;\;\mathsf{fma}\left(b, a - 0.5, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a - 0.5, y\right)\\
\end{array}
\end{array}
if (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) < -4e5Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6478.4
Applied rewrites78.4%
Taylor expanded in y around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6458.3
Applied rewrites58.3%
if -4e5 < (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6478.4
Applied rewrites78.4%
Taylor expanded in x around 0
+-commutativeN/A
lift-fma.f64N/A
lift--.f6458.5
Applied rewrites58.5%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (- a 0.5) b)) (t_2 (fma b (- a 0.5) x))) (if (<= t_1 -5e+207) t_2 (if (<= t_1 4e+20) (+ y x) t_2))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a - 0.5) * b;
double t_2 = fma(b, (a - 0.5), x);
double tmp;
if (t_1 <= -5e+207) {
tmp = t_2;
} else if (t_1 <= 4e+20) {
tmp = y + x;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a - 0.5) * b) t_2 = fma(b, Float64(a - 0.5), x) tmp = 0.0 if (t_1 <= -5e+207) tmp = t_2; elseif (t_1 <= 4e+20) tmp = Float64(y + x); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]}, Block[{t$95$2 = N[(b * N[(a - 0.5), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+207], t$95$2, If[LessEqual[t$95$1, 4e+20], N[(y + x), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot b\\
t_2 := \mathsf{fma}\left(b, a - 0.5, x\right)\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+207}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+20}:\\
\;\;\;\;y + x\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -4.9999999999999999e207 or 4e20 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6478.4
Applied rewrites78.4%
Taylor expanded in y around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6458.3
Applied rewrites58.3%
if -4.9999999999999999e207 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 4e20Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6478.4
Applied rewrites78.4%
Taylor expanded in b around 0
+-commutativeN/A
lower-+.f6441.3
Applied rewrites41.3%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (- a 0.5) b))) (if (<= t_1 -4e+208) (* b a) (if (<= t_1 5e+264) (+ y x) (* b a)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a - 0.5) * b;
double tmp;
if (t_1 <= -4e+208) {
tmp = b * a;
} else if (t_1 <= 5e+264) {
tmp = y + x;
} else {
tmp = b * 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)
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) :: t_1
real(8) :: tmp
t_1 = (a - 0.5d0) * b
if (t_1 <= (-4d+208)) then
tmp = b * a
else if (t_1 <= 5d+264) then
tmp = y + x
else
tmp = b * a
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a - 0.5) * b;
double tmp;
if (t_1 <= -4e+208) {
tmp = b * a;
} else if (t_1 <= 5e+264) {
tmp = y + x;
} else {
tmp = b * a;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (a - 0.5) * b tmp = 0 if t_1 <= -4e+208: tmp = b * a elif t_1 <= 5e+264: tmp = y + x else: tmp = b * a return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a - 0.5) * b) tmp = 0.0 if (t_1 <= -4e+208) tmp = Float64(b * a); elseif (t_1 <= 5e+264) tmp = Float64(y + x); else tmp = Float64(b * a); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (a - 0.5) * b; tmp = 0.0; if (t_1 <= -4e+208) tmp = b * a; elseif (t_1 <= 5e+264) tmp = y + x; else tmp = b * a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+208], N[(b * a), $MachinePrecision], If[LessEqual[t$95$1, 5e+264], N[(y + x), $MachinePrecision], N[(b * a), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot b\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+208}:\\
\;\;\;\;b \cdot a\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+264}:\\
\;\;\;\;y + x\\
\mathbf{else}:\\
\;\;\;\;b \cdot a\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -3.9999999999999999e208 or 5.00000000000000033e264 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 99.8%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6426.9
Applied rewrites26.9%
if -3.9999999999999999e208 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 5.00000000000000033e264Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6478.4
Applied rewrites78.4%
Taylor expanded in b around 0
+-commutativeN/A
lower-+.f6441.3
Applied rewrites41.3%
(FPCore (x y z t a b) :precision binary64 (+ y x))
double code(double x, double y, double z, double t, double a, double b) {
return y + x;
}
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)
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
code = y + x
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return y + x;
}
def code(x, y, z, t, a, b): return y + x
function code(x, y, z, t, a, b) return Float64(y + x) end
function tmp = code(x, y, z, t, a, b) tmp = y + x; end
code[x_, y_, z_, t_, a_, b_] := N[(y + x), $MachinePrecision]
\begin{array}{l}
\\
y + x
\end{array}
Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6478.4
Applied rewrites78.4%
Taylor expanded in b around 0
+-commutativeN/A
lower-+.f6441.3
Applied rewrites41.3%
(FPCore (x y z t a b) :precision binary64 y)
double code(double x, double y, double z, double t, double a, double b) {
return y;
}
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)
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
code = y
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return y;
}
def code(x, y, z, t, a, b): return y
function code(x, y, z, t, a, b) return y end
function tmp = code(x, y, z, t, a, b) tmp = y; end
code[x_, y_, z_, t_, a_, b_] := y
\begin{array}{l}
\\
y
\end{array}
Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6478.4
Applied rewrites78.4%
Taylor expanded in b around 0
+-commutativeN/A
lower-+.f6441.3
Applied rewrites41.3%
Taylor expanded in x around 0
Applied rewrites21.7%
herbie shell --seed 2025140
(FPCore (x y z t a b)
:name "Numeric.SpecFunctions:logBeta from math-functions-0.1.5.2, A"
:precision binary64
(+ (- (+ (+ x y) z) (* z (log t))) (* (- a 0.5) b)))