
(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]
\begin{array}{l}
\\
x \cdot \left(\left(\left(\left(y + z\right) + z\right) + y\right) + t\right) + y \cdot 5
\end{array}
Herbie found 12 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]
\begin{array}{l}
\\
x \cdot \left(\left(\left(\left(y + z\right) + z\right) + y\right) + t\right) + y \cdot 5
\end{array}
(FPCore (x y z t) :precision binary64 (fma y 5.0 (* (+ (+ (fma 2.0 z y) y) t) x)))
double code(double x, double y, double z, double t) {
return fma(y, 5.0, (((fma(2.0, z, y) + y) + t) * x));
}
function code(x, y, z, t) return fma(y, 5.0, Float64(Float64(Float64(fma(2.0, z, y) + y) + t) * x)) end
code[x_, y_, z_, t_] := N[(y * 5.0 + N[(N[(N[(N[(2.0 * z + y), $MachinePrecision] + y), $MachinePrecision] + t), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, 5, \left(\left(\mathsf{fma}\left(2, z, y\right) + y\right) + t\right) \cdot x\right)
\end{array}
Initial program 99.9%
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
(FPCore (x y z t) :precision binary64 (fma (fma 2.0 (+ z y) t) x (* 5.0 y)))
double code(double x, double y, double z, double t) {
return fma(fma(2.0, (z + y), t), x, (5.0 * y));
}
function code(x, y, z, t) return fma(fma(2.0, Float64(z + y), t), x, Float64(5.0 * y)) end
code[x_, y_, z_, t_] := N[(N[(2.0 * N[(z + y), $MachinePrecision] + t), $MachinePrecision] * x + N[(5.0 * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(2, z + y, t\right), x, 5 \cdot y\right)
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
distribute-lft-outN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f6499.9
Applied rewrites99.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (fma (+ z y) 2.0 t) x)))
(if (<= x -2.5)
t_1
(if (<= x 3.4e-6) (fma y 5.0 (* (fma z 2.0 t) x)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma((z + y), 2.0, t) * x;
double tmp;
if (x <= -2.5) {
tmp = t_1;
} else if (x <= 3.4e-6) {
tmp = fma(y, 5.0, (fma(z, 2.0, t) * x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(fma(Float64(z + y), 2.0, t) * x) tmp = 0.0 if (x <= -2.5) tmp = t_1; elseif (x <= 3.4e-6) tmp = fma(y, 5.0, Float64(fma(z, 2.0, t) * x)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(z + y), $MachinePrecision] * 2.0 + t), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -2.5], t$95$1, If[LessEqual[x, 3.4e-6], N[(y * 5.0 + N[(N[(z * 2.0 + t), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(z + y, 2, t\right) \cdot x\\
\mathbf{if}\;x \leq -2.5:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 3.4 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{fma}\left(y, 5, \mathsf{fma}\left(z, 2, t\right) \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -2.5 or 3.40000000000000006e-6 < x Initial program 99.9%
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in y around 0
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6498.1
Applied rewrites98.1%
Taylor expanded in x around inf
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
+-commutativeN/A
count-2-revN/A
associate-+l+N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites71.4%
if -2.5 < x < 3.40000000000000006e-6Initial program 99.9%
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6484.8
Applied rewrites84.8%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (fma (+ z y) 2.0 t) x)))
(if (<= x -0.0145)
t_1
(if (<= x 1.15e-126)
(fma y 5.0 (* (+ z z) x))
(if (<= x 2.35e-35) (fma t x (* 5.0 y)) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = fma((z + y), 2.0, t) * x;
double tmp;
if (x <= -0.0145) {
tmp = t_1;
} else if (x <= 1.15e-126) {
tmp = fma(y, 5.0, ((z + z) * x));
} else if (x <= 2.35e-35) {
tmp = fma(t, x, (5.0 * y));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(fma(Float64(z + y), 2.0, t) * x) tmp = 0.0 if (x <= -0.0145) tmp = t_1; elseif (x <= 1.15e-126) tmp = fma(y, 5.0, Float64(Float64(z + z) * x)); elseif (x <= 2.35e-35) tmp = fma(t, x, Float64(5.0 * y)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(z + y), $MachinePrecision] * 2.0 + t), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -0.0145], t$95$1, If[LessEqual[x, 1.15e-126], N[(y * 5.0 + N[(N[(z + z), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.35e-35], N[(t * x + N[(5.0 * y), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(z + y, 2, t\right) \cdot x\\
\mathbf{if}\;x \leq -0.0145:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.15 \cdot 10^{-126}:\\
\;\;\;\;\mathsf{fma}\left(y, 5, \left(z + z\right) \cdot x\right)\\
\mathbf{elif}\;x \leq 2.35 \cdot 10^{-35}:\\
\;\;\;\;\mathsf{fma}\left(t, x, 5 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -0.0145000000000000007 or 2.35e-35 < x Initial program 99.9%
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in y around 0
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6498.1
Applied rewrites98.1%
Taylor expanded in x around inf
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
+-commutativeN/A
count-2-revN/A
associate-+l+N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites71.4%
if -0.0145000000000000007 < x < 1.15000000000000005e-126Initial program 99.9%
Taylor expanded in t around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f6474.2
Applied rewrites74.2%
Taylor expanded in y around 0
Applied rewrites58.0%
lift-*.f64N/A
lift-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6458.0
lift-*.f64N/A
count-2-revN/A
lower-+.f6458.0
Applied rewrites58.0%
if 1.15000000000000005e-126 < x < 2.35e-35Initial program 99.9%
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in y around 0
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6498.1
Applied rewrites98.1%
Taylor expanded in z around 0
Applied rewrites73.6%
Taylor expanded in x around 0
Applied rewrites58.4%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fma y 5.0 (* (+ z z) x))))
(if (<= z -7.5e+38)
t_1
(if (<= z 2.15e+83) (fma (fma 2.0 y t) x (* 5.0 y)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma(y, 5.0, ((z + z) * x));
double tmp;
if (z <= -7.5e+38) {
tmp = t_1;
} else if (z <= 2.15e+83) {
tmp = fma(fma(2.0, y, t), x, (5.0 * y));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(y, 5.0, Float64(Float64(z + z) * x)) tmp = 0.0 if (z <= -7.5e+38) tmp = t_1; elseif (z <= 2.15e+83) tmp = fma(fma(2.0, y, t), x, Float64(5.0 * y)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * 5.0 + N[(N[(z + z), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -7.5e+38], t$95$1, If[LessEqual[z, 2.15e+83], N[(N[(2.0 * y + t), $MachinePrecision] * x + N[(5.0 * y), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y, 5, \left(z + z\right) \cdot x\right)\\
\mathbf{if}\;z \leq -7.5 \cdot 10^{+38}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2.15 \cdot 10^{+83}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(2, y, t\right), x, 5 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -7.4999999999999999e38 or 2.15e83 < z Initial program 99.9%
Taylor expanded in t around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f6474.2
Applied rewrites74.2%
Taylor expanded in y around 0
Applied rewrites58.0%
lift-*.f64N/A
lift-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6458.0
lift-*.f64N/A
count-2-revN/A
lower-+.f6458.0
Applied rewrites58.0%
if -7.4999999999999999e38 < z < 2.15e83Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-*.f6474.4
Applied rewrites74.4%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (fma (+ z y) 2.0 t) x))) (if (<= x -5.6e-58) t_1 (if (<= x 2.35e-35) (fma t x (* 5.0 y)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma((z + y), 2.0, t) * x;
double tmp;
if (x <= -5.6e-58) {
tmp = t_1;
} else if (x <= 2.35e-35) {
tmp = fma(t, x, (5.0 * y));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(fma(Float64(z + y), 2.0, t) * x) tmp = 0.0 if (x <= -5.6e-58) tmp = t_1; elseif (x <= 2.35e-35) tmp = fma(t, x, Float64(5.0 * y)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(z + y), $MachinePrecision] * 2.0 + t), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -5.6e-58], t$95$1, If[LessEqual[x, 2.35e-35], N[(t * x + N[(5.0 * y), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(z + y, 2, t\right) \cdot x\\
\mathbf{if}\;x \leq -5.6 \cdot 10^{-58}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2.35 \cdot 10^{-35}:\\
\;\;\;\;\mathsf{fma}\left(t, x, 5 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -5.6000000000000001e-58 or 2.35e-35 < x Initial program 99.9%
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in y around 0
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6498.1
Applied rewrites98.1%
Taylor expanded in x around inf
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
+-commutativeN/A
count-2-revN/A
associate-+l+N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites71.4%
if -5.6000000000000001e-58 < x < 2.35e-35Initial program 99.9%
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in y around 0
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6498.1
Applied rewrites98.1%
Taylor expanded in z around 0
Applied rewrites73.6%
Taylor expanded in x around 0
Applied rewrites58.4%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (fma 2.0 x 5.0) y))) (if (<= y -1.15e+73) t_1 (if (<= y 5.4e+48) (* (fma 2.0 z t) x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma(2.0, x, 5.0) * y;
double tmp;
if (y <= -1.15e+73) {
tmp = t_1;
} else if (y <= 5.4e+48) {
tmp = fma(2.0, z, t) * x;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(fma(2.0, x, 5.0) * y) tmp = 0.0 if (y <= -1.15e+73) tmp = t_1; elseif (y <= 5.4e+48) tmp = Float64(fma(2.0, z, t) * x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(2.0 * x + 5.0), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[y, -1.15e+73], t$95$1, If[LessEqual[y, 5.4e+48], N[(N[(2.0 * z + t), $MachinePrecision] * x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(2, x, 5\right) \cdot y\\
\mathbf{if}\;y \leq -1.15 \cdot 10^{+73}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 5.4 \cdot 10^{+48}:\\
\;\;\;\;\mathsf{fma}\left(2, z, t\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -1.15e73 or 5.40000000000000007e48 < y Initial program 99.9%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6448.1
Applied rewrites48.1%
if -1.15e73 < y < 5.40000000000000007e48Initial program 99.9%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6456.9
Applied rewrites56.9%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (+ x x) z))) (if (<= z -1.42e+94) t_1 (if (<= z 1e+67) (* (fma 2.0 x 5.0) y) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (x + x) * z;
double tmp;
if (z <= -1.42e+94) {
tmp = t_1;
} else if (z <= 1e+67) {
tmp = fma(2.0, x, 5.0) * y;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(x + x) * z) tmp = 0.0 if (z <= -1.42e+94) tmp = t_1; elseif (z <= 1e+67) tmp = Float64(fma(2.0, x, 5.0) * y); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x + x), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -1.42e+94], t$95$1, If[LessEqual[z, 1e+67], N[(N[(2.0 * x + 5.0), $MachinePrecision] * y), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x + x\right) \cdot z\\
\mathbf{if}\;z \leq -1.42 \cdot 10^{+94}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 10^{+67}:\\
\;\;\;\;\mathsf{fma}\left(2, x, 5\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.4200000000000001e94 or 9.99999999999999983e66 < z Initial program 99.9%
Taylor expanded in z around inf
associate-*r*N/A
lower-*.f64N/A
count-2-revN/A
lower-+.f6430.3
Applied rewrites30.3%
if -1.4200000000000001e94 < z < 9.99999999999999983e66Initial program 99.9%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6448.1
Applied rewrites48.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (+ x x) z)))
(if (<= x -6.5e+174)
t_1
(if (<= x -110000000.0)
(* (+ x x) y)
(if (<= x -5.6e-58) t_1 (if (<= x 1.06e-107) (* 5.0 y) (* t x)))))))
double code(double x, double y, double z, double t) {
double t_1 = (x + x) * z;
double tmp;
if (x <= -6.5e+174) {
tmp = t_1;
} else if (x <= -110000000.0) {
tmp = (x + x) * y;
} else if (x <= -5.6e-58) {
tmp = t_1;
} else if (x <= 1.06e-107) {
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) :: t_1
real(8) :: tmp
t_1 = (x + x) * z
if (x <= (-6.5d+174)) then
tmp = t_1
else if (x <= (-110000000.0d0)) then
tmp = (x + x) * y
else if (x <= (-5.6d-58)) then
tmp = t_1
else if (x <= 1.06d-107) 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 t_1 = (x + x) * z;
double tmp;
if (x <= -6.5e+174) {
tmp = t_1;
} else if (x <= -110000000.0) {
tmp = (x + x) * y;
} else if (x <= -5.6e-58) {
tmp = t_1;
} else if (x <= 1.06e-107) {
tmp = 5.0 * y;
} else {
tmp = t * x;
}
return tmp;
}
def code(x, y, z, t): t_1 = (x + x) * z tmp = 0 if x <= -6.5e+174: tmp = t_1 elif x <= -110000000.0: tmp = (x + x) * y elif x <= -5.6e-58: tmp = t_1 elif x <= 1.06e-107: tmp = 5.0 * y else: tmp = t * x return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x + x) * z) tmp = 0.0 if (x <= -6.5e+174) tmp = t_1; elseif (x <= -110000000.0) tmp = Float64(Float64(x + x) * y); elseif (x <= -5.6e-58) tmp = t_1; elseif (x <= 1.06e-107) tmp = Float64(5.0 * y); else tmp = Float64(t * x); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x + x) * z; tmp = 0.0; if (x <= -6.5e+174) tmp = t_1; elseif (x <= -110000000.0) tmp = (x + x) * y; elseif (x <= -5.6e-58) tmp = t_1; elseif (x <= 1.06e-107) tmp = 5.0 * y; else tmp = t * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x + x), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[x, -6.5e+174], t$95$1, If[LessEqual[x, -110000000.0], N[(N[(x + x), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[x, -5.6e-58], t$95$1, If[LessEqual[x, 1.06e-107], N[(5.0 * y), $MachinePrecision], N[(t * x), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x + x\right) \cdot z\\
\mathbf{if}\;x \leq -6.5 \cdot 10^{+174}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -110000000:\\
\;\;\;\;\left(x + x\right) \cdot y\\
\mathbf{elif}\;x \leq -5.6 \cdot 10^{-58}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.06 \cdot 10^{-107}:\\
\;\;\;\;5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;t \cdot x\\
\end{array}
\end{array}
if x < -6.5000000000000001e174 or -1.1e8 < x < -5.6000000000000001e-58Initial program 99.9%
Taylor expanded in z around inf
associate-*r*N/A
lower-*.f64N/A
count-2-revN/A
lower-+.f6430.3
Applied rewrites30.3%
if -6.5000000000000001e174 < x < -1.1e8Initial program 99.9%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6448.1
Applied rewrites48.1%
Taylor expanded in x around inf
associate-*r*N/A
lower-*.f64N/A
count-2-revN/A
lift-+.f6420.4
Applied rewrites20.4%
if -5.6000000000000001e-58 < x < 1.05999999999999998e-107Initial program 99.9%
Taylor expanded in x around 0
lower-*.f6429.9
Applied rewrites29.9%
if 1.05999999999999998e-107 < x Initial program 99.9%
Taylor expanded in t around inf
lower-*.f6430.8
Applied rewrites30.8%
(FPCore (x y z t) :precision binary64 (if (<= x -4.4e+149) (* t x) (if (<= x -0.0115) (* (+ x x) y) (if (<= x 1.06e-107) (* 5.0 y) (* t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -4.4e+149) {
tmp = t * x;
} else if (x <= -0.0115) {
tmp = (x + x) * y;
} else if (x <= 1.06e-107) {
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 <= (-4.4d+149)) then
tmp = t * x
else if (x <= (-0.0115d0)) then
tmp = (x + x) * y
else if (x <= 1.06d-107) 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 <= -4.4e+149) {
tmp = t * x;
} else if (x <= -0.0115) {
tmp = (x + x) * y;
} else if (x <= 1.06e-107) {
tmp = 5.0 * y;
} else {
tmp = t * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -4.4e+149: tmp = t * x elif x <= -0.0115: tmp = (x + x) * y elif x <= 1.06e-107: tmp = 5.0 * y else: tmp = t * x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -4.4e+149) tmp = Float64(t * x); elseif (x <= -0.0115) tmp = Float64(Float64(x + x) * y); elseif (x <= 1.06e-107) 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 <= -4.4e+149) tmp = t * x; elseif (x <= -0.0115) tmp = (x + x) * y; elseif (x <= 1.06e-107) tmp = 5.0 * y; else tmp = t * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -4.4e+149], N[(t * x), $MachinePrecision], If[LessEqual[x, -0.0115], N[(N[(x + x), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[x, 1.06e-107], N[(5.0 * y), $MachinePrecision], N[(t * x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.4 \cdot 10^{+149}:\\
\;\;\;\;t \cdot x\\
\mathbf{elif}\;x \leq -0.0115:\\
\;\;\;\;\left(x + x\right) \cdot y\\
\mathbf{elif}\;x \leq 1.06 \cdot 10^{-107}:\\
\;\;\;\;5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;t \cdot x\\
\end{array}
\end{array}
if x < -4.4e149 or 1.05999999999999998e-107 < x Initial program 99.9%
Taylor expanded in t around inf
lower-*.f6430.8
Applied rewrites30.8%
if -4.4e149 < x < -0.0115Initial program 99.9%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6448.1
Applied rewrites48.1%
Taylor expanded in x around inf
associate-*r*N/A
lower-*.f64N/A
count-2-revN/A
lift-+.f6420.4
Applied rewrites20.4%
if -0.0115 < x < 1.05999999999999998e-107Initial program 99.9%
Taylor expanded in x around 0
lower-*.f6429.9
Applied rewrites29.9%
(FPCore (x y z t) :precision binary64 (if (<= x -0.00038) (* t x) (if (<= x 1.06e-107) (* 5.0 y) (* t x))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -0.00038) {
tmp = t * x;
} else if (x <= 1.06e-107) {
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 <= (-0.00038d0)) then
tmp = t * x
else if (x <= 1.06d-107) 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 <= -0.00038) {
tmp = t * x;
} else if (x <= 1.06e-107) {
tmp = 5.0 * y;
} else {
tmp = t * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -0.00038: tmp = t * x elif x <= 1.06e-107: tmp = 5.0 * y else: tmp = t * x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -0.00038) tmp = Float64(t * x); elseif (x <= 1.06e-107) 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 <= -0.00038) tmp = t * x; elseif (x <= 1.06e-107) tmp = 5.0 * y; else tmp = t * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -0.00038], N[(t * x), $MachinePrecision], If[LessEqual[x, 1.06e-107], N[(5.0 * y), $MachinePrecision], N[(t * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.00038:\\
\;\;\;\;t \cdot x\\
\mathbf{elif}\;x \leq 1.06 \cdot 10^{-107}:\\
\;\;\;\;5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;t \cdot x\\
\end{array}
\end{array}
if x < -3.8000000000000002e-4 or 1.05999999999999998e-107 < x Initial program 99.9%
Taylor expanded in t around inf
lower-*.f6430.8
Applied rewrites30.8%
if -3.8000000000000002e-4 < x < 1.05999999999999998e-107Initial program 99.9%
Taylor expanded in x around 0
lower-*.f6429.9
Applied rewrites29.9%
(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]
\begin{array}{l}
\\
5 \cdot y
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
lower-*.f6429.9
Applied rewrites29.9%
herbie shell --seed 2025142
(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)))