
(FPCore (x y z) :precision binary64 (+ (+ (/ x 2.0) (* y x)) z))
double code(double x, double y, double z) {
return ((x / 2.0) + (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 / 2.0d0) + (y * x)) + z
end function
public static double code(double x, double y, double z) {
return ((x / 2.0) + (y * x)) + z;
}
def code(x, y, z): return ((x / 2.0) + (y * x)) + z
function code(x, y, z) return Float64(Float64(Float64(x / 2.0) + Float64(y * x)) + z) end
function tmp = code(x, y, z) tmp = ((x / 2.0) + (y * x)) + z; end
code[x_, y_, z_] := N[(N[(N[(x / 2.0), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{x}{2} + y \cdot x\right) + z
\end{array}
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (+ (/ x 2.0) (* y x)) z))
double code(double x, double y, double z) {
return ((x / 2.0) + (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 / 2.0d0) + (y * x)) + z
end function
public static double code(double x, double y, double z) {
return ((x / 2.0) + (y * x)) + z;
}
def code(x, y, z): return ((x / 2.0) + (y * x)) + z
function code(x, y, z) return Float64(Float64(Float64(x / 2.0) + Float64(y * x)) + z) end
function tmp = code(x, y, z) tmp = ((x / 2.0) + (y * x)) + z; end
code[x_, y_, z_] := N[(N[(N[(x / 2.0), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{x}{2} + y \cdot x\right) + z
\end{array}
(FPCore (x y z) :precision binary64 (fma y x (fma 0.5 x z)))
double code(double x, double y, double z) {
return fma(y, x, fma(0.5, x, z));
}
function code(x, y, z) return fma(y, x, fma(0.5, x, z)) end
code[x_, y_, z_] := N[(y * x + N[(0.5 * x + z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, x, \mathsf{fma}\left(0.5, x, z\right)\right)
\end{array}
Initial program 100.0%
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
add-flip-revN/A
sub-flipN/A
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f64N/A
metadata-eval100.0
Applied rewrites100.0%
(FPCore (x y z) :precision binary64 (fma (- y -0.5) x z))
double code(double x, double y, double z) {
return fma((y - -0.5), x, z);
}
function code(x, y, z) return fma(Float64(y - -0.5), x, z) end
code[x_, y_, z_] := N[(N[(y - -0.5), $MachinePrecision] * x + z), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y - -0.5, x, z\right)
\end{array}
Initial program 100.0%
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flipN/A
distribute-lft-outN/A
*-commutativeN/A
lower-fma.f64N/A
add-flipN/A
distribute-frac-neg2N/A
lower--.f64N/A
metadata-evalN/A
metadata-eval100.0
Applied rewrites100.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ (/ x 2.0) (* y x))) (t_1 (* (- y -0.5) x))) (if (<= t_0 -5e+195) t_1 (if (<= t_0 5e+153) (fma 0.5 x z) t_1))))
double code(double x, double y, double z) {
double t_0 = (x / 2.0) + (y * x);
double t_1 = (y - -0.5) * x;
double tmp;
if (t_0 <= -5e+195) {
tmp = t_1;
} else if (t_0 <= 5e+153) {
tmp = fma(0.5, x, z);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(x / 2.0) + Float64(y * x)) t_1 = Float64(Float64(y - -0.5) * x) tmp = 0.0 if (t_0 <= -5e+195) tmp = t_1; elseif (t_0 <= 5e+153) tmp = fma(0.5, x, z); else tmp = t_1; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x / 2.0), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(y - -0.5), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+195], t$95$1, If[LessEqual[t$95$0, 5e+153], N[(0.5 * x + z), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{2} + y \cdot x\\
t_1 := \left(y - -0.5\right) \cdot x\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+195}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+153}:\\
\;\;\;\;\mathsf{fma}\left(0.5, x, z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 (/.f64 x #s(literal 2 binary64)) (*.f64 y x)) < -4.9999999999999998e195 or 5.00000000000000018e153 < (+.f64 (/.f64 x #s(literal 2 binary64)) (*.f64 y x)) Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites41.4%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f6460.1
Applied rewrites60.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6460.1
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lower--.f6460.1
Applied rewrites60.1%
if -4.9999999999999998e195 < (+.f64 (/.f64 x #s(literal 2 binary64)) (*.f64 y x)) < 5.00000000000000018e153Initial program 100.0%
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flipN/A
distribute-lft-outN/A
*-commutativeN/A
lower-fma.f64N/A
add-flipN/A
distribute-frac-neg2N/A
lower--.f64N/A
metadata-evalN/A
metadata-eval100.0
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites65.2%
(FPCore (x y z) :precision binary64 (if (<= y -1.26e+166) (* x y) (if (<= y 1.1e+25) (fma 0.5 x z) (* x y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.26e+166) {
tmp = x * y;
} else if (y <= 1.1e+25) {
tmp = fma(0.5, x, z);
} else {
tmp = x * y;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -1.26e+166) tmp = Float64(x * y); elseif (y <= 1.1e+25) tmp = fma(0.5, x, z); else tmp = Float64(x * y); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -1.26e+166], N[(x * y), $MachinePrecision], If[LessEqual[y, 1.1e+25], N[(0.5 * x + z), $MachinePrecision], N[(x * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.26 \cdot 10^{+166}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{+25}:\\
\;\;\;\;\mathsf{fma}\left(0.5, x, z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if y < -1.26e166 or 1.1e25 < y Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites41.4%
Taylor expanded in y around inf
lower-*.f6436.5
Applied rewrites36.5%
if -1.26e166 < y < 1.1e25Initial program 100.0%
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flipN/A
distribute-lft-outN/A
*-commutativeN/A
lower-fma.f64N/A
add-flipN/A
distribute-frac-neg2N/A
lower--.f64N/A
metadata-evalN/A
metadata-eval100.0
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites65.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (/ x 2.0) (* y x))))
(if (<= t_0 -5e+296)
(* x y)
(if (<= t_0 -5e+92)
(* x 0.5)
(if (<= t_0 5e+153) z (if (<= t_0 2e+263) (* x 0.5) (* x y)))))))
double code(double x, double y, double z) {
double t_0 = (x / 2.0) + (y * x);
double tmp;
if (t_0 <= -5e+296) {
tmp = x * y;
} else if (t_0 <= -5e+92) {
tmp = x * 0.5;
} else if (t_0 <= 5e+153) {
tmp = z;
} else if (t_0 <= 2e+263) {
tmp = x * 0.5;
} else {
tmp = x * 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 = (x / 2.0d0) + (y * x)
if (t_0 <= (-5d+296)) then
tmp = x * y
else if (t_0 <= (-5d+92)) then
tmp = x * 0.5d0
else if (t_0 <= 5d+153) then
tmp = z
else if (t_0 <= 2d+263) then
tmp = x * 0.5d0
else
tmp = x * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x / 2.0) + (y * x);
double tmp;
if (t_0 <= -5e+296) {
tmp = x * y;
} else if (t_0 <= -5e+92) {
tmp = x * 0.5;
} else if (t_0 <= 5e+153) {
tmp = z;
} else if (t_0 <= 2e+263) {
tmp = x * 0.5;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z): t_0 = (x / 2.0) + (y * x) tmp = 0 if t_0 <= -5e+296: tmp = x * y elif t_0 <= -5e+92: tmp = x * 0.5 elif t_0 <= 5e+153: tmp = z elif t_0 <= 2e+263: tmp = x * 0.5 else: tmp = x * y return tmp
function code(x, y, z) t_0 = Float64(Float64(x / 2.0) + Float64(y * x)) tmp = 0.0 if (t_0 <= -5e+296) tmp = Float64(x * y); elseif (t_0 <= -5e+92) tmp = Float64(x * 0.5); elseif (t_0 <= 5e+153) tmp = z; elseif (t_0 <= 2e+263) tmp = Float64(x * 0.5); else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x / 2.0) + (y * x); tmp = 0.0; if (t_0 <= -5e+296) tmp = x * y; elseif (t_0 <= -5e+92) tmp = x * 0.5; elseif (t_0 <= 5e+153) tmp = z; elseif (t_0 <= 2e+263) tmp = x * 0.5; else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x / 2.0), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+296], N[(x * y), $MachinePrecision], If[LessEqual[t$95$0, -5e+92], N[(x * 0.5), $MachinePrecision], If[LessEqual[t$95$0, 5e+153], z, If[LessEqual[t$95$0, 2e+263], N[(x * 0.5), $MachinePrecision], N[(x * y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{2} + y \cdot x\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+296}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;t\_0 \leq -5 \cdot 10^{+92}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+153}:\\
\;\;\;\;z\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+263}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if (+.f64 (/.f64 x #s(literal 2 binary64)) (*.f64 y x)) < -5.0000000000000001e296 or 2.00000000000000003e263 < (+.f64 (/.f64 x #s(literal 2 binary64)) (*.f64 y x)) Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites41.4%
Taylor expanded in y around inf
lower-*.f6436.5
Applied rewrites36.5%
if -5.0000000000000001e296 < (+.f64 (/.f64 x #s(literal 2 binary64)) (*.f64 y x)) < -5.00000000000000022e92 or 5.00000000000000018e153 < (+.f64 (/.f64 x #s(literal 2 binary64)) (*.f64 y x)) < 2.00000000000000003e263Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites41.4%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f6460.1
Applied rewrites60.1%
Taylor expanded in y around 0
Applied rewrites25.8%
if -5.00000000000000022e92 < (+.f64 (/.f64 x #s(literal 2 binary64)) (*.f64 y x)) < 5.00000000000000018e153Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites41.4%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ (/ x 2.0) (* y x)))) (if (<= t_0 -5e+203) (* x y) (if (<= t_0 4e+157) z (* x y)))))
double code(double x, double y, double z) {
double t_0 = (x / 2.0) + (y * x);
double tmp;
if (t_0 <= -5e+203) {
tmp = x * y;
} else if (t_0 <= 4e+157) {
tmp = z;
} else {
tmp = x * 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 = (x / 2.0d0) + (y * x)
if (t_0 <= (-5d+203)) then
tmp = x * y
else if (t_0 <= 4d+157) then
tmp = z
else
tmp = x * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x / 2.0) + (y * x);
double tmp;
if (t_0 <= -5e+203) {
tmp = x * y;
} else if (t_0 <= 4e+157) {
tmp = z;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z): t_0 = (x / 2.0) + (y * x) tmp = 0 if t_0 <= -5e+203: tmp = x * y elif t_0 <= 4e+157: tmp = z else: tmp = x * y return tmp
function code(x, y, z) t_0 = Float64(Float64(x / 2.0) + Float64(y * x)) tmp = 0.0 if (t_0 <= -5e+203) tmp = Float64(x * y); elseif (t_0 <= 4e+157) tmp = z; else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x / 2.0) + (y * x); tmp = 0.0; if (t_0 <= -5e+203) tmp = x * y; elseif (t_0 <= 4e+157) tmp = z; else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x / 2.0), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+203], N[(x * y), $MachinePrecision], If[LessEqual[t$95$0, 4e+157], z, N[(x * y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{2} + y \cdot x\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+203}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+157}:\\
\;\;\;\;z\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if (+.f64 (/.f64 x #s(literal 2 binary64)) (*.f64 y x)) < -4.99999999999999994e203 or 3.99999999999999993e157 < (+.f64 (/.f64 x #s(literal 2 binary64)) (*.f64 y x)) Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites41.4%
Taylor expanded in y around inf
lower-*.f6436.5
Applied rewrites36.5%
if -4.99999999999999994e203 < (+.f64 (/.f64 x #s(literal 2 binary64)) (*.f64 y x)) < 3.99999999999999993e157Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites41.4%
(FPCore (x y z) :precision binary64 z)
double code(double x, double y, double z) {
return 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 = z
end function
public static double code(double x, double y, double z) {
return z;
}
def code(x, y, z): return z
function code(x, y, z) return z end
function tmp = code(x, y, z) tmp = z; end
code[x_, y_, z_] := z
\begin{array}{l}
\\
z
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites41.4%
herbie shell --seed 2025154
(FPCore (x y z)
:name "Data.Histogram.Bin.BinF:$cfromIndex from histogram-fill-0.8.4.1"
:precision binary64
(+ (+ (/ x 2.0) (* y x)) z))