
(FPCore (x y z t) :precision binary64 (+ (* x (+ (+ (+ (+ y z) z) y) t)) (* y 5.0)))
double code(double x, double y, double z, double t) {
return (x * ((((y + z) + z) + y) + t)) + (y * 5.0);
}
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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x * ((((y + z) + z) + y) + t)) + (y * 5.0d0)
end function
public static double code(double x, double y, double z, double t) {
return (x * ((((y + z) + z) + y) + t)) + (y * 5.0);
}
def code(x, y, z, t): return (x * ((((y + z) + z) + y) + t)) + (y * 5.0)
function code(x, y, z, t) return Float64(Float64(x * Float64(Float64(Float64(Float64(y + z) + z) + y) + t)) + Float64(y * 5.0)) end
function tmp = code(x, y, z, t) tmp = (x * ((((y + z) + z) + y) + t)) + (y * 5.0); end
code[x_, y_, z_, t_] := N[(N[(x * N[(N[(N[(N[(y + z), $MachinePrecision] + z), $MachinePrecision] + y), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision] + N[(y * 5.0), $MachinePrecision]), $MachinePrecision]
x \cdot \left(\left(\left(\left(y + z\right) + z\right) + y\right) + t\right) + y \cdot 5
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ (* x (+ (+ (+ (+ y z) z) y) t)) (* y 5.0)))
double code(double x, double y, double z, double t) {
return (x * ((((y + z) + z) + y) + t)) + (y * 5.0);
}
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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x * ((((y + z) + z) + y) + t)) + (y * 5.0d0)
end function
public static double code(double x, double y, double z, double t) {
return (x * ((((y + z) + z) + y) + t)) + (y * 5.0);
}
def code(x, y, z, t): return (x * ((((y + z) + z) + y) + t)) + (y * 5.0)
function code(x, y, z, t) return Float64(Float64(x * Float64(Float64(Float64(Float64(y + z) + z) + y) + t)) + Float64(y * 5.0)) end
function tmp = code(x, y, z, t) tmp = (x * ((((y + z) + z) + y) + t)) + (y * 5.0); end
code[x_, y_, z_, t_] := N[(N[(x * N[(N[(N[(N[(y + z), $MachinePrecision] + z), $MachinePrecision] + y), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision] + N[(y * 5.0), $MachinePrecision]), $MachinePrecision]
x \cdot \left(\left(\left(\left(y + z\right) + z\right) + y\right) + t\right) + y \cdot 5
(FPCore (x y z t) :precision binary64 (fma y 5.0 (* (fma 2.0 (+ z y) t) x)))
double code(double x, double y, double z, double t) {
return fma(y, 5.0, (fma(2.0, (z + y), t) * x));
}
function code(x, y, z, t) return fma(y, 5.0, Float64(fma(2.0, Float64(z + y), t) * x)) end
code[x_, y_, z_, t_] := N[(y * 5.0 + N[(N[(2.0 * N[(z + y), $MachinePrecision] + t), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]
\mathsf{fma}\left(y, 5, \mathsf{fma}\left(2, z + y, t\right) \cdot x\right)
Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64100.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f64100.0
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lift-+.f64N/A
count-2N/A
lower-fma.f64100.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
(FPCore (x y z t) :precision binary64 (if (<= y -1.35e+74) (fma 5.0 y (* x (+ t (* 2.0 y)))) (fma y 5.0 (* (fma 2.0 z t) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.35e+74) {
tmp = fma(5.0, y, (x * (t + (2.0 * y))));
} else {
tmp = fma(y, 5.0, (fma(2.0, z, t) * x));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -1.35e+74) tmp = fma(5.0, y, Float64(x * Float64(t + Float64(2.0 * y)))); else tmp = fma(y, 5.0, Float64(fma(2.0, z, t) * x)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.35e+74], N[(5.0 * y + N[(x * N[(t + N[(2.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * 5.0 + N[(N[(2.0 * z + t), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;y \leq -1.35 \cdot 10^{+74}:\\
\;\;\;\;\mathsf{fma}\left(5, y, x \cdot \left(t + 2 \cdot y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, 5, \mathsf{fma}\left(2, z, t\right) \cdot x\right)\\
\end{array}
if y < -1.3499999999999999e74Initial program 99.9%
Taylor expanded in z around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6474.1
Applied rewrites74.1%
if -1.3499999999999999e74 < y Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64100.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f64100.0
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lift-+.f64N/A
count-2N/A
lower-fma.f64100.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites84.8%
(FPCore (x y z t) :precision binary64 (if (<= y -1.35e+74) (fma (fma 2.0 y t) x (* 5.0 y)) (fma y 5.0 (* (fma 2.0 z t) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.35e+74) {
tmp = fma(fma(2.0, y, t), x, (5.0 * y));
} else {
tmp = fma(y, 5.0, (fma(2.0, z, t) * x));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -1.35e+74) tmp = fma(fma(2.0, y, t), x, Float64(5.0 * y)); else tmp = fma(y, 5.0, Float64(fma(2.0, z, t) * x)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.35e+74], N[(N[(2.0 * y + t), $MachinePrecision] * x + N[(5.0 * y), $MachinePrecision]), $MachinePrecision], N[(y * 5.0 + N[(N[(2.0 * z + t), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;y \leq -1.35 \cdot 10^{+74}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(2, y, t\right), x, 5 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, 5, \mathsf{fma}\left(2, z, t\right) \cdot x\right)\\
\end{array}
if y < -1.3499999999999999e74Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64100.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f64100.0
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lift-+.f64N/A
count-2N/A
lower-fma.f64100.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in z around 0
lower-+.f64N/A
lower-*.f6474.1
Applied rewrites74.1%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
Applied rewrites74.0%
if -1.3499999999999999e74 < y Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64100.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f64100.0
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lift-+.f64N/A
count-2N/A
lower-fma.f64100.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites84.8%
(FPCore (x y z t) :precision binary64 (if (<= y -1.35e+74) (fma (+ 5.0 x) y (* x y)) (fma y 5.0 (* (fma 2.0 z t) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.35e+74) {
tmp = fma((5.0 + x), y, (x * y));
} else {
tmp = fma(y, 5.0, (fma(2.0, z, t) * x));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -1.35e+74) tmp = fma(Float64(5.0 + x), y, Float64(x * y)); else tmp = fma(y, 5.0, Float64(fma(2.0, z, t) * x)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.35e+74], N[(N[(5.0 + x), $MachinePrecision] * y + N[(x * y), $MachinePrecision]), $MachinePrecision], N[(y * 5.0 + N[(N[(2.0 * z + t), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;y \leq -1.35 \cdot 10^{+74}:\\
\;\;\;\;\mathsf{fma}\left(5 + x, y, x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, 5, \mathsf{fma}\left(2, z, t\right) \cdot x\right)\\
\end{array}
if y < -1.3499999999999999e74Initial program 99.9%
Taylor expanded in y around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6448.0
Applied rewrites48.0%
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
count-2-revN/A
associate-+r+N/A
distribute-rgt-inN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-*.f6448.0
Applied rewrites48.0%
if -1.3499999999999999e74 < y Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64100.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f64100.0
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lift-+.f64N/A
count-2N/A
lower-fma.f64100.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites84.8%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (fma (+ 5.0 x) y (* x y)))) (if (<= y -1.22e-8) t_1 (if (<= y 5.2e+94) (* x (+ t (* 2.0 z))) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma((5.0 + x), y, (x * y));
double tmp;
if (y <= -1.22e-8) {
tmp = t_1;
} else if (y <= 5.2e+94) {
tmp = x * (t + (2.0 * z));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(Float64(5.0 + x), y, Float64(x * y)) tmp = 0.0 if (y <= -1.22e-8) tmp = t_1; elseif (y <= 5.2e+94) tmp = Float64(x * Float64(t + Float64(2.0 * z))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(5.0 + x), $MachinePrecision] * y + N[(x * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.22e-8], t$95$1, If[LessEqual[y, 5.2e+94], N[(x * N[(t + N[(2.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(5 + x, y, x \cdot y\right)\\
\mathbf{if}\;y \leq -1.22 \cdot 10^{-8}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 5.2 \cdot 10^{+94}:\\
\;\;\;\;x \cdot \left(t + 2 \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if y < -1.22e-8 or 5.1999999999999998e94 < y Initial program 99.9%
Taylor expanded in y around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6448.0
Applied rewrites48.0%
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
count-2-revN/A
associate-+r+N/A
distribute-rgt-inN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-*.f6448.0
Applied rewrites48.0%
if -1.22e-8 < y < 5.1999999999999998e94Initial program 99.9%
Taylor expanded in y around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6456.8
Applied rewrites56.8%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (fma x 2.0 5.0) y))) (if (<= y -1.22e-8) t_1 (if (<= y 5.2e+94) (* x (+ t (* 2.0 z))) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma(x, 2.0, 5.0) * y;
double tmp;
if (y <= -1.22e-8) {
tmp = t_1;
} else if (y <= 5.2e+94) {
tmp = x * (t + (2.0 * z));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(fma(x, 2.0, 5.0) * y) tmp = 0.0 if (y <= -1.22e-8) tmp = t_1; elseif (y <= 5.2e+94) tmp = Float64(x * Float64(t + Float64(2.0 * z))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * 2.0 + 5.0), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[y, -1.22e-8], t$95$1, If[LessEqual[y, 5.2e+94], N[(x * N[(t + N[(2.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(x, 2, 5\right) \cdot y\\
\mathbf{if}\;y \leq -1.22 \cdot 10^{-8}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 5.2 \cdot 10^{+94}:\\
\;\;\;\;x \cdot \left(t + 2 \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if y < -1.22e-8 or 5.1999999999999998e94 < y Initial program 99.9%
Taylor expanded in y around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6448.0
Applied rewrites48.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6448.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6448.0
Applied rewrites48.0%
if -1.22e-8 < y < 5.1999999999999998e94Initial program 99.9%
Taylor expanded in y around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6456.8
Applied rewrites56.8%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (+ z z) x))) (if (<= z -5.2e+161) t_1 (if (<= z 1.56e+147) (fma y 5.0 (* t x)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (z + z) * x;
double tmp;
if (z <= -5.2e+161) {
tmp = t_1;
} else if (z <= 1.56e+147) {
tmp = fma(y, 5.0, (t * x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(z + z) * x) tmp = 0.0 if (z <= -5.2e+161) tmp = t_1; elseif (z <= 1.56e+147) tmp = fma(y, 5.0, Float64(t * x)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z + z), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[z, -5.2e+161], t$95$1, If[LessEqual[z, 1.56e+147], N[(y * 5.0 + N[(t * x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \left(z + z\right) \cdot x\\
\mathbf{if}\;z \leq -5.2 \cdot 10^{+161}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.56 \cdot 10^{+147}:\\
\;\;\;\;\mathsf{fma}\left(y, 5, t \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if z < -5.1999999999999996e161 or 1.56e147 < z Initial program 99.9%
Taylor expanded in z around inf
lower-*.f64N/A
lower-*.f6430.9
Applied rewrites30.9%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6430.9
lift-*.f64N/A
count-2-revN/A
lower-+.f6430.9
Applied rewrites30.9%
if -5.1999999999999996e161 < z < 1.56e147Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64100.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f64100.0
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
+-commutativeN/A
lift-+.f64N/A
count-2N/A
lower-fma.f64100.0
lift-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in z around 0
lower-+.f64N/A
lower-*.f6474.1
Applied rewrites74.1%
Taylor expanded in y around 0
Applied rewrites58.0%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (fma x 2.0 5.0) y))) (if (<= y -1.22e-8) t_1 (if (<= y 1.7e-48) (* t x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma(x, 2.0, 5.0) * y;
double tmp;
if (y <= -1.22e-8) {
tmp = t_1;
} else if (y <= 1.7e-48) {
tmp = t * x;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(fma(x, 2.0, 5.0) * y) tmp = 0.0 if (y <= -1.22e-8) tmp = t_1; elseif (y <= 1.7e-48) tmp = Float64(t * x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * 2.0 + 5.0), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[y, -1.22e-8], t$95$1, If[LessEqual[y, 1.7e-48], N[(t * x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(x, 2, 5\right) \cdot y\\
\mathbf{if}\;y \leq -1.22 \cdot 10^{-8}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{-48}:\\
\;\;\;\;t \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if y < -1.22e-8 or 1.70000000000000014e-48 < y Initial program 99.9%
Taylor expanded in y around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6448.0
Applied rewrites48.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6448.0
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6448.0
Applied rewrites48.0%
if -1.22e-8 < y < 1.70000000000000014e-48Initial program 99.9%
Taylor expanded in t around inf
lower-*.f6430.3
Applied rewrites30.3%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (+ z z) x)))
(if (<= z -3.7e+161)
t_1
(if (<= z -1.7)
(* 5.0 y)
(if (<= z 6.6e-157)
(* t x)
(if (<= z 1.9e-24) (* 5.0 y) (if (<= z 3.2e+39) (* t x) t_1)))))))double code(double x, double y, double z, double t) {
double t_1 = (z + z) * x;
double tmp;
if (z <= -3.7e+161) {
tmp = t_1;
} else if (z <= -1.7) {
tmp = 5.0 * y;
} else if (z <= 6.6e-157) {
tmp = t * x;
} else if (z <= 1.9e-24) {
tmp = 5.0 * y;
} else if (z <= 3.2e+39) {
tmp = t * x;
} else {
tmp = t_1;
}
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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = (z + z) * x
if (z <= (-3.7d+161)) then
tmp = t_1
else if (z <= (-1.7d0)) then
tmp = 5.0d0 * y
else if (z <= 6.6d-157) then
tmp = t * x
else if (z <= 1.9d-24) then
tmp = 5.0d0 * y
else if (z <= 3.2d+39) then
tmp = t * x
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (z + z) * x;
double tmp;
if (z <= -3.7e+161) {
tmp = t_1;
} else if (z <= -1.7) {
tmp = 5.0 * y;
} else if (z <= 6.6e-157) {
tmp = t * x;
} else if (z <= 1.9e-24) {
tmp = 5.0 * y;
} else if (z <= 3.2e+39) {
tmp = t * x;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = (z + z) * x tmp = 0 if z <= -3.7e+161: tmp = t_1 elif z <= -1.7: tmp = 5.0 * y elif z <= 6.6e-157: tmp = t * x elif z <= 1.9e-24: tmp = 5.0 * y elif z <= 3.2e+39: tmp = t * x else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(z + z) * x) tmp = 0.0 if (z <= -3.7e+161) tmp = t_1; elseif (z <= -1.7) tmp = Float64(5.0 * y); elseif (z <= 6.6e-157) tmp = Float64(t * x); elseif (z <= 1.9e-24) tmp = Float64(5.0 * y); elseif (z <= 3.2e+39) tmp = Float64(t * x); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (z + z) * x; tmp = 0.0; if (z <= -3.7e+161) tmp = t_1; elseif (z <= -1.7) tmp = 5.0 * y; elseif (z <= 6.6e-157) tmp = t * x; elseif (z <= 1.9e-24) tmp = 5.0 * y; elseif (z <= 3.2e+39) tmp = t * x; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z + z), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[z, -3.7e+161], t$95$1, If[LessEqual[z, -1.7], N[(5.0 * y), $MachinePrecision], If[LessEqual[z, 6.6e-157], N[(t * x), $MachinePrecision], If[LessEqual[z, 1.9e-24], N[(5.0 * y), $MachinePrecision], If[LessEqual[z, 3.2e+39], N[(t * x), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
t_1 := \left(z + z\right) \cdot x\\
\mathbf{if}\;z \leq -3.7 \cdot 10^{+161}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -1.7:\\
\;\;\;\;5 \cdot y\\
\mathbf{elif}\;z \leq 6.6 \cdot 10^{-157}:\\
\;\;\;\;t \cdot x\\
\mathbf{elif}\;z \leq 1.9 \cdot 10^{-24}:\\
\;\;\;\;5 \cdot y\\
\mathbf{elif}\;z \leq 3.2 \cdot 10^{+39}:\\
\;\;\;\;t \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if z < -3.69999999999999979e161 or 3.19999999999999993e39 < z Initial program 99.9%
Taylor expanded in z around inf
lower-*.f64N/A
lower-*.f6430.9
Applied rewrites30.9%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6430.9
lift-*.f64N/A
count-2-revN/A
lower-+.f6430.9
Applied rewrites30.9%
if -3.69999999999999979e161 < z < -1.69999999999999996 or 6.59999999999999998e-157 < z < 1.90000000000000013e-24Initial program 99.9%
Taylor expanded in x around 0
lower-*.f6430.0
Applied rewrites30.0%
if -1.69999999999999996 < z < 6.59999999999999998e-157 or 1.90000000000000013e-24 < z < 3.19999999999999993e39Initial program 99.9%
Taylor expanded in t around inf
lower-*.f6430.3
Applied rewrites30.3%
(FPCore (x y z t) :precision binary64 (if (<= x -7.6e-7) (* t x) (if (<= x 1.6e-155) (* 5.0 y) (* t x))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -7.6e-7) {
tmp = t * x;
} else if (x <= 1.6e-155) {
tmp = 5.0 * y;
} else {
tmp = t * 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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (x <= (-7.6d-7)) then
tmp = t * x
else if (x <= 1.6d-155) then
tmp = 5.0d0 * y
else
tmp = t * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -7.6e-7) {
tmp = t * x;
} else if (x <= 1.6e-155) {
tmp = 5.0 * y;
} else {
tmp = t * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -7.6e-7: tmp = t * x elif x <= 1.6e-155: tmp = 5.0 * y else: tmp = t * x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -7.6e-7) tmp = Float64(t * x); elseif (x <= 1.6e-155) tmp = Float64(5.0 * y); else tmp = Float64(t * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -7.6e-7) tmp = t * x; elseif (x <= 1.6e-155) tmp = 5.0 * y; else tmp = t * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -7.6e-7], N[(t * x), $MachinePrecision], If[LessEqual[x, 1.6e-155], N[(5.0 * y), $MachinePrecision], N[(t * x), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;x \leq -7.6 \cdot 10^{-7}:\\
\;\;\;\;t \cdot x\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{-155}:\\
\;\;\;\;5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;t \cdot x\\
\end{array}
if x < -7.60000000000000029e-7 or 1.60000000000000006e-155 < x Initial program 99.9%
Taylor expanded in t around inf
lower-*.f6430.3
Applied rewrites30.3%
if -7.60000000000000029e-7 < x < 1.60000000000000006e-155Initial program 99.9%
Taylor expanded in x around 0
lower-*.f6430.0
Applied rewrites30.0%
(FPCore (x y z t) :precision binary64 (* 5.0 y))
double code(double x, double y, double z, double t) {
return 5.0 * y;
}
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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = 5.0d0 * y
end function
public static double code(double x, double y, double z, double t) {
return 5.0 * y;
}
def code(x, y, z, t): return 5.0 * y
function code(x, y, z, t) return Float64(5.0 * y) end
function tmp = code(x, y, z, t) tmp = 5.0 * y; end
code[x_, y_, z_, t_] := N[(5.0 * y), $MachinePrecision]
5 \cdot y
Initial program 99.9%
Taylor expanded in x around 0
lower-*.f6430.0
Applied rewrites30.0%
herbie shell --seed 2025172
(FPCore (x y z t)
:name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendOutside from plot-0.2.3.4, B"
:precision binary64
(+ (* x (+ (+ (+ (+ y z) z) y) t)) (* y 5.0)))