
(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 2.0 x z) (fma 2.0 y x)))
double code(double x, double y, double z) {
return fma(2.0, x, z) + fma(2.0, y, x);
}
function code(x, y, z) return Float64(fma(2.0, x, z) + fma(2.0, y, x)) end
code[x_, y_, z_] := N[(N[(2.0 * x + z), $MachinePrecision] + N[(2.0 * y + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(2, x, z\right) + \mathsf{fma}\left(2, y, x\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-+r+N/A
associate-+l+N/A
+-commutativeN/A
count-2-revN/A
associate-+l+N/A
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
associate-+l+N/A
count-2-revN/A
+-commutativeN/A
lower-fma.f6499.9
Applied rewrites99.9%
(FPCore (x y z) :precision binary64 (if (<= x -8.2e-22) (+ (+ x x) (fma 2.0 y x)) (if (<= x 5.5e+42) (fma 2.0 y z) (fma 3.0 x (+ y y)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -8.2e-22) {
tmp = (x + x) + fma(2.0, y, x);
} else if (x <= 5.5e+42) {
tmp = fma(2.0, y, z);
} else {
tmp = fma(3.0, x, (y + y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -8.2e-22) tmp = Float64(Float64(x + x) + fma(2.0, y, x)); elseif (x <= 5.5e+42) tmp = fma(2.0, y, z); else tmp = fma(3.0, x, Float64(y + y)); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -8.2e-22], N[(N[(x + x), $MachinePrecision] + N[(2.0 * y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.5e+42], N[(2.0 * y + z), $MachinePrecision], N[(3.0 * x + N[(y + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.2 \cdot 10^{-22}:\\
\;\;\;\;\left(x + x\right) + \mathsf{fma}\left(2, y, x\right)\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{+42}:\\
\;\;\;\;\mathsf{fma}\left(2, y, z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(3, x, y + y\right)\\
\end{array}
\end{array}
if x < -8.1999999999999999e-22Initial program 99.8%
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-+r+N/A
associate-+l+N/A
+-commutativeN/A
count-2-revN/A
associate-+l+N/A
lower-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
associate-+l+N/A
count-2-revN/A
+-commutativeN/A
lower-fma.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
count-2-revN/A
lower-+.f6478.8
Applied rewrites78.8%
if -8.1999999999999999e-22 < x < 5.50000000000000001e42Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f6490.8
Applied rewrites90.8%
if 5.50000000000000001e42 < x Initial program 99.8%
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-+.f6481.5
Applied rewrites81.5%
(FPCore (x y z) :precision binary64 (let* ((t_0 (fma 3.0 x (+ y y)))) (if (<= x -8.2e-22) t_0 (if (<= x 5.5e+42) (fma 2.0 y z) t_0))))
double code(double x, double y, double z) {
double t_0 = fma(3.0, x, (y + y));
double tmp;
if (x <= -8.2e-22) {
tmp = t_0;
} else if (x <= 5.5e+42) {
tmp = fma(2.0, y, 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 (x <= -8.2e-22) tmp = t_0; elseif (x <= 5.5e+42) tmp = fma(2.0, y, 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[x, -8.2e-22], t$95$0, If[LessEqual[x, 5.5e+42], N[(2.0 * y + z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(3, x, y + y\right)\\
\mathbf{if}\;x \leq -8.2 \cdot 10^{-22}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{+42}:\\
\;\;\;\;\mathsf{fma}\left(2, y, z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -8.1999999999999999e-22 or 5.50000000000000001e42 < x Initial program 99.8%
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-+.f6480.0
Applied rewrites80.0%
if -8.1999999999999999e-22 < x < 5.50000000000000001e42Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f6490.8
Applied rewrites90.8%
(FPCore (x y z) :precision binary64 (if (<= x -9.8e+23) (fma 3.0 x z) (if (<= x 9.5e+78) (fma 2.0 y z) (fma 3.0 x z))))
double code(double x, double y, double z) {
double tmp;
if (x <= -9.8e+23) {
tmp = fma(3.0, x, z);
} else if (x <= 9.5e+78) {
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 <= -9.8e+23) tmp = fma(3.0, x, z); elseif (x <= 9.5e+78) tmp = fma(2.0, y, z); else tmp = fma(3.0, x, z); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -9.8e+23], N[(3.0 * x + z), $MachinePrecision], If[LessEqual[x, 9.5e+78], N[(2.0 * y + z), $MachinePrecision], N[(3.0 * x + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.8 \cdot 10^{+23}:\\
\;\;\;\;\mathsf{fma}\left(3, x, z\right)\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{+78}:\\
\;\;\;\;\mathsf{fma}\left(2, y, z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(3, x, z\right)\\
\end{array}
\end{array}
if x < -9.8000000000000006e23 or 9.5000000000000006e78 < x Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
associate-+r+N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-fma.f6480.6
Applied rewrites80.6%
if -9.8000000000000006e23 < x < 9.5000000000000006e78Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f6488.5
Applied rewrites88.5%
(FPCore (x y z) :precision binary64 (if (<= x -1.4e+137) (* 3.0 x) (if (<= x 1.6e+79) (fma 2.0 y z) (* 3.0 x))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.4e+137) {
tmp = 3.0 * x;
} else if (x <= 1.6e+79) {
tmp = fma(2.0, y, z);
} else {
tmp = 3.0 * x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -1.4e+137) tmp = Float64(3.0 * x); elseif (x <= 1.6e+79) tmp = fma(2.0, y, z); else tmp = Float64(3.0 * x); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -1.4e+137], N[(3.0 * x), $MachinePrecision], If[LessEqual[x, 1.6e+79], N[(2.0 * y + z), $MachinePrecision], N[(3.0 * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.4 \cdot 10^{+137}:\\
\;\;\;\;3 \cdot x\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{+79}:\\
\;\;\;\;\mathsf{fma}\left(2, y, z\right)\\
\mathbf{else}:\\
\;\;\;\;3 \cdot x\\
\end{array}
\end{array}
if x < -1.4e137 or 1.60000000000000001e79 < x Initial program 99.8%
Taylor expanded in x around inf
lower-*.f6469.4
Applied rewrites69.4%
if -1.4e137 < x < 1.60000000000000001e79Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f6484.7
Applied rewrites84.7%
(FPCore (x y z)
:precision binary64
(if (<= y -3.2e+76)
(+ y y)
(if (<= y -2.4e-110)
(+ z x)
(if (<= y -8.5e-219) (* 3.0 x) (if (<= y 2.6e+74) (+ z x) (+ y y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.2e+76) {
tmp = y + y;
} else if (y <= -2.4e-110) {
tmp = z + x;
} else if (y <= -8.5e-219) {
tmp = 3.0 * x;
} else if (y <= 2.6e+74) {
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.2d+76)) then
tmp = y + y
else if (y <= (-2.4d-110)) then
tmp = z + x
else if (y <= (-8.5d-219)) then
tmp = 3.0d0 * x
else if (y <= 2.6d+74) 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.2e+76) {
tmp = y + y;
} else if (y <= -2.4e-110) {
tmp = z + x;
} else if (y <= -8.5e-219) {
tmp = 3.0 * x;
} else if (y <= 2.6e+74) {
tmp = z + x;
} else {
tmp = y + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.2e+76: tmp = y + y elif y <= -2.4e-110: tmp = z + x elif y <= -8.5e-219: tmp = 3.0 * x elif y <= 2.6e+74: tmp = z + x else: tmp = y + y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.2e+76) tmp = Float64(y + y); elseif (y <= -2.4e-110) tmp = Float64(z + x); elseif (y <= -8.5e-219) tmp = Float64(3.0 * x); elseif (y <= 2.6e+74) 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.2e+76) tmp = y + y; elseif (y <= -2.4e-110) tmp = z + x; elseif (y <= -8.5e-219) tmp = 3.0 * x; elseif (y <= 2.6e+74) tmp = z + x; else tmp = y + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.2e+76], N[(y + y), $MachinePrecision], If[LessEqual[y, -2.4e-110], N[(z + x), $MachinePrecision], If[LessEqual[y, -8.5e-219], N[(3.0 * x), $MachinePrecision], If[LessEqual[y, 2.6e+74], N[(z + x), $MachinePrecision], N[(y + y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.2 \cdot 10^{+76}:\\
\;\;\;\;y + y\\
\mathbf{elif}\;y \leq -2.4 \cdot 10^{-110}:\\
\;\;\;\;z + x\\
\mathbf{elif}\;y \leq -8.5 \cdot 10^{-219}:\\
\;\;\;\;3 \cdot x\\
\mathbf{elif}\;y \leq 2.6 \cdot 10^{+74}:\\
\;\;\;\;z + x\\
\mathbf{else}:\\
\;\;\;\;y + y\\
\end{array}
\end{array}
if y < -3.19999999999999976e76 or 2.6000000000000001e74 < y Initial program 99.9%
Taylor expanded in y around inf
count-2-revN/A
lower-+.f6466.9
Applied rewrites66.9%
if -3.19999999999999976e76 < y < -2.40000000000000006e-110 or -8.49999999999999964e-219 < y < 2.6000000000000001e74Initial program 99.9%
Taylor expanded in z around inf
Applied rewrites49.7%
if -2.40000000000000006e-110 < y < -8.49999999999999964e-219Initial program 99.8%
Taylor expanded in x around inf
lower-*.f6445.8
Applied rewrites45.8%
(FPCore (x y z) :precision binary64 (if (<= y -3.2e+76) (+ y y) (if (<= y 2.6e+74) (+ z x) (+ y y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.2e+76) {
tmp = y + y;
} else if (y <= 2.6e+74) {
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.2d+76)) then
tmp = y + y
else if (y <= 2.6d+74) 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.2e+76) {
tmp = y + y;
} else if (y <= 2.6e+74) {
tmp = z + x;
} else {
tmp = y + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.2e+76: tmp = y + y elif y <= 2.6e+74: tmp = z + x else: tmp = y + y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.2e+76) tmp = Float64(y + y); elseif (y <= 2.6e+74) 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.2e+76) tmp = y + y; elseif (y <= 2.6e+74) tmp = z + x; else tmp = y + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.2e+76], N[(y + y), $MachinePrecision], If[LessEqual[y, 2.6e+74], N[(z + x), $MachinePrecision], N[(y + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.2 \cdot 10^{+76}:\\
\;\;\;\;y + y\\
\mathbf{elif}\;y \leq 2.6 \cdot 10^{+74}:\\
\;\;\;\;z + x\\
\mathbf{else}:\\
\;\;\;\;y + y\\
\end{array}
\end{array}
if y < -3.19999999999999976e76 or 2.6000000000000001e74 < y Initial program 99.9%
Taylor expanded in y around inf
count-2-revN/A
lower-+.f6466.9
Applied rewrites66.9%
if -3.19999999999999976e76 < y < 2.6000000000000001e74Initial program 99.9%
Taylor expanded in z around inf
Applied rewrites50.6%
(FPCore (x y z) :precision binary64 (if (<= y -3.4e+74) (+ y y) (if (<= y 2.3e+74) z (+ y y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.4e+74) {
tmp = y + y;
} else if (y <= 2.3e+74) {
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.4d+74)) then
tmp = y + y
else if (y <= 2.3d+74) 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.4e+74) {
tmp = y + y;
} else if (y <= 2.3e+74) {
tmp = z;
} else {
tmp = y + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.4e+74: tmp = y + y elif y <= 2.3e+74: tmp = z else: tmp = y + y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.4e+74) tmp = Float64(y + y); elseif (y <= 2.3e+74) tmp = z; else tmp = Float64(y + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.4e+74) tmp = y + y; elseif (y <= 2.3e+74) tmp = z; else tmp = y + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.4e+74], N[(y + y), $MachinePrecision], If[LessEqual[y, 2.3e+74], z, N[(y + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.4 \cdot 10^{+74}:\\
\;\;\;\;y + y\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{+74}:\\
\;\;\;\;z\\
\mathbf{else}:\\
\;\;\;\;y + y\\
\end{array}
\end{array}
if y < -3.3999999999999999e74 or 2.2999999999999999e74 < y Initial program 99.9%
Taylor expanded in y around inf
count-2-revN/A
lower-+.f6466.7
Applied rewrites66.7%
if -3.3999999999999999e74 < y < 2.2999999999999999e74Initial program 99.9%
Taylor expanded in z around inf
Applied rewrites44.2%
(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 rewrites34.2%
herbie shell --seed 2025119
(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))