
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
double code(double x, double y, double z) {
return x * (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 - (y * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - (y * z));
}
def code(x, y, z): return x * (1.0 - (y * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(y * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - (y * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - y \cdot z\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
double code(double x, double y, double z) {
return x * (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 - (y * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - (y * z));
}
def code(x, y, z): return x * (1.0 - (y * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(y * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - (y * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - y \cdot z\right)
\end{array}
(FPCore (x y z) :precision binary64 (if (<= (- 1.0 (* y z)) -5e+234) (* (* (- x) y) z) (- x (* (* z y) x))))
double code(double x, double y, double z) {
double tmp;
if ((1.0 - (y * z)) <= -5e+234) {
tmp = (-x * y) * z;
} else {
tmp = x - ((z * y) * x);
}
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 * z)) <= (-5d+234)) then
tmp = (-x * y) * z
else
tmp = x - ((z * y) * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((1.0 - (y * z)) <= -5e+234) {
tmp = (-x * y) * z;
} else {
tmp = x - ((z * y) * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (1.0 - (y * z)) <= -5e+234: tmp = (-x * y) * z else: tmp = x - ((z * y) * x) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(1.0 - Float64(y * z)) <= -5e+234) tmp = Float64(Float64(Float64(-x) * y) * z); else tmp = Float64(x - Float64(Float64(z * y) * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((1.0 - (y * z)) <= -5e+234) tmp = (-x * y) * z; else tmp = x - ((z * y) * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision], -5e+234], N[(N[((-x) * y), $MachinePrecision] * z), $MachinePrecision], N[(x - N[(N[(z * y), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;1 - y \cdot z \leq -5 \cdot 10^{+234}:\\
\;\;\;\;\left(\left(-x\right) \cdot y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;x - \left(z \cdot y\right) \cdot x\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) (*.f64 y z)) < -5.0000000000000003e234Initial program 64.1%
Taylor expanded in y around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6464.1
Applied rewrites64.1%
Taylor expanded in y around inf
distribute-rgt-out--N/A
*-lft-identityN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
distribute-lft-neg-outN/A
lift-*.f64N/A
lift-neg.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
lift-neg.f64N/A
lift-*.f64N/A
associate-*l*N/A
mul-1-negN/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lift-neg.f6499.9
Applied rewrites99.9%
if -5.0000000000000003e234 < (-.f64 #s(literal 1 binary64) (*.f64 y z)) Initial program 98.3%
Taylor expanded in y around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6498.3
Applied rewrites98.3%
Final simplification98.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* (- x) y) z)))
(if (<= (* y z) -2000.0)
t_0
(if (<= (* y z) 0.05) x (if (<= (* y z) 2e+234) (* x (* (- y) z)) t_0)))))
double code(double x, double y, double z) {
double t_0 = (-x * y) * z;
double tmp;
if ((y * z) <= -2000.0) {
tmp = t_0;
} else if ((y * z) <= 0.05) {
tmp = x;
} else if ((y * z) <= 2e+234) {
tmp = x * (-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 = (-x * y) * z
if ((y * z) <= (-2000.0d0)) then
tmp = t_0
else if ((y * z) <= 0.05d0) then
tmp = x
else if ((y * z) <= 2d+234) then
tmp = x * (-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 = (-x * y) * z;
double tmp;
if ((y * z) <= -2000.0) {
tmp = t_0;
} else if ((y * z) <= 0.05) {
tmp = x;
} else if ((y * z) <= 2e+234) {
tmp = x * (-y * z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (-x * y) * z tmp = 0 if (y * z) <= -2000.0: tmp = t_0 elif (y * z) <= 0.05: tmp = x elif (y * z) <= 2e+234: tmp = x * (-y * z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(-x) * y) * z) tmp = 0.0 if (Float64(y * z) <= -2000.0) tmp = t_0; elseif (Float64(y * z) <= 0.05) tmp = x; elseif (Float64(y * z) <= 2e+234) tmp = Float64(x * Float64(Float64(-y) * 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 ((y * z) <= -2000.0) tmp = t_0; elseif ((y * z) <= 0.05) tmp = x; elseif ((y * z) <= 2e+234) tmp = x * (-y * 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[(y * z), $MachinePrecision], -2000.0], t$95$0, If[LessEqual[N[(y * z), $MachinePrecision], 0.05], x, If[LessEqual[N[(y * z), $MachinePrecision], 2e+234], N[(x * N[((-y) * z), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(-x\right) \cdot y\right) \cdot z\\
\mathbf{if}\;y \cdot z \leq -2000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \cdot z \leq 0.05:\\
\;\;\;\;x\\
\mathbf{elif}\;y \cdot z \leq 2 \cdot 10^{+234}:\\
\;\;\;\;x \cdot \left(\left(-y\right) \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (*.f64 y z) < -2e3 or 2.00000000000000004e234 < (*.f64 y z) Initial program 86.1%
Taylor expanded in y around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6486.1
Applied rewrites86.1%
Taylor expanded in y around inf
distribute-rgt-out--N/A
*-lft-identityN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
distribute-lft-neg-outN/A
lift-*.f64N/A
lift-neg.f6493.0
Applied rewrites93.0%
lift-*.f64N/A
lift-neg.f64N/A
lift-*.f64N/A
associate-*l*N/A
mul-1-negN/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lift-neg.f6494.7
Applied rewrites94.7%
if -2e3 < (*.f64 y z) < 0.050000000000000003Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites96.0%
if 0.050000000000000003 < (*.f64 y z) < 2.00000000000000004e234Initial program 99.5%
Taylor expanded in y around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6495.3
Applied rewrites95.3%
Final simplification95.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (* y z))))
(if (<= t_0 -100000.0)
(* (* (- x) z) y)
(if (<= t_0 2.0) x (* (* (- x) y) z)))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (y * z);
double tmp;
if (t_0 <= -100000.0) {
tmp = (-x * z) * y;
} else if (t_0 <= 2.0) {
tmp = x;
} 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) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (y * z)
if (t_0 <= (-100000.0d0)) then
tmp = (-x * z) * y
else if (t_0 <= 2.0d0) then
tmp = x
else
tmp = (-x * y) * z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 - (y * z);
double tmp;
if (t_0 <= -100000.0) {
tmp = (-x * z) * y;
} else if (t_0 <= 2.0) {
tmp = x;
} else {
tmp = (-x * y) * z;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y * z) tmp = 0 if t_0 <= -100000.0: tmp = (-x * z) * y elif t_0 <= 2.0: tmp = x else: tmp = (-x * y) * z return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(y * z)) tmp = 0.0 if (t_0 <= -100000.0) tmp = Float64(Float64(Float64(-x) * z) * y); elseif (t_0 <= 2.0) tmp = x; else tmp = Float64(Float64(Float64(-x) * y) * z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (y * z); tmp = 0.0; if (t_0 <= -100000.0) tmp = (-x * z) * y; elseif (t_0 <= 2.0) tmp = x; else tmp = (-x * y) * z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -100000.0], N[(N[((-x) * z), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t$95$0, 2.0], x, N[(N[((-x) * y), $MachinePrecision] * z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - y \cdot z\\
\mathbf{if}\;t\_0 \leq -100000:\\
\;\;\;\;\left(\left(-x\right) \cdot z\right) \cdot y\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-x\right) \cdot y\right) \cdot z\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) (*.f64 y z)) < -1e5Initial program 86.2%
Taylor expanded in y around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6486.2
Applied rewrites86.2%
Taylor expanded in y around inf
distribute-rgt-out--N/A
*-lft-identityN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
distribute-lft-neg-outN/A
lift-*.f64N/A
lift-neg.f6480.3
Applied rewrites80.3%
if -1e5 < (-.f64 #s(literal 1 binary64) (*.f64 y z)) < 2Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites96.0%
if 2 < (-.f64 #s(literal 1 binary64) (*.f64 y z)) Initial program 93.7%
Taylor expanded in y around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6493.7
Applied rewrites93.7%
Taylor expanded in y around inf
distribute-rgt-out--N/A
*-lft-identityN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
distribute-lft-neg-outN/A
lift-*.f64N/A
lift-neg.f6490.7
Applied rewrites90.7%
lift-*.f64N/A
lift-neg.f64N/A
lift-*.f64N/A
associate-*l*N/A
mul-1-negN/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lift-neg.f6493.0
Applied rewrites93.0%
Final simplification91.8%
(FPCore (x y z) :precision binary64 (if (or (<= (* y z) -2000.0) (not (<= (* y z) 0.05))) (* (* (- x) y) z) x))
double code(double x, double y, double z) {
double tmp;
if (((y * z) <= -2000.0) || !((y * z) <= 0.05)) {
tmp = (-x * y) * z;
} else {
tmp = x;
}
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 (((y * z) <= (-2000.0d0)) .or. (.not. ((y * z) <= 0.05d0))) then
tmp = (-x * y) * z
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (((y * z) <= -2000.0) || !((y * z) <= 0.05)) {
tmp = (-x * y) * z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((y * z) <= -2000.0) or not ((y * z) <= 0.05): tmp = (-x * y) * z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((Float64(y * z) <= -2000.0) || !(Float64(y * z) <= 0.05)) tmp = Float64(Float64(Float64(-x) * y) * z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (((y * z) <= -2000.0) || ~(((y * z) <= 0.05))) tmp = (-x * y) * z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[N[(y * z), $MachinePrecision], -2000.0], N[Not[LessEqual[N[(y * z), $MachinePrecision], 0.05]], $MachinePrecision]], N[(N[((-x) * y), $MachinePrecision] * z), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -2000 \lor \neg \left(y \cdot z \leq 0.05\right):\\
\;\;\;\;\left(\left(-x\right) \cdot y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if (*.f64 y z) < -2e3 or 0.050000000000000003 < (*.f64 y z) Initial program 90.1%
Taylor expanded in y around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6490.1
Applied rewrites90.1%
Taylor expanded in y around inf
distribute-rgt-out--N/A
*-lft-identityN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
distribute-lft-neg-outN/A
lift-*.f64N/A
lift-neg.f6485.7
Applied rewrites85.7%
lift-*.f64N/A
lift-neg.f64N/A
lift-*.f64N/A
associate-*l*N/A
mul-1-negN/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lift-neg.f6492.6
Applied rewrites92.6%
if -2e3 < (*.f64 y z) < 0.050000000000000003Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites96.0%
Final simplification94.4%
(FPCore (x y z) :precision binary64 (- x (* (* y x) z)))
double code(double x, double y, double z) {
return x - ((y * 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 - ((y * x) * z)
end function
public static double code(double x, double y, double z) {
return x - ((y * x) * z);
}
def code(x, y, z): return x - ((y * x) * z)
function code(x, y, z) return Float64(x - Float64(Float64(y * x) * z)) end
function tmp = code(x, y, z) tmp = x - ((y * x) * z); end
code[x_, y_, z_] := N[(x - N[(N[(y * x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \left(y \cdot x\right) \cdot z
\end{array}
Initial program 95.5%
Taylor expanded in y around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6495.5
Applied rewrites95.5%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6495.0
Applied rewrites95.0%
Final simplification95.0%
(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.5%
Taylor expanded in y around 0
Applied rewrites53.8%
Final simplification53.8%
herbie shell --seed 2025051
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))