
(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]
\begin{array}{l}
\\
\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x
\end{array}
Herbie found 9 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]
\begin{array}{l}
\\
\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x
\end{array}
(FPCore (x y z) :precision binary64 (+ (fma 3.0 x (+ y y)) z))
double code(double x, double y, double z) {
return fma(3.0, x, (y + y)) + z;
}
function code(x, y, z) return Float64(fma(3.0, x, Float64(y + y)) + z) end
code[x_, y_, z_] := N[(N[(3.0 * x + N[(y + y), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(3, x, y + y\right) + z
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
count-2-revN/A
lower-+.f64100.0
Applied rewrites100.0%
(FPCore (x y z) :precision binary64 (if (<= z -1e+47) (fma 3.0 x z) (if (<= z 7.6e+105) (fma 3.0 x (+ y y)) (fma 2.0 y z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1e+47) {
tmp = fma(3.0, x, z);
} else if (z <= 7.6e+105) {
tmp = fma(3.0, x, (y + y));
} else {
tmp = fma(2.0, y, z);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -1e+47) tmp = fma(3.0, x, z); elseif (z <= 7.6e+105) tmp = fma(3.0, x, Float64(y + y)); else tmp = fma(2.0, y, z); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -1e+47], N[(3.0 * x + z), $MachinePrecision], If[LessEqual[z, 7.6e+105], N[(3.0 * x + N[(y + y), $MachinePrecision]), $MachinePrecision], N[(2.0 * y + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \cdot 10^{+47}:\\
\;\;\;\;\mathsf{fma}\left(3, x, z\right)\\
\mathbf{elif}\;z \leq 7.6 \cdot 10^{+105}:\\
\;\;\;\;\mathsf{fma}\left(3, x, y + y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(2, y, z\right)\\
\end{array}
\end{array}
if z < -1e47Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
count-2-revN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-fma.f6466.1
Applied rewrites66.1%
if -1e47 < z < 7.6e105Initial program 99.9%
Taylor expanded in z around 0
associate-+r+N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-fma.f64N/A
count-2-revN/A
lower-+.f6467.2
Applied rewrites67.2%
if 7.6e105 < z Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f6467.0
Applied rewrites67.0%
(FPCore (x y z) :precision binary64 (if (<= y -3.85e+37) (fma 2.0 y z) (if (<= y 1.95e-69) (fma 3.0 x z) (fma 2.0 y z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.85e+37) {
tmp = fma(2.0, y, z);
} else if (y <= 1.95e-69) {
tmp = fma(3.0, x, z);
} else {
tmp = fma(2.0, y, z);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -3.85e+37) tmp = fma(2.0, y, z); elseif (y <= 1.95e-69) tmp = fma(3.0, x, z); else tmp = fma(2.0, y, z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -3.85e+37], N[(2.0 * y + z), $MachinePrecision], If[LessEqual[y, 1.95e-69], N[(3.0 * x + z), $MachinePrecision], N[(2.0 * y + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.85 \cdot 10^{+37}:\\
\;\;\;\;\mathsf{fma}\left(2, y, z\right)\\
\mathbf{elif}\;y \leq 1.95 \cdot 10^{-69}:\\
\;\;\;\;\mathsf{fma}\left(3, x, z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(2, y, z\right)\\
\end{array}
\end{array}
if y < -3.85000000000000011e37 or 1.9499999999999999e-69 < y Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f6467.0
Applied rewrites67.0%
if -3.85000000000000011e37 < y < 1.9499999999999999e-69Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
count-2-revN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-fma.f6466.1
Applied rewrites66.1%
(FPCore (x y z) :precision binary64 (if (<= y -2.3e+89) (+ y y) (if (<= y 3.7e+39) (fma 3.0 x z) (+ y y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.3e+89) {
tmp = y + y;
} else if (y <= 3.7e+39) {
tmp = fma(3.0, x, z);
} else {
tmp = y + y;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -2.3e+89) tmp = Float64(y + y); elseif (y <= 3.7e+39) tmp = fma(3.0, x, z); else tmp = Float64(y + y); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -2.3e+89], N[(y + y), $MachinePrecision], If[LessEqual[y, 3.7e+39], N[(3.0 * x + z), $MachinePrecision], N[(y + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.3 \cdot 10^{+89}:\\
\;\;\;\;y + y\\
\mathbf{elif}\;y \leq 3.7 \cdot 10^{+39}:\\
\;\;\;\;\mathsf{fma}\left(3, x, z\right)\\
\mathbf{else}:\\
\;\;\;\;y + y\\
\end{array}
\end{array}
if y < -2.2999999999999999e89 or 3.70000000000000012e39 < y Initial program 99.9%
Taylor expanded in z around 0
associate-+r+N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-fma.f64N/A
count-2-revN/A
lower-+.f6467.2
Applied rewrites67.2%
Taylor expanded in x around 0
count-2-revN/A
lift-+.f6435.1
Applied rewrites35.1%
if -2.2999999999999999e89 < y < 3.70000000000000012e39Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
count-2-revN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-fma.f6466.1
Applied rewrites66.1%
(FPCore (x y z)
:precision binary64
(if (<= y -4.3e+85)
(+ y y)
(if (<= y -2.35e-17)
(+ z x)
(if (<= y -2e-270)
(* 3.0 x)
(if (<= y 2.7e-272)
(+ z x)
(if (<= y 4.1e-108)
(* 3.0 x)
(if (<= y 1.02e+37) (+ z x) (+ y y))))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4.3e+85) {
tmp = y + y;
} else if (y <= -2.35e-17) {
tmp = z + x;
} else if (y <= -2e-270) {
tmp = 3.0 * x;
} else if (y <= 2.7e-272) {
tmp = z + x;
} else if (y <= 4.1e-108) {
tmp = 3.0 * x;
} else if (y <= 1.02e+37) {
tmp = z + x;
} else {
tmp = y + 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 <= (-4.3d+85)) then
tmp = y + y
else if (y <= (-2.35d-17)) then
tmp = z + x
else if (y <= (-2d-270)) then
tmp = 3.0d0 * x
else if (y <= 2.7d-272) then
tmp = z + x
else if (y <= 4.1d-108) then
tmp = 3.0d0 * x
else if (y <= 1.02d+37) then
tmp = z + x
else
tmp = y + y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -4.3e+85) {
tmp = y + y;
} else if (y <= -2.35e-17) {
tmp = z + x;
} else if (y <= -2e-270) {
tmp = 3.0 * x;
} else if (y <= 2.7e-272) {
tmp = z + x;
} else if (y <= 4.1e-108) {
tmp = 3.0 * x;
} else if (y <= 1.02e+37) {
tmp = z + x;
} else {
tmp = y + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4.3e+85: tmp = y + y elif y <= -2.35e-17: tmp = z + x elif y <= -2e-270: tmp = 3.0 * x elif y <= 2.7e-272: tmp = z + x elif y <= 4.1e-108: tmp = 3.0 * x elif y <= 1.02e+37: tmp = z + x else: tmp = y + y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4.3e+85) tmp = Float64(y + y); elseif (y <= -2.35e-17) tmp = Float64(z + x); elseif (y <= -2e-270) tmp = Float64(3.0 * x); elseif (y <= 2.7e-272) tmp = Float64(z + x); elseif (y <= 4.1e-108) tmp = Float64(3.0 * x); elseif (y <= 1.02e+37) tmp = Float64(z + x); else tmp = Float64(y + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4.3e+85) tmp = y + y; elseif (y <= -2.35e-17) tmp = z + x; elseif (y <= -2e-270) tmp = 3.0 * x; elseif (y <= 2.7e-272) tmp = z + x; elseif (y <= 4.1e-108) tmp = 3.0 * x; elseif (y <= 1.02e+37) tmp = z + x; else tmp = y + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4.3e+85], N[(y + y), $MachinePrecision], If[LessEqual[y, -2.35e-17], N[(z + x), $MachinePrecision], If[LessEqual[y, -2e-270], N[(3.0 * x), $MachinePrecision], If[LessEqual[y, 2.7e-272], N[(z + x), $MachinePrecision], If[LessEqual[y, 4.1e-108], N[(3.0 * x), $MachinePrecision], If[LessEqual[y, 1.02e+37], N[(z + x), $MachinePrecision], N[(y + y), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.3 \cdot 10^{+85}:\\
\;\;\;\;y + y\\
\mathbf{elif}\;y \leq -2.35 \cdot 10^{-17}:\\
\;\;\;\;z + x\\
\mathbf{elif}\;y \leq -2 \cdot 10^{-270}:\\
\;\;\;\;3 \cdot x\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{-272}:\\
\;\;\;\;z + x\\
\mathbf{elif}\;y \leq 4.1 \cdot 10^{-108}:\\
\;\;\;\;3 \cdot x\\
\mathbf{elif}\;y \leq 1.02 \cdot 10^{+37}:\\
\;\;\;\;z + x\\
\mathbf{else}:\\
\;\;\;\;y + y\\
\end{array}
\end{array}
if y < -4.2999999999999999e85 or 1.01999999999999995e37 < y Initial program 99.9%
Taylor expanded in z around 0
associate-+r+N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-fma.f64N/A
count-2-revN/A
lower-+.f6467.2
Applied rewrites67.2%
Taylor expanded in x around 0
count-2-revN/A
lift-+.f6435.1
Applied rewrites35.1%
if -4.2999999999999999e85 < y < -2.35e-17 or -2.0000000000000001e-270 < y < 2.69999999999999993e-272 or 4.10000000000000037e-108 < y < 1.01999999999999995e37Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-fma.f6466.1
Applied rewrites66.1%
Taylor expanded in x around 0
Applied rewrites38.8%
if -2.35e-17 < y < -2.0000000000000001e-270 or 2.69999999999999993e-272 < y < 4.10000000000000037e-108Initial program 99.9%
Taylor expanded in x around inf
lower-*.f6433.9
Applied rewrites33.9%
(FPCore (x y z) :precision binary64 (if (<= z -1.35e+42) (+ z x) (if (<= z 3.6e+142) (+ y y) (+ z x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.35e+42) {
tmp = z + x;
} else if (z <= 3.6e+142) {
tmp = y + y;
} else {
tmp = z + 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 (z <= (-1.35d+42)) then
tmp = z + x
else if (z <= 3.6d+142) then
tmp = y + y
else
tmp = z + x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.35e+42) {
tmp = z + x;
} else if (z <= 3.6e+142) {
tmp = y + y;
} else {
tmp = z + x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.35e+42: tmp = z + x elif z <= 3.6e+142: tmp = y + y else: tmp = z + x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.35e+42) tmp = Float64(z + x); elseif (z <= 3.6e+142) tmp = Float64(y + y); else tmp = Float64(z + x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.35e+42) tmp = z + x; elseif (z <= 3.6e+142) tmp = y + y; else tmp = z + x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.35e+42], N[(z + x), $MachinePrecision], If[LessEqual[z, 3.6e+142], N[(y + y), $MachinePrecision], N[(z + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.35 \cdot 10^{+42}:\\
\;\;\;\;z + x\\
\mathbf{elif}\;z \leq 3.6 \cdot 10^{+142}:\\
\;\;\;\;y + y\\
\mathbf{else}:\\
\;\;\;\;z + x\\
\end{array}
\end{array}
if z < -1.35e42 or 3.6000000000000001e142 < z Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-fma.f6466.1
Applied rewrites66.1%
Taylor expanded in x around 0
Applied rewrites38.8%
if -1.35e42 < z < 3.6000000000000001e142Initial program 99.9%
Taylor expanded in z around 0
associate-+r+N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-fma.f64N/A
count-2-revN/A
lower-+.f6467.2
Applied rewrites67.2%
Taylor expanded in x around 0
count-2-revN/A
lift-+.f6435.1
Applied rewrites35.1%
(FPCore (x y z) :precision binary64 (if (<= z -1.35e+42) z (if (<= z 3.6e+142) (+ y y) z)))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.35e+42) {
tmp = z;
} else if (z <= 3.6e+142) {
tmp = y + y;
} else {
tmp = 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 (z <= (-1.35d+42)) then
tmp = z
else if (z <= 3.6d+142) then
tmp = y + y
else
tmp = z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.35e+42) {
tmp = z;
} else if (z <= 3.6e+142) {
tmp = y + y;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.35e+42: tmp = z elif z <= 3.6e+142: tmp = y + y else: tmp = z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.35e+42) tmp = z; elseif (z <= 3.6e+142) tmp = Float64(y + y); else tmp = z; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.35e+42) tmp = z; elseif (z <= 3.6e+142) tmp = y + y; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.35e+42], z, If[LessEqual[z, 3.6e+142], N[(y + y), $MachinePrecision], z]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.35 \cdot 10^{+42}:\\
\;\;\;\;z\\
\mathbf{elif}\;z \leq 3.6 \cdot 10^{+142}:\\
\;\;\;\;y + y\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if z < -1.35e42 or 3.6000000000000001e142 < z Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
count-2-revN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-fma.f6466.1
Applied rewrites66.1%
Taylor expanded in x around 0
Applied rewrites33.9%
if -1.35e42 < z < 3.6000000000000001e142Initial program 99.9%
Taylor expanded in z around 0
associate-+r+N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-fma.f64N/A
count-2-revN/A
lower-+.f6467.2
Applied rewrites67.2%
Taylor expanded in x around 0
count-2-revN/A
lift-+.f6435.1
Applied rewrites35.1%
(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 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
count-2-revN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-fma.f6466.1
Applied rewrites66.1%
Taylor expanded in x around 0
Applied rewrites33.9%
(FPCore (x y z) :precision binary64 2.0)
double code(double x, double y, double z) {
return 2.0;
}
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 = 2.0d0
end function
public static double code(double x, double y, double z) {
return 2.0;
}
def code(x, y, z): return 2.0
function code(x, y, z) return 2.0 end
function tmp = code(x, y, z) tmp = 2.0; end
code[x_, y_, z_] := 2.0
\begin{array}{l}
\\
2
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
count-2-revN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-fma.f6466.1
Applied rewrites66.1%
Taylor expanded in x around 0
Applied rewrites33.9%
Taylor expanded in y around inf
count-2-revN/A
flip-+N/A
+-inversesN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
+-inversesN/A
metadata-evalN/A
flip-+N/A
metadata-eval3.0
Applied rewrites3.0%
herbie shell --seed 2025134
(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))