
(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 x 3.0 (fma 2.0 y z)))
double code(double x, double y, double z) {
return fma(x, 3.0, fma(2.0, y, z));
}
function code(x, y, z) return fma(x, 3.0, fma(2.0, y, z)) end
code[x_, y_, z_] := N[(x * 3.0 + N[(2.0 * y + z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, 3, \mathsf{fma}\left(2, y, z\right)\right)
\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%
lift-+.f64N/A
lift-fma.f64N/A
lift-+.f64N/A
count-2-revN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
lift-fma.f64100.0
Applied rewrites100.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (fma 3.0 x (+ y y)))) (if (<= y -3.5e+39) t_0 (if (<= y 2.3e+20) (fma 3.0 x z) t_0))))
double code(double x, double y, double z) {
double t_0 = fma(3.0, x, (y + y));
double tmp;
if (y <= -3.5e+39) {
tmp = t_0;
} else if (y <= 2.3e+20) {
tmp = fma(3.0, x, z);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = fma(3.0, x, Float64(y + y)) tmp = 0.0 if (y <= -3.5e+39) tmp = t_0; elseif (y <= 2.3e+20) tmp = fma(3.0, x, z); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(3.0 * x + N[(y + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.5e+39], t$95$0, If[LessEqual[y, 2.3e+20], N[(3.0 * x + z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(3, x, y + y\right)\\
\mathbf{if}\;y \leq -3.5 \cdot 10^{+39}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{+20}:\\
\;\;\;\;\mathsf{fma}\left(3, x, z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -3.5000000000000002e39 or 2.3e20 < 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.7
Applied rewrites67.7%
if -3.5000000000000002e39 < y < 2.3e20Initial 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.f6467.1
Applied rewrites67.1%
(FPCore (x y z) :precision binary64 (if (<= x -2.35e+49) (fma 3.0 x z) (if (<= x 1.25e+19) (fma 2.0 y z) (- z (* -3.0 x)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.35e+49) {
tmp = fma(3.0, x, z);
} else if (x <= 1.25e+19) {
tmp = fma(2.0, y, z);
} else {
tmp = z - (-3.0 * x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -2.35e+49) tmp = fma(3.0, x, z); elseif (x <= 1.25e+19) tmp = fma(2.0, y, z); else tmp = Float64(z - Float64(-3.0 * x)); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -2.35e+49], N[(3.0 * x + z), $MachinePrecision], If[LessEqual[x, 1.25e+19], N[(2.0 * y + z), $MachinePrecision], N[(z - N[(-3.0 * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.35 \cdot 10^{+49}:\\
\;\;\;\;\mathsf{fma}\left(3, x, z\right)\\
\mathbf{elif}\;x \leq 1.25 \cdot 10^{+19}:\\
\;\;\;\;\mathsf{fma}\left(2, y, z\right)\\
\mathbf{else}:\\
\;\;\;\;z - -3 \cdot x\\
\end{array}
\end{array}
if x < -2.3499999999999999e49Initial 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.f6467.1
Applied rewrites67.1%
if -2.3499999999999999e49 < x < 1.25e19Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f6465.5
Applied rewrites65.5%
if 1.25e19 < x 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.f6467.1
Applied rewrites67.1%
lift-fma.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
lower-*.f6467.0
Applied rewrites67.0%
(FPCore (x y z) :precision binary64 (if (<= x -2.35e+49) (fma 3.0 x z) (if (<= x 1.25e+19) (fma 2.0 y z) (fma 3.0 x z))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.35e+49) {
tmp = fma(3.0, x, z);
} else if (x <= 1.25e+19) {
tmp = fma(2.0, y, z);
} else {
tmp = fma(3.0, x, z);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -2.35e+49) tmp = fma(3.0, x, z); elseif (x <= 1.25e+19) tmp = fma(2.0, y, z); else tmp = fma(3.0, x, z); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -2.35e+49], N[(3.0 * x + z), $MachinePrecision], If[LessEqual[x, 1.25e+19], N[(2.0 * y + z), $MachinePrecision], N[(3.0 * x + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.35 \cdot 10^{+49}:\\
\;\;\;\;\mathsf{fma}\left(3, x, z\right)\\
\mathbf{elif}\;x \leq 1.25 \cdot 10^{+19}:\\
\;\;\;\;\mathsf{fma}\left(2, y, z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(3, x, z\right)\\
\end{array}
\end{array}
if x < -2.3499999999999999e49 or 1.25e19 < x 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.f6467.1
Applied rewrites67.1%
if -2.3499999999999999e49 < x < 1.25e19Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f6465.5
Applied rewrites65.5%
(FPCore (x y z) :precision binary64 (if (<= y -2.6e+111) (+ y y) (if (<= y 2.8e+92) (fma 3.0 x z) (+ y y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.6e+111) {
tmp = y + y;
} else if (y <= 2.8e+92) {
tmp = fma(3.0, x, z);
} else {
tmp = y + y;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -2.6e+111) tmp = Float64(y + y); elseif (y <= 2.8e+92) tmp = fma(3.0, x, z); else tmp = Float64(y + y); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -2.6e+111], N[(y + y), $MachinePrecision], If[LessEqual[y, 2.8e+92], N[(3.0 * x + z), $MachinePrecision], N[(y + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.6 \cdot 10^{+111}:\\
\;\;\;\;y + y\\
\mathbf{elif}\;y \leq 2.8 \cdot 10^{+92}:\\
\;\;\;\;\mathsf{fma}\left(3, x, z\right)\\
\mathbf{else}:\\
\;\;\;\;y + y\\
\end{array}
\end{array}
if y < -2.5999999999999999e111 or 2.80000000000000001e92 < 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.7
Applied rewrites67.7%
Taylor expanded in x around 0
count-2-revN/A
lift-+.f6434.0
Applied rewrites34.0%
if -2.5999999999999999e111 < y < 2.80000000000000001e92Initial 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.f6467.1
Applied rewrites67.1%
(FPCore (x y z) :precision binary64 (if (<= x -6.8e+70) (* 3.0 x) (if (<= x 3.1e-276) (+ y y) (if (<= x 1.6e+43) (+ z x) (* 3.0 x)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -6.8e+70) {
tmp = 3.0 * x;
} else if (x <= 3.1e-276) {
tmp = y + y;
} else if (x <= 1.6e+43) {
tmp = z + x;
} 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 <= (-6.8d+70)) then
tmp = 3.0d0 * x
else if (x <= 3.1d-276) then
tmp = y + y
else if (x <= 1.6d+43) then
tmp = z + x
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 <= -6.8e+70) {
tmp = 3.0 * x;
} else if (x <= 3.1e-276) {
tmp = y + y;
} else if (x <= 1.6e+43) {
tmp = z + x;
} else {
tmp = 3.0 * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -6.8e+70: tmp = 3.0 * x elif x <= 3.1e-276: tmp = y + y elif x <= 1.6e+43: tmp = z + x else: tmp = 3.0 * x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -6.8e+70) tmp = Float64(3.0 * x); elseif (x <= 3.1e-276) tmp = Float64(y + y); elseif (x <= 1.6e+43) tmp = Float64(z + x); else tmp = Float64(3.0 * x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -6.8e+70) tmp = 3.0 * x; elseif (x <= 3.1e-276) tmp = y + y; elseif (x <= 1.6e+43) tmp = z + x; else tmp = 3.0 * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -6.8e+70], N[(3.0 * x), $MachinePrecision], If[LessEqual[x, 3.1e-276], N[(y + y), $MachinePrecision], If[LessEqual[x, 1.6e+43], N[(z + x), $MachinePrecision], N[(3.0 * x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.8 \cdot 10^{+70}:\\
\;\;\;\;3 \cdot x\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{-276}:\\
\;\;\;\;y + y\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{+43}:\\
\;\;\;\;z + x\\
\mathbf{else}:\\
\;\;\;\;3 \cdot x\\
\end{array}
\end{array}
if x < -6.8000000000000002e70 or 1.60000000000000007e43 < x Initial program 99.9%
Taylor expanded in x around inf
lower-*.f6435.4
Applied rewrites35.4%
if -6.8000000000000002e70 < x < 3.09999999999999989e-276Initial 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.7
Applied rewrites67.7%
Taylor expanded in x around 0
count-2-revN/A
lift-+.f6434.0
Applied rewrites34.0%
if 3.09999999999999989e-276 < x < 1.60000000000000007e43Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-fma.f6467.0
Applied rewrites67.0%
Taylor expanded in x around 0
Applied rewrites38.7%
(FPCore (x y z) :precision binary64 (if (<= y -7.2e+39) (+ y y) (if (<= y 3.8e+20) (+ z x) (+ y y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -7.2e+39) {
tmp = y + y;
} else if (y <= 3.8e+20) {
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 <= (-7.2d+39)) then
tmp = y + y
else if (y <= 3.8d+20) 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 <= -7.2e+39) {
tmp = y + y;
} else if (y <= 3.8e+20) {
tmp = z + x;
} else {
tmp = y + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -7.2e+39: tmp = y + y elif y <= 3.8e+20: tmp = z + x else: tmp = y + y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -7.2e+39) tmp = Float64(y + y); elseif (y <= 3.8e+20) 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 <= -7.2e+39) tmp = y + y; elseif (y <= 3.8e+20) tmp = z + x; else tmp = y + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -7.2e+39], N[(y + y), $MachinePrecision], If[LessEqual[y, 3.8e+20], N[(z + x), $MachinePrecision], N[(y + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.2 \cdot 10^{+39}:\\
\;\;\;\;y + y\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{+20}:\\
\;\;\;\;z + x\\
\mathbf{else}:\\
\;\;\;\;y + y\\
\end{array}
\end{array}
if y < -7.19999999999999969e39 or 3.8e20 < 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.7
Applied rewrites67.7%
Taylor expanded in x around 0
count-2-revN/A
lift-+.f6434.0
Applied rewrites34.0%
if -7.19999999999999969e39 < y < 3.8e20Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-fma.f6467.0
Applied rewrites67.0%
Taylor expanded in x around 0
Applied rewrites38.7%
(FPCore (x y z) :precision binary64 (if (<= y -5e+39) (+ y y) (if (<= y 2.3e+20) z (+ y y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -5e+39) {
tmp = y + y;
} else if (y <= 2.3e+20) {
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 <= (-5d+39)) then
tmp = y + y
else if (y <= 2.3d+20) 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 <= -5e+39) {
tmp = y + y;
} else if (y <= 2.3e+20) {
tmp = z;
} else {
tmp = y + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5e+39: tmp = y + y elif y <= 2.3e+20: tmp = z else: tmp = y + y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5e+39) tmp = Float64(y + y); elseif (y <= 2.3e+20) tmp = z; else tmp = Float64(y + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5e+39) tmp = y + y; elseif (y <= 2.3e+20) tmp = z; else tmp = y + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5e+39], N[(y + y), $MachinePrecision], If[LessEqual[y, 2.3e+20], z, N[(y + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{+39}:\\
\;\;\;\;y + y\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{+20}:\\
\;\;\;\;z\\
\mathbf{else}:\\
\;\;\;\;y + y\\
\end{array}
\end{array}
if y < -5.00000000000000015e39 or 2.3e20 < 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.7
Applied rewrites67.7%
Taylor expanded in x around 0
count-2-revN/A
lift-+.f6434.0
Applied rewrites34.0%
if -5.00000000000000015e39 < y < 2.3e20Initial 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.f6467.1
Applied rewrites67.1%
lift-fma.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
lower-*.f6467.0
Applied rewrites67.0%
Taylor expanded in x around 0
Applied rewrites33.4%
(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.f6467.1
Applied rewrites67.1%
lift-fma.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
lower-*.f6467.0
Applied rewrites67.0%
Taylor expanded in x around 0
Applied rewrites33.4%
herbie shell --seed 2025139
(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))