
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * (1.0d0 - ((1.0d0 - y) * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
def code(x, y, z): return x * (1.0 - ((1.0 - y) * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - ((1.0 - y) * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\end{array}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * (1.0d0 - ((1.0d0 - y) * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
def code(x, y, z): return x * (1.0 - ((1.0 - y) * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - ((1.0 - y) * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\end{array}
(FPCore (x y z) :precision binary64 (let* ((t_0 (fma (* (- y 1.0) x) z x))) (if (<= z -2e-17) t_0 (if (<= z 1.05e-92) (* x (- 1.0 (* (- y) z))) t_0))))
double code(double x, double y, double z) {
double t_0 = fma(((y - 1.0) * x), z, x);
double tmp;
if (z <= -2e-17) {
tmp = t_0;
} else if (z <= 1.05e-92) {
tmp = x * (1.0 - (-y * z));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = fma(Float64(Float64(y - 1.0) * x), z, x) tmp = 0.0 if (z <= -2e-17) tmp = t_0; elseif (z <= 1.05e-92) tmp = Float64(x * Float64(1.0 - Float64(Float64(-y) * z))); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(y - 1.0), $MachinePrecision] * x), $MachinePrecision] * z + x), $MachinePrecision]}, If[LessEqual[z, -2e-17], t$95$0, If[LessEqual[z, 1.05e-92], N[(x * N[(1.0 - N[((-y) * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\left(y - 1\right) \cdot x, z, x\right)\\
\mathbf{if}\;z \leq -2 \cdot 10^{-17}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.05 \cdot 10^{-92}:\\
\;\;\;\;x \cdot \left(1 - \left(-y\right) \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -2.00000000000000014e-17 or 1.05e-92 < z Initial program 96.0%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
sub-negate-revN/A
+-commutativeN/A
distribute-lft1-inN/A
*-commutativeN/A
sub-negate-revN/A
mul-1-negN/A
*-commutativeN/A
associate-*l*N/A
mul-1-negN/A
sub-negate-revN/A
lower-fma.f64N/A
Applied rewrites95.9%
if -2.00000000000000014e-17 < z < 1.05e-92Initial program 96.0%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6471.7
Applied rewrites71.7%
(FPCore (x y z) :precision binary64 (if (<= x 1e-16) (fma (* (- y 1.0) x) z x) (fma (- y 1.0) (* z x) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= 1e-16) {
tmp = fma(((y - 1.0) * x), z, x);
} else {
tmp = fma((y - 1.0), (z * x), x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 1e-16) tmp = fma(Float64(Float64(y - 1.0) * x), z, x); else tmp = fma(Float64(y - 1.0), Float64(z * x), x); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 1e-16], N[(N[(N[(y - 1.0), $MachinePrecision] * x), $MachinePrecision] * z + x), $MachinePrecision], N[(N[(y - 1.0), $MachinePrecision] * N[(z * x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{-16}:\\
\;\;\;\;\mathsf{fma}\left(\left(y - 1\right) \cdot x, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y - 1, z \cdot x, x\right)\\
\end{array}
\end{array}
if x < 9.9999999999999998e-17Initial program 96.0%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
sub-negate-revN/A
+-commutativeN/A
distribute-lft1-inN/A
*-commutativeN/A
sub-negate-revN/A
mul-1-negN/A
*-commutativeN/A
associate-*l*N/A
mul-1-negN/A
sub-negate-revN/A
lower-fma.f64N/A
Applied rewrites95.9%
if 9.9999999999999998e-17 < x Initial program 96.0%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
sub-negate-revN/A
+-commutativeN/A
distribute-lft1-inN/A
*-commutativeN/A
sub-negate-revN/A
mul-1-negN/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
mul-1-negN/A
sub-negate-revN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6497.8
Applied rewrites97.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (- 1.0 y) z)) (t_1 (* x (- (* z y) z))))
(if (<= t_0 -2e+24)
t_1
(if (<= t_0 20.0)
(* x (- 1.0 (* (- y) z)))
(if (<= t_0 2e+299) t_1 (fma (* x y) z x))))))
double code(double x, double y, double z) {
double t_0 = (1.0 - y) * z;
double t_1 = x * ((z * y) - z);
double tmp;
if (t_0 <= -2e+24) {
tmp = t_1;
} else if (t_0 <= 20.0) {
tmp = x * (1.0 - (-y * z));
} else if (t_0 <= 2e+299) {
tmp = t_1;
} else {
tmp = fma((x * y), z, x);
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(1.0 - y) * z) t_1 = Float64(x * Float64(Float64(z * y) - z)) tmp = 0.0 if (t_0 <= -2e+24) tmp = t_1; elseif (t_0 <= 20.0) tmp = Float64(x * Float64(1.0 - Float64(Float64(-y) * z))); elseif (t_0 <= 2e+299) tmp = t_1; else tmp = fma(Float64(x * y), z, x); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(N[(z * y), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e+24], t$95$1, If[LessEqual[t$95$0, 20.0], N[(x * N[(1.0 - N[((-y) * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+299], t$95$1, N[(N[(x * y), $MachinePrecision] * z + x), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - y\right) \cdot z\\
t_1 := x \cdot \left(z \cdot y - z\right)\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{+24}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 20:\\
\;\;\;\;x \cdot \left(1 - \left(-y\right) \cdot z\right)\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+299}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x \cdot y, z, x\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 #s(literal 1 binary64) y) z) < -2e24 or 20 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) < 2.0000000000000001e299Initial program 96.0%
Taylor expanded in z around inf
sub-flipN/A
metadata-evalN/A
distribute-rgt-inN/A
mul-1-negN/A
sub-flipN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6459.4
Applied rewrites59.4%
if -2e24 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) < 20Initial program 96.0%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6471.7
Applied rewrites71.7%
if 2.0000000000000001e299 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) Initial program 96.0%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
sub-negate-revN/A
+-commutativeN/A
distribute-lft1-inN/A
*-commutativeN/A
sub-negate-revN/A
mul-1-negN/A
*-commutativeN/A
associate-*l*N/A
mul-1-negN/A
sub-negate-revN/A
lower-fma.f64N/A
Applied rewrites95.9%
Taylor expanded in y around inf
lower-*.f6471.6
Applied rewrites71.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- (* z y) z))) (t_1 (- 1.0 (* (- 1.0 y) z))))
(if (<= t_1 (- INFINITY))
(fma (* x y) z x)
(if (<= t_1 -1e+15) t_0 (if (<= t_1 2.0) (fma (- x) z x) t_0)))))
double code(double x, double y, double z) {
double t_0 = x * ((z * y) - z);
double t_1 = 1.0 - ((1.0 - y) * z);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = fma((x * y), z, x);
} else if (t_1 <= -1e+15) {
tmp = t_0;
} else if (t_1 <= 2.0) {
tmp = fma(-x, z, x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(x * Float64(Float64(z * y) - z)) t_1 = Float64(1.0 - Float64(Float64(1.0 - y) * z)) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = fma(Float64(x * y), z, x); elseif (t_1 <= -1e+15) tmp = t_0; elseif (t_1 <= 2.0) tmp = fma(Float64(-x), z, x); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(N[(z * y), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(x * y), $MachinePrecision] * z + x), $MachinePrecision], If[LessEqual[t$95$1, -1e+15], t$95$0, If[LessEqual[t$95$1, 2.0], N[((-x) * z + x), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(z \cdot y - z\right)\\
t_1 := 1 - \left(1 - y\right) \cdot z\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(x \cdot y, z, x\right)\\
\mathbf{elif}\;t\_1 \leq -1 \cdot 10^{+15}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 2:\\
\;\;\;\;\mathsf{fma}\left(-x, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) (*.f64 (-.f64 #s(literal 1 binary64) y) z)) < -inf.0Initial program 96.0%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
sub-negate-revN/A
+-commutativeN/A
distribute-lft1-inN/A
*-commutativeN/A
sub-negate-revN/A
mul-1-negN/A
*-commutativeN/A
associate-*l*N/A
mul-1-negN/A
sub-negate-revN/A
lower-fma.f64N/A
Applied rewrites95.9%
Taylor expanded in y around inf
lower-*.f6471.6
Applied rewrites71.6%
if -inf.0 < (-.f64 #s(literal 1 binary64) (*.f64 (-.f64 #s(literal 1 binary64) y) z)) < -1e15 or 2 < (-.f64 #s(literal 1 binary64) (*.f64 (-.f64 #s(literal 1 binary64) y) z)) Initial program 96.0%
Taylor expanded in z around inf
sub-flipN/A
metadata-evalN/A
distribute-rgt-inN/A
mul-1-negN/A
sub-flipN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6459.4
Applied rewrites59.4%
if -1e15 < (-.f64 #s(literal 1 binary64) (*.f64 (-.f64 #s(literal 1 binary64) y) z)) < 2Initial program 96.0%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
sub-negate-revN/A
+-commutativeN/A
distribute-lft1-inN/A
*-commutativeN/A
sub-negate-revN/A
mul-1-negN/A
*-commutativeN/A
associate-*l*N/A
mul-1-negN/A
sub-negate-revN/A
lower-fma.f64N/A
Applied rewrites95.9%
Taylor expanded in y around 0
mul-1-negN/A
lower-neg.f6466.1
Applied rewrites66.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (fma (* x y) z x))) (if (<= y -600000000000.0) t_0 (if (<= y 1.2e-13) (fma (- x) z x) t_0))))
double code(double x, double y, double z) {
double t_0 = fma((x * y), z, x);
double tmp;
if (y <= -600000000000.0) {
tmp = t_0;
} else if (y <= 1.2e-13) {
tmp = fma(-x, z, x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = fma(Float64(x * y), z, x) tmp = 0.0 if (y <= -600000000000.0) tmp = t_0; elseif (y <= 1.2e-13) tmp = fma(Float64(-x), z, x); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * y), $MachinePrecision] * z + x), $MachinePrecision]}, If[LessEqual[y, -600000000000.0], t$95$0, If[LessEqual[y, 1.2e-13], N[((-x) * z + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(x \cdot y, z, x\right)\\
\mathbf{if}\;y \leq -600000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{-13}:\\
\;\;\;\;\mathsf{fma}\left(-x, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -6e11 or 1.1999999999999999e-13 < y Initial program 96.0%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
sub-negate-revN/A
+-commutativeN/A
distribute-lft1-inN/A
*-commutativeN/A
sub-negate-revN/A
mul-1-negN/A
*-commutativeN/A
associate-*l*N/A
mul-1-negN/A
sub-negate-revN/A
lower-fma.f64N/A
Applied rewrites95.9%
Taylor expanded in y around inf
lower-*.f6471.6
Applied rewrites71.6%
if -6e11 < y < 1.1999999999999999e-13Initial program 96.0%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
sub-negate-revN/A
+-commutativeN/A
distribute-lft1-inN/A
*-commutativeN/A
sub-negate-revN/A
mul-1-negN/A
*-commutativeN/A
associate-*l*N/A
mul-1-negN/A
sub-negate-revN/A
lower-fma.f64N/A
Applied rewrites95.9%
Taylor expanded in y around 0
mul-1-negN/A
lower-neg.f6466.1
Applied rewrites66.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (* z y)))) (if (<= y -5.6e+15) t_0 (if (<= y 4.6e+130) (fma (- x) z x) t_0))))
double code(double x, double y, double z) {
double t_0 = x * (z * y);
double tmp;
if (y <= -5.6e+15) {
tmp = t_0;
} else if (y <= 4.6e+130) {
tmp = fma(-x, z, x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(x * Float64(z * y)) tmp = 0.0 if (y <= -5.6e+15) tmp = t_0; elseif (y <= 4.6e+130) tmp = fma(Float64(-x), z, x); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -5.6e+15], t$95$0, If[LessEqual[y, 4.6e+130], N[((-x) * z + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(z \cdot y\right)\\
\mathbf{if}\;y \leq -5.6 \cdot 10^{+15}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 4.6 \cdot 10^{+130}:\\
\;\;\;\;\mathsf{fma}\left(-x, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -5.6e15 or 4.60000000000000042e130 < y Initial program 96.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6435.8
Applied rewrites35.8%
if -5.6e15 < y < 4.60000000000000042e130Initial program 96.0%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
sub-negate-revN/A
+-commutativeN/A
distribute-lft1-inN/A
*-commutativeN/A
sub-negate-revN/A
mul-1-negN/A
*-commutativeN/A
associate-*l*N/A
mul-1-negN/A
sub-negate-revN/A
lower-fma.f64N/A
Applied rewrites95.9%
Taylor expanded in y around 0
mul-1-negN/A
lower-neg.f6466.1
Applied rewrites66.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (* z y)))) (if (<= y -5.6e+15) t_0 (if (<= y 4.6e+130) (* x (- 1.0 z)) t_0))))
double code(double x, double y, double z) {
double t_0 = x * (z * y);
double tmp;
if (y <= -5.6e+15) {
tmp = t_0;
} else if (y <= 4.6e+130) {
tmp = x * (1.0 - z);
} else {
tmp = t_0;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = x * (z * y)
if (y <= (-5.6d+15)) then
tmp = t_0
else if (y <= 4.6d+130) then
tmp = x * (1.0d0 - z)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (z * y);
double tmp;
if (y <= -5.6e+15) {
tmp = t_0;
} else if (y <= 4.6e+130) {
tmp = x * (1.0 - z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (z * y) tmp = 0 if y <= -5.6e+15: tmp = t_0 elif y <= 4.6e+130: tmp = x * (1.0 - z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(z * y)) tmp = 0.0 if (y <= -5.6e+15) tmp = t_0; elseif (y <= 4.6e+130) tmp = Float64(x * Float64(1.0 - z)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (z * y); tmp = 0.0; if (y <= -5.6e+15) tmp = t_0; elseif (y <= 4.6e+130) tmp = x * (1.0 - z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -5.6e+15], t$95$0, If[LessEqual[y, 4.6e+130], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(z \cdot y\right)\\
\mathbf{if}\;y \leq -5.6 \cdot 10^{+15}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 4.6 \cdot 10^{+130}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -5.6e15 or 4.60000000000000042e130 < y Initial program 96.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6435.8
Applied rewrites35.8%
if -5.6e15 < y < 4.60000000000000042e130Initial program 96.0%
Taylor expanded in y around 0
Applied rewrites66.1%
(FPCore (x y z) :precision binary64 (* x (- 1.0 z)))
double code(double x, double y, double z) {
return x * (1.0 - z);
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * (1.0d0 - z)
end function
public static double code(double x, double y, double z) {
return x * (1.0 - z);
}
def code(x, y, z): return x * (1.0 - z)
function code(x, y, z) return Float64(x * Float64(1.0 - z)) end
function tmp = code(x, y, z) tmp = x * (1.0 - z); end
code[x_, y_, z_] := N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - z\right)
\end{array}
Initial program 96.0%
Taylor expanded in y around 0
Applied rewrites66.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (- z)))) (if (<= z -2.7e+19) t_0 (if (<= z 4e-7) (* x 1.0) t_0))))
double code(double x, double y, double z) {
double t_0 = x * -z;
double tmp;
if (z <= -2.7e+19) {
tmp = t_0;
} else if (z <= 4e-7) {
tmp = x * 1.0;
} else {
tmp = t_0;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = x * -z
if (z <= (-2.7d+19)) then
tmp = t_0
else if (z <= 4d-7) then
tmp = x * 1.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * -z;
double tmp;
if (z <= -2.7e+19) {
tmp = t_0;
} else if (z <= 4e-7) {
tmp = x * 1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * -z tmp = 0 if z <= -2.7e+19: tmp = t_0 elif z <= 4e-7: tmp = x * 1.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(-z)) tmp = 0.0 if (z <= -2.7e+19) tmp = t_0; elseif (z <= 4e-7) tmp = Float64(x * 1.0); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * -z; tmp = 0.0; if (z <= -2.7e+19) tmp = t_0; elseif (z <= 4e-7) tmp = x * 1.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * (-z)), $MachinePrecision]}, If[LessEqual[z, -2.7e+19], t$95$0, If[LessEqual[z, 4e-7], N[(x * 1.0), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(-z\right)\\
\mathbf{if}\;z \leq -2.7 \cdot 10^{+19}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 4 \cdot 10^{-7}:\\
\;\;\;\;x \cdot 1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -2.7e19 or 3.9999999999999998e-7 < z Initial program 96.0%
Taylor expanded in z around inf
sub-flipN/A
metadata-evalN/A
distribute-rgt-inN/A
mul-1-negN/A
sub-flipN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6459.4
Applied rewrites59.4%
Taylor expanded in y around 0
mul-1-negN/A
lower-neg.f6430.3
Applied rewrites30.3%
if -2.7e19 < z < 3.9999999999999998e-7Initial program 96.0%
Taylor expanded in z around inf
sub-flipN/A
metadata-evalN/A
distribute-rgt-inN/A
mul-1-negN/A
sub-flipN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6459.4
Applied rewrites59.4%
Taylor expanded in y around 0
mul-1-negN/A
lower-neg.f6430.3
Applied rewrites30.3%
Taylor expanded in z around 0
Applied rewrites38.6%
(FPCore (x y z) :precision binary64 (* x 1.0))
double code(double x, double y, double z) {
return x * 1.0;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * 1.0d0
end function
public static double code(double x, double y, double z) {
return x * 1.0;
}
def code(x, y, z): return x * 1.0
function code(x, y, z) return Float64(x * 1.0) end
function tmp = code(x, y, z) tmp = x * 1.0; end
code[x_, y_, z_] := N[(x * 1.0), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 1
\end{array}
Initial program 96.0%
Taylor expanded in z around inf
sub-flipN/A
metadata-evalN/A
distribute-rgt-inN/A
mul-1-negN/A
sub-flipN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6459.4
Applied rewrites59.4%
Taylor expanded in y around 0
mul-1-negN/A
lower-neg.f6430.3
Applied rewrites30.3%
Taylor expanded in z around 0
Applied rewrites38.6%
herbie shell --seed 2025134
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, J"
:precision binary64
(* x (- 1.0 (* (- 1.0 y) z))))