
(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 -6e+92) t_0 (if (<= x 5.4e+84) (+ (+ (* 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 <= -6e+92) {
tmp = t_0;
} else if (x <= 5.4e+84) {
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 <= -6e+92) tmp = t_0; elseif (x <= 5.4e+84) 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, -6e+92], t$95$0, If[LessEqual[x, 5.4e+84], 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 -6 \cdot 10^{+92}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 5.4 \cdot 10^{+84}:\\
\;\;\;\;\left(2 \cdot y + z\right) + x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -6.00000000000000026e92 or 5.4e84 < 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-*.f6465.7
Applied rewrites65.7%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
count-2-revN/A
lower-+.f6465.8
Applied rewrites65.8%
if -6.00000000000000026e92 < x < 5.4e84Initial program 99.9%
Taylor expanded in x around 0
lower-*.f6472.2
Applied rewrites72.2%
(FPCore (x y z) :precision binary64 (if (<= z -38000000000000.0) (fma x 3.0 z) (if (<= z 1.8e+123) (fma x 3.0 (+ y y)) (fma x 3.0 z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -38000000000000.0) {
tmp = fma(x, 3.0, z);
} else if (z <= 1.8e+123) {
tmp = fma(x, 3.0, (y + y));
} else {
tmp = fma(x, 3.0, z);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -38000000000000.0) tmp = fma(x, 3.0, z); elseif (z <= 1.8e+123) tmp = fma(x, 3.0, Float64(y + y)); else tmp = fma(x, 3.0, z); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -38000000000000.0], N[(x * 3.0 + z), $MachinePrecision], If[LessEqual[z, 1.8e+123], N[(x * 3.0 + N[(y + y), $MachinePrecision]), $MachinePrecision], N[(x * 3.0 + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -38000000000000:\\
\;\;\;\;\mathsf{fma}\left(x, 3, z\right)\\
\mathbf{elif}\;z \leq 1.8 \cdot 10^{+123}:\\
\;\;\;\;\mathsf{fma}\left(x, 3, y + y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, 3, z\right)\\
\end{array}
\end{array}
if z < -3.8e13 or 1.79999999999999999e123 < z 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.7%
if -3.8e13 < z < 1.79999999999999999e123Initial 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-*.f6465.7
Applied rewrites65.7%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
count-2-revN/A
lower-+.f6465.8
Applied rewrites65.8%
(FPCore (x y z) :precision binary64 (if (<= x -4.8e-131) (fma x 3.0 z) (if (<= x 7e+106) (fma y 2.0 z) (fma x 3.0 z))))
double code(double x, double y, double z) {
double tmp;
if (x <= -4.8e-131) {
tmp = fma(x, 3.0, z);
} else if (x <= 7e+106) {
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 <= -4.8e-131) tmp = fma(x, 3.0, z); elseif (x <= 7e+106) tmp = fma(y, 2.0, z); else tmp = fma(x, 3.0, z); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -4.8e-131], N[(x * 3.0 + z), $MachinePrecision], If[LessEqual[x, 7e+106], N[(y * 2.0 + z), $MachinePrecision], N[(x * 3.0 + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.8 \cdot 10^{-131}:\\
\;\;\;\;\mathsf{fma}\left(x, 3, z\right)\\
\mathbf{elif}\;x \leq 7 \cdot 10^{+106}:\\
\;\;\;\;\mathsf{fma}\left(y, 2, z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, 3, z\right)\\
\end{array}
\end{array}
if x < -4.7999999999999999e-131 or 6.99999999999999962e106 < 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.7%
if -4.7999999999999999e-131 < x < 6.99999999999999962e106Initial program 99.9%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f6467.5
Applied rewrites67.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6467.5
Applied rewrites67.5%
(FPCore (x y z) :precision binary64 (if (<= y -9e+155) (+ y y) (if (<= y 4e+197) (fma x 3.0 z) (+ y y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -9e+155) {
tmp = y + y;
} else if (y <= 4e+197) {
tmp = fma(x, 3.0, z);
} else {
tmp = y + y;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -9e+155) tmp = Float64(y + y); elseif (y <= 4e+197) tmp = fma(x, 3.0, z); else tmp = Float64(y + y); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -9e+155], N[(y + y), $MachinePrecision], If[LessEqual[y, 4e+197], N[(x * 3.0 + z), $MachinePrecision], N[(y + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9 \cdot 10^{+155}:\\
\;\;\;\;y + y\\
\mathbf{elif}\;y \leq 4 \cdot 10^{+197}:\\
\;\;\;\;\mathsf{fma}\left(x, 3, z\right)\\
\mathbf{else}:\\
\;\;\;\;y + y\\
\end{array}
\end{array}
if y < -8.99999999999999947e155 or 3.9999999999999998e197 < 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-*.f6465.7
Applied rewrites65.7%
Taylor expanded in x around 0
lower-*.f6434.1
Applied rewrites34.1%
Applied rewrites34.1%
if -8.99999999999999947e155 < y < 3.9999999999999998e197Initial 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.7%
(FPCore (x y z) :precision binary64 (if (<= x -6e+92) (* 3.0 x) (if (<= x 1.25e-33) (+ z x) (if (<= x 7e+106) (+ y y) (* 3.0 x)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -6e+92) {
tmp = 3.0 * x;
} else if (x <= 1.25e-33) {
tmp = z + x;
} else if (x <= 7e+106) {
tmp = y + y;
} 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 <= (-6d+92)) then
tmp = 3.0d0 * x
else if (x <= 1.25d-33) then
tmp = z + x
else if (x <= 7d+106) then
tmp = y + y
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 <= -6e+92) {
tmp = 3.0 * x;
} else if (x <= 1.25e-33) {
tmp = z + x;
} else if (x <= 7e+106) {
tmp = y + y;
} else {
tmp = 3.0 * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -6e+92: tmp = 3.0 * x elif x <= 1.25e-33: tmp = z + x elif x <= 7e+106: tmp = y + y else: tmp = 3.0 * x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -6e+92) tmp = Float64(3.0 * x); elseif (x <= 1.25e-33) tmp = Float64(z + x); elseif (x <= 7e+106) tmp = Float64(y + y); else tmp = Float64(3.0 * x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -6e+92) tmp = 3.0 * x; elseif (x <= 1.25e-33) tmp = z + x; elseif (x <= 7e+106) tmp = y + y; else tmp = 3.0 * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -6e+92], N[(3.0 * x), $MachinePrecision], If[LessEqual[x, 1.25e-33], N[(z + x), $MachinePrecision], If[LessEqual[x, 7e+106], N[(y + y), $MachinePrecision], N[(3.0 * x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6 \cdot 10^{+92}:\\
\;\;\;\;3 \cdot x\\
\mathbf{elif}\;x \leq 1.25 \cdot 10^{-33}:\\
\;\;\;\;z + x\\
\mathbf{elif}\;x \leq 7 \cdot 10^{+106}:\\
\;\;\;\;y + y\\
\mathbf{else}:\\
\;\;\;\;3 \cdot x\\
\end{array}
\end{array}
if x < -6.00000000000000026e92 or 6.99999999999999962e106 < x Initial program 99.9%
Taylor expanded in x around inf
lower-*.f6433.3
Applied rewrites33.3%
if -6.00000000000000026e92 < x < 1.25000000000000007e-33Initial 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 rewrites40.1%
if 1.25000000000000007e-33 < x < 6.99999999999999962e106Initial 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-*.f6465.7
Applied rewrites65.7%
Taylor expanded in x around 0
lower-*.f6434.1
Applied rewrites34.1%
Applied rewrites34.1%
(FPCore (x y z) :precision binary64 (if (<= z -90000000000.0) (+ z x) (if (<= z 1.05e+66) (+ y y) (+ z x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -90000000000.0) {
tmp = z + x;
} else if (z <= 1.05e+66) {
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 <= (-90000000000.0d0)) then
tmp = z + x
else if (z <= 1.05d+66) 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 <= -90000000000.0) {
tmp = z + x;
} else if (z <= 1.05e+66) {
tmp = y + y;
} else {
tmp = z + x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -90000000000.0: tmp = z + x elif z <= 1.05e+66: tmp = y + y else: tmp = z + x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -90000000000.0) tmp = Float64(z + x); elseif (z <= 1.05e+66) 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 <= -90000000000.0) tmp = z + x; elseif (z <= 1.05e+66) tmp = y + y; else tmp = z + x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -90000000000.0], N[(z + x), $MachinePrecision], If[LessEqual[z, 1.05e+66], N[(y + y), $MachinePrecision], N[(z + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -90000000000:\\
\;\;\;\;z + x\\
\mathbf{elif}\;z \leq 1.05 \cdot 10^{+66}:\\
\;\;\;\;y + y\\
\mathbf{else}:\\
\;\;\;\;z + x\\
\end{array}
\end{array}
if z < -9e10 or 1.05000000000000003e66 < z Initial 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 rewrites40.1%
if -9e10 < z < 1.05000000000000003e66Initial 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-*.f6465.7
Applied rewrites65.7%
Taylor expanded in x around 0
lower-*.f6434.1
Applied rewrites34.1%
Applied rewrites34.1%
(FPCore (x y z) :precision binary64 (if (<= z -90000000000.0) z (if (<= z 1.8e+123) (+ y y) z)))
double code(double x, double y, double z) {
double tmp;
if (z <= -90000000000.0) {
tmp = z;
} else if (z <= 1.8e+123) {
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 <= (-90000000000.0d0)) then
tmp = z
else if (z <= 1.8d+123) 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 <= -90000000000.0) {
tmp = z;
} else if (z <= 1.8e+123) {
tmp = y + y;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -90000000000.0: tmp = z elif z <= 1.8e+123: tmp = y + y else: tmp = z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -90000000000.0) tmp = z; elseif (z <= 1.8e+123) tmp = Float64(y + y); else tmp = z; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -90000000000.0) tmp = z; elseif (z <= 1.8e+123) tmp = y + y; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -90000000000.0], z, If[LessEqual[z, 1.8e+123], N[(y + y), $MachinePrecision], z]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -90000000000:\\
\;\;\;\;z\\
\mathbf{elif}\;z \leq 1.8 \cdot 10^{+123}:\\
\;\;\;\;y + y\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if z < -9e10 or 1.79999999999999999e123 < z 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 rewrites35.2%
if -9e10 < z < 1.79999999999999999e123Initial 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-*.f6465.7
Applied rewrites65.7%
Taylor expanded in x around 0
lower-*.f6434.1
Applied rewrites34.1%
Applied rewrites34.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%
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 rewrites35.2%
herbie shell --seed 2025154
(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))