
(FPCore (x y z) :precision binary64 (+ (+ (/ x 2) (* 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), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision]
\left(\frac{x}{2} + y \cdot x\right) + z
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (+ (/ x 2) (* 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), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision]
\left(\frac{x}{2} + y \cdot x\right) + z
(FPCore (x y z) :precision binary64 (- (+ z (* y x)) (* -1/2 x)))
double code(double x, double y, double z) {
return (z + (y * x)) - (-0.5 * 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 = (z + (y * x)) - ((-0.5d0) * x)
end function
public static double code(double x, double y, double z) {
return (z + (y * x)) - (-0.5 * x);
}
def code(x, y, z): return (z + (y * x)) - (-0.5 * x)
function code(x, y, z) return Float64(Float64(z + Float64(y * x)) - Float64(-0.5 * x)) end
function tmp = code(x, y, z) tmp = (z + (y * x)) - (-0.5 * x); end
code[x_, y_, z_] := N[(N[(z + N[(y * x), $MachinePrecision]), $MachinePrecision] - N[(-1/2 * x), $MachinePrecision]), $MachinePrecision]
\left(z + y \cdot x\right) - \frac{-1}{2} \cdot x
Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
mult-flip-revN/A
distribute-neg-fracN/A
distribute-neg-frac2N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
metadata-eval100.0%
Applied rewrites100.0%
(FPCore (x y z) :precision binary64 (- z (* (- -1/2 y) x)))
double code(double x, double y, double z) {
return z - ((-0.5 - y) * 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 = z - (((-0.5d0) - y) * x)
end function
public static double code(double x, double y, double z) {
return z - ((-0.5 - y) * x);
}
def code(x, y, z): return z - ((-0.5 - y) * x)
function code(x, y, z) return Float64(z - Float64(Float64(-0.5 - y) * x)) end
function tmp = code(x, y, z) tmp = z - ((-0.5 - y) * x); end
code[x_, y_, z_] := N[(z - N[(N[(-1/2 - y), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]
z - \left(\frac{-1}{2} - y\right) \cdot x
Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
lift-/.f64N/A
frac-2negN/A
mult-flipN/A
distribute-lft-out--N/A
distribute-lft-neg-outN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
metadata-evalN/A
metadata-eval100.0%
Applied rewrites100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (/ x 2) (* y x))) (t_1 (* x (+ 1/2 y))))
(if (<=
t_0
-49999999999999997640261112569083403345625645676430849265210811744256)
t_1
(if (<= t_0 10000000000000000000000) (+ z (* 1/2 x)) t_1))))double code(double x, double y, double z) {
double t_0 = (x / 2.0) + (y * x);
double t_1 = x * (0.5 + y);
double tmp;
if (t_0 <= -5e+67) {
tmp = t_1;
} else if (t_0 <= 1e+22) {
tmp = z + (0.5 * x);
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (x / 2.0d0) + (y * x)
t_1 = x * (0.5d0 + y)
if (t_0 <= (-5d+67)) then
tmp = t_1
else if (t_0 <= 1d+22) then
tmp = z + (0.5d0 * x)
else
tmp = t_1
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 t_1 = x * (0.5 + y);
double tmp;
if (t_0 <= -5e+67) {
tmp = t_1;
} else if (t_0 <= 1e+22) {
tmp = z + (0.5 * x);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = (x / 2.0) + (y * x) t_1 = x * (0.5 + y) tmp = 0 if t_0 <= -5e+67: tmp = t_1 elif t_0 <= 1e+22: tmp = z + (0.5 * x) else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(Float64(x / 2.0) + Float64(y * x)) t_1 = Float64(x * Float64(0.5 + y)) tmp = 0.0 if (t_0 <= -5e+67) tmp = t_1; elseif (t_0 <= 1e+22) tmp = Float64(z + Float64(0.5 * x)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x / 2.0) + (y * x); t_1 = x * (0.5 + y); tmp = 0.0; if (t_0 <= -5e+67) tmp = t_1; elseif (t_0 <= 1e+22) tmp = z + (0.5 * x); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x / 2), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(1/2 + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -49999999999999997640261112569083403345625645676430849265210811744256], t$95$1, If[LessEqual[t$95$0, 10000000000000000000000], N[(z + N[(1/2 * x), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := \frac{x}{2} + y \cdot x\\
t_1 := x \cdot \left(\frac{1}{2} + y\right)\\
\mathbf{if}\;t\_0 \leq -49999999999999997640261112569083403345625645676430849265210811744256:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 10000000000000000000000:\\
\;\;\;\;z + \frac{1}{2} \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if (+.f64 (/.f64 x #s(literal 2 binary64)) (*.f64 y x)) < -4.9999999999999998e67 or 1e22 < (+.f64 (/.f64 x #s(literal 2 binary64)) (*.f64 y x)) Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
mult-flip-revN/A
distribute-neg-fracN/A
distribute-neg-frac2N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
metadata-eval100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f6461.2%
Applied rewrites61.2%
if -4.9999999999999998e67 < (+.f64 (/.f64 x #s(literal 2 binary64)) (*.f64 y x)) < 1e22Initial program 100.0%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6464.9%
Applied rewrites64.9%
(FPCore (x y z) :precision binary64 (if (<= y -16000000000000001252664646473539901476885764798177869824) (* x y) (if (<= y 6800000000000000100663296) (+ z (* 1/2 x)) (* x y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.6e+55) {
tmp = x * y;
} else if (y <= 6.8e+24) {
tmp = z + (0.5 * x);
} 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) :: tmp
if (y <= (-1.6d+55)) then
tmp = x * y
else if (y <= 6.8d+24) then
tmp = z + (0.5d0 * x)
else
tmp = x * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.6e+55) {
tmp = x * y;
} else if (y <= 6.8e+24) {
tmp = z + (0.5 * x);
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.6e+55: tmp = x * y elif y <= 6.8e+24: tmp = z + (0.5 * x) else: tmp = x * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.6e+55) tmp = Float64(x * y); elseif (y <= 6.8e+24) tmp = Float64(z + Float64(0.5 * x)); else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.6e+55) tmp = x * y; elseif (y <= 6.8e+24) tmp = z + (0.5 * x); else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -16000000000000001252664646473539901476885764798177869824], N[(x * y), $MachinePrecision], If[LessEqual[y, 6800000000000000100663296], N[(z + N[(1/2 * x), $MachinePrecision]), $MachinePrecision], N[(x * y), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;y \leq -16000000000000001252664646473539901476885764798177869824:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;y \leq 6800000000000000100663296:\\
\;\;\;\;z + \frac{1}{2} \cdot x\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
if y < -1.6000000000000001e55 or 6.8000000000000001e24 < y Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
mult-flip-revN/A
distribute-neg-fracN/A
distribute-neg-frac2N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
metadata-eval100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f6461.2%
Applied rewrites61.2%
Taylor expanded in y around 0
Applied rewrites26.8%
Taylor expanded in y around inf
Applied rewrites36.6%
if -1.6000000000000001e55 < y < 6.8000000000000001e24Initial program 100.0%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6464.9%
Applied rewrites64.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (/ x 2) (* y x))))
(if (<=
t_0
-49999999999999997640261112569083403345625645676430849265210811744256)
(* x y)
(if (<= t_0 199999999999999995497619646912068059136)
z
(if (<=
t_0
5000000000000000262523801276022101243522342905540795774579270577559012289944540978931856875402239320218522219164419390884712616176802152878223960923933534914241936004632879018689151168973940450296844766174853999725405595194838204400373263713900712472896293944100284214190578347360981934327297002700800)
(* x 1/2)
(* x y))))))double code(double x, double y, double z) {
double t_0 = (x / 2.0) + (y * x);
double tmp;
if (t_0 <= -5e+67) {
tmp = x * y;
} else if (t_0 <= 2e+38) {
tmp = z;
} else if (t_0 <= 5e+300) {
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+67)) then
tmp = x * y
else if (t_0 <= 2d+38) then
tmp = z
else if (t_0 <= 5d+300) 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+67) {
tmp = x * y;
} else if (t_0 <= 2e+38) {
tmp = z;
} else if (t_0 <= 5e+300) {
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+67: tmp = x * y elif t_0 <= 2e+38: tmp = z elif t_0 <= 5e+300: 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+67) tmp = Float64(x * y); elseif (t_0 <= 2e+38) tmp = z; elseif (t_0 <= 5e+300) 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+67) tmp = x * y; elseif (t_0 <= 2e+38) tmp = z; elseif (t_0 <= 5e+300) 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), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -49999999999999997640261112569083403345625645676430849265210811744256], N[(x * y), $MachinePrecision], If[LessEqual[t$95$0, 199999999999999995497619646912068059136], z, If[LessEqual[t$95$0, 5000000000000000262523801276022101243522342905540795774579270577559012289944540978931856875402239320218522219164419390884712616176802152878223960923933534914241936004632879018689151168973940450296844766174853999725405595194838204400373263713900712472896293944100284214190578347360981934327297002700800], N[(x * 1/2), $MachinePrecision], N[(x * y), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \frac{x}{2} + y \cdot x\\
\mathbf{if}\;t\_0 \leq -49999999999999997640261112569083403345625645676430849265210811744256:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;t\_0 \leq 199999999999999995497619646912068059136:\\
\;\;\;\;z\\
\mathbf{elif}\;t\_0 \leq 5000000000000000262523801276022101243522342905540795774579270577559012289944540978931856875402239320218522219164419390884712616176802152878223960923933534914241936004632879018689151168973940450296844766174853999725405595194838204400373263713900712472896293944100284214190578347360981934327297002700800:\\
\;\;\;\;x \cdot \frac{1}{2}\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
if (+.f64 (/.f64 x #s(literal 2 binary64)) (*.f64 y x)) < -4.9999999999999998e67 or 5.0000000000000003e300 < (+.f64 (/.f64 x #s(literal 2 binary64)) (*.f64 y x)) Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
mult-flip-revN/A
distribute-neg-fracN/A
distribute-neg-frac2N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
metadata-eval100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f6461.2%
Applied rewrites61.2%
Taylor expanded in y around 0
Applied rewrites26.8%
Taylor expanded in y around inf
Applied rewrites36.6%
if -4.9999999999999998e67 < (+.f64 (/.f64 x #s(literal 2 binary64)) (*.f64 y x)) < 2e38Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites40.2%
if 2e38 < (+.f64 (/.f64 x #s(literal 2 binary64)) (*.f64 y x)) < 5.0000000000000003e300Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
mult-flip-revN/A
distribute-neg-fracN/A
distribute-neg-frac2N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
metadata-eval100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f6461.2%
Applied rewrites61.2%
Taylor expanded in y around 0
Applied rewrites26.8%
(FPCore (x y z)
:precision binary64
(if (<=
x
-339999999999999990744261413686282949153855044567478797263246375049027131228789615831797219808308176004137591354633276357074691968990303803880243200)
(* x 1/2)
(if (<= x 16000000000000000718171402849214668568788992)
z
(* x 1/2))))double code(double x, double y, double z) {
double tmp;
if (x <= -3.4e+146) {
tmp = x * 0.5;
} else if (x <= 1.6e+43) {
tmp = z;
} else {
tmp = x * 0.5;
}
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 (x <= (-3.4d+146)) then
tmp = x * 0.5d0
else if (x <= 1.6d+43) then
tmp = z
else
tmp = x * 0.5d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -3.4e+146) {
tmp = x * 0.5;
} else if (x <= 1.6e+43) {
tmp = z;
} else {
tmp = x * 0.5;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -3.4e+146: tmp = x * 0.5 elif x <= 1.6e+43: tmp = z else: tmp = x * 0.5 return tmp
function code(x, y, z) tmp = 0.0 if (x <= -3.4e+146) tmp = Float64(x * 0.5); elseif (x <= 1.6e+43) tmp = z; else tmp = Float64(x * 0.5); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -3.4e+146) tmp = x * 0.5; elseif (x <= 1.6e+43) tmp = z; else tmp = x * 0.5; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -339999999999999990744261413686282949153855044567478797263246375049027131228789615831797219808308176004137591354633276357074691968990303803880243200], N[(x * 1/2), $MachinePrecision], If[LessEqual[x, 16000000000000000718171402849214668568788992], z, N[(x * 1/2), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;x \leq -339999999999999990744261413686282949153855044567478797263246375049027131228789615831797219808308176004137591354633276357074691968990303803880243200:\\
\;\;\;\;x \cdot \frac{1}{2}\\
\mathbf{elif}\;x \leq 16000000000000000718171402849214668568788992:\\
\;\;\;\;z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{1}{2}\\
\end{array}
if x < -3.3999999999999999e146 or 1.6000000000000001e43 < x Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
mult-flip-revN/A
distribute-neg-fracN/A
distribute-neg-frac2N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
metadata-eval100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f6461.2%
Applied rewrites61.2%
Taylor expanded in y around 0
Applied rewrites26.8%
if -3.3999999999999999e146 < x < 1.6000000000000001e43Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites40.2%
(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
z
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites40.2%
herbie shell --seed 2025271 -o generate:evaluate
(FPCore (x y z)
:name "Data.Histogram.Bin.BinF:$cfromIndex from histogram-fill-0.8.4.1"
:precision binary64
(+ (+ (/ x 2) (* y x)) z))