
(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 9 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) z))) (if (<= z -15600000000.0) t_0 (if (<= z 2.5e-7) (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 <= -15600000000.0) {
tmp = t_0;
} else if (z <= 2.5e-7) {
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 <= -15600000000.0) tmp = t_0; elseif (z <= 2.5e-7) tmp = fma(Float64(y * 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, -15600000000.0], t$95$0, If[LessEqual[z, 2.5e-7], N[(N[(y * z), $MachinePrecision] * x + 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 -15600000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2.5 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot z, x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.56e10 or 2.49999999999999989e-7 < z Initial program 91.7%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
Applied rewrites99.9%
Taylor expanded in z around inf
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f6498.8
Applied rewrites98.8%
if -1.56e10 < z < 2.49999999999999989e-7Initial program 99.9%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
Applied rewrites96.7%
Taylor expanded in y around inf
Applied rewrites95.1%
lift-*.f64N/A
lift-fma.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6498.3
Applied rewrites98.3%
(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 95.7%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
Applied rewrites98.3%
(FPCore (x y z) :precision binary64 (let* ((t_0 (fma y (* z x) x))) (if (<= y -550.0) t_0 (if (<= y 1.0) (- x (* z x)) t_0))))
double code(double x, double y, double z) {
double t_0 = fma(y, (z * x), x);
double tmp;
if (y <= -550.0) {
tmp = t_0;
} else if (y <= 1.0) {
tmp = x - (z * x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = fma(y, Float64(z * x), x) tmp = 0.0 if (y <= -550.0) tmp = t_0; elseif (y <= 1.0) tmp = Float64(x - Float64(z * x)); 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, -550.0], t$95$0, If[LessEqual[y, 1.0], N[(x - N[(z * x), $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 -550:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;x - z \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -550 or 1 < y Initial program 91.3%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
Applied rewrites96.6%
Taylor expanded in y around inf
Applied rewrites95.7%
if -550 < y < 1Initial program 100.0%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
Applied rewrites100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-*.f6499.2
Applied rewrites99.2%
lift-+.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
distribute-lft-neg-inN/A
fp-cancel-sub-signN/A
lower--.f64N/A
*-commutativeN/A
lift-*.f6499.2
Applied rewrites99.2%
(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]
\begin{array}{l}
\\
\mathsf{fma}\left(\left(y - 1\right) \cdot x, z, x\right)
\end{array}
Initial program 95.7%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
Applied rewrites96.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (fma (* x y) z x))) (if (<= y -550.0) t_0 (if (<= y 1.0) (- x (* z x)) t_0))))
double code(double x, double y, double z) {
double t_0 = fma((x * y), z, x);
double tmp;
if (y <= -550.0) {
tmp = t_0;
} else if (y <= 1.0) {
tmp = x - (z * x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = fma(Float64(x * y), z, x) tmp = 0.0 if (y <= -550.0) tmp = t_0; elseif (y <= 1.0) tmp = Float64(x - Float64(z * x)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * y), $MachinePrecision] * z + x), $MachinePrecision]}, If[LessEqual[y, -550.0], t$95$0, If[LessEqual[y, 1.0], N[(x - N[(z * x), $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 -550:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;x - z \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -550 or 1 < y Initial program 91.3%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
Applied rewrites91.8%
Taylor expanded in y around inf
lower-*.f6491.0
Applied rewrites91.0%
if -550 < y < 1Initial program 100.0%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
Applied rewrites100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-*.f6499.2
Applied rewrites99.2%
lift-+.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
distribute-lft-neg-inN/A
fp-cancel-sub-signN/A
lower--.f64N/A
*-commutativeN/A
lift-*.f6499.2
Applied rewrites99.2%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (* z y)))) (if (<= y -1.15e+49) t_0 (if (<= y 5e+14) (- x (* z x)) t_0))))
double code(double x, double y, double z) {
double t_0 = x * (z * y);
double tmp;
if (y <= -1.15e+49) {
tmp = t_0;
} else if (y <= 5e+14) {
tmp = x - (z * 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 * y)
if (y <= (-1.15d+49)) then
tmp = t_0
else if (y <= 5d+14) then
tmp = x - (z * 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 * y);
double tmp;
if (y <= -1.15e+49) {
tmp = t_0;
} else if (y <= 5e+14) {
tmp = x - (z * x);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (z * y) tmp = 0 if y <= -1.15e+49: tmp = t_0 elif y <= 5e+14: tmp = x - (z * x) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(z * y)) tmp = 0.0 if (y <= -1.15e+49) tmp = t_0; elseif (y <= 5e+14) tmp = Float64(x - Float64(z * x)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (z * y); tmp = 0.0; if (y <= -1.15e+49) tmp = t_0; elseif (y <= 5e+14) tmp = x - (z * x); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.15e+49], t$95$0, If[LessEqual[y, 5e+14], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(z \cdot y\right)\\
\mathbf{if}\;y \leq -1.15 \cdot 10^{+49}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 5 \cdot 10^{+14}:\\
\;\;\;\;x - z \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.15000000000000001e49 or 5e14 < y Initial program 90.7%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6468.3
Applied rewrites68.3%
if -1.15000000000000001e49 < y < 5e14Initial program 99.8%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
Applied rewrites99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-*.f6495.4
Applied rewrites95.4%
lift-+.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
distribute-lft-neg-inN/A
fp-cancel-sub-signN/A
lower--.f64N/A
*-commutativeN/A
lift-*.f6495.4
Applied rewrites95.4%
(FPCore (x y z) :precision binary64 (- x (* z x)))
double code(double x, double y, double z) {
return x - (z * 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 - (z * x)
end function
public static double code(double x, double y, double z) {
return x - (z * x);
}
def code(x, y, z): return x - (z * x)
function code(x, y, z) return Float64(x - Float64(z * x)) end
function tmp = code(x, y, z) tmp = x - (z * x); end
code[x_, y_, z_] := N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - z \cdot x
\end{array}
Initial program 95.7%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
Applied rewrites98.3%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-*.f6466.3
Applied rewrites66.3%
lift-+.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
distribute-lft-neg-inN/A
fp-cancel-sub-signN/A
lower--.f64N/A
*-commutativeN/A
lift-*.f6466.3
Applied rewrites66.3%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (- z)))) (if (<= z -15600000000.0) t_0 (if (<= z 2.05e+22) x t_0))))
double code(double x, double y, double z) {
double t_0 = x * -z;
double tmp;
if (z <= -15600000000.0) {
tmp = t_0;
} else if (z <= 2.05e+22) {
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 <= (-15600000000.0d0)) then
tmp = t_0
else if (z <= 2.05d+22) 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 <= -15600000000.0) {
tmp = t_0;
} else if (z <= 2.05e+22) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * -z tmp = 0 if z <= -15600000000.0: tmp = t_0 elif z <= 2.05e+22: tmp = x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(-z)) tmp = 0.0 if (z <= -15600000000.0) tmp = t_0; elseif (z <= 2.05e+22) 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 <= -15600000000.0) tmp = t_0; elseif (z <= 2.05e+22) 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, -15600000000.0], t$95$0, If[LessEqual[z, 2.05e+22], x, t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(-z\right)\\
\mathbf{if}\;z \leq -15600000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2.05 \cdot 10^{+22}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.56e10 or 2.0499999999999999e22 < z Initial program 91.3%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6491.2
Applied rewrites91.2%
Taylor expanded in y around 0
mul-1-negN/A
lower-neg.f6457.0
Applied rewrites57.0%
if -1.56e10 < z < 2.0499999999999999e22Initial program 99.8%
Taylor expanded in z around 0
Applied rewrites71.1%
(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 95.7%
Taylor expanded in z around 0
Applied rewrites38.4%
herbie shell --seed 2025112
(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))))