
(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]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
Herbie found 8 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]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
(FPCore (x y z)
:precision binary64
(*
(copysign 1.0 x)
(if (<= (fabs x) 5e-44)
(fma (* (- y 1.0) (fabs x)) z (fabs x))
(fma (- y 1.0) (* z (fabs x)) (fabs x)))))double code(double x, double y, double z) {
double tmp;
if (fabs(x) <= 5e-44) {
tmp = fma(((y - 1.0) * fabs(x)), z, fabs(x));
} else {
tmp = fma((y - 1.0), (z * fabs(x)), fabs(x));
}
return copysign(1.0, x) * tmp;
}
function code(x, y, z) tmp = 0.0 if (abs(x) <= 5e-44) tmp = fma(Float64(Float64(y - 1.0) * abs(x)), z, abs(x)); else tmp = fma(Float64(y - 1.0), Float64(z * abs(x)), abs(x)); end return Float64(copysign(1.0, x) * tmp) end
code[x_, y_, z_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[x], $MachinePrecision], 5e-44], N[(N[(N[(y - 1.0), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * z + N[Abs[x], $MachinePrecision]), $MachinePrecision], N[(N[(y - 1.0), $MachinePrecision] * N[(z * N[Abs[x], $MachinePrecision]), $MachinePrecision] + N[Abs[x], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, x\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 5 \cdot 10^{-44}:\\
\;\;\;\;\mathsf{fma}\left(\left(y - 1\right) \cdot \left|x\right|, z, \left|x\right|\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y - 1, z \cdot \left|x\right|, \left|x\right|\right)\\
\end{array}
if x < 5.00000000000000039e-44Initial program 96.2%
lift-*.f64N/A
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lift-*.f64N/A
distribute-lft-neg-outN/A
lift--.f64N/A
sub-negate-revN/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6495.9
Applied rewrites95.9%
if 5.00000000000000039e-44 < x Initial program 96.2%
lift-*.f64N/A
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
distribute-lft-inN/A
lift-*.f64N/A
distribute-lft-neg-outN/A
lift--.f64N/A
sub-negate-revN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-rgt-identityN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6498.0
Applied rewrites98.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (- 1.0 y) z)) (t_1 (fma (* x y) z x)))
(if (<= t_0 -2e+290)
t_1
(if (<= t_0 -100000.0)
(* x (- (* z y) z))
(if (<= t_0 10000000000.0)
(* x (- 1.0 z))
(if (<= t_0 1e+307) (* x (* z (- y 1.0))) t_1))))))double code(double x, double y, double z) {
double t_0 = (1.0 - y) * z;
double t_1 = fma((x * y), z, x);
double tmp;
if (t_0 <= -2e+290) {
tmp = t_1;
} else if (t_0 <= -100000.0) {
tmp = x * ((z * y) - z);
} else if (t_0 <= 10000000000.0) {
tmp = x * (1.0 - z);
} else if (t_0 <= 1e+307) {
tmp = x * (z * (y - 1.0));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(1.0 - y) * z) t_1 = fma(Float64(x * y), z, x) tmp = 0.0 if (t_0 <= -2e+290) tmp = t_1; elseif (t_0 <= -100000.0) tmp = Float64(x * Float64(Float64(z * y) - z)); elseif (t_0 <= 10000000000.0) tmp = Float64(x * Float64(1.0 - z)); elseif (t_0 <= 1e+307) tmp = Float64(x * Float64(z * Float64(y - 1.0))); else tmp = t_1; 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[(N[(x * y), $MachinePrecision] * z + x), $MachinePrecision]}, If[LessEqual[t$95$0, -2e+290], t$95$1, If[LessEqual[t$95$0, -100000.0], N[(x * N[(N[(z * y), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 10000000000.0], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+307], N[(x * N[(z * N[(y - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
t_0 := \left(1 - y\right) \cdot z\\
t_1 := \mathsf{fma}\left(x \cdot y, z, x\right)\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{+290}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq -100000:\\
\;\;\;\;x \cdot \left(z \cdot y - z\right)\\
\mathbf{elif}\;t\_0 \leq 10000000000:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{elif}\;t\_0 \leq 10^{+307}:\\
\;\;\;\;x \cdot \left(z \cdot \left(y - 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if (*.f64 (-.f64 #s(literal 1 binary64) y) z) < -2.00000000000000012e290 or 9.99999999999999986e306 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) Initial program 96.2%
lift-*.f64N/A
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lift-*.f64N/A
distribute-lft-neg-outN/A
lift--.f64N/A
sub-negate-revN/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6495.9
Applied rewrites95.9%
Taylor expanded in y around inf
lower-*.f6472.7
Applied rewrites72.7%
if -2.00000000000000012e290 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) < -1e5Initial program 96.2%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f6458.3
Applied rewrites58.3%
lift-*.f64N/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
lift-*.f64N/A
add-flipN/A
distribute-lft-neg-outN/A
remove-double-negN/A
*-lft-identityN/A
lower--.f6458.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6458.3
Applied rewrites58.3%
if -1e5 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) < 1e10Initial program 96.2%
Taylor expanded in y around 0
Applied rewrites66.6%
if 1e10 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) < 9.99999999999999986e306Initial program 96.2%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f6458.3
Applied rewrites58.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (* z (- y 1.0))))
(t_1 (- 1.0 (* (- 1.0 y) z)))
(t_2 (fma (* x y) z x)))
(if (<= t_1 (- INFINITY))
t_2
(if (<= t_1 -2e+31)
t_0
(if (<= t_1 5.0) (* x (- 1.0 z)) (if (<= t_1 5e+280) t_0 t_2))))))double code(double x, double y, double z) {
double t_0 = x * (z * (y - 1.0));
double t_1 = 1.0 - ((1.0 - y) * z);
double t_2 = fma((x * y), z, x);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t_2;
} else if (t_1 <= -2e+31) {
tmp = t_0;
} else if (t_1 <= 5.0) {
tmp = x * (1.0 - z);
} else if (t_1 <= 5e+280) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(x * Float64(z * Float64(y - 1.0))) t_1 = Float64(1.0 - Float64(Float64(1.0 - y) * z)) t_2 = fma(Float64(x * y), z, x) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = t_2; elseif (t_1 <= -2e+31) tmp = t_0; elseif (t_1 <= 5.0) tmp = Float64(x * Float64(1.0 - z)); elseif (t_1 <= 5e+280) tmp = t_0; else tmp = t_2; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(z * N[(y - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] * z + x), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], t$95$2, If[LessEqual[t$95$1, -2e+31], t$95$0, If[LessEqual[t$95$1, 5.0], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+280], t$95$0, t$95$2]]]]]]]
\begin{array}{l}
t_0 := x \cdot \left(z \cdot \left(y - 1\right)\right)\\
t_1 := 1 - \left(1 - y\right) \cdot z\\
t_2 := \mathsf{fma}\left(x \cdot y, z, x\right)\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq -2 \cdot 10^{+31}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 5:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+280}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
if (-.f64 #s(literal 1 binary64) (*.f64 (-.f64 #s(literal 1 binary64) y) z)) < -inf.0 or 5.0000000000000002e280 < (-.f64 #s(literal 1 binary64) (*.f64 (-.f64 #s(literal 1 binary64) y) z)) Initial program 96.2%
lift-*.f64N/A
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lift-*.f64N/A
distribute-lft-neg-outN/A
lift--.f64N/A
sub-negate-revN/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6495.9
Applied rewrites95.9%
Taylor expanded in y around inf
lower-*.f6472.7
Applied rewrites72.7%
if -inf.0 < (-.f64 #s(literal 1 binary64) (*.f64 (-.f64 #s(literal 1 binary64) y) z)) < -1.9999999999999999e31 or 5 < (-.f64 #s(literal 1 binary64) (*.f64 (-.f64 #s(literal 1 binary64) y) z)) < 5.0000000000000002e280Initial program 96.2%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f6458.3
Applied rewrites58.3%
if -1.9999999999999999e31 < (-.f64 #s(literal 1 binary64) (*.f64 (-.f64 #s(literal 1 binary64) y) z)) < 5Initial program 96.2%
Taylor expanded in y around 0
Applied rewrites66.6%
(FPCore (x y z) :precision binary64 (fma (* (- y 1.0) x) z x))
double code(double x, double y, double z) {
return fma(((y - 1.0) * x), z, x);
}
function code(x, y, z) return fma(Float64(Float64(y - 1.0) * x), z, x) end
code[x_, y_, z_] := N[(N[(N[(y - 1.0), $MachinePrecision] * x), $MachinePrecision] * z + x), $MachinePrecision]
\mathsf{fma}\left(\left(y - 1\right) \cdot x, z, x\right)
Initial program 96.2%
lift-*.f64N/A
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lift-*.f64N/A
distribute-lft-neg-outN/A
lift--.f64N/A
sub-negate-revN/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6495.9
Applied rewrites95.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (fma (* x y) z x))) (if (<= (- 1.0 y) -500.0) t_0 (if (<= (- 1.0 y) 1.1) (* x (- 1.0 z)) t_0))))
double code(double x, double y, double z) {
double t_0 = fma((x * y), z, x);
double tmp;
if ((1.0 - y) <= -500.0) {
tmp = t_0;
} else if ((1.0 - y) <= 1.1) {
tmp = x * (1.0 - z);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = fma(Float64(x * y), z, x) tmp = 0.0 if (Float64(1.0 - y) <= -500.0) tmp = t_0; elseif (Float64(1.0 - y) <= 1.1) tmp = Float64(x * Float64(1.0 - z)); 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[N[(1.0 - y), $MachinePrecision], -500.0], t$95$0, If[LessEqual[N[(1.0 - y), $MachinePrecision], 1.1], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \mathsf{fma}\left(x \cdot y, z, x\right)\\
\mathbf{if}\;1 - y \leq -500:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;1 - y \leq 1.1:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if (-.f64 #s(literal 1 binary64) y) < -500 or 1.1000000000000001 < (-.f64 #s(literal 1 binary64) y) Initial program 96.2%
lift-*.f64N/A
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lift-*.f64N/A
distribute-lft-neg-outN/A
lift--.f64N/A
sub-negate-revN/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6495.9
Applied rewrites95.9%
Taylor expanded in y around inf
lower-*.f6472.7
Applied rewrites72.7%
if -500 < (-.f64 #s(literal 1 binary64) y) < 1.1000000000000001Initial program 96.2%
Taylor expanded in y around 0
Applied rewrites66.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (* y z))))
(if (<= (- 1.0 y) -5e+31)
t_0
(if (<= (- 1.0 y) 2e+53) (* x (- 1.0 z)) t_0))))double code(double x, double y, double z) {
double t_0 = x * (y * z);
double tmp;
if ((1.0 - y) <= -5e+31) {
tmp = t_0;
} else if ((1.0 - y) <= 2e+53) {
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 * (y * z)
if ((1.0d0 - y) <= (-5d+31)) then
tmp = t_0
else if ((1.0d0 - y) <= 2d+53) 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 * (y * z);
double tmp;
if ((1.0 - y) <= -5e+31) {
tmp = t_0;
} else if ((1.0 - y) <= 2e+53) {
tmp = x * (1.0 - z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (y * z) tmp = 0 if (1.0 - y) <= -5e+31: tmp = t_0 elif (1.0 - y) <= 2e+53: tmp = x * (1.0 - z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(y * z)) tmp = 0.0 if (Float64(1.0 - y) <= -5e+31) tmp = t_0; elseif (Float64(1.0 - y) <= 2e+53) 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 * (y * z); tmp = 0.0; if ((1.0 - y) <= -5e+31) tmp = t_0; elseif ((1.0 - y) <= 2e+53) 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[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 - y), $MachinePrecision], -5e+31], t$95$0, If[LessEqual[N[(1.0 - y), $MachinePrecision], 2e+53], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := x \cdot \left(y \cdot z\right)\\
\mathbf{if}\;1 - y \leq -5 \cdot 10^{+31}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;1 - y \leq 2 \cdot 10^{+53}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if (-.f64 #s(literal 1 binary64) y) < -5.00000000000000027e31 or 2e53 < (-.f64 #s(literal 1 binary64) y) Initial program 96.2%
Taylor expanded in y around inf
lower-*.f6435.9
Applied rewrites35.9%
if -5.00000000000000027e31 < (-.f64 #s(literal 1 binary64) y) < 2e53Initial program 96.2%
Taylor expanded in y around 0
Applied rewrites66.6%
(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]
x \cdot \left(1 - z\right)
Initial program 96.2%
Taylor expanded in y around 0
Applied rewrites66.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]
x \cdot 1
Initial program 96.2%
Taylor expanded in y around 0
Applied rewrites66.6%
Taylor expanded in z around 0
Applied rewrites39.9%
herbie shell --seed 2025167
(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))))