
(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 10 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
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.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.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.5
Applied rewrites98.5%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (fma 2.0 (+ z y) t) x))) (if (<= x -1.95e-27) t_1 (if (<= x 0.0061) (fma y 5.0 (* (+ z z) x)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma(2.0, (z + y), t) * x;
double tmp;
if (x <= -1.95e-27) {
tmp = t_1;
} else if (x <= 0.0061) {
tmp = fma(y, 5.0, ((z + z) * x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(fma(2.0, Float64(z + y), t) * x) tmp = 0.0 if (x <= -1.95e-27) tmp = t_1; elseif (x <= 0.0061) tmp = fma(y, 5.0, Float64(Float64(z + z) * x)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(2.0 * N[(z + y), $MachinePrecision] + t), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -1.95e-27], t$95$1, If[LessEqual[x, 0.0061], N[(y * 5.0 + N[(N[(z + z), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(2, z + y, t\right) \cdot x\\
\mathbf{if}\;x \leq -1.95 \cdot 10^{-27}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 0.0061:\\
\;\;\;\;\mathsf{fma}\left(y, 5, \left(z + z\right) \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -1.94999999999999986e-27 or 0.00610000000000000039 < x Initial program 99.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-outN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f6497.7
Applied rewrites97.7%
if -1.94999999999999986e-27 < x < 0.00610000000000000039Initial program 99.8%
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in z around inf
associate-+l+N/A
count-2-revN/A
distribute-lft-inN/A
count-2-revN/A
lower-+.f6479.5
Applied rewrites79.5%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (fma 2.0 (+ z y) t) x))) (if (<= x -2.8) t_1 (if (<= x 2.8e-11) (fma y 5.0 (* t x)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma(2.0, (z + y), t) * x;
double tmp;
if (x <= -2.8) {
tmp = t_1;
} else if (x <= 2.8e-11) {
tmp = fma(y, 5.0, (t * x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(fma(2.0, Float64(z + y), t) * x) tmp = 0.0 if (x <= -2.8) tmp = t_1; elseif (x <= 2.8e-11) 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[(2.0 * N[(z + y), $MachinePrecision] + t), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -2.8], t$95$1, If[LessEqual[x, 2.8e-11], N[(y * 5.0 + N[(t * x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(2, z + y, t\right) \cdot x\\
\mathbf{if}\;x \leq -2.8:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{-11}:\\
\;\;\;\;\mathsf{fma}\left(y, 5, t \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -2.7999999999999998 or 2.8e-11 < x Initial program 99.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-outN/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f6498.6
Applied rewrites98.6%
if -2.7999999999999998 < x < 2.8e-11Initial program 99.8%
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in t around inf
associate-+l+78.5
count-2-rev78.5
distribute-lft-in78.5
Applied rewrites78.5%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (fma 2.0 x 5.0) y))) (if (<= y -2.05e+29) t_1 (if (<= y 2.7e+51) (* (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 <= -2.05e+29) {
tmp = t_1;
} else if (y <= 2.7e+51) {
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 <= -2.05e+29) tmp = t_1; elseif (y <= 2.7e+51) 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, -2.05e+29], t$95$1, If[LessEqual[y, 2.7e+51], 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 -2.05 \cdot 10^{+29}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{+51}:\\
\;\;\;\;\mathsf{fma}\left(2, z, t\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -2.0500000000000002e29 or 2.69999999999999992e51 < y Initial program 99.8%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6479.8
Applied rewrites79.8%
if -2.0500000000000002e29 < y < 2.69999999999999992e51Initial program 99.9%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6478.4
Applied rewrites78.4%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (fma 2.0 x 5.0) y)))
(if (<= y -5e-23)
t_1
(if (<= y -7.7e-233)
(* t x)
(if (<= y 0.0015) (* (+ x x) z) (if (<= y 9.2e+29) (* 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 <= -5e-23) {
tmp = t_1;
} else if (y <= -7.7e-233) {
tmp = t * x;
} else if (y <= 0.0015) {
tmp = (x + x) * z;
} else if (y <= 9.2e+29) {
tmp = 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 <= -5e-23) tmp = t_1; elseif (y <= -7.7e-233) tmp = Float64(t * x); elseif (y <= 0.0015) tmp = Float64(Float64(x + x) * z); elseif (y <= 9.2e+29) tmp = Float64(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, -5e-23], t$95$1, If[LessEqual[y, -7.7e-233], N[(t * x), $MachinePrecision], If[LessEqual[y, 0.0015], N[(N[(x + x), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[y, 9.2e+29], N[(t * 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 -5 \cdot 10^{-23}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -7.7 \cdot 10^{-233}:\\
\;\;\;\;t \cdot x\\
\mathbf{elif}\;y \leq 0.0015:\\
\;\;\;\;\left(x + x\right) \cdot z\\
\mathbf{elif}\;y \leq 9.2 \cdot 10^{+29}:\\
\;\;\;\;t \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -5.0000000000000002e-23 or 9.2000000000000004e29 < y Initial program 99.8%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f6476.0
Applied rewrites76.0%
if -5.0000000000000002e-23 < y < -7.70000000000000007e-233 or 0.0015 < y < 9.2000000000000004e29Initial program 99.9%
Taylor expanded in t around inf
lower-*.f6440.0
Applied rewrites40.0%
if -7.70000000000000007e-233 < y < 0.0015Initial program 100.0%
Taylor expanded in z around inf
associate-*r*N/A
lower-*.f64N/A
count-2-revN/A
lower-+.f6445.4
Applied rewrites45.4%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (+ x x) z)))
(if (<= z -7.6e+31)
t_1
(if (<= z -3e-299) (* t x) (if (<= z 8.5e-17) (* 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 <= -7.6e+31) {
tmp = t_1;
} else if (z <= -3e-299) {
tmp = t * x;
} else if (z <= 8.5e-17) {
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 = (x + x) * z
if (z <= (-7.6d+31)) then
tmp = t_1
else if (z <= (-3d-299)) then
tmp = t * x
else if (z <= 8.5d-17) 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 = (x + x) * z;
double tmp;
if (z <= -7.6e+31) {
tmp = t_1;
} else if (z <= -3e-299) {
tmp = t * x;
} else if (z <= 8.5e-17) {
tmp = 5.0 * y;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = (x + x) * z tmp = 0 if z <= -7.6e+31: tmp = t_1 elif z <= -3e-299: tmp = t * x elif z <= 8.5e-17: tmp = 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 <= -7.6e+31) tmp = t_1; elseif (z <= -3e-299) tmp = Float64(t * x); elseif (z <= 8.5e-17) tmp = Float64(5.0 * y); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x + x) * z; tmp = 0.0; if (z <= -7.6e+31) tmp = t_1; elseif (z <= -3e-299) tmp = t * x; elseif (z <= 8.5e-17) tmp = 5.0 * y; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x + x), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -7.6e+31], t$95$1, If[LessEqual[z, -3e-299], N[(t * x), $MachinePrecision], If[LessEqual[z, 8.5e-17], N[(5.0 * y), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x + x\right) \cdot z\\
\mathbf{if}\;z \leq -7.6 \cdot 10^{+31}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -3 \cdot 10^{-299}:\\
\;\;\;\;t \cdot x\\
\mathbf{elif}\;z \leq 8.5 \cdot 10^{-17}:\\
\;\;\;\;5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -7.6000000000000003e31 or 8.5e-17 < z Initial program 99.9%
Taylor expanded in z around inf
associate-*r*N/A
lower-*.f64N/A
count-2-revN/A
lower-+.f6453.2
Applied rewrites53.2%
if -7.6000000000000003e31 < z < -2.99999999999999984e-299Initial program 99.9%
Taylor expanded in t around inf
lower-*.f6436.7
Applied rewrites36.7%
if -2.99999999999999984e-299 < z < 8.5e-17Initial program 99.9%
Taylor expanded in x around 0
lower-*.f6436.0
Applied rewrites36.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (+ x x) y)))
(if (<= x -7.8e+208)
t_1
(if (<= x -1.95e-27)
(* t x)
(if (<= x 1500.0) (* 5.0 y) (if (<= x 2.65e+255) t_1 (* t x)))))))
double code(double x, double y, double z, double t) {
double t_1 = (x + x) * y;
double tmp;
if (x <= -7.8e+208) {
tmp = t_1;
} else if (x <= -1.95e-27) {
tmp = t * x;
} else if (x <= 1500.0) {
tmp = 5.0 * y;
} else if (x <= 2.65e+255) {
tmp = t_1;
} 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) * y
if (x <= (-7.8d+208)) then
tmp = t_1
else if (x <= (-1.95d-27)) then
tmp = t * x
else if (x <= 1500.0d0) then
tmp = 5.0d0 * y
else if (x <= 2.65d+255) then
tmp = t_1
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) * y;
double tmp;
if (x <= -7.8e+208) {
tmp = t_1;
} else if (x <= -1.95e-27) {
tmp = t * x;
} else if (x <= 1500.0) {
tmp = 5.0 * y;
} else if (x <= 2.65e+255) {
tmp = t_1;
} else {
tmp = t * x;
}
return tmp;
}
def code(x, y, z, t): t_1 = (x + x) * y tmp = 0 if x <= -7.8e+208: tmp = t_1 elif x <= -1.95e-27: tmp = t * x elif x <= 1500.0: tmp = 5.0 * y elif x <= 2.65e+255: tmp = t_1 else: tmp = t * x return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x + x) * y) tmp = 0.0 if (x <= -7.8e+208) tmp = t_1; elseif (x <= -1.95e-27) tmp = Float64(t * x); elseif (x <= 1500.0) tmp = Float64(5.0 * y); elseif (x <= 2.65e+255) tmp = t_1; else tmp = Float64(t * x); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x + x) * y; tmp = 0.0; if (x <= -7.8e+208) tmp = t_1; elseif (x <= -1.95e-27) tmp = t * x; elseif (x <= 1500.0) tmp = 5.0 * y; elseif (x <= 2.65e+255) tmp = t_1; else tmp = t * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x + x), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[x, -7.8e+208], t$95$1, If[LessEqual[x, -1.95e-27], N[(t * x), $MachinePrecision], If[LessEqual[x, 1500.0], N[(5.0 * y), $MachinePrecision], If[LessEqual[x, 2.65e+255], t$95$1, N[(t * x), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x + x\right) \cdot y\\
\mathbf{if}\;x \leq -7.8 \cdot 10^{+208}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -1.95 \cdot 10^{-27}:\\
\;\;\;\;t \cdot x\\
\mathbf{elif}\;x \leq 1500:\\
\;\;\;\;5 \cdot y\\
\mathbf{elif}\;x \leq 2.65 \cdot 10^{+255}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t \cdot x\\
\end{array}
\end{array}
if x < -7.8000000000000001e208 or 1500 < x < 2.6499999999999999e255Initial program 100.0%
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in y around inf
*-commutativeN/A
associate-+l+N/A
+-commutativeN/A
count-2-revN/A
associate-+l+N/A
associate-+l+N/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6440.0
Applied rewrites40.0%
Taylor expanded in x around inf
count-2-revN/A
lift-+.f6439.5
Applied rewrites39.5%
if -7.8000000000000001e208 < x < -1.94999999999999986e-27 or 2.6499999999999999e255 < x Initial program 99.8%
Taylor expanded in t around inf
lower-*.f6437.2
Applied rewrites37.2%
if -1.94999999999999986e-27 < x < 1500Initial program 99.8%
Taylor expanded in x around 0
lower-*.f6458.9
Applied rewrites58.9%
(FPCore (x y z t) :precision binary64 (if (<= x -1.95e-27) (* t x) (if (<= x 0.0061) (* 5.0 y) (* t x))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.95e-27) {
tmp = t * x;
} else if (x <= 0.0061) {
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.95d-27)) then
tmp = t * x
else if (x <= 0.0061d0) 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.95e-27) {
tmp = t * x;
} else if (x <= 0.0061) {
tmp = 5.0 * y;
} else {
tmp = t * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -1.95e-27: tmp = t * x elif x <= 0.0061: tmp = 5.0 * y else: tmp = t * x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -1.95e-27) tmp = Float64(t * x); elseif (x <= 0.0061) 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.95e-27) tmp = t * x; elseif (x <= 0.0061) tmp = 5.0 * y; else tmp = t * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -1.95e-27], N[(t * x), $MachinePrecision], If[LessEqual[x, 0.0061], N[(5.0 * y), $MachinePrecision], N[(t * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.95 \cdot 10^{-27}:\\
\;\;\;\;t \cdot x\\
\mathbf{elif}\;x \leq 0.0061:\\
\;\;\;\;5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;t \cdot x\\
\end{array}
\end{array}
if x < -1.94999999999999986e-27 or 0.00610000000000000039 < x Initial program 99.9%
Taylor expanded in t around inf
lower-*.f6437.3
Applied rewrites37.3%
if -1.94999999999999986e-27 < x < 0.00610000000000000039Initial program 99.8%
Taylor expanded in x around 0
lower-*.f6459.4
Applied rewrites59.4%
(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-*.f6430.0
Applied rewrites30.0%
herbie shell --seed 2025119
(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)))