
(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 y 2.0 (fma 3.0 x z)))
double code(double x, double y, double z) {
return fma(y, 2.0, fma(3.0, x, z));
}
function code(x, y, z) return fma(y, 2.0, fma(3.0, x, z)) end
code[x_, y_, z_] := N[(y * 2.0 + N[(3.0 * x + z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, 2, \mathsf{fma}\left(3, x, z\right)\right)
\end{array}
Initial program 99.9%
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
associate-+l+N/A
+-commutativeN/A
count-2-revN/A
distribute-lft-outN/A
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
associate-+r+N/A
distribute-rgt1-inN/A
metadata-evalN/A
+-commutativeN/A
+-commutativeN/A
associate-+l+N/A
Applied rewrites100.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ (fma 2.0 y z) x))) (if (<= y -1.8e+50) t_0 (if (<= y 1200000.0) (fma 3.0 x z) t_0))))
double code(double x, double y, double z) {
double t_0 = fma(2.0, y, z) + x;
double tmp;
if (y <= -1.8e+50) {
tmp = t_0;
} else if (y <= 1200000.0) {
tmp = fma(3.0, x, z);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(fma(2.0, y, z) + x) tmp = 0.0 if (y <= -1.8e+50) tmp = t_0; elseif (y <= 1200000.0) tmp = fma(3.0, x, z); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(2.0 * y + z), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[y, -1.8e+50], t$95$0, If[LessEqual[y, 1200000.0], N[(3.0 * x + z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(2, y, z\right) + x\\
\mathbf{if}\;y \leq -1.8 \cdot 10^{+50}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1200000:\\
\;\;\;\;\mathsf{fma}\left(3, x, z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.79999999999999993e50 or 1.2e6 < y Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f6483.6
Applied rewrites83.6%
if -1.79999999999999993e50 < y < 1.2e6Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
associate-+r+N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-fma.f6489.5
Applied rewrites89.5%
(FPCore (x y z) :precision binary64 (if (<= y -1.8e+50) (fma 2.0 y z) (if (<= y 28000000000000.0) (fma 3.0 x z) (fma 3.0 x (+ y y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.8e+50) {
tmp = fma(2.0, y, z);
} else if (y <= 28000000000000.0) {
tmp = fma(3.0, x, z);
} else {
tmp = fma(3.0, x, (y + y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -1.8e+50) tmp = fma(2.0, y, z); elseif (y <= 28000000000000.0) tmp = fma(3.0, x, z); else tmp = fma(3.0, x, Float64(y + y)); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -1.8e+50], N[(2.0 * y + z), $MachinePrecision], If[LessEqual[y, 28000000000000.0], N[(3.0 * x + z), $MachinePrecision], N[(3.0 * x + N[(y + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.8 \cdot 10^{+50}:\\
\;\;\;\;\mathsf{fma}\left(2, y, z\right)\\
\mathbf{elif}\;y \leq 28000000000000:\\
\;\;\;\;\mathsf{fma}\left(3, x, z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(3, x, y + y\right)\\
\end{array}
\end{array}
if y < -1.79999999999999993e50Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f6482.0
Applied rewrites82.0%
if -1.79999999999999993e50 < y < 2.8e13Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
associate-+r+N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-fma.f6489.3
Applied rewrites89.3%
if 2.8e13 < 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-+.f6479.2
Applied rewrites79.2%
(FPCore (x y z) :precision binary64 (if (<= y -1.8e+50) (fma 2.0 y z) (if (<= y 2150000.0) (fma 3.0 x z) (fma 2.0 y z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.8e+50) {
tmp = fma(2.0, y, z);
} else if (y <= 2150000.0) {
tmp = fma(3.0, x, z);
} else {
tmp = fma(2.0, y, z);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -1.8e+50) tmp = fma(2.0, y, z); elseif (y <= 2150000.0) tmp = fma(3.0, x, z); else tmp = fma(2.0, y, z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -1.8e+50], N[(2.0 * y + z), $MachinePrecision], If[LessEqual[y, 2150000.0], N[(3.0 * x + z), $MachinePrecision], N[(2.0 * y + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.8 \cdot 10^{+50}:\\
\;\;\;\;\mathsf{fma}\left(2, y, z\right)\\
\mathbf{elif}\;y \leq 2150000:\\
\;\;\;\;\mathsf{fma}\left(3, x, z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(2, y, z\right)\\
\end{array}
\end{array}
if y < -1.79999999999999993e50 or 2.15e6 < y Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f6481.1
Applied rewrites81.1%
if -1.79999999999999993e50 < y < 2.15e6Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
associate-+r+N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-fma.f6489.5
Applied rewrites89.5%
(FPCore (x y z) :precision binary64 (if (<= x -2.4e+150) (* 3.0 x) (if (<= x 1.6e+207) (fma 2.0 y z) (* 3.0 x))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.4e+150) {
tmp = 3.0 * x;
} else if (x <= 1.6e+207) {
tmp = fma(2.0, y, z);
} else {
tmp = 3.0 * x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -2.4e+150) tmp = Float64(3.0 * x); elseif (x <= 1.6e+207) tmp = fma(2.0, y, z); else tmp = Float64(3.0 * x); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -2.4e+150], N[(3.0 * x), $MachinePrecision], If[LessEqual[x, 1.6e+207], N[(2.0 * y + z), $MachinePrecision], N[(3.0 * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.4 \cdot 10^{+150}:\\
\;\;\;\;3 \cdot x\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{+207}:\\
\;\;\;\;\mathsf{fma}\left(2, y, z\right)\\
\mathbf{else}:\\
\;\;\;\;3 \cdot x\\
\end{array}
\end{array}
if x < -2.40000000000000003e150 or 1.6000000000000001e207 < x Initial program 99.8%
Taylor expanded in x around inf
lower-*.f6476.4
Applied rewrites76.4%
if -2.40000000000000003e150 < x < 1.6000000000000001e207Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f6478.5
Applied rewrites78.5%
(FPCore (x y z) :precision binary64 (if (<= y -3.9e+108) (+ y y) (if (<= y -7.8e-292) (+ z x) (if (<= y 2100000.0) (* 3.0 x) (+ y y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.9e+108) {
tmp = y + y;
} else if (y <= -7.8e-292) {
tmp = z + x;
} else if (y <= 2100000.0) {
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 <= (-3.9d+108)) then
tmp = y + y
else if (y <= (-7.8d-292)) then
tmp = z + x
else if (y <= 2100000.0d0) 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 <= -3.9e+108) {
tmp = y + y;
} else if (y <= -7.8e-292) {
tmp = z + x;
} else if (y <= 2100000.0) {
tmp = 3.0 * x;
} else {
tmp = y + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.9e+108: tmp = y + y elif y <= -7.8e-292: tmp = z + x elif y <= 2100000.0: tmp = 3.0 * x else: tmp = y + y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.9e+108) tmp = Float64(y + y); elseif (y <= -7.8e-292) tmp = Float64(z + x); elseif (y <= 2100000.0) 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 <= -3.9e+108) tmp = y + y; elseif (y <= -7.8e-292) tmp = z + x; elseif (y <= 2100000.0) tmp = 3.0 * x; else tmp = y + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.9e+108], N[(y + y), $MachinePrecision], If[LessEqual[y, -7.8e-292], N[(z + x), $MachinePrecision], If[LessEqual[y, 2100000.0], N[(3.0 * x), $MachinePrecision], N[(y + y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.9 \cdot 10^{+108}:\\
\;\;\;\;y + y\\
\mathbf{elif}\;y \leq -7.8 \cdot 10^{-292}:\\
\;\;\;\;z + x\\
\mathbf{elif}\;y \leq 2100000:\\
\;\;\;\;3 \cdot x\\
\mathbf{else}:\\
\;\;\;\;y + y\\
\end{array}
\end{array}
if y < -3.89999999999999985e108 or 2.1e6 < y Initial program 99.9%
Taylor expanded in y around inf
count-2-revN/A
lower-+.f6464.4
Applied rewrites64.4%
if -3.89999999999999985e108 < y < -7.8e-292Initial program 99.9%
Taylor expanded in z around inf
Applied rewrites48.0%
if -7.8e-292 < y < 2.1e6Initial program 99.9%
Taylor expanded in x around inf
lower-*.f6446.4
Applied rewrites46.4%
(FPCore (x y z) :precision binary64 (if (<= y -3.9e+108) (+ y y) (if (<= y 28000000000000.0) (+ z x) (+ y y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.9e+108) {
tmp = y + y;
} else if (y <= 28000000000000.0) {
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.9d+108)) then
tmp = y + y
else if (y <= 28000000000000.0d0) 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.9e+108) {
tmp = y + y;
} else if (y <= 28000000000000.0) {
tmp = z + x;
} else {
tmp = y + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.9e+108: tmp = y + y elif y <= 28000000000000.0: tmp = z + x else: tmp = y + y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.9e+108) tmp = Float64(y + y); elseif (y <= 28000000000000.0) 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.9e+108) tmp = y + y; elseif (y <= 28000000000000.0) tmp = z + x; else tmp = y + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.9e+108], N[(y + y), $MachinePrecision], If[LessEqual[y, 28000000000000.0], N[(z + x), $MachinePrecision], N[(y + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.9 \cdot 10^{+108}:\\
\;\;\;\;y + y\\
\mathbf{elif}\;y \leq 28000000000000:\\
\;\;\;\;z + x\\
\mathbf{else}:\\
\;\;\;\;y + y\\
\end{array}
\end{array}
if y < -3.89999999999999985e108 or 2.8e13 < y Initial program 99.9%
Taylor expanded in y around inf
count-2-revN/A
lower-+.f6464.9
Applied rewrites64.9%
if -3.89999999999999985e108 < y < 2.8e13Initial program 99.9%
Taylor expanded in z around inf
Applied rewrites50.4%
(FPCore (x y z) :precision binary64 (if (<= y -3.1e+108) (+ y y) (if (<= y 28000000000000.0) z (+ y y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.1e+108) {
tmp = y + y;
} else if (y <= 28000000000000.0) {
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 <= (-3.1d+108)) then
tmp = y + y
else if (y <= 28000000000000.0d0) 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 <= -3.1e+108) {
tmp = y + y;
} else if (y <= 28000000000000.0) {
tmp = z;
} else {
tmp = y + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.1e+108: tmp = y + y elif y <= 28000000000000.0: tmp = z else: tmp = y + y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.1e+108) tmp = Float64(y + y); elseif (y <= 28000000000000.0) tmp = z; else tmp = Float64(y + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.1e+108) tmp = y + y; elseif (y <= 28000000000000.0) tmp = z; else tmp = y + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.1e+108], N[(y + y), $MachinePrecision], If[LessEqual[y, 28000000000000.0], z, N[(y + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.1 \cdot 10^{+108}:\\
\;\;\;\;y + y\\
\mathbf{elif}\;y \leq 28000000000000:\\
\;\;\;\;z\\
\mathbf{else}:\\
\;\;\;\;y + y\\
\end{array}
\end{array}
if y < -3.1000000000000001e108 or 2.8e13 < y Initial program 99.9%
Taylor expanded in y around inf
count-2-revN/A
lower-+.f6464.9
Applied rewrites64.9%
if -3.1000000000000001e108 < y < 2.8e13Initial program 99.9%
Taylor expanded in z around inf
Applied rewrites43.9%
(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 z around inf
Applied rewrites33.9%
herbie shell --seed 2025106
(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))