
(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 (+ (- (+ (+ 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}
Initial program 99.8%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ x y) 5e-159) (+ (fma b (- a 0.5) (- z (* (log t) z))) x) (+ (fma (- 1.0 (log t)) z (* b (- a 0.5))) y)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x + y) <= 5e-159) {
tmp = fma(b, (a - 0.5), (z - (log(t) * z))) + x;
} else {
tmp = fma((1.0 - log(t)), z, (b * (a - 0.5))) + y;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x + y) <= 5e-159) tmp = Float64(fma(b, Float64(a - 0.5), Float64(z - Float64(log(t) * z))) + x); else tmp = Float64(fma(Float64(1.0 - log(t)), z, Float64(b * Float64(a - 0.5))) + y); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x + y), $MachinePrecision], 5e-159], N[(N[(b * N[(a - 0.5), $MachinePrecision] + N[(z - N[(N[Log[t], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + N[(b * N[(a - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq 5 \cdot 10^{-159}:\\
\;\;\;\;\mathsf{fma}\left(b, a - 0.5, z - \log t \cdot z\right) + x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 - \log t, z, b \cdot \left(a - 0.5\right)\right) + y\\
\end{array}
\end{array}
if (+.f64 x y) < 5.00000000000000032e-159Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6478.6
Applied rewrites78.6%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
associate-+r-N/A
+-commutativeN/A
lower-+.f64N/A
associate--l+N/A
*-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
lower--.f64N/A
*-commutativeN/A
lift-log.f64N/A
lift-*.f6478.8
Applied rewrites78.8%
if 5.00000000000000032e-159 < (+.f64 x y) 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.f6478.8
Applied rewrites78.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f64N/A
lower-*.f64N/A
lift--.f6478.8
Applied rewrites78.8%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ x y) -2e+14) (+ (fma (- a 0.5) b y) x) (+ (fma (- 1.0 (log t)) z (* b (- a 0.5))) y)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x + y) <= -2e+14) {
tmp = fma((a - 0.5), b, y) + x;
} else {
tmp = fma((1.0 - log(t)), z, (b * (a - 0.5))) + y;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x + y) <= -2e+14) tmp = Float64(fma(Float64(a - 0.5), b, y) + x); else tmp = Float64(fma(Float64(1.0 - log(t)), z, Float64(b * Float64(a - 0.5))) + y); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x + y), $MachinePrecision], -2e+14], N[(N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + N[(b * N[(a - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq -2 \cdot 10^{+14}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y\right) + x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 - \log t, z, b \cdot \left(a - 0.5\right)\right) + y\\
\end{array}
\end{array}
if (+.f64 x y) < -2e14Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6478.6
Applied rewrites78.6%
if -2e14 < (+.f64 x y) 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.f6478.8
Applied rewrites78.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f64N/A
lower-*.f64N/A
lift--.f6478.8
Applied rewrites78.8%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (fma (- a 0.5) b y) x)))
(if (<= b -2.2e-37)
t_1
(if (<= b 7.8e-95) (+ (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 <= -2.2e-37) {
tmp = t_1;
} else if (b <= 7.8e-95) {
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 <= -2.2e-37) tmp = t_1; elseif (b <= 7.8e-95) 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, -2.2e-37], t$95$1, If[LessEqual[b, 7.8e-95], 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 -2.2 \cdot 10^{-37}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq 7.8 \cdot 10^{-95}:\\
\;\;\;\;\mathsf{fma}\left(1 - \log t, z, y\right) + x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if b < -2.20000000000000002e-37 or 7.8e-95 < 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.6
Applied rewrites78.6%
if -2.20000000000000002e-37 < b < 7.8e-95Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6478.6
Applied rewrites78.6%
Taylor expanded in b around 0
associate-+l+N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lift-log.f64N/A
lift-*.f6463.3
Applied rewrites63.3%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lift-log.f6463.3
Applied rewrites63.3%
(FPCore (x y z t a b) :precision binary64 (if (<= z -2.65e+219) (+ y (- z (* (log t) z))) (if (<= z 8e+197) (+ (fma (- a 0.5) b y) x) (fma (- 1.0 (log t)) z y))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= -2.65e+219) {
tmp = y + (z - (log(t) * z));
} else if (z <= 8e+197) {
tmp = fma((a - 0.5), b, y) + x;
} else {
tmp = fma((1.0 - log(t)), z, y);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= -2.65e+219) tmp = Float64(y + Float64(z - Float64(log(t) * z))); elseif (z <= 8e+197) tmp = Float64(fma(Float64(a - 0.5), b, y) + x); else tmp = fma(Float64(1.0 - log(t)), z, y); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -2.65e+219], N[(y + N[(z - N[(N[Log[t], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 8e+197], N[(N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision] + x), $MachinePrecision], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.65 \cdot 10^{+219}:\\
\;\;\;\;y + \left(z - \log t \cdot z\right)\\
\mathbf{elif}\;z \leq 8 \cdot 10^{+197}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y\right) + x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 - \log t, z, y\right)\\
\end{array}
\end{array}
if z < -2.64999999999999992e219Initial 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.f6478.8
Applied rewrites78.8%
Taylor expanded in b around 0
lower--.f64N/A
*-commutativeN/A
lift-log.f64N/A
lift-*.f6442.7
Applied rewrites42.7%
if -2.64999999999999992e219 < z < 7.9999999999999996e197Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6478.6
Applied rewrites78.6%
if 7.9999999999999996e197 < 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.f6478.8
Applied rewrites78.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f64N/A
lower-*.f64N/A
lift--.f6478.8
Applied rewrites78.8%
Taylor expanded in b around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f6442.8
Applied rewrites42.8%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (fma (- 1.0 (log t)) z y)))
(if (<= z -2.65e+219)
t_1
(if (<= z 8e+197) (+ (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 = fma((1.0 - log(t)), z, y);
double tmp;
if (z <= -2.65e+219) {
tmp = t_1;
} else if (z <= 8e+197) {
tmp = fma((a - 0.5), b, y) + x;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(Float64(1.0 - log(t)), z, y) tmp = 0.0 if (z <= -2.65e+219) tmp = t_1; elseif (z <= 8e+197) 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 + y), $MachinePrecision]}, If[LessEqual[z, -2.65e+219], t$95$1, If[LessEqual[z, 8e+197], N[(N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(1 - \log t, z, y\right)\\
\mathbf{if}\;z \leq -2.65 \cdot 10^{+219}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 8 \cdot 10^{+197}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y\right) + x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -2.64999999999999992e219 or 7.9999999999999996e197 < 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.f6478.8
Applied rewrites78.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f64N/A
lower-*.f64N/A
lift--.f6478.8
Applied rewrites78.8%
Taylor expanded in b around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f6442.8
Applied rewrites42.8%
if -2.64999999999999992e219 < z < 7.9999999999999996e197Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6478.6
Applied rewrites78.6%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (- 1.0 (log t)) z)))
(if (<= z -5.8e+224)
t_1
(if (<= z 3.7e+200) (+ (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 <= -5.8e+224) {
tmp = t_1;
} else if (z <= 3.7e+200) {
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 <= -5.8e+224) tmp = t_1; elseif (z <= 3.7e+200) 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, -5.8e+224], t$95$1, If[LessEqual[z, 3.7e+200], 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 -5.8 \cdot 10^{+224}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 3.7 \cdot 10^{+200}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y\right) + x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -5.79999999999999978e224 or 3.7000000000000001e200 < z Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lift-log.f6422.6
Applied rewrites22.6%
if -5.79999999999999978e224 < z < 3.7000000000000001e200Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6478.6
Applied rewrites78.6%
(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.6
Applied rewrites78.6%
(FPCore (x y z t a b) :precision binary64 (if (<= (- (+ (+ x y) z) (* z (log t))) -2e-174) (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))) <= -2e-174) {
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))) <= -2e-174) 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], -2e-174], 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 -2 \cdot 10^{-174}:\\
\;\;\;\;\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))) < -2e-174Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6478.6
Applied rewrites78.6%
Taylor expanded in y around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6457.9
Applied rewrites57.9%
if -2e-174 < (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) 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.f6478.8
Applied rewrites78.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6458.0
Applied rewrites58.0%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (- a 0.5) b)) (t_2 (fma b (- a 0.5) y))) (if (<= t_1 -2e-6) t_2 (if (<= t_1 4e+90) (+ 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), y);
double tmp;
if (t_1 <= -2e-6) {
tmp = t_2;
} else if (t_1 <= 4e+90) {
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), y) tmp = 0.0 if (t_1 <= -2e-6) tmp = t_2; elseif (t_1 <= 4e+90) 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] + y), $MachinePrecision]}, If[LessEqual[t$95$1, -2e-6], t$95$2, If[LessEqual[t$95$1, 4e+90], 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, y\right)\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{-6}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+90}:\\
\;\;\;\;y + x\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -1.99999999999999991e-6 or 3.99999999999999987e90 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) 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.f6478.8
Applied rewrites78.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6458.0
Applied rewrites58.0%
if -1.99999999999999991e-6 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 3.99999999999999987e90Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6478.6
Applied rewrites78.6%
Taylor expanded in b around 0
+-commutativeN/A
lower-+.f6442.4
Applied rewrites42.4%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (- a 0.5) b))) (if (<= t_1 -4e+197) (* b a) (if (<= t_1 2e+254) (+ 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+197) {
tmp = b * a;
} else if (t_1 <= 2e+254) {
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+197)) then
tmp = b * a
else if (t_1 <= 2d+254) 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+197) {
tmp = b * a;
} else if (t_1 <= 2e+254) {
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+197: tmp = b * a elif t_1 <= 2e+254: 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+197) tmp = Float64(b * a); elseif (t_1 <= 2e+254) 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+197) tmp = b * a; elseif (t_1 <= 2e+254) 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+197], N[(b * a), $MachinePrecision], If[LessEqual[t$95$1, 2e+254], 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^{+197}:\\
\;\;\;\;b \cdot a\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+254}:\\
\;\;\;\;y + x\\
\mathbf{else}:\\
\;\;\;\;b \cdot a\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -3.9999999999999998e197 or 1.9999999999999999e254 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 99.8%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6425.4
Applied rewrites25.4%
if -3.9999999999999998e197 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 1.9999999999999999e254Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6478.6
Applied rewrites78.6%
Taylor expanded in b around 0
+-commutativeN/A
lower-+.f6442.4
Applied rewrites42.4%
(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.6
Applied rewrites78.6%
Taylor expanded in b around 0
+-commutativeN/A
lower-+.f6442.4
Applied rewrites42.4%
(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.6
Applied rewrites78.6%
Taylor expanded in b around 0
+-commutativeN/A
lower-+.f6442.4
Applied rewrites42.4%
Taylor expanded in x around 0
Applied rewrites22.2%
herbie shell --seed 2025127
(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)))