
(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 (* (- y 1.0) x)))
(if (<= z -4.3e+15)
(* t_0 z)
(if (<= z 4e-67) (* x (- 1.0 (* (- y) z))) (fma t_0 z x)))))
double code(double x, double y, double z) {
double t_0 = (y - 1.0) * x;
double tmp;
if (z <= -4.3e+15) {
tmp = t_0 * z;
} else if (z <= 4e-67) {
tmp = x * (1.0 - (-y * z));
} else {
tmp = fma(t_0, z, x);
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(y - 1.0) * x) tmp = 0.0 if (z <= -4.3e+15) tmp = Float64(t_0 * z); elseif (z <= 4e-67) tmp = Float64(x * Float64(1.0 - Float64(Float64(-y) * z))); else tmp = fma(t_0, z, x); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y - 1.0), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[z, -4.3e+15], N[(t$95$0 * z), $MachinePrecision], If[LessEqual[z, 4e-67], N[(x * N[(1.0 - N[((-y) * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * z + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y - 1\right) \cdot x\\
\mathbf{if}\;z \leq -4.3 \cdot 10^{+15}:\\
\;\;\;\;t\_0 \cdot z\\
\mathbf{elif}\;z \leq 4 \cdot 10^{-67}:\\
\;\;\;\;x \cdot \left(1 - \left(-y\right) \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_0, z, x\right)\\
\end{array}
\end{array}
if z < -4.3e15Initial program 91.8%
Taylor expanded in z around inf
negate-subN/A
metadata-evalN/A
distribute-rgt-inN/A
mul-1-negN/A
negate-subN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6491.8
Applied rewrites91.8%
Taylor expanded in y around 0
mul-1-negN/A
lower-neg.f6456.5
Applied rewrites56.5%
Taylor expanded in z around inf
*-commutativeN/A
cancel-sign-sub-invN/A
negate-sub2N/A
*-commutativeN/A
+-commutativeN/A
distribute-lft1-inN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f6499.9
Applied rewrites99.9%
if -4.3e15 < z < 3.99999999999999977e-67Initial program 99.9%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6498.3
Applied rewrites98.3%
if 3.99999999999999977e-67 < z Initial program 93.6%
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lower-*.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
negate-sub2N/A
+-commutativeN/A
distribute-lft1-inN/A
*-commutativeN/A
negate-sub2N/A
mul-1-negN/A
*-commutativeN/A
associate-*r*N/A
mul-1-negN/A
negate-sub2N/A
lower-fma.f64N/A
Applied rewrites99.6%
(FPCore (x y z) :precision binary64 (fma (- y 1.0) (* z x) x))
double code(double x, double y, double z) {
return fma((y - 1.0), (z * x), x);
}
function code(x, y, z) return fma(Float64(y - 1.0), Float64(z * x), x) end
code[x_, y_, z_] := N[(N[(y - 1.0), $MachinePrecision] * N[(z * x), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y - 1, z \cdot x, x\right)
\end{array}
Initial program 96.1%
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lower-*.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
negate-sub2N/A
+-commutativeN/A
distribute-lft1-inN/A
*-commutativeN/A
negate-sub2N/A
mul-1-negN/A
*-commutativeN/A
associate-*r*N/A
mul-1-negN/A
negate-sub2N/A
Applied rewrites98.2%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (* (- y 1.0) x) z))) (if (<= z -4.3e+15) t_0 (if (<= z 1.0) (* x (- 1.0 (* (- y) z))) t_0))))
double code(double x, double y, double z) {
double t_0 = ((y - 1.0) * x) * z;
double tmp;
if (z <= -4.3e+15) {
tmp = t_0;
} else if (z <= 1.0) {
tmp = x * (1.0 - (-y * 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 = ((y - 1.0d0) * x) * z
if (z <= (-4.3d+15)) then
tmp = t_0
else if (z <= 1.0d0) then
tmp = x * (1.0d0 - (-y * z))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = ((y - 1.0) * x) * z;
double tmp;
if (z <= -4.3e+15) {
tmp = t_0;
} else if (z <= 1.0) {
tmp = x * (1.0 - (-y * z));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = ((y - 1.0) * x) * z tmp = 0 if z <= -4.3e+15: tmp = t_0 elif z <= 1.0: tmp = x * (1.0 - (-y * z)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(y - 1.0) * x) * z) tmp = 0.0 if (z <= -4.3e+15) tmp = t_0; elseif (z <= 1.0) tmp = Float64(x * Float64(1.0 - Float64(Float64(-y) * z))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((y - 1.0) * x) * z; tmp = 0.0; if (z <= -4.3e+15) tmp = t_0; elseif (z <= 1.0) tmp = x * (1.0 - (-y * z)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(y - 1.0), $MachinePrecision] * x), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -4.3e+15], t$95$0, If[LessEqual[z, 1.0], N[(x * N[(1.0 - N[((-y) * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(y - 1\right) \cdot x\right) \cdot z\\
\mathbf{if}\;z \leq -4.3 \cdot 10^{+15}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x \cdot \left(1 - \left(-y\right) \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -4.3e15 or 1 < z Initial program 92.1%
Taylor expanded in z around inf
negate-subN/A
metadata-evalN/A
distribute-rgt-inN/A
mul-1-negN/A
negate-subN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6491.5
Applied rewrites91.5%
Taylor expanded in y around 0
mul-1-negN/A
lower-neg.f6455.4
Applied rewrites55.4%
Taylor expanded in z around inf
*-commutativeN/A
cancel-sign-sub-invN/A
negate-sub2N/A
*-commutativeN/A
+-commutativeN/A
distribute-lft1-inN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f6499.3
Applied rewrites99.3%
if -4.3e15 < z < 1Initial program 99.9%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6498.1
Applied rewrites98.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (* (- y 1.0) x) z))) (if (<= z -1.65e-11) t_0 (if (<= z 1.0) (fma y (* z x) x) t_0))))
double code(double x, double y, double z) {
double t_0 = ((y - 1.0) * x) * z;
double tmp;
if (z <= -1.65e-11) {
tmp = t_0;
} else if (z <= 1.0) {
tmp = fma(y, (z * x), x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(Float64(y - 1.0) * x) * z) tmp = 0.0 if (z <= -1.65e-11) tmp = t_0; elseif (z <= 1.0) tmp = fma(y, Float64(z * x), x); 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), $MachinePrecision]}, If[LessEqual[z, -1.65e-11], t$95$0, If[LessEqual[z, 1.0], N[(y * N[(z * x), $MachinePrecision] + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(y - 1\right) \cdot x\right) \cdot z\\
\mathbf{if}\;z \leq -1.65 \cdot 10^{-11}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;\mathsf{fma}\left(y, z \cdot x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.6500000000000001e-11 or 1 < z Initial program 92.4%
Taylor expanded in z around inf
negate-subN/A
metadata-evalN/A
distribute-rgt-inN/A
mul-1-negN/A
negate-subN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6490.7
Applied rewrites90.7%
Taylor expanded in y around 0
mul-1-negN/A
lower-neg.f6454.2
Applied rewrites54.2%
Taylor expanded in z around inf
*-commutativeN/A
cancel-sign-sub-invN/A
negate-sub2N/A
*-commutativeN/A
+-commutativeN/A
distribute-lft1-inN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f6498.2
Applied rewrites98.2%
if -1.6500000000000001e-11 < z < 1Initial program 99.9%
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lower-*.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
negate-sub2N/A
+-commutativeN/A
distribute-lft1-inN/A
*-commutativeN/A
negate-sub2N/A
mul-1-negN/A
*-commutativeN/A
associate-*r*N/A
mul-1-negN/A
negate-sub2N/A
Applied rewrites96.5%
Taylor expanded in y around inf
Applied rewrites96.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (fma y (* z x) x))) (if (<= y -720000000.0) t_0 (if (<= y 1.0) (* x (- 1.0 z)) t_0))))
double code(double x, double y, double z) {
double t_0 = fma(y, (z * x), x);
double tmp;
if (y <= -720000000.0) {
tmp = t_0;
} else if (y <= 1.0) {
tmp = x * (1.0 - z);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = fma(y, Float64(z * x), x) tmp = 0.0 if (y <= -720000000.0) tmp = t_0; elseif (y <= 1.0) tmp = Float64(x * Float64(1.0 - z)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(z * x), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[y, -720000000.0], t$95$0, If[LessEqual[y, 1.0], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(y, z \cdot x, x\right)\\
\mathbf{if}\;y \leq -720000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -7.2e8 or 1 < y Initial program 92.2%
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lower-*.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
negate-sub2N/A
+-commutativeN/A
distribute-lft1-inN/A
*-commutativeN/A
negate-sub2N/A
mul-1-negN/A
*-commutativeN/A
associate-*r*N/A
mul-1-negN/A
negate-sub2N/A
Applied rewrites96.4%
Taylor expanded in y around inf
Applied rewrites95.9%
if -7.2e8 < y < 1Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites98.7%
(FPCore (x y z) :precision binary64 (if (<= (- 1.0 y) -1000000000.0) (* x (* z y)) (if (<= (- 1.0 y) 5e+103) (* x (- 1.0 z)) (* (* x y) z))))
double code(double x, double y, double z) {
double tmp;
if ((1.0 - y) <= -1000000000.0) {
tmp = x * (z * y);
} else if ((1.0 - y) <= 5e+103) {
tmp = x * (1.0 - z);
} else {
tmp = (x * y) * z;
}
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) :: tmp
if ((1.0d0 - y) <= (-1000000000.0d0)) then
tmp = x * (z * y)
else if ((1.0d0 - y) <= 5d+103) then
tmp = x * (1.0d0 - z)
else
tmp = (x * y) * z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((1.0 - y) <= -1000000000.0) {
tmp = x * (z * y);
} else if ((1.0 - y) <= 5e+103) {
tmp = x * (1.0 - z);
} else {
tmp = (x * y) * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (1.0 - y) <= -1000000000.0: tmp = x * (z * y) elif (1.0 - y) <= 5e+103: tmp = x * (1.0 - z) else: tmp = (x * y) * z return tmp
function code(x, y, z) tmp = 0.0 if (Float64(1.0 - y) <= -1000000000.0) tmp = Float64(x * Float64(z * y)); elseif (Float64(1.0 - y) <= 5e+103) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(Float64(x * y) * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((1.0 - y) <= -1000000000.0) tmp = x * (z * y); elseif ((1.0 - y) <= 5e+103) tmp = x * (1.0 - z); else tmp = (x * y) * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(1.0 - y), $MachinePrecision], -1000000000.0], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 - y), $MachinePrecision], 5e+103], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;1 - y \leq -1000000000:\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\mathbf{elif}\;1 - y \leq 5 \cdot 10^{+103}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot y\right) \cdot z\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) y) < -1e9Initial program 91.3%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6466.6
Applied rewrites66.6%
if -1e9 < (-.f64 #s(literal 1 binary64) y) < 5e103Initial program 99.4%
Taylor expanded in y around 0
Applied rewrites92.1%
if 5e103 < (-.f64 #s(literal 1 binary64) y) Initial program 91.1%
Taylor expanded in z around inf
negate-subN/A
metadata-evalN/A
distribute-rgt-inN/A
mul-1-negN/A
negate-subN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6475.9
Applied rewrites75.9%
Taylor expanded in y around 0
mul-1-negN/A
lower-neg.f6416.8
Applied rewrites16.8%
Taylor expanded in z around inf
*-commutativeN/A
cancel-sign-sub-invN/A
negate-sub2N/A
*-commutativeN/A
+-commutativeN/A
distribute-lft1-inN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f6479.1
Applied rewrites79.1%
Taylor expanded in y around inf
lower-*.f6479.1
Applied rewrites79.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* x y) z)))
(if (<= (- 1.0 y) -1000000000.0)
t_0
(if (<= (- 1.0 y) 5e+103) (* 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) <= -1000000000.0) {
tmp = t_0;
} else if ((1.0 - y) <= 5e+103) {
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) <= (-1000000000.0d0)) then
tmp = t_0
else if ((1.0d0 - y) <= 5d+103) 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) <= -1000000000.0) {
tmp = t_0;
} else if ((1.0 - y) <= 5e+103) {
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) <= -1000000000.0: tmp = t_0 elif (1.0 - y) <= 5e+103: tmp = x * (1.0 - z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x * y) * z) tmp = 0.0 if (Float64(1.0 - y) <= -1000000000.0) tmp = t_0; elseif (Float64(1.0 - y) <= 5e+103) 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) <= -1000000000.0) tmp = t_0; elseif ((1.0 - y) <= 5e+103) tmp = x * (1.0 - z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * y), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[N[(1.0 - y), $MachinePrecision], -1000000000.0], t$95$0, If[LessEqual[N[(1.0 - y), $MachinePrecision], 5e+103], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x \cdot y\right) \cdot z\\
\mathbf{if}\;1 - y \leq -1000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;1 - y \leq 5 \cdot 10^{+103}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) y) < -1e9 or 5e103 < (-.f64 #s(literal 1 binary64) y) Initial program 91.2%
Taylor expanded in z around inf
negate-subN/A
metadata-evalN/A
distribute-rgt-inN/A
mul-1-negN/A
negate-subN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6470.4
Applied rewrites70.4%
Taylor expanded in y around 0
mul-1-negN/A
lower-neg.f647.9
Applied rewrites7.9%
Taylor expanded in z around inf
*-commutativeN/A
cancel-sign-sub-invN/A
negate-sub2N/A
*-commutativeN/A
+-commutativeN/A
distribute-lft1-inN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f6475.0
Applied rewrites75.0%
Taylor expanded in y around inf
lower-*.f6474.9
Applied rewrites74.9%
if -1e9 < (-.f64 #s(literal 1 binary64) y) < 5e103Initial program 99.4%
Taylor expanded in y around 0
Applied rewrites92.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.1%
Taylor expanded in y around 0
Applied rewrites65.8%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (- z)))) (if (<= z -4.3e+15) t_0 (if (<= z 1.0) x t_0))))
double code(double x, double y, double z) {
double t_0 = x * -z;
double tmp;
if (z <= -4.3e+15) {
tmp = t_0;
} else if (z <= 1.0) {
tmp = x;
} 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 <= (-4.3d+15)) then
tmp = t_0
else if (z <= 1.0d0) then
tmp = x
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 <= -4.3e+15) {
tmp = t_0;
} else if (z <= 1.0) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * -z tmp = 0 if z <= -4.3e+15: tmp = t_0 elif z <= 1.0: tmp = x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(-z)) tmp = 0.0 if (z <= -4.3e+15) tmp = t_0; elseif (z <= 1.0) tmp = x; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * -z; tmp = 0.0; if (z <= -4.3e+15) tmp = t_0; elseif (z <= 1.0) tmp = x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * (-z)), $MachinePrecision]}, If[LessEqual[z, -4.3e+15], t$95$0, If[LessEqual[z, 1.0], x, t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(-z\right)\\
\mathbf{if}\;z \leq -4.3 \cdot 10^{+15}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -4.3e15 or 1 < z Initial program 92.1%
Taylor expanded in z around inf
negate-subN/A
metadata-evalN/A
distribute-rgt-inN/A
mul-1-negN/A
negate-subN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6491.5
Applied rewrites91.5%
Taylor expanded in y around 0
mul-1-negN/A
lower-neg.f6455.4
Applied rewrites55.4%
if -4.3e15 < z < 1Initial program 99.9%
Taylor expanded in z around 0
Applied rewrites73.2%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 96.1%
Taylor expanded in z around 0
Applied rewrites39.3%
herbie shell --seed 2025110
(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))))