
(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 5 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 (* 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}
Initial program 98.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (* y z))))
(if (or (<= t_0 -5000000000.0) (not (<= t_0 200000000.0)))
(* (* x z) (- y))
x)))
double code(double x, double y, double z) {
double t_0 = 1.0 - (y * z);
double tmp;
if ((t_0 <= -5000000000.0) || !(t_0 <= 200000000.0)) {
tmp = (x * z) * -y;
} 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) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (y * z)
if ((t_0 <= (-5000000000.0d0)) .or. (.not. (t_0 <= 200000000.0d0))) then
tmp = (x * z) * -y
else
tmp = x
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 <= -5000000000.0) || !(t_0 <= 200000000.0)) {
tmp = (x * z) * -y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y * z) tmp = 0 if (t_0 <= -5000000000.0) or not (t_0 <= 200000000.0): tmp = (x * z) * -y else: tmp = x return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(y * z)) tmp = 0.0 if ((t_0 <= -5000000000.0) || !(t_0 <= 200000000.0)) tmp = Float64(Float64(x * z) * Float64(-y)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (y * z); tmp = 0.0; if ((t_0 <= -5000000000.0) || ~((t_0 <= 200000000.0))) tmp = (x * z) * -y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -5000000000.0], N[Not[LessEqual[t$95$0, 200000000.0]], $MachinePrecision]], N[(N[(x * z), $MachinePrecision] * (-y)), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - y \cdot z\\
\mathbf{if}\;t\_0 \leq -5000000000 \lor \neg \left(t\_0 \leq 200000000\right):\\
\;\;\;\;\left(x \cdot z\right) \cdot \left(-y\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) (*.f64 y z)) < -5e9 or 2e8 < (-.f64 #s(literal 1 binary64) (*.f64 y z)) Initial program 96.1%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
flip--N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites55.7%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6450.4
Applied rewrites50.4%
Taylor expanded in y around inf
Applied rewrites93.7%
Applied rewrites90.0%
if -5e9 < (-.f64 #s(literal 1 binary64) (*.f64 y z)) < 2e8Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites95.9%
Final simplification93.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (* y z))))
(if (<= t_0 -5000000000.0)
(* (* (- y) x) z)
(if (<= t_0 200000000.0) x (* (* x z) (- y))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (y * z);
double tmp;
if (t_0 <= -5000000000.0) {
tmp = (-y * x) * z;
} else if (t_0 <= 200000000.0) {
tmp = x;
} else {
tmp = (x * z) * -y;
}
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 <= (-5000000000.0d0)) then
tmp = (-y * x) * z
else if (t_0 <= 200000000.0d0) then
tmp = x
else
tmp = (x * z) * -y
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 <= -5000000000.0) {
tmp = (-y * x) * z;
} else if (t_0 <= 200000000.0) {
tmp = x;
} else {
tmp = (x * z) * -y;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y * z) tmp = 0 if t_0 <= -5000000000.0: tmp = (-y * x) * z elif t_0 <= 200000000.0: tmp = x else: tmp = (x * z) * -y return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(y * z)) tmp = 0.0 if (t_0 <= -5000000000.0) tmp = Float64(Float64(Float64(-y) * x) * z); elseif (t_0 <= 200000000.0) tmp = x; else tmp = Float64(Float64(x * z) * Float64(-y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (y * z); tmp = 0.0; if (t_0 <= -5000000000.0) tmp = (-y * x) * z; elseif (t_0 <= 200000000.0) tmp = x; else tmp = (x * z) * -y; 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, -5000000000.0], N[(N[((-y) * x), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[t$95$0, 200000000.0], x, N[(N[(x * z), $MachinePrecision] * (-y)), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - y \cdot z\\
\mathbf{if}\;t\_0 \leq -5000000000:\\
\;\;\;\;\left(\left(-y\right) \cdot x\right) \cdot z\\
\mathbf{elif}\;t\_0 \leq 200000000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot z\right) \cdot \left(-y\right)\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) (*.f64 y z)) < -5e9Initial program 93.5%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
flip--N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites58.7%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6452.4
Applied rewrites52.4%
Taylor expanded in y around inf
Applied rewrites96.1%
if -5e9 < (-.f64 #s(literal 1 binary64) (*.f64 y z)) < 2e8Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites95.9%
if 2e8 < (-.f64 #s(literal 1 binary64) (*.f64 y z)) Initial program 98.4%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
flip--N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites52.9%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6448.7
Applied rewrites48.7%
Taylor expanded in y around inf
Applied rewrites91.6%
Applied rewrites89.9%
(FPCore (x y z) :precision binary64 (if (<= (* y z) -100000000.0) (* x (* (- y) z)) (if (<= (* y z) 0.001) x (* (* (- y) x) z))))
double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -100000000.0) {
tmp = x * (-y * z);
} else if ((y * z) <= 0.001) {
tmp = x;
} else {
tmp = (-y * 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) :: tmp
if ((y * z) <= (-100000000.0d0)) then
tmp = x * (-y * z)
else if ((y * z) <= 0.001d0) then
tmp = x
else
tmp = (-y * x) * z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -100000000.0) {
tmp = x * (-y * z);
} else if ((y * z) <= 0.001) {
tmp = x;
} else {
tmp = (-y * x) * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y * z) <= -100000000.0: tmp = x * (-y * z) elif (y * z) <= 0.001: tmp = x else: tmp = (-y * x) * z return tmp
function code(x, y, z) tmp = 0.0 if (Float64(y * z) <= -100000000.0) tmp = Float64(x * Float64(Float64(-y) * z)); elseif (Float64(y * z) <= 0.001) tmp = x; else tmp = Float64(Float64(Float64(-y) * x) * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y * z) <= -100000000.0) tmp = x * (-y * z); elseif ((y * z) <= 0.001) tmp = x; else tmp = (-y * x) * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(y * z), $MachinePrecision], -100000000.0], N[(x * N[((-y) * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y * z), $MachinePrecision], 0.001], x, N[(N[((-y) * x), $MachinePrecision] * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -100000000:\\
\;\;\;\;x \cdot \left(\left(-y\right) \cdot z\right)\\
\mathbf{elif}\;y \cdot z \leq 0.001:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-y\right) \cdot x\right) \cdot z\\
\end{array}
\end{array}
if (*.f64 y z) < -1e8Initial program 98.4%
Taylor expanded in y around inf
Applied rewrites97.8%
if -1e8 < (*.f64 y z) < 1e-3Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites96.6%
if 1e-3 < (*.f64 y z) Initial program 93.5%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
flip--N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites58.7%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6452.4
Applied rewrites52.4%
Taylor expanded in y around inf
Applied rewrites96.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 98.0%
Taylor expanded in y around 0
Applied rewrites50.4%
herbie shell --seed 2025018
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))