
(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 13 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.8%
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fma (fma 2.0 y t) x (* 5.0 y))))
(if (<= t -9.8e+190)
t_1
(if (<= t 1.44e+54) (fma (* 2.0 (+ z y)) x (* 5.0 y)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma(fma(2.0, y, t), x, (5.0 * y));
double tmp;
if (t <= -9.8e+190) {
tmp = t_1;
} else if (t <= 1.44e+54) {
tmp = fma((2.0 * (z + y)), x, (5.0 * y));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(fma(2.0, y, t), x, Float64(5.0 * y)) tmp = 0.0 if (t <= -9.8e+190) tmp = t_1; elseif (t <= 1.44e+54) tmp = fma(Float64(2.0 * Float64(z + y)), x, Float64(5.0 * y)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(2.0 * y + t), $MachinePrecision] * x + N[(5.0 * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -9.8e+190], t$95$1, If[LessEqual[t, 1.44e+54], N[(N[(2.0 * N[(z + y), $MachinePrecision]), $MachinePrecision] * x + N[(5.0 * y), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\mathsf{fma}\left(2, y, t\right), x, 5 \cdot y\right)\\
\mathbf{if}\;t \leq -9.8 \cdot 10^{+190}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 1.44 \cdot 10^{+54}:\\
\;\;\;\;\mathsf{fma}\left(2 \cdot \left(z + y\right), x, 5 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -9.7999999999999993e190 or 1.44e54 < t Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-*.f6489.4
Applied rewrites89.4%
if -9.7999999999999993e190 < t < 1.44e54Initial program 99.8%
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-*.f6486.7
Applied rewrites86.7%
(FPCore (x y z t) :precision binary64 (if (<= z -2.8e+57) (fma y 5.0 (* (+ z z) x)) (if (<= z 9.5e+79) (fma (fma 2.0 y t) x (* 5.0 y)) (* (fma 2.0 z t) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.8e+57) {
tmp = fma(y, 5.0, ((z + z) * x));
} else if (z <= 9.5e+79) {
tmp = fma(fma(2.0, y, t), x, (5.0 * y));
} else {
tmp = fma(2.0, z, t) * x;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (z <= -2.8e+57) tmp = fma(y, 5.0, Float64(Float64(z + z) * x)); elseif (z <= 9.5e+79) tmp = fma(fma(2.0, y, t), x, Float64(5.0 * y)); else tmp = Float64(fma(2.0, z, t) * x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -2.8e+57], N[(y * 5.0 + N[(N[(z + z), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 9.5e+79], N[(N[(2.0 * y + t), $MachinePrecision] * x + N[(5.0 * y), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * z + t), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.8 \cdot 10^{+57}:\\
\;\;\;\;\mathsf{fma}\left(y, 5, \left(z + z\right) \cdot x\right)\\
\mathbf{elif}\;z \leq 9.5 \cdot 10^{+79}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(2, y, t\right), x, 5 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(2, z, t\right) \cdot x\\
\end{array}
\end{array}
if z < -2.8e57Initial program 99.8%
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6480.1
Applied rewrites80.1%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6480.1
Applied rewrites80.1%
if -2.8e57 < z < 9.49999999999999994e79Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-*.f6490.9
Applied rewrites90.9%
if 9.49999999999999994e79 < z Initial program 99.7%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6474.3
Applied rewrites74.3%
(FPCore (x y z t) :precision binary64 (if (<= z -6.5e+48) (fma y 5.0 (* (+ z z) x)) (if (<= z 9.5e+79) (fma (fma 2.0 x 5.0) y (* t x)) (* (fma 2.0 z t) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -6.5e+48) {
tmp = fma(y, 5.0, ((z + z) * x));
} else if (z <= 9.5e+79) {
tmp = fma(fma(2.0, x, 5.0), y, (t * x));
} else {
tmp = fma(2.0, z, t) * x;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (z <= -6.5e+48) tmp = fma(y, 5.0, Float64(Float64(z + z) * x)); elseif (z <= 9.5e+79) tmp = fma(fma(2.0, x, 5.0), y, Float64(t * x)); else tmp = Float64(fma(2.0, z, t) * x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -6.5e+48], N[(y * 5.0 + N[(N[(z + z), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 9.5e+79], N[(N[(2.0 * x + 5.0), $MachinePrecision] * y + N[(t * x), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * z + t), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.5 \cdot 10^{+48}:\\
\;\;\;\;\mathsf{fma}\left(y, 5, \left(z + z\right) \cdot x\right)\\
\mathbf{elif}\;z \leq 9.5 \cdot 10^{+79}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(2, x, 5\right), y, t \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(2, z, t\right) \cdot x\\
\end{array}
\end{array}
if z < -6.49999999999999972e48Initial program 99.8%
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6478.7
Applied rewrites78.7%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6478.7
Applied rewrites78.7%
if -6.49999999999999972e48 < z < 9.49999999999999994e79Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6498.6
Applied rewrites98.6%
Taylor expanded in z around 0
Applied rewrites89.9%
if 9.49999999999999994e79 < z Initial program 99.7%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6474.3
Applied rewrites74.3%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (* z x) 2.0)))
(if (<= x -1.35e+135)
(* t x)
(if (<= x -9.2e-11) t_1 (if (<= x 2.5e-38) (* 5.0 y) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = (z * x) * 2.0;
double tmp;
if (x <= -1.35e+135) {
tmp = t * x;
} else if (x <= -9.2e-11) {
tmp = t_1;
} else if (x <= 2.5e-38) {
tmp = 5.0 * y;
} 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 * x) * 2.0d0
if (x <= (-1.35d+135)) then
tmp = t * x
else if (x <= (-9.2d-11)) then
tmp = t_1
else if (x <= 2.5d-38) then
tmp = 5.0d0 * y
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 * x) * 2.0;
double tmp;
if (x <= -1.35e+135) {
tmp = t * x;
} else if (x <= -9.2e-11) {
tmp = t_1;
} else if (x <= 2.5e-38) {
tmp = 5.0 * y;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = (z * x) * 2.0 tmp = 0 if x <= -1.35e+135: tmp = t * x elif x <= -9.2e-11: tmp = t_1 elif x <= 2.5e-38: tmp = 5.0 * y else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(z * x) * 2.0) tmp = 0.0 if (x <= -1.35e+135) tmp = Float64(t * x); elseif (x <= -9.2e-11) tmp = t_1; elseif (x <= 2.5e-38) tmp = Float64(5.0 * y); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (z * x) * 2.0; tmp = 0.0; if (x <= -1.35e+135) tmp = t * x; elseif (x <= -9.2e-11) tmp = t_1; elseif (x <= 2.5e-38) tmp = 5.0 * y; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z * x), $MachinePrecision] * 2.0), $MachinePrecision]}, If[LessEqual[x, -1.35e+135], N[(t * x), $MachinePrecision], If[LessEqual[x, -9.2e-11], t$95$1, If[LessEqual[x, 2.5e-38], N[(5.0 * y), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(z \cdot x\right) \cdot 2\\
\mathbf{if}\;x \leq -1.35 \cdot 10^{+135}:\\
\;\;\;\;t \cdot x\\
\mathbf{elif}\;x \leq -9.2 \cdot 10^{-11}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{-38}:\\
\;\;\;\;5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -1.34999999999999992e135Initial program 99.8%
Taylor expanded in t around inf
lower-*.f6443.1
Applied rewrites43.1%
if -1.34999999999999992e135 < x < -9.20000000000000054e-11 or 2.50000000000000017e-38 < x Initial program 100.0%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6436.7
Applied rewrites36.7%
if -9.20000000000000054e-11 < x < 2.50000000000000017e-38Initial program 99.7%
Taylor expanded in x around 0
lower-*.f6458.4
Applied rewrites58.4%
(FPCore (x y z t) :precision binary64 (if (<= y -0.028) (fma (* z 2.0) x (* 5.0 y)) (if (<= y 9.8e-26) (* (fma 2.0 z t) x) (fma y 5.0 (* (+ y y) x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -0.028) {
tmp = fma((z * 2.0), x, (5.0 * y));
} else if (y <= 9.8e-26) {
tmp = fma(2.0, z, t) * x;
} else {
tmp = fma(y, 5.0, ((y + y) * x));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -0.028) tmp = fma(Float64(z * 2.0), x, Float64(5.0 * y)); elseif (y <= 9.8e-26) tmp = Float64(fma(2.0, z, t) * x); else tmp = fma(y, 5.0, Float64(Float64(y + y) * x)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -0.028], N[(N[(z * 2.0), $MachinePrecision] * x + N[(5.0 * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 9.8e-26], N[(N[(2.0 * z + t), $MachinePrecision] * x), $MachinePrecision], N[(y * 5.0 + N[(N[(y + y), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.028:\\
\;\;\;\;\mathsf{fma}\left(z \cdot 2, x, 5 \cdot y\right)\\
\mathbf{elif}\;y \leq 9.8 \cdot 10^{-26}:\\
\;\;\;\;\mathsf{fma}\left(2, z, t\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, 5, \left(y + y\right) \cdot x\right)\\
\end{array}
\end{array}
if y < -0.0280000000000000006Initial program 99.7%
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6459.5
Applied rewrites59.5%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6459.5
Applied rewrites59.5%
if -0.0280000000000000006 < y < 9.7999999999999998e-26Initial program 99.9%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6482.7
Applied rewrites82.7%
if 9.7999999999999998e-26 < y Initial program 99.8%
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
Taylor expanded in y around inf
lower-*.f6471.2
Applied rewrites71.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6471.2
Applied rewrites71.2%
(FPCore (x y z t) :precision binary64 (if (<= y -0.028) (fma y 5.0 (* (+ z z) x)) (if (<= y 9.8e-26) (* (fma 2.0 z t) x) (fma y 5.0 (* (+ y y) x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -0.028) {
tmp = fma(y, 5.0, ((z + z) * x));
} else if (y <= 9.8e-26) {
tmp = fma(2.0, z, t) * x;
} else {
tmp = fma(y, 5.0, ((y + y) * x));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -0.028) tmp = fma(y, 5.0, Float64(Float64(z + z) * x)); elseif (y <= 9.8e-26) tmp = Float64(fma(2.0, z, t) * x); else tmp = fma(y, 5.0, Float64(Float64(y + y) * x)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -0.028], N[(y * 5.0 + N[(N[(z + z), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 9.8e-26], N[(N[(2.0 * z + t), $MachinePrecision] * x), $MachinePrecision], N[(y * 5.0 + N[(N[(y + y), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.028:\\
\;\;\;\;\mathsf{fma}\left(y, 5, \left(z + z\right) \cdot x\right)\\
\mathbf{elif}\;y \leq 9.8 \cdot 10^{-26}:\\
\;\;\;\;\mathsf{fma}\left(2, z, t\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, 5, \left(y + y\right) \cdot x\right)\\
\end{array}
\end{array}
if y < -0.0280000000000000006Initial program 99.7%
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6459.5
Applied rewrites59.5%
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f6459.5
Applied rewrites59.5%
if -0.0280000000000000006 < y < 9.7999999999999998e-26Initial program 99.9%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6482.7
Applied rewrites82.7%
if 9.7999999999999998e-26 < y Initial program 99.8%
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
Taylor expanded in y around inf
lower-*.f6471.2
Applied rewrites71.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6471.2
Applied rewrites71.2%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (fma y 5.0 (* (+ y y) x)))) (if (<= y -190000000.0) t_1 (if (<= y 9.8e-26) (* (fma 2.0 z t) x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma(y, 5.0, ((y + y) * x));
double tmp;
if (y <= -190000000.0) {
tmp = t_1;
} else if (y <= 9.8e-26) {
tmp = fma(2.0, z, t) * x;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(y, 5.0, Float64(Float64(y + y) * x)) tmp = 0.0 if (y <= -190000000.0) tmp = t_1; elseif (y <= 9.8e-26) 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[(y * 5.0 + N[(N[(y + y), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -190000000.0], t$95$1, If[LessEqual[y, 9.8e-26], N[(N[(2.0 * z + t), $MachinePrecision] * x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y, 5, \left(y + y\right) \cdot x\right)\\
\mathbf{if}\;y \leq -190000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 9.8 \cdot 10^{-26}:\\
\;\;\;\;\mathsf{fma}\left(2, z, t\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -1.9e8 or 9.7999999999999998e-26 < y Initial program 99.7%
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in y around inf
lower-*.f6474.0
Applied rewrites74.0%
lift-*.f64N/A
count-2-revN/A
lower-+.f6474.0
Applied rewrites74.0%
if -1.9e8 < y < 9.7999999999999998e-26Initial program 99.9%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6482.2
Applied rewrites82.2%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (fma 2.0 x 5.0) y))) (if (<= y -190000000.0) t_1 (if (<= y 9.8e-26) (* (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 <= -190000000.0) {
tmp = t_1;
} else if (y <= 9.8e-26) {
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 <= -190000000.0) tmp = t_1; elseif (y <= 9.8e-26) 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, -190000000.0], t$95$1, If[LessEqual[y, 9.8e-26], 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 -190000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 9.8 \cdot 10^{-26}:\\
\;\;\;\;\mathsf{fma}\left(2, z, t\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -1.9e8 or 9.7999999999999998e-26 < y Initial program 99.7%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6474.0
Applied rewrites74.0%
if -1.9e8 < y < 9.7999999999999998e-26Initial program 99.9%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6482.2
Applied rewrites82.2%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (* z x) 2.0))) (if (<= z -4.4e+26) t_1 (if (<= z 9.2e+60) (* (fma 2.0 x 5.0) y) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (z * x) * 2.0;
double tmp;
if (z <= -4.4e+26) {
tmp = t_1;
} else if (z <= 9.2e+60) {
tmp = fma(2.0, x, 5.0) * y;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(z * x) * 2.0) tmp = 0.0 if (z <= -4.4e+26) tmp = t_1; elseif (z <= 9.2e+60) 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[(z * x), $MachinePrecision] * 2.0), $MachinePrecision]}, If[LessEqual[z, -4.4e+26], t$95$1, If[LessEqual[z, 9.2e+60], N[(N[(2.0 * x + 5.0), $MachinePrecision] * y), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(z \cdot x\right) \cdot 2\\
\mathbf{if}\;z \leq -4.4 \cdot 10^{+26}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 9.2 \cdot 10^{+60}:\\
\;\;\;\;\mathsf{fma}\left(2, x, 5\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -4.40000000000000014e26 or 9.20000000000000068e60 < z Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6457.5
Applied rewrites57.5%
if -4.40000000000000014e26 < z < 9.20000000000000068e60Initial program 99.9%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6456.9
Applied rewrites56.9%
(FPCore (x y z t) :precision binary64 (fma (fma 2.0 x 5.0) y (* (fma 2.0 z t) x)))
double code(double x, double y, double z, double t) {
return fma(fma(2.0, x, 5.0), y, (fma(2.0, z, t) * x));
}
function code(x, y, z, t) return fma(fma(2.0, x, 5.0), y, Float64(fma(2.0, z, t) * x)) end
code[x_, y_, z_, t_] := N[(N[(2.0 * x + 5.0), $MachinePrecision] * y + N[(N[(2.0 * z + t), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(2, x, 5\right), y, \mathsf{fma}\left(2, z, t\right) \cdot x\right)
\end{array}
Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6498.2
Applied rewrites98.2%
(FPCore (x y z t) :precision binary64 (if (<= x -1.4e-54) (* t x) (if (<= x 0.000236) (* 5.0 y) (* t x))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.4e-54) {
tmp = t * x;
} else if (x <= 0.000236) {
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 <= (-1.4d-54)) then
tmp = t * x
else if (x <= 0.000236d0) 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 <= -1.4e-54) {
tmp = t * x;
} else if (x <= 0.000236) {
tmp = 5.0 * y;
} else {
tmp = t * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -1.4e-54: tmp = t * x elif x <= 0.000236: tmp = 5.0 * y else: tmp = t * x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -1.4e-54) tmp = Float64(t * x); elseif (x <= 0.000236) 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 <= -1.4e-54) tmp = t * x; elseif (x <= 0.000236) tmp = 5.0 * y; else tmp = t * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -1.4e-54], N[(t * x), $MachinePrecision], If[LessEqual[x, 0.000236], N[(5.0 * y), $MachinePrecision], N[(t * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.4 \cdot 10^{-54}:\\
\;\;\;\;t \cdot x\\
\mathbf{elif}\;x \leq 0.000236:\\
\;\;\;\;5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;t \cdot x\\
\end{array}
\end{array}
if x < -1.4000000000000001e-54 or 2.3599999999999999e-4 < x Initial program 99.9%
Taylor expanded in t around inf
lower-*.f6438.6
Applied rewrites38.6%
if -1.4000000000000001e-54 < x < 2.3599999999999999e-4Initial program 99.7%
Taylor expanded in x around 0
lower-*.f6458.3
Applied rewrites58.3%
(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.8%
Taylor expanded in x around 0
lower-*.f6429.4
Applied rewrites29.4%
herbie shell --seed 2025088
(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)))