
(FPCore (x y z) :precision binary64 (+ (+ (+ (+ (+ x y) y) x) z) x))
double code(double x, double y, double z) {
return ((((x + y) + y) + x) + z) + x;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((((x + y) + y) + x) + z) + x
end function
public static double code(double x, double y, double z) {
return ((((x + y) + y) + x) + z) + x;
}
def code(x, y, z): return ((((x + y) + y) + x) + z) + x
function code(x, y, z) return Float64(Float64(Float64(Float64(Float64(x + y) + y) + x) + z) + x) end
function tmp = code(x, y, z) tmp = ((((x + y) + y) + x) + z) + x; end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x + y), $MachinePrecision] + y), $MachinePrecision] + x), $MachinePrecision] + z), $MachinePrecision] + x), $MachinePrecision]
\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (+ (+ (+ (+ x y) y) x) z) x))
double code(double x, double y, double z) {
return ((((x + y) + y) + x) + z) + x;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((((x + y) + y) + x) + z) + x
end function
public static double code(double x, double y, double z) {
return ((((x + y) + y) + x) + z) + x;
}
def code(x, y, z): return ((((x + y) + y) + x) + z) + x
function code(x, y, z) return Float64(Float64(Float64(Float64(Float64(x + y) + y) + x) + z) + x) end
function tmp = code(x, y, z) tmp = ((((x + y) + y) + x) + z) + x; end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x + y), $MachinePrecision] + y), $MachinePrecision] + x), $MachinePrecision] + z), $MachinePrecision] + x), $MachinePrecision]
\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x
(FPCore (x y z) :precision binary64 (- (+ z x) (* -2 (+ y x))))
double code(double x, double y, double z) {
return (z + x) - (-2.0 * (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 + x) - ((-2.0d0) * (y + x))
end function
public static double code(double x, double y, double z) {
return (z + x) - (-2.0 * (y + x));
}
def code(x, y, z): return (z + x) - (-2.0 * (y + x))
function code(x, y, z) return Float64(Float64(z + x) - Float64(-2.0 * Float64(y + x))) end
function tmp = code(x, y, z) tmp = (z + x) - (-2.0 * (y + x)); end
code[x_, y_, z_] := N[(N[(z + x), $MachinePrecision] - N[(-2 * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(z + x\right) - -2 \cdot \left(y + x\right)
Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
add-flipN/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lift-+.f64N/A
count-2N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9%
Applied rewrites99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (+ (+ (+ y y) x) z) x)))
(if (<= y -299999999999999997114318848)
t_0
(if (<= y 5299999999999999786239590985776899293184)
(+ (+ (+ x x) z) x)
t_0))))double code(double x, double y, double z) {
double t_0 = (((y + y) + x) + z) + x;
double tmp;
if (y <= -3e+26) {
tmp = t_0;
} else if (y <= 5.3e+39) {
tmp = ((x + x) + z) + x;
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (((y + y) + x) + z) + x
if (y <= (-3d+26)) then
tmp = t_0
else if (y <= 5.3d+39) then
tmp = ((x + x) + z) + x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (((y + y) + x) + z) + x;
double tmp;
if (y <= -3e+26) {
tmp = t_0;
} else if (y <= 5.3e+39) {
tmp = ((x + x) + z) + x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (((y + y) + x) + z) + x tmp = 0 if y <= -3e+26: tmp = t_0 elif y <= 5.3e+39: tmp = ((x + x) + z) + x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(Float64(y + y) + x) + z) + x) tmp = 0.0 if (y <= -3e+26) tmp = t_0; elseif (y <= 5.3e+39) tmp = Float64(Float64(Float64(x + x) + z) + x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (((y + y) + x) + z) + x; tmp = 0.0; if (y <= -3e+26) tmp = t_0; elseif (y <= 5.3e+39) tmp = ((x + x) + z) + x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(N[(y + y), $MachinePrecision] + x), $MachinePrecision] + z), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[y, -299999999999999997114318848], t$95$0, If[LessEqual[y, 5299999999999999786239590985776899293184], N[(N[(N[(x + x), $MachinePrecision] + z), $MachinePrecision] + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \left(\left(\left(y + y\right) + x\right) + z\right) + x\\
\mathbf{if}\;y \leq -299999999999999997114318848:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 5299999999999999786239590985776899293184:\\
\;\;\;\;\left(\left(x + x\right) + z\right) + x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -3e26 or 5.2999999999999998e39 < y Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites72.2%
if -3e26 < y < 5.2999999999999998e39Initial program 99.9%
Taylor expanded in x around inf
lower-*.f6466.1%
Applied rewrites66.1%
lift-*.f64N/A
count-2-revN/A
lower-+.f6466.1%
Applied rewrites66.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (+ z (* 2 y)) x)))
(if (<= y -299999999999999997114318848)
t_0
(if (<= y 5299999999999999786239590985776899293184)
(+ (+ (+ x x) z) x)
t_0))))double code(double x, double y, double z) {
double t_0 = (z + (2.0 * y)) + x;
double tmp;
if (y <= -3e+26) {
tmp = t_0;
} else if (y <= 5.3e+39) {
tmp = ((x + x) + z) + x;
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (z + (2.0d0 * y)) + x
if (y <= (-3d+26)) then
tmp = t_0
else if (y <= 5.3d+39) then
tmp = ((x + x) + z) + x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (z + (2.0 * y)) + x;
double tmp;
if (y <= -3e+26) {
tmp = t_0;
} else if (y <= 5.3e+39) {
tmp = ((x + x) + z) + x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (z + (2.0 * y)) + x tmp = 0 if y <= -3e+26: tmp = t_0 elif y <= 5.3e+39: tmp = ((x + x) + z) + x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(z + Float64(2.0 * y)) + x) tmp = 0.0 if (y <= -3e+26) tmp = t_0; elseif (y <= 5.3e+39) tmp = Float64(Float64(Float64(x + x) + z) + x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (z + (2.0 * y)) + x; tmp = 0.0; if (y <= -3e+26) tmp = t_0; elseif (y <= 5.3e+39) tmp = ((x + x) + z) + x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z + N[(2 * y), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[y, -299999999999999997114318848], t$95$0, If[LessEqual[y, 5299999999999999786239590985776899293184], N[(N[(N[(x + x), $MachinePrecision] + z), $MachinePrecision] + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \left(z + 2 \cdot y\right) + x\\
\mathbf{if}\;y \leq -299999999999999997114318848:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 5299999999999999786239590985776899293184:\\
\;\;\;\;\left(\left(x + x\right) + z\right) + x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -3e26 or 5.2999999999999998e39 < y Initial program 99.9%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f6471.4%
Applied rewrites71.4%
if -3e26 < y < 5.2999999999999998e39Initial program 99.9%
Taylor expanded in x around inf
lower-*.f6466.1%
Applied rewrites66.1%
lift-*.f64N/A
count-2-revN/A
lower-+.f6466.1%
Applied rewrites66.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (+ y y) z)))
(if (<= y -73999999999999997971165888386204294016634191872)
t_0
(if (<= y 5299999999999999786239590985776899293184)
(+ (+ (+ x x) z) x)
t_0))))double code(double x, double y, double z) {
double t_0 = (y + y) + z;
double tmp;
if (y <= -7.4e+46) {
tmp = t_0;
} else if (y <= 5.3e+39) {
tmp = ((x + x) + z) + x;
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (y + y) + z
if (y <= (-7.4d+46)) then
tmp = t_0
else if (y <= 5.3d+39) then
tmp = ((x + x) + z) + x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (y + y) + z;
double tmp;
if (y <= -7.4e+46) {
tmp = t_0;
} else if (y <= 5.3e+39) {
tmp = ((x + x) + z) + x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (y + y) + z tmp = 0 if y <= -7.4e+46: tmp = t_0 elif y <= 5.3e+39: tmp = ((x + x) + z) + x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(y + y) + z) tmp = 0.0 if (y <= -7.4e+46) tmp = t_0; elseif (y <= 5.3e+39) tmp = Float64(Float64(Float64(x + x) + z) + x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y + y) + z; tmp = 0.0; if (y <= -7.4e+46) tmp = t_0; elseif (y <= 5.3e+39) tmp = ((x + x) + z) + x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y + y), $MachinePrecision] + z), $MachinePrecision]}, If[LessEqual[y, -73999999999999997971165888386204294016634191872], t$95$0, If[LessEqual[y, 5299999999999999786239590985776899293184], N[(N[(N[(x + x), $MachinePrecision] + z), $MachinePrecision] + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \left(y + y\right) + z\\
\mathbf{if}\;y \leq -73999999999999997971165888386204294016634191872:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 5299999999999999786239590985776899293184:\\
\;\;\;\;\left(\left(x + x\right) + z\right) + x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -7.3999999999999998e46 or 5.2999999999999998e39 < y Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
add-flipN/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lift-+.f64N/A
count-2N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9%
Applied rewrites99.9%
Taylor expanded in x around 0
lower--.f64N/A
lower-*.f6466.6%
Applied rewrites66.6%
Applied rewrites66.6%
if -7.3999999999999998e46 < y < 5.2999999999999998e39Initial program 99.9%
Taylor expanded in x around inf
lower-*.f6466.1%
Applied rewrites66.1%
lift-*.f64N/A
count-2-revN/A
lower-+.f6466.1%
Applied rewrites66.1%
(FPCore (x y z)
:precision binary64
(if (<=
x
-240000000000000004852530990517427277258263117571445857873066445489920961199559434246087478607872)
(* 3 x)
(if (<=
x
102000000000000002923230082887857256260896210505761714049709740517660113588191232)
(+ (+ y y) z)
(* 3 x))))double code(double x, double y, double z) {
double tmp;
if (x <= -2.4e+95) {
tmp = 3.0 * x;
} else if (x <= 1.02e+80) {
tmp = (y + y) + z;
} else {
tmp = 3.0 * 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 (x <= (-2.4d+95)) then
tmp = 3.0d0 * x
else if (x <= 1.02d+80) then
tmp = (y + y) + z
else
tmp = 3.0d0 * x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -2.4e+95) {
tmp = 3.0 * x;
} else if (x <= 1.02e+80) {
tmp = (y + y) + z;
} else {
tmp = 3.0 * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -2.4e+95: tmp = 3.0 * x elif x <= 1.02e+80: tmp = (y + y) + z else: tmp = 3.0 * x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -2.4e+95) tmp = Float64(3.0 * x); elseif (x <= 1.02e+80) tmp = Float64(Float64(y + y) + z); else tmp = Float64(3.0 * x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -2.4e+95) tmp = 3.0 * x; elseif (x <= 1.02e+80) tmp = (y + y) + z; else tmp = 3.0 * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -240000000000000004852530990517427277258263117571445857873066445489920961199559434246087478607872], N[(3 * x), $MachinePrecision], If[LessEqual[x, 102000000000000002923230082887857256260896210505761714049709740517660113588191232], N[(N[(y + y), $MachinePrecision] + z), $MachinePrecision], N[(3 * x), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;x \leq -240000000000000004852530990517427277258263117571445857873066445489920961199559434246087478607872:\\
\;\;\;\;3 \cdot x\\
\mathbf{elif}\;x \leq 102000000000000002923230082887857256260896210505761714049709740517660113588191232:\\
\;\;\;\;\left(y + y\right) + z\\
\mathbf{else}:\\
\;\;\;\;3 \cdot x\\
\end{array}
if x < -2.4e95 or 1.02e80 < x Initial program 99.9%
Taylor expanded in x around inf
lower-*.f6434.5%
Applied rewrites34.5%
if -2.4e95 < x < 1.02e80Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
add-flipN/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lift-+.f64N/A
count-2N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9%
Applied rewrites99.9%
Taylor expanded in x around 0
lower--.f64N/A
lower-*.f6466.6%
Applied rewrites66.6%
Applied rewrites66.6%
(FPCore (x y z) :precision binary64 (if (<= x -3530822107858469/144115188075855872) (* 3 x) (if (<= x 16000000000000000718171402849214668568788992) z (* 3 x))))
double code(double x, double y, double z) {
double tmp;
if (x <= -0.0245) {
tmp = 3.0 * x;
} else if (x <= 1.6e+43) {
tmp = z;
} else {
tmp = 3.0 * 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 (x <= (-0.0245d0)) then
tmp = 3.0d0 * x
else if (x <= 1.6d+43) then
tmp = z
else
tmp = 3.0d0 * x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -0.0245) {
tmp = 3.0 * x;
} else if (x <= 1.6e+43) {
tmp = z;
} else {
tmp = 3.0 * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -0.0245: tmp = 3.0 * x elif x <= 1.6e+43: tmp = z else: tmp = 3.0 * x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -0.0245) tmp = Float64(3.0 * x); elseif (x <= 1.6e+43) tmp = z; else tmp = Float64(3.0 * x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -0.0245) tmp = 3.0 * x; elseif (x <= 1.6e+43) tmp = z; else tmp = 3.0 * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -3530822107858469/144115188075855872], N[(3 * x), $MachinePrecision], If[LessEqual[x, 16000000000000000718171402849214668568788992], z, N[(3 * x), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;x \leq \frac{-3530822107858469}{144115188075855872}:\\
\;\;\;\;3 \cdot x\\
\mathbf{elif}\;x \leq 16000000000000000718171402849214668568788992:\\
\;\;\;\;z\\
\mathbf{else}:\\
\;\;\;\;3 \cdot x\\
\end{array}
if x < -0.024500000000000001 or 1.6000000000000001e43 < x Initial program 99.9%
Taylor expanded in x around inf
lower-*.f6434.5%
Applied rewrites34.5%
if -0.024500000000000001 < x < 1.6000000000000001e43Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
add-flipN/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lift-+.f64N/A
count-2N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9%
Applied rewrites99.9%
Taylor expanded in x around 0
lower--.f64N/A
lower-*.f6466.6%
Applied rewrites66.6%
Applied rewrites66.6%
Taylor expanded in y around 0
Applied rewrites33.5%
(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 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
add-flipN/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lift-+.f64N/A
count-2N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval99.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9%
Applied rewrites99.9%
Taylor expanded in x around 0
lower--.f64N/A
lower-*.f6466.6%
Applied rewrites66.6%
Applied rewrites66.6%
Taylor expanded in y around 0
Applied rewrites33.5%
herbie shell --seed 2025271 -o generate:evaluate
(FPCore (x y z)
:name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendInside from plot-0.2.3.4"
:precision binary64
(+ (+ (+ (+ (+ x y) y) x) z) x))