
(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 y 2.0 z)))
double code(double x, double y, double z) {
return fma(x, 3.0, fma(y, 2.0, z));
}
function code(x, y, z) return fma(x, 3.0, fma(y, 2.0, z)) end
code[x_, y_, z_] := N[(x * 3.0 + N[(y * 2.0 + z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, 3, \mathsf{fma}\left(y, 2, z\right)\right)
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Applied rewrites100.0%
(FPCore (x y z) :precision binary64 (if (<= y -1.52e+41) (+ (+ (* 2.0 y) z) x) (if (<= y 1.1e+47) (fma x 3.0 z) (fma x 3.0 (+ y y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.52e+41) {
tmp = ((2.0 * y) + z) + x;
} else if (y <= 1.1e+47) {
tmp = fma(x, 3.0, z);
} else {
tmp = fma(x, 3.0, (y + y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -1.52e+41) tmp = Float64(Float64(Float64(2.0 * y) + z) + x); elseif (y <= 1.1e+47) tmp = fma(x, 3.0, z); else tmp = fma(x, 3.0, Float64(y + y)); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -1.52e+41], N[(N[(N[(2.0 * y), $MachinePrecision] + z), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 1.1e+47], N[(x * 3.0 + z), $MachinePrecision], N[(x * 3.0 + N[(y + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.52 \cdot 10^{+41}:\\
\;\;\;\;\left(2 \cdot y + z\right) + x\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{+47}:\\
\;\;\;\;\mathsf{fma}\left(x, 3, z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, 3, y + y\right)\\
\end{array}
\end{array}
if y < -1.52000000000000002e41Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites71.8%
if -1.52000000000000002e41 < y < 1.1e47Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in y around 0
Applied rewrites65.9%
Applied rewrites66.0%
if 1.1e47 < y Initial program 99.9%
Taylor expanded in z around 0
Applied rewrites67.4%
Applied rewrites67.4%
Applied rewrites67.4%
(FPCore (x y z) :precision binary64 (if (<= y -1.52e+41) (fma y 2.0 z) (if (<= y 1.1e+47) (fma x 3.0 z) (fma x 3.0 (+ y y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.52e+41) {
tmp = fma(y, 2.0, z);
} else if (y <= 1.1e+47) {
tmp = fma(x, 3.0, z);
} else {
tmp = fma(x, 3.0, (y + y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -1.52e+41) tmp = fma(y, 2.0, z); elseif (y <= 1.1e+47) tmp = fma(x, 3.0, z); else tmp = fma(x, 3.0, Float64(y + y)); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -1.52e+41], N[(y * 2.0 + z), $MachinePrecision], If[LessEqual[y, 1.1e+47], N[(x * 3.0 + z), $MachinePrecision], N[(x * 3.0 + N[(y + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.52 \cdot 10^{+41}:\\
\;\;\;\;\mathsf{fma}\left(y, 2, z\right)\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{+47}:\\
\;\;\;\;\mathsf{fma}\left(x, 3, z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, 3, y + y\right)\\
\end{array}
\end{array}
if y < -1.52000000000000002e41Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites67.1%
Applied rewrites67.1%
if -1.52000000000000002e41 < y < 1.1e47Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in y around 0
Applied rewrites65.9%
Applied rewrites66.0%
if 1.1e47 < y Initial program 99.9%
Taylor expanded in z around 0
Applied rewrites67.4%
Applied rewrites67.4%
Applied rewrites67.4%
(FPCore (x y z) :precision binary64 (if (<= y -1.52e+41) (fma y 2.0 z) (if (<= y 8.5e+55) (fma x 3.0 z) (fma y 2.0 z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.52e+41) {
tmp = fma(y, 2.0, z);
} else if (y <= 8.5e+55) {
tmp = fma(x, 3.0, z);
} else {
tmp = fma(y, 2.0, z);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -1.52e+41) tmp = fma(y, 2.0, z); elseif (y <= 8.5e+55) tmp = fma(x, 3.0, z); else tmp = fma(y, 2.0, z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -1.52e+41], N[(y * 2.0 + z), $MachinePrecision], If[LessEqual[y, 8.5e+55], N[(x * 3.0 + z), $MachinePrecision], N[(y * 2.0 + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.52 \cdot 10^{+41}:\\
\;\;\;\;\mathsf{fma}\left(y, 2, z\right)\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{+55}:\\
\;\;\;\;\mathsf{fma}\left(x, 3, z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, 2, z\right)\\
\end{array}
\end{array}
if y < -1.52000000000000002e41 or 8.50000000000000002e55 < y Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites67.1%
Applied rewrites67.1%
if -1.52000000000000002e41 < y < 8.50000000000000002e55Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in y around 0
Applied rewrites65.9%
Applied rewrites66.0%
(FPCore (x y z) :precision binary64 (if (<= x -3.4e+106) (* 3.0 x) (if (<= x 1.05e+154) (fma y 2.0 z) (* 3.0 x))))
double code(double x, double y, double z) {
double tmp;
if (x <= -3.4e+106) {
tmp = 3.0 * x;
} else if (x <= 1.05e+154) {
tmp = fma(y, 2.0, z);
} else {
tmp = 3.0 * x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -3.4e+106) tmp = Float64(3.0 * x); elseif (x <= 1.05e+154) tmp = fma(y, 2.0, z); else tmp = Float64(3.0 * x); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -3.4e+106], N[(3.0 * x), $MachinePrecision], If[LessEqual[x, 1.05e+154], N[(y * 2.0 + z), $MachinePrecision], N[(3.0 * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.4 \cdot 10^{+106}:\\
\;\;\;\;3 \cdot x\\
\mathbf{elif}\;x \leq 1.05 \cdot 10^{+154}:\\
\;\;\;\;\mathsf{fma}\left(y, 2, z\right)\\
\mathbf{else}:\\
\;\;\;\;3 \cdot x\\
\end{array}
\end{array}
if x < -3.39999999999999994e106 or 1.04999999999999997e154 < x Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites34.2%
if -3.39999999999999994e106 < x < 1.04999999999999997e154Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites67.1%
Applied rewrites67.1%
(FPCore (x y z) :precision binary64 (if (<= y -3.05e+38) (+ y y) (if (<= y -1.12e-256) (* 3.0 x) (if (<= y 2.2e+47) (+ z x) (+ y y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.05e+38) {
tmp = y + y;
} else if (y <= -1.12e-256) {
tmp = 3.0 * x;
} else if (y <= 2.2e+47) {
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 <= (-3.05d+38)) then
tmp = y + y
else if (y <= (-1.12d-256)) then
tmp = 3.0d0 * x
else if (y <= 2.2d+47) 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 <= -3.05e+38) {
tmp = y + y;
} else if (y <= -1.12e-256) {
tmp = 3.0 * x;
} else if (y <= 2.2e+47) {
tmp = z + x;
} else {
tmp = y + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.05e+38: tmp = y + y elif y <= -1.12e-256: tmp = 3.0 * x elif y <= 2.2e+47: tmp = z + x else: tmp = y + y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.05e+38) tmp = Float64(y + y); elseif (y <= -1.12e-256) tmp = Float64(3.0 * x); elseif (y <= 2.2e+47) 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 <= -3.05e+38) tmp = y + y; elseif (y <= -1.12e-256) tmp = 3.0 * x; elseif (y <= 2.2e+47) tmp = z + x; else tmp = y + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.05e+38], N[(y + y), $MachinePrecision], If[LessEqual[y, -1.12e-256], N[(3.0 * x), $MachinePrecision], If[LessEqual[y, 2.2e+47], N[(z + x), $MachinePrecision], N[(y + y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.05 \cdot 10^{+38}:\\
\;\;\;\;y + y\\
\mathbf{elif}\;y \leq -1.12 \cdot 10^{-256}:\\
\;\;\;\;3 \cdot x\\
\mathbf{elif}\;y \leq 2.2 \cdot 10^{+47}:\\
\;\;\;\;z + x\\
\mathbf{else}:\\
\;\;\;\;y + y\\
\end{array}
\end{array}
if y < -3.05e38 or 2.1999999999999999e47 < y Initial program 99.9%
Taylor expanded in z around 0
Applied rewrites67.4%
Applied rewrites67.4%
Taylor expanded in x around 0
Applied rewrites35.2%
Applied rewrites35.2%
if -3.05e38 < y < -1.12e-256Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites34.2%
if -1.12e-256 < y < 2.1999999999999999e47Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites65.9%
Taylor expanded in x around 0
Applied rewrites38.7%
(FPCore (x y z) :precision binary64 (if (<= y -2.7e+41) (+ y y) (if (<= y 2.2e+47) (+ z x) (+ y y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.7e+41) {
tmp = y + y;
} else if (y <= 2.2e+47) {
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 <= (-2.7d+41)) then
tmp = y + y
else if (y <= 2.2d+47) 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 <= -2.7e+41) {
tmp = y + y;
} else if (y <= 2.2e+47) {
tmp = z + x;
} else {
tmp = y + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.7e+41: tmp = y + y elif y <= 2.2e+47: tmp = z + x else: tmp = y + y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.7e+41) tmp = Float64(y + y); elseif (y <= 2.2e+47) 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 <= -2.7e+41) tmp = y + y; elseif (y <= 2.2e+47) tmp = z + x; else tmp = y + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.7e+41], N[(y + y), $MachinePrecision], If[LessEqual[y, 2.2e+47], N[(z + x), $MachinePrecision], N[(y + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{+41}:\\
\;\;\;\;y + y\\
\mathbf{elif}\;y \leq 2.2 \cdot 10^{+47}:\\
\;\;\;\;z + x\\
\mathbf{else}:\\
\;\;\;\;y + y\\
\end{array}
\end{array}
if y < -2.7e41 or 2.1999999999999999e47 < y Initial program 99.9%
Taylor expanded in z around 0
Applied rewrites67.4%
Applied rewrites67.4%
Taylor expanded in x around 0
Applied rewrites35.2%
Applied rewrites35.2%
if -2.7e41 < y < 2.1999999999999999e47Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites65.9%
Taylor expanded in x around 0
Applied rewrites38.7%
(FPCore (x y z) :precision binary64 (if (<= y -2.35e+41) (+ y y) (if (<= y 3.7e+22) z (+ y y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.35e+41) {
tmp = y + y;
} else if (y <= 3.7e+22) {
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 <= (-2.35d+41)) then
tmp = y + y
else if (y <= 3.7d+22) 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 <= -2.35e+41) {
tmp = y + y;
} else if (y <= 3.7e+22) {
tmp = z;
} else {
tmp = y + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.35e+41: tmp = y + y elif y <= 3.7e+22: tmp = z else: tmp = y + y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.35e+41) tmp = Float64(y + y); elseif (y <= 3.7e+22) tmp = z; else tmp = Float64(y + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.35e+41) tmp = y + y; elseif (y <= 3.7e+22) tmp = z; else tmp = y + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.35e+41], N[(y + y), $MachinePrecision], If[LessEqual[y, 3.7e+22], z, N[(y + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.35 \cdot 10^{+41}:\\
\;\;\;\;y + y\\
\mathbf{elif}\;y \leq 3.7 \cdot 10^{+22}:\\
\;\;\;\;z\\
\mathbf{else}:\\
\;\;\;\;y + y\\
\end{array}
\end{array}
if y < -2.35e41 or 3.6999999999999998e22 < y Initial program 99.9%
Taylor expanded in z around 0
Applied rewrites67.4%
Applied rewrites67.4%
Taylor expanded in x around 0
Applied rewrites35.2%
Applied rewrites35.2%
if -2.35e41 < y < 3.6999999999999998e22Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in y around 0
Applied rewrites65.9%
Applied rewrites66.0%
Taylor expanded in x around 0
Applied rewrites33.7%
(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
Applied rewrites99.9%
Taylor expanded in y around 0
Applied rewrites65.9%
Applied rewrites66.0%
Taylor expanded in x around 0
Applied rewrites33.7%
herbie shell --seed 2025161
(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))