
(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 (fma 2.0 y z)))
double code(double x, double y, double z) {
return fma(3.0, x, fma(2.0, y, z));
}
function code(x, y, z) return fma(3.0, x, fma(2.0, y, z)) end
code[x_, y_, z_] := N[(3.0 * x + N[(2.0 * y + z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(3, x, \mathsf{fma}\left(2, y, z\right)\right)
\end{array}
Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
associate-+r+N/A
associate-+l+N/A
associate-+r+N/A
count-2N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-fma.f64N/A
count-2N/A
lower-fma.f64100.0
Applied rewrites100.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (fma x 3.0 (+ y y)))) (if (<= x -1.22e+81) t_0 (if (<= x 4.3e+77) (+ (+ (* 2.0 y) z) x) t_0))))
double code(double x, double y, double z) {
double t_0 = fma(x, 3.0, (y + y));
double tmp;
if (x <= -1.22e+81) {
tmp = t_0;
} else if (x <= 4.3e+77) {
tmp = ((2.0 * y) + z) + x;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = fma(x, 3.0, Float64(y + y)) tmp = 0.0 if (x <= -1.22e+81) tmp = t_0; elseif (x <= 4.3e+77) tmp = Float64(Float64(Float64(2.0 * y) + z) + x); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * 3.0 + N[(y + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.22e+81], t$95$0, If[LessEqual[x, 4.3e+77], N[(N[(N[(2.0 * y), $MachinePrecision] + z), $MachinePrecision] + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(x, 3, y + y\right)\\
\mathbf{if}\;x \leq -1.22 \cdot 10^{+81}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4.3 \cdot 10^{+77}:\\
\;\;\;\;\left(2 \cdot y + z\right) + x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.21999999999999995e81 or 4.29999999999999991e77 < x Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
associate-+r+N/A
associate-+l+N/A
associate-+r+N/A
count-2N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-fma.f64N/A
count-2N/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-*.f6466.5
Applied rewrites66.5%
lift-fma.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f64N/A
count-2-revN/A
lower-+.f6466.5
Applied rewrites66.5%
if -1.21999999999999995e81 < x < 4.29999999999999991e77Initial program 99.9%
Taylor expanded in x around 0
lower-*.f6471.8
Applied rewrites71.8%
(FPCore (x y z) :precision binary64 (let* ((t_0 (fma x 3.0 (+ y y)))) (if (<= x -1.12e+81) t_0 (if (<= x 1.02e+76) (fma y 2.0 z) t_0))))
double code(double x, double y, double z) {
double t_0 = fma(x, 3.0, (y + y));
double tmp;
if (x <= -1.12e+81) {
tmp = t_0;
} else if (x <= 1.02e+76) {
tmp = fma(y, 2.0, z);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = fma(x, 3.0, Float64(y + y)) tmp = 0.0 if (x <= -1.12e+81) tmp = t_0; elseif (x <= 1.02e+76) tmp = fma(y, 2.0, z); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * 3.0 + N[(y + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.12e+81], t$95$0, If[LessEqual[x, 1.02e+76], N[(y * 2.0 + z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(x, 3, y + y\right)\\
\mathbf{if}\;x \leq -1.12 \cdot 10^{+81}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.02 \cdot 10^{+76}:\\
\;\;\;\;\mathsf{fma}\left(y, 2, z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.11999999999999994e81 or 1.02000000000000007e76 < x Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
associate-+r+N/A
associate-+l+N/A
associate-+r+N/A
count-2N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-fma.f64N/A
count-2N/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-*.f6466.5
Applied rewrites66.5%
lift-fma.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f64N/A
count-2-revN/A
lower-+.f6466.5
Applied rewrites66.5%
if -1.11999999999999994e81 < x < 1.02000000000000007e76Initial program 99.9%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f6467.1
Applied rewrites67.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6467.1
Applied rewrites67.1%
(FPCore (x y z) :precision binary64 (if (<= x -1.6e+89) (fma x 3.0 z) (if (<= x 1.05e+29) (fma y 2.0 z) (fma x 3.0 z))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.6e+89) {
tmp = fma(x, 3.0, z);
} else if (x <= 1.05e+29) {
tmp = fma(y, 2.0, z);
} else {
tmp = fma(x, 3.0, z);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -1.6e+89) tmp = fma(x, 3.0, z); elseif (x <= 1.05e+29) tmp = fma(y, 2.0, z); else tmp = fma(x, 3.0, z); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -1.6e+89], N[(x * 3.0 + z), $MachinePrecision], If[LessEqual[x, 1.05e+29], N[(y * 2.0 + z), $MachinePrecision], N[(x * 3.0 + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.6 \cdot 10^{+89}:\\
\;\;\;\;\mathsf{fma}\left(x, 3, z\right)\\
\mathbf{elif}\;x \leq 1.05 \cdot 10^{+29}:\\
\;\;\;\;\mathsf{fma}\left(y, 2, z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, 3, z\right)\\
\end{array}
\end{array}
if x < -1.59999999999999994e89 or 1.0500000000000001e29 < x Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
associate-+r+N/A
associate-+l+N/A
associate-+r+N/A
count-2N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-fma.f64N/A
count-2N/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6466.6
Applied rewrites66.6%
Applied rewrites66.6%
if -1.59999999999999994e89 < x < 1.0500000000000001e29Initial program 99.9%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f6467.1
Applied rewrites67.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6467.1
Applied rewrites67.1%
(FPCore (x y z) :precision binary64 (if (<= y -9.5e+137) (+ y y) (if (<= y 2.65e+159) (fma x 3.0 z) (+ y y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -9.5e+137) {
tmp = y + y;
} else if (y <= 2.65e+159) {
tmp = fma(x, 3.0, z);
} else {
tmp = y + y;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -9.5e+137) tmp = Float64(y + y); elseif (y <= 2.65e+159) tmp = fma(x, 3.0, z); else tmp = Float64(y + y); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -9.5e+137], N[(y + y), $MachinePrecision], If[LessEqual[y, 2.65e+159], N[(x * 3.0 + z), $MachinePrecision], N[(y + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.5 \cdot 10^{+137}:\\
\;\;\;\;y + y\\
\mathbf{elif}\;y \leq 2.65 \cdot 10^{+159}:\\
\;\;\;\;\mathsf{fma}\left(x, 3, z\right)\\
\mathbf{else}:\\
\;\;\;\;y + y\\
\end{array}
\end{array}
if y < -9.50000000000000031e137 or 2.6499999999999999e159 < y Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
associate-+r+N/A
associate-+l+N/A
associate-+r+N/A
count-2N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-fma.f64N/A
count-2N/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-*.f6466.5
Applied rewrites66.5%
Taylor expanded in x around 0
lower-*.f6434.3
Applied rewrites34.3%
Applied rewrites34.3%
if -9.50000000000000031e137 < y < 2.6499999999999999e159Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
associate-+r+N/A
associate-+l+N/A
associate-+r+N/A
count-2N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-fma.f64N/A
count-2N/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6466.6
Applied rewrites66.6%
Applied rewrites66.6%
(FPCore (x y z) :precision binary64 (if (<= y -1.75e+34) (+ y y) (if (<= y 1.2e-150) (+ z x) (if (<= y 6.5e+67) (* 3.0 x) (+ y y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.75e+34) {
tmp = y + y;
} else if (y <= 1.2e-150) {
tmp = z + x;
} else if (y <= 6.5e+67) {
tmp = 3.0 * 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 <= (-1.75d+34)) then
tmp = y + y
else if (y <= 1.2d-150) then
tmp = z + x
else if (y <= 6.5d+67) then
tmp = 3.0d0 * 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 <= -1.75e+34) {
tmp = y + y;
} else if (y <= 1.2e-150) {
tmp = z + x;
} else if (y <= 6.5e+67) {
tmp = 3.0 * x;
} else {
tmp = y + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.75e+34: tmp = y + y elif y <= 1.2e-150: tmp = z + x elif y <= 6.5e+67: tmp = 3.0 * x else: tmp = y + y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.75e+34) tmp = Float64(y + y); elseif (y <= 1.2e-150) tmp = Float64(z + x); elseif (y <= 6.5e+67) tmp = Float64(3.0 * x); else tmp = Float64(y + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.75e+34) tmp = y + y; elseif (y <= 1.2e-150) tmp = z + x; elseif (y <= 6.5e+67) tmp = 3.0 * x; else tmp = y + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.75e+34], N[(y + y), $MachinePrecision], If[LessEqual[y, 1.2e-150], N[(z + x), $MachinePrecision], If[LessEqual[y, 6.5e+67], N[(3.0 * x), $MachinePrecision], N[(y + y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.75 \cdot 10^{+34}:\\
\;\;\;\;y + y\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{-150}:\\
\;\;\;\;z + x\\
\mathbf{elif}\;y \leq 6.5 \cdot 10^{+67}:\\
\;\;\;\;3 \cdot x\\
\mathbf{else}:\\
\;\;\;\;y + y\\
\end{array}
\end{array}
if y < -1.74999999999999999e34 or 6.4999999999999995e67 < y Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
associate-+r+N/A
associate-+l+N/A
associate-+r+N/A
count-2N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-fma.f64N/A
count-2N/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-*.f6466.5
Applied rewrites66.5%
Taylor expanded in x around 0
lower-*.f6434.3
Applied rewrites34.3%
Applied rewrites34.3%
if -1.74999999999999999e34 < y < 1.2e-150Initial program 99.9%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6466.6
Applied rewrites66.6%
Taylor expanded in x around 0
Applied rewrites39.6%
if 1.2e-150 < y < 6.4999999999999995e67Initial program 99.9%
Taylor expanded in x around inf
lower-*.f6434.0
Applied rewrites34.0%
(FPCore (x y z) :precision binary64 (if (<= y -1.75e+34) (+ y y) (if (<= y 7.8e-8) (+ z x) (+ y y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.75e+34) {
tmp = y + y;
} else if (y <= 7.8e-8) {
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 <= (-1.75d+34)) then
tmp = y + y
else if (y <= 7.8d-8) 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 <= -1.75e+34) {
tmp = y + y;
} else if (y <= 7.8e-8) {
tmp = z + x;
} else {
tmp = y + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.75e+34: tmp = y + y elif y <= 7.8e-8: tmp = z + x else: tmp = y + y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.75e+34) tmp = Float64(y + y); elseif (y <= 7.8e-8) 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 <= -1.75e+34) tmp = y + y; elseif (y <= 7.8e-8) tmp = z + x; else tmp = y + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.75e+34], N[(y + y), $MachinePrecision], If[LessEqual[y, 7.8e-8], N[(z + x), $MachinePrecision], N[(y + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.75 \cdot 10^{+34}:\\
\;\;\;\;y + y\\
\mathbf{elif}\;y \leq 7.8 \cdot 10^{-8}:\\
\;\;\;\;z + x\\
\mathbf{else}:\\
\;\;\;\;y + y\\
\end{array}
\end{array}
if y < -1.74999999999999999e34 or 7.7999999999999997e-8 < y Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
associate-+r+N/A
associate-+l+N/A
associate-+r+N/A
count-2N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-fma.f64N/A
count-2N/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-*.f6466.5
Applied rewrites66.5%
Taylor expanded in x around 0
lower-*.f6434.3
Applied rewrites34.3%
Applied rewrites34.3%
if -1.74999999999999999e34 < y < 7.7999999999999997e-8Initial program 99.9%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6466.6
Applied rewrites66.6%
Taylor expanded in x around 0
Applied rewrites39.6%
(FPCore (x y z) :precision binary64 (if (<= y -6.5e+33) (+ y y) (if (<= y 5.3e-8) z (+ y y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -6.5e+33) {
tmp = y + y;
} else if (y <= 5.3e-8) {
tmp = z;
} 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 <= (-6.5d+33)) then
tmp = y + y
else if (y <= 5.3d-8) then
tmp = z
else
tmp = y + y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -6.5e+33) {
tmp = y + y;
} else if (y <= 5.3e-8) {
tmp = z;
} else {
tmp = y + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -6.5e+33: tmp = y + y elif y <= 5.3e-8: tmp = z else: tmp = y + y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -6.5e+33) tmp = Float64(y + y); elseif (y <= 5.3e-8) tmp = z; else tmp = Float64(y + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -6.5e+33) tmp = y + y; elseif (y <= 5.3e-8) tmp = z; else tmp = y + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -6.5e+33], N[(y + y), $MachinePrecision], If[LessEqual[y, 5.3e-8], z, N[(y + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.5 \cdot 10^{+33}:\\
\;\;\;\;y + y\\
\mathbf{elif}\;y \leq 5.3 \cdot 10^{-8}:\\
\;\;\;\;z\\
\mathbf{else}:\\
\;\;\;\;y + y\\
\end{array}
\end{array}
if y < -6.49999999999999993e33 or 5.2999999999999998e-8 < y Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
associate-+r+N/A
associate-+l+N/A
associate-+r+N/A
count-2N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-fma.f64N/A
count-2N/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-*.f6466.5
Applied rewrites66.5%
Taylor expanded in x around 0
lower-*.f6434.3
Applied rewrites34.3%
Applied rewrites34.3%
if -6.49999999999999993e33 < y < 5.2999999999999998e-8Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
associate-+r+N/A
associate-+l+N/A
associate-+r+N/A
count-2N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-fma.f64N/A
count-2N/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6466.6
Applied rewrites66.6%
Taylor expanded in x around 0
Applied rewrites34.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
\begin{array}{l}
\\
z
\end{array}
Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
associate-+r+N/A
associate-+l+N/A
associate-+r+N/A
count-2N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-fma.f64N/A
count-2N/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6466.6
Applied rewrites66.6%
Taylor expanded in x around 0
Applied rewrites34.5%
herbie shell --seed 2025149
(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))