
(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 (- a 0.5) b (+ (fma (- 1.0 (log t)) z y) x)))
double code(double x, double y, double z, double t, double a, double b) {
return fma((a - 0.5), b, (fma((1.0 - log(t)), z, y) + x));
}
function code(x, y, z, t, a, b) return fma(Float64(a - 0.5), b, Float64(fma(Float64(1.0 - log(t)), z, y) + x)) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(a - 0.5), $MachinePrecision] * b + N[(N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + y), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a - 0.5, b, \mathsf{fma}\left(1 - \log t, z, y\right) + x\right)
\end{array}
Initial program 99.9%
Applied rewrites99.9%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- 1.0 (log t))))
(if (<= (- (+ (+ x y) z) (* z (log t))) -2e-76)
(fma (- a 0.5) b (fma t_1 z x))
(+ (fma t_1 z y) (* (- a 0.5) b)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = 1.0 - log(t);
double tmp;
if ((((x + y) + z) - (z * log(t))) <= -2e-76) {
tmp = fma((a - 0.5), b, fma(t_1, z, x));
} else {
tmp = fma(t_1, z, y) + ((a - 0.5) * b);
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(1.0 - log(t)) tmp = 0.0 if (Float64(Float64(Float64(x + y) + z) - Float64(z * log(t))) <= -2e-76) tmp = fma(Float64(a - 0.5), b, fma(t_1, z, x)); else tmp = Float64(fma(t_1, z, y) + Float64(Float64(a - 0.5) * b)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision] - N[(z * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2e-76], N[(N[(a - 0.5), $MachinePrecision] * b + N[(t$95$1 * z + x), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 * z + y), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := 1 - \log t\\
\mathbf{if}\;\left(\left(x + y\right) + z\right) - z \cdot \log t \leq -2 \cdot 10^{-76}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, \mathsf{fma}\left(t\_1, z, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, z, y\right) + \left(a - 0.5\right) \cdot b\\
\end{array}
\end{array}
if (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) < -1.99999999999999985e-76Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f6479.3
Applied rewrites79.3%
if -1.99999999999999985e-76 < (-.f64 (+.f64 (+.f64 x y) z) (*.f64 z (log.f64 t))) Initial program 99.9%
Taylor expanded in x around 0
associate--l+N/A
sub-flipN/A
*-rgt-identityN/A
distribute-rgt-neg-outN/A
mul-1-negN/A
distribute-lft-outN/A
mul-1-negN/A
sub-flipN/A
+-commutativeN/A
*-commutativeN/A
sub-flipN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
sub-flipN/A
lower--.f64N/A
lift-log.f6478.0
Applied rewrites78.0%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ x y) 1e+63) (fma (- a 0.5) b (fma (- 1.0 (log t)) z x)) (+ (fma (- a 0.5) b y) x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x + y) <= 1e+63) {
tmp = fma((a - 0.5), b, fma((1.0 - log(t)), z, x));
} else {
tmp = fma((a - 0.5), b, y) + x;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x + y) <= 1e+63) tmp = fma(Float64(a - 0.5), b, fma(Float64(1.0 - log(t)), z, x)); else tmp = Float64(fma(Float64(a - 0.5), b, y) + x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x + y), $MachinePrecision], 1e+63], N[(N[(a - 0.5), $MachinePrecision] * b + N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq 10^{+63}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, \mathsf{fma}\left(1 - \log t, z, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y\right) + x\\
\end{array}
\end{array}
if (+.f64 x y) < 1.00000000000000006e63Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f6479.3
Applied rewrites79.3%
if 1.00000000000000006e63 < (+.f64 x y) Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6479.0
Applied rewrites79.0%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (fma (- a 0.5) b (* z (- 1.0 (log t)))))) (if (<= z -1.5e+135) t_1 (if (<= z 6e+179) (fma (- a 0.5) b (+ x y)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma((a - 0.5), b, (z * (1.0 - log(t))));
double tmp;
if (z <= -1.5e+135) {
tmp = t_1;
} else if (z <= 6e+179) {
tmp = fma((a - 0.5), b, (x + y));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = fma(Float64(a - 0.5), b, Float64(z * Float64(1.0 - log(t)))) tmp = 0.0 if (z <= -1.5e+135) tmp = t_1; elseif (z <= 6e+179) tmp = fma(Float64(a - 0.5), b, Float64(x + y)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a - 0.5), $MachinePrecision] * b + N[(z * N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.5e+135], t$95$1, If[LessEqual[z, 6e+179], N[(N[(a - 0.5), $MachinePrecision] * b + N[(x + y), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(a - 0.5, b, z \cdot \left(1 - \log t\right)\right)\\
\mathbf{if}\;z \leq -1.5 \cdot 10^{+135}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 6 \cdot 10^{+179}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, x + y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.5e135 or 5.9999999999999996e179 < z Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f6479.3
Applied rewrites79.3%
Taylor expanded in x around 0
lower-*.f64N/A
lift-log.f64N/A
lift--.f6458.0
Applied rewrites58.0%
if -1.5e135 < z < 5.9999999999999996e179Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in z around 0
lower-+.f6479.1
Applied rewrites79.1%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (- a 0.5) b)))
(if (<= t_1 -2000000000.0)
(+ (fma (- a 0.5) b y) x)
(if (<= t_1 5e+58)
(- (+ (+ z y) x) (* (log t) z))
(fma (- a 0.5) b (+ x y))))))
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 <= -2000000000.0) {
tmp = fma((a - 0.5), b, y) + x;
} else if (t_1 <= 5e+58) {
tmp = ((z + y) + x) - (log(t) * z);
} else {
tmp = fma((a - 0.5), b, (x + y));
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a - 0.5) * b) tmp = 0.0 if (t_1 <= -2000000000.0) tmp = Float64(fma(Float64(a - 0.5), b, y) + x); elseif (t_1 <= 5e+58) tmp = Float64(Float64(Float64(z + y) + x) - Float64(log(t) * z)); else tmp = fma(Float64(a - 0.5), b, Float64(x + y)); end return 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, -2000000000.0], N[(N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t$95$1, 5e+58], N[(N[(N[(z + y), $MachinePrecision] + x), $MachinePrecision] - N[(N[Log[t], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(N[(a - 0.5), $MachinePrecision] * b + N[(x + y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot b\\
\mathbf{if}\;t\_1 \leq -2000000000:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y\right) + x\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+58}:\\
\;\;\;\;\left(\left(z + y\right) + x\right) - \log t \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, x + y\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -2e9Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6479.0
Applied rewrites79.0%
if -2e9 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 4.99999999999999986e58Initial program 99.9%
Taylor expanded in a around -inf
mul-1-negN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
+-commutativeN/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f64N/A
Applied rewrites72.5%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-fma.f64N/A
mult-flipN/A
lower-*.f64N/A
Applied rewrites72.4%
Taylor expanded in b around 0
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lift-log.f64N/A
lift-*.f6463.0
Applied rewrites63.0%
if 4.99999999999999986e58 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in z around 0
lower-+.f6479.1
Applied rewrites79.1%
(FPCore (x y z t a b) :precision binary64 (if (<= z 5.8e+212) (fma (- a 0.5) b (+ x y)) (* (- 1.0 (log t)) z)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= 5.8e+212) {
tmp = fma((a - 0.5), b, (x + y));
} else {
tmp = (1.0 - log(t)) * z;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (z <= 5.8e+212) tmp = fma(Float64(a - 0.5), b, Float64(x + y)); else tmp = Float64(Float64(1.0 - log(t)) * z); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, 5.8e+212], N[(N[(a - 0.5), $MachinePrecision] * b + N[(x + y), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 5.8 \cdot 10^{+212}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, x + y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \log t\right) \cdot z\\
\end{array}
\end{array}
if z < 5.7999999999999997e212Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in z around 0
lower-+.f6479.1
Applied rewrites79.1%
if 5.7999999999999997e212 < z Initial program 99.9%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6426.4
Applied rewrites26.4%
Taylor expanded in z around -inf
*-commutativeN/A
mul-1-negN/A
sub-flipN/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6422.0
Applied rewrites22.0%
(FPCore (x y z t a b) :precision binary64 (fma (- a 0.5) b (+ x y)))
double code(double x, double y, double z, double t, double a, double b) {
return fma((a - 0.5), b, (x + y));
}
function code(x, y, z, t, a, b) return fma(Float64(a - 0.5), b, Float64(x + y)) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(a - 0.5), $MachinePrecision] * b + N[(x + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a - 0.5, b, x + y\right)
\end{array}
Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in z around 0
lower-+.f6479.1
Applied rewrites79.1%
(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.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6479.0
Applied rewrites79.0%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ x y) -1e+74) (* (- a) (/ (- x) a)) (fma (- a 0.5) b y)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x + y) <= -1e+74) {
tmp = -a * (-x / a);
} else {
tmp = fma((a - 0.5), b, y);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x + y) <= -1e+74) tmp = Float64(Float64(-a) * Float64(Float64(-x) / a)); else tmp = fma(Float64(a - 0.5), b, y); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x + y), $MachinePrecision], -1e+74], N[((-a) * N[((-x) / a), $MachinePrecision]), $MachinePrecision], N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq -1 \cdot 10^{+74}:\\
\;\;\;\;\left(-a\right) \cdot \frac{-x}{a}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a - 0.5, b, y\right)\\
\end{array}
\end{array}
if (+.f64 x y) < -9.99999999999999952e73Initial program 99.9%
Taylor expanded in a around -inf
mul-1-negN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
+-commutativeN/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f64N/A
Applied rewrites72.5%
Taylor expanded in x around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6416.0
Applied rewrites16.0%
if -9.99999999999999952e73 < (+.f64 x y) Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in z around 0
lower-+.f6479.1
Applied rewrites79.1%
Taylor expanded in x around 0
Applied rewrites57.8%
(FPCore (x y z t a b) :precision binary64 (fma (- a 0.5) b y))
double code(double x, double y, double z, double t, double a, double b) {
return fma((a - 0.5), b, y);
}
function code(x, y, z, t, a, b) return fma(Float64(a - 0.5), b, y) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a - 0.5, b, y\right)
\end{array}
Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in z around 0
lower-+.f6479.1
Applied rewrites79.1%
Taylor expanded in x around 0
Applied rewrites57.8%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (- a 0.5) b)) (t_2 (* b (- a 0.5)))) (if (<= t_1 -10.0) t_2 (if (<= t_1 2e+180) (fma -0.5 b y) 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 = b * (a - 0.5);
double tmp;
if (t_1 <= -10.0) {
tmp = t_2;
} else if (t_1 <= 2e+180) {
tmp = fma(-0.5, b, y);
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a - 0.5) * b) t_2 = Float64(b * Float64(a - 0.5)) tmp = 0.0 if (t_1 <= -10.0) tmp = t_2; elseif (t_1 <= 2e+180) tmp = fma(-0.5, b, y); 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]), $MachinePrecision]}, If[LessEqual[t$95$1, -10.0], t$95$2, If[LessEqual[t$95$1, 2e+180], N[(-0.5 * b + y), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot b\\
t_2 := b \cdot \left(a - 0.5\right)\\
\mathbf{if}\;t\_1 \leq -10:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+180}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, b, y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -10 or 2e180 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) Initial program 99.9%
Taylor expanded in a around -inf
mul-1-negN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
+-commutativeN/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f64N/A
Applied rewrites72.5%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-log.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-fma.f64N/A
mult-flipN/A
lower-*.f64N/A
Applied rewrites72.4%
Taylor expanded in b around inf
lower-*.f64N/A
lift--.f6438.0
Applied rewrites38.0%
if -10 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 2e180Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in z around 0
lower-+.f6479.1
Applied rewrites79.1%
Taylor expanded in x around 0
Applied rewrites57.8%
Taylor expanded in a around 0
Applied rewrites33.4%
(FPCore (x y z t a b) :precision binary64 (if (<= a -3e+50) (* b a) (if (<= a 2.7e+52) (fma -0.5 b y) (* b a))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= -3e+50) {
tmp = b * a;
} else if (a <= 2.7e+52) {
tmp = fma(-0.5, b, y);
} else {
tmp = b * a;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= -3e+50) tmp = Float64(b * a); elseif (a <= 2.7e+52) tmp = fma(-0.5, b, y); else tmp = Float64(b * a); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -3e+50], N[(b * a), $MachinePrecision], If[LessEqual[a, 2.7e+52], N[(-0.5 * b + y), $MachinePrecision], N[(b * a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3 \cdot 10^{+50}:\\
\;\;\;\;b \cdot a\\
\mathbf{elif}\;a \leq 2.7 \cdot 10^{+52}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, b, y\right)\\
\mathbf{else}:\\
\;\;\;\;b \cdot a\\
\end{array}
\end{array}
if a < -2.9999999999999998e50 or 2.7e52 < a Initial program 99.9%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6426.4
Applied rewrites26.4%
if -2.9999999999999998e50 < a < 2.7e52Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in z around 0
lower-+.f6479.1
Applied rewrites79.1%
Taylor expanded in x around 0
Applied rewrites57.8%
Taylor expanded in a around 0
Applied rewrites33.4%
(FPCore (x y z t a b) :precision binary64 (* b a))
double code(double x, double y, double z, double t, double a, double b) {
return b * 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)
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 = b * a
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return b * a;
}
def code(x, y, z, t, a, b): return b * a
function code(x, y, z, t, a, b) return Float64(b * a) end
function tmp = code(x, y, z, t, a, b) tmp = b * a; end
code[x_, y_, z_, t_, a_, b_] := N[(b * a), $MachinePrecision]
\begin{array}{l}
\\
b \cdot a
\end{array}
Initial program 99.9%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f6426.4
Applied rewrites26.4%
herbie shell --seed 2025136
(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)))