
(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 -5e-30) t_0 (if (<= z 1.05e-11) (* 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 <= -5e-30) {
tmp = t_0;
} else if (z <= 1.05e-11) {
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 <= -5e-30) tmp = t_0; elseif (z <= 1.05e-11) 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, -5e-30], t$95$0, If[LessEqual[z, 1.05e-11], 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 -5 \cdot 10^{-30}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.05 \cdot 10^{-11}:\\
\;\;\;\;x \cdot \left(1 - \left(-y\right) \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -4.99999999999999972e-30 or 1.0499999999999999e-11 < z Initial program 96.3%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
flip--N/A
Applied rewrites95.7%
if -4.99999999999999972e-30 < z < 1.0499999999999999e-11Initial program 96.3%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6472.8
Applied rewrites72.8%
(FPCore (x y z) :precision binary64 (if (<= x 1000000000.0) (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 <= 1000000000.0) {
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 <= 1000000000.0) 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, 1000000000.0], 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 1000000000:\\
\;\;\;\;\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 < 1e9Initial program 96.3%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
flip--N/A
Applied rewrites95.7%
if 1e9 < x Initial program 96.3%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
flip--N/A
Applied rewrites98.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (* (- y 1.0) x) z))) (if (<= z -1.05) t_0 (if (<= z 59.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 <= -1.05) {
tmp = t_0;
} else if (z <= 59.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 <= (-1.05d0)) then
tmp = t_0
else if (z <= 59.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 <= -1.05) {
tmp = t_0;
} else if (z <= 59.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 <= -1.05: tmp = t_0 elif z <= 59.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 <= -1.05) tmp = t_0; elseif (z <= 59.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 <= -1.05) tmp = t_0; elseif (z <= 59.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, -1.05], t$95$0, If[LessEqual[z, 59.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 -1.05:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 59:\\
\;\;\;\;x \cdot \left(1 - \left(-y\right) \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.05000000000000004 or 59 < z Initial program 96.3%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
flip--N/A
Applied rewrites98.1%
Taylor expanded in z around inf
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f6459.7
Applied rewrites59.7%
if -1.05000000000000004 < z < 59Initial program 96.3%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6472.8
Applied rewrites72.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (* (- 1.0 y) z))))
(if (<= t_0 -5e+19)
(* (- y 1.0) (* x z))
(if (<= t_0 10000000.0) (* x (- 1.0 z)) (* (* (- y 1.0) x) z)))))
double code(double x, double y, double z) {
double t_0 = 1.0 - ((1.0 - y) * z);
double tmp;
if (t_0 <= -5e+19) {
tmp = (y - 1.0) * (x * z);
} else if (t_0 <= 10000000.0) {
tmp = x * (1.0 - z);
} else {
tmp = ((y - 1.0) * x) * 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) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - ((1.0d0 - y) * z)
if (t_0 <= (-5d+19)) then
tmp = (y - 1.0d0) * (x * z)
else if (t_0 <= 10000000.0d0) then
tmp = x * (1.0d0 - z)
else
tmp = ((y - 1.0d0) * x) * z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 - ((1.0 - y) * z);
double tmp;
if (t_0 <= -5e+19) {
tmp = (y - 1.0) * (x * z);
} else if (t_0 <= 10000000.0) {
tmp = x * (1.0 - z);
} else {
tmp = ((y - 1.0) * x) * z;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - ((1.0 - y) * z) tmp = 0 if t_0 <= -5e+19: tmp = (y - 1.0) * (x * z) elif t_0 <= 10000000.0: tmp = x * (1.0 - z) else: tmp = ((y - 1.0) * x) * z return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(Float64(1.0 - y) * z)) tmp = 0.0 if (t_0 <= -5e+19) tmp = Float64(Float64(y - 1.0) * Float64(x * z)); elseif (t_0 <= 10000000.0) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(Float64(Float64(y - 1.0) * x) * z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - ((1.0 - y) * z); tmp = 0.0; if (t_0 <= -5e+19) tmp = (y - 1.0) * (x * z); elseif (t_0 <= 10000000.0) tmp = x * (1.0 - z); else tmp = ((y - 1.0) * x) * z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+19], N[(N[(y - 1.0), $MachinePrecision] * N[(x * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 10000000.0], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y - 1.0), $MachinePrecision] * x), $MachinePrecision] * z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \left(1 - y\right) \cdot z\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+19}:\\
\;\;\;\;\left(y - 1\right) \cdot \left(x \cdot z\right)\\
\mathbf{elif}\;t\_0 \leq 10000000:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(y - 1\right) \cdot x\right) \cdot z\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) (*.f64 (-.f64 #s(literal 1 binary64) y) z)) < -5e19Initial program 96.3%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
flip--N/A
Applied rewrites98.1%
Taylor expanded in z around inf
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f6459.7
Applied rewrites59.7%
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift--.f64N/A
lower-*.f6459.9
Applied rewrites59.9%
if -5e19 < (-.f64 #s(literal 1 binary64) (*.f64 (-.f64 #s(literal 1 binary64) y) z)) < 1e7Initial program 96.3%
Taylor expanded in y around 0
Applied rewrites66.9%
if 1e7 < (-.f64 #s(literal 1 binary64) (*.f64 (-.f64 #s(literal 1 binary64) y) z)) Initial program 96.3%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
flip--N/A
Applied rewrites98.1%
Taylor expanded in z around inf
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f6459.7
Applied rewrites59.7%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- 1.0 (* (- 1.0 y) z))) (t_1 (* (* (- y 1.0) x) z))) (if (<= t_0 -5e+19) t_1 (if (<= t_0 10000000.0) (* x (- 1.0 z)) t_1))))
double code(double x, double y, double z) {
double t_0 = 1.0 - ((1.0 - y) * z);
double t_1 = ((y - 1.0) * x) * z;
double tmp;
if (t_0 <= -5e+19) {
tmp = t_1;
} else if (t_0 <= 10000000.0) {
tmp = x * (1.0 - z);
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - ((1.0d0 - y) * z)
t_1 = ((y - 1.0d0) * x) * z
if (t_0 <= (-5d+19)) then
tmp = t_1
else if (t_0 <= 10000000.0d0) then
tmp = x * (1.0d0 - z)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 - ((1.0 - y) * z);
double t_1 = ((y - 1.0) * x) * z;
double tmp;
if (t_0 <= -5e+19) {
tmp = t_1;
} else if (t_0 <= 10000000.0) {
tmp = x * (1.0 - z);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - ((1.0 - y) * z) t_1 = ((y - 1.0) * x) * z tmp = 0 if t_0 <= -5e+19: tmp = t_1 elif t_0 <= 10000000.0: tmp = x * (1.0 - z) else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(Float64(1.0 - y) * z)) t_1 = Float64(Float64(Float64(y - 1.0) * x) * z) tmp = 0.0 if (t_0 <= -5e+19) tmp = t_1; elseif (t_0 <= 10000000.0) tmp = Float64(x * Float64(1.0 - z)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - ((1.0 - y) * z); t_1 = ((y - 1.0) * x) * z; tmp = 0.0; if (t_0 <= -5e+19) tmp = t_1; elseif (t_0 <= 10000000.0) tmp = x * (1.0 - z); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(y - 1.0), $MachinePrecision] * x), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+19], t$95$1, If[LessEqual[t$95$0, 10000000.0], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \left(1 - y\right) \cdot z\\
t_1 := \left(\left(y - 1\right) \cdot x\right) \cdot z\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+19}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 10000000:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) (*.f64 (-.f64 #s(literal 1 binary64) y) z)) < -5e19 or 1e7 < (-.f64 #s(literal 1 binary64) (*.f64 (-.f64 #s(literal 1 binary64) y) z)) Initial program 96.3%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
flip--N/A
Applied rewrites98.1%
Taylor expanded in z around inf
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f6459.7
Applied rewrites59.7%
if -5e19 < (-.f64 #s(literal 1 binary64) (*.f64 (-.f64 #s(literal 1 binary64) y) z)) < 1e7Initial program 96.3%
Taylor expanded in y around 0
Applied rewrites66.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (fma (* x y) z x))) (if (<= y -1.45e+30) t_0 (if (<= y 1.0) (* 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 (y <= -1.45e+30) {
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(Float64(x * y), z, x) tmp = 0.0 if (y <= -1.45e+30) 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[(N[(x * y), $MachinePrecision] * z + x), $MachinePrecision]}, If[LessEqual[y, -1.45e+30], 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(x \cdot y, z, x\right)\\
\mathbf{if}\;y \leq -1.45 \cdot 10^{+30}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.4499999999999999e30 or 1 < y Initial program 96.3%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
flip--N/A
Applied rewrites95.7%
Taylor expanded in y around inf
lower-*.f6472.2
Applied rewrites72.2%
if -1.4499999999999999e30 < y < 1Initial program 96.3%
Taylor expanded in y around 0
Applied rewrites66.9%
(FPCore (x y z) :precision binary64 (if (<= (- 1.0 y) -4e+46) (* x (* z y)) (if (<= (- 1.0 y) 1e+88) (* x (- 1.0 z)) (* (* x y) z))))
double code(double x, double y, double z) {
double tmp;
if ((1.0 - y) <= -4e+46) {
tmp = x * (z * y);
} else if ((1.0 - y) <= 1e+88) {
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) <= (-4d+46)) then
tmp = x * (z * y)
else if ((1.0d0 - y) <= 1d+88) 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) <= -4e+46) {
tmp = x * (z * y);
} else if ((1.0 - y) <= 1e+88) {
tmp = x * (1.0 - z);
} else {
tmp = (x * y) * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (1.0 - y) <= -4e+46: tmp = x * (z * y) elif (1.0 - y) <= 1e+88: 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) <= -4e+46) tmp = Float64(x * Float64(z * y)); elseif (Float64(1.0 - y) <= 1e+88) 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) <= -4e+46) tmp = x * (z * y); elseif ((1.0 - y) <= 1e+88) 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], -4e+46], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 - y), $MachinePrecision], 1e+88], 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 -4 \cdot 10^{+46}:\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\mathbf{elif}\;1 - y \leq 10^{+88}:\\
\;\;\;\;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) < -4e46Initial program 96.3%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6435.4
Applied rewrites35.4%
if -4e46 < (-.f64 #s(literal 1 binary64) y) < 9.99999999999999959e87Initial program 96.3%
Taylor expanded in y around 0
Applied rewrites66.9%
if 9.99999999999999959e87 < (-.f64 #s(literal 1 binary64) y) Initial program 96.3%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
flip--N/A
Applied rewrites98.1%
Taylor expanded in z around inf
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f6459.7
Applied rewrites59.7%
Taylor expanded in y around inf
lower-*.f6437.1
Applied rewrites37.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* x y) z)))
(if (<= (- 1.0 y) -4e+46)
t_0
(if (<= (- 1.0 y) 1e+88) (* 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) <= -4e+46) {
tmp = t_0;
} else if ((1.0 - y) <= 1e+88) {
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) <= (-4d+46)) then
tmp = t_0
else if ((1.0d0 - y) <= 1d+88) 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) <= -4e+46) {
tmp = t_0;
} else if ((1.0 - y) <= 1e+88) {
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) <= -4e+46: tmp = t_0 elif (1.0 - y) <= 1e+88: 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) <= -4e+46) tmp = t_0; elseif (Float64(1.0 - y) <= 1e+88) 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) <= -4e+46) tmp = t_0; elseif ((1.0 - y) <= 1e+88) 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], -4e+46], t$95$0, If[LessEqual[N[(1.0 - y), $MachinePrecision], 1e+88], 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 -4 \cdot 10^{+46}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;1 - y \leq 10^{+88}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) y) < -4e46 or 9.99999999999999959e87 < (-.f64 #s(literal 1 binary64) y) Initial program 96.3%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
flip--N/A
Applied rewrites98.1%
Taylor expanded in z around inf
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f6459.7
Applied rewrites59.7%
Taylor expanded in y around inf
lower-*.f6437.1
Applied rewrites37.1%
if -4e46 < (-.f64 #s(literal 1 binary64) y) < 9.99999999999999959e87Initial program 96.3%
Taylor expanded in y around 0
Applied rewrites66.9%
(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.3%
Taylor expanded in y around 0
Applied rewrites66.9%
(FPCore (x y z) :precision binary64 (* x (- z)))
double code(double x, double y, double z) {
return x * -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 * -z
end function
public static double code(double x, double y, double z) {
return x * -z;
}
def code(x, y, z): return x * -z
function code(x, y, z) return Float64(x * Float64(-z)) end
function tmp = code(x, y, z) tmp = x * -z; end
code[x_, y_, z_] := N[(x * (-z)), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(-z\right)
\end{array}
Initial program 96.3%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6458.0
Applied rewrites58.0%
Taylor expanded in y around 0
mul-1-negN/A
lower-neg.f6429.5
Applied rewrites29.5%
herbie shell --seed 2025139
(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))))