
(FPCore (x y z t a b c) :precision binary64 (+ (- (+ (* x y) (/ (* z t) 16.0)) (/ (* a b) 4.0)) c))
double code(double x, double y, double z, double t, double a, double b, double c) {
return (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + c;
}
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, a, b, c)
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), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (((x * y) + ((z * t) / 16.0d0)) - ((a * b) / 4.0d0)) + c
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
return (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + c;
}
def code(x, y, z, t, a, b, c): return (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + c
function code(x, y, z, t, a, b, c) return Float64(Float64(Float64(Float64(x * y) + Float64(Float64(z * t) / 16.0)) - Float64(Float64(a * b) / 4.0)) + c) end
function tmp = code(x, y, z, t, a, b, c) tmp = (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + c; end
code[x_, y_, z_, t_, a_, b_, c_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(N[(z * t), $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision] - N[(N[(a * b), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision] + c), $MachinePrecision]
\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b c) :precision binary64 (+ (- (+ (* x y) (/ (* z t) 16.0)) (/ (* a b) 4.0)) c))
double code(double x, double y, double z, double t, double a, double b, double c) {
return (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + c;
}
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, a, b, c)
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), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (((x * y) + ((z * t) / 16.0d0)) - ((a * b) / 4.0d0)) + c
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
return (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + c;
}
def code(x, y, z, t, a, b, c): return (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + c
function code(x, y, z, t, a, b, c) return Float64(Float64(Float64(Float64(x * y) + Float64(Float64(z * t) / 16.0)) - Float64(Float64(a * b) / 4.0)) + c) end
function tmp = code(x, y, z, t, a, b, c) tmp = (((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + c; end
code[x_, y_, z_, t_, a_, b_, c_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(N[(z * t), $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision] - N[(N[(a * b), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision] + c), $MachinePrecision]
\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c
(FPCore (x y z t a b c) :precision binary64 (if (<= (+ (- (+ (* x y) (/ (* z t) 16.0)) (/ (* a b) 4.0)) c) INFINITY) (fma (* b -0.25) a (+ c (fma 0.0625 (* t z) (* y x)))) (fma (* 0.0625 z) t (fma x y c))))
double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if (((((x * y) + ((z * t) / 16.0)) - ((a * b) / 4.0)) + c) <= ((double) INFINITY)) {
tmp = fma((b * -0.25), a, (c + fma(0.0625, (t * z), (y * x))));
} else {
tmp = fma((0.0625 * z), t, fma(x, y, c));
}
return tmp;
}
function code(x, y, z, t, a, b, c) tmp = 0.0 if (Float64(Float64(Float64(Float64(x * y) + Float64(Float64(z * t) / 16.0)) - Float64(Float64(a * b) / 4.0)) + c) <= Inf) tmp = fma(Float64(b * -0.25), a, Float64(c + fma(0.0625, Float64(t * z), Float64(y * x)))); else tmp = fma(Float64(0.0625 * z), t, fma(x, y, c)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_] := If[LessEqual[N[(N[(N[(N[(x * y), $MachinePrecision] + N[(N[(z * t), $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision] - N[(N[(a * b), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision] + c), $MachinePrecision], Infinity], N[(N[(b * -0.25), $MachinePrecision] * a + N[(c + N[(0.0625 * N[(t * z), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.0625 * z), $MachinePrecision] * t + N[(x * y + c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(b \cdot -0.25, a, c + \mathsf{fma}\left(0.0625, t \cdot z, y \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.0625 \cdot z, t, \mathsf{fma}\left(x, y, c\right)\right)\\
\end{array}
if (+.f64 (-.f64 (+.f64 (*.f64 x y) (/.f64 (*.f64 z t) #s(literal 16 binary64))) (/.f64 (*.f64 a b) #s(literal 4 binary64))) c) < +inf.0Initial program 97.7%
lift-+.f64N/A
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
associate-+l+N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
distribute-lft-neg-inN/A
+-commutativeN/A
lower-fma.f64N/A
mult-flipN/A
distribute-rgt-neg-inN/A
distribute-neg-frac2N/A
lower-*.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-+.f6498.5%
Applied rewrites98.5%
if +inf.0 < (+.f64 (-.f64 (+.f64 (*.f64 x y) (/.f64 (*.f64 z t) #s(literal 16 binary64))) (/.f64 (*.f64 a b) #s(literal 4 binary64))) c) Initial program 97.7%
Taylor expanded in a around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.5%
Applied rewrites74.5%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
associate-+l+N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lower-fma.f6474.8%
Applied rewrites74.8%
(FPCore (x y z t a b c)
:precision binary64
(let* ((t_1 (/ (* a b) 4.0)))
(if (<= t_1 -4e+71)
(fma (* b -0.25) a (fma y x c))
(if (<= t_1 5e+149)
(fma (* 0.0625 z) t (fma x y c))
(fma (* b -0.25) a (+ c (* 0.0625 (* t z))))))))double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = (a * b) / 4.0;
double tmp;
if (t_1 <= -4e+71) {
tmp = fma((b * -0.25), a, fma(y, x, c));
} else if (t_1 <= 5e+149) {
tmp = fma((0.0625 * z), t, fma(x, y, c));
} else {
tmp = fma((b * -0.25), a, (c + (0.0625 * (t * z))));
}
return tmp;
}
function code(x, y, z, t, a, b, c) t_1 = Float64(Float64(a * b) / 4.0) tmp = 0.0 if (t_1 <= -4e+71) tmp = fma(Float64(b * -0.25), a, fma(y, x, c)); elseif (t_1 <= 5e+149) tmp = fma(Float64(0.0625 * z), t, fma(x, y, c)); else tmp = fma(Float64(b * -0.25), a, Float64(c + Float64(0.0625 * Float64(t * z)))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(N[(a * b), $MachinePrecision] / 4.0), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+71], N[(N[(b * -0.25), $MachinePrecision] * a + N[(y * x + c), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+149], N[(N[(0.0625 * z), $MachinePrecision] * t + N[(x * y + c), $MachinePrecision]), $MachinePrecision], N[(N[(b * -0.25), $MachinePrecision] * a + N[(c + N[(0.0625 * N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_1 := \frac{a \cdot b}{4}\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+71}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot -0.25, a, \mathsf{fma}\left(y, x, c\right)\right)\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+149}:\\
\;\;\;\;\mathsf{fma}\left(0.0625 \cdot z, t, \mathsf{fma}\left(x, y, c\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot -0.25, a, c + 0.0625 \cdot \left(t \cdot z\right)\right)\\
\end{array}
if (/.f64 (*.f64 a b) #s(literal 4 binary64)) < -4.0000000000000002e71Initial program 97.7%
lift-+.f64N/A
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
associate-+l+N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
distribute-lft-neg-inN/A
+-commutativeN/A
lower-fma.f64N/A
mult-flipN/A
distribute-rgt-neg-inN/A
distribute-neg-frac2N/A
lower-*.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-+.f6498.5%
Applied rewrites98.5%
Taylor expanded in z around 0
lower-+.f64N/A
lower-*.f6474.3%
Applied rewrites74.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6474.3%
Applied rewrites74.3%
if -4.0000000000000002e71 < (/.f64 (*.f64 a b) #s(literal 4 binary64)) < 4.9999999999999999e149Initial program 97.7%
Taylor expanded in a around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.5%
Applied rewrites74.5%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
associate-+l+N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lower-fma.f6474.8%
Applied rewrites74.8%
if 4.9999999999999999e149 < (/.f64 (*.f64 a b) #s(literal 4 binary64)) Initial program 97.7%
lift-+.f64N/A
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
associate-+l+N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
distribute-lft-neg-inN/A
+-commutativeN/A
lower-fma.f64N/A
mult-flipN/A
distribute-rgt-neg-inN/A
distribute-neg-frac2N/A
lower-*.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-+.f6498.5%
Applied rewrites98.5%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f6474.2%
Applied rewrites74.2%
(FPCore (x y z t a b c)
:precision binary64
(let* ((t_1 (/ (* a b) 4.0)) (t_2 (fma (* b -0.25) a (fma y x c))))
(if (<= t_1 -4e+71)
t_2
(if (<= t_1 5e+79) (fma (* 0.0625 z) t (fma x y c)) t_2))))double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = (a * b) / 4.0;
double t_2 = fma((b * -0.25), a, fma(y, x, c));
double tmp;
if (t_1 <= -4e+71) {
tmp = t_2;
} else if (t_1 <= 5e+79) {
tmp = fma((0.0625 * z), t, fma(x, y, c));
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a, b, c) t_1 = Float64(Float64(a * b) / 4.0) t_2 = fma(Float64(b * -0.25), a, fma(y, x, c)) tmp = 0.0 if (t_1 <= -4e+71) tmp = t_2; elseif (t_1 <= 5e+79) tmp = fma(Float64(0.0625 * z), t, fma(x, y, c)); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(N[(a * b), $MachinePrecision] / 4.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(b * -0.25), $MachinePrecision] * a + N[(y * x + c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+71], t$95$2, If[LessEqual[t$95$1, 5e+79], N[(N[(0.0625 * z), $MachinePrecision] * t + N[(x * y + c), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
t_1 := \frac{a \cdot b}{4}\\
t_2 := \mathsf{fma}\left(b \cdot -0.25, a, \mathsf{fma}\left(y, x, c\right)\right)\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+71}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+79}:\\
\;\;\;\;\mathsf{fma}\left(0.0625 \cdot z, t, \mathsf{fma}\left(x, y, c\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
if (/.f64 (*.f64 a b) #s(literal 4 binary64)) < -4.0000000000000002e71 or 5e79 < (/.f64 (*.f64 a b) #s(literal 4 binary64)) Initial program 97.7%
lift-+.f64N/A
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
associate-+l+N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
distribute-lft-neg-inN/A
+-commutativeN/A
lower-fma.f64N/A
mult-flipN/A
distribute-rgt-neg-inN/A
distribute-neg-frac2N/A
lower-*.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-+.f6498.5%
Applied rewrites98.5%
Taylor expanded in z around 0
lower-+.f64N/A
lower-*.f6474.3%
Applied rewrites74.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6474.3%
Applied rewrites74.3%
if -4.0000000000000002e71 < (/.f64 (*.f64 a b) #s(literal 4 binary64)) < 5e79Initial program 97.7%
Taylor expanded in a around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.5%
Applied rewrites74.5%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
associate-+l+N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lower-fma.f6474.8%
Applied rewrites74.8%
(FPCore (x y z t a b c)
:precision binary64
(let* ((t_1 (/ (* a b) 4.0)) (t_2 (* -0.25 (* a b))))
(if (<= t_1 -1e+248)
t_2
(if (<= t_1 2e+156) (fma (* 0.0625 z) t (fma x y c)) (+ t_2 c)))))double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = (a * b) / 4.0;
double t_2 = -0.25 * (a * b);
double tmp;
if (t_1 <= -1e+248) {
tmp = t_2;
} else if (t_1 <= 2e+156) {
tmp = fma((0.0625 * z), t, fma(x, y, c));
} else {
tmp = t_2 + c;
}
return tmp;
}
function code(x, y, z, t, a, b, c) t_1 = Float64(Float64(a * b) / 4.0) t_2 = Float64(-0.25 * Float64(a * b)) tmp = 0.0 if (t_1 <= -1e+248) tmp = t_2; elseif (t_1 <= 2e+156) tmp = fma(Float64(0.0625 * z), t, fma(x, y, c)); else tmp = Float64(t_2 + c); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(N[(a * b), $MachinePrecision] / 4.0), $MachinePrecision]}, Block[{t$95$2 = N[(-0.25 * N[(a * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+248], t$95$2, If[LessEqual[t$95$1, 2e+156], N[(N[(0.0625 * z), $MachinePrecision] * t + N[(x * y + c), $MachinePrecision]), $MachinePrecision], N[(t$95$2 + c), $MachinePrecision]]]]]
\begin{array}{l}
t_1 := \frac{a \cdot b}{4}\\
t_2 := -0.25 \cdot \left(a \cdot b\right)\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+248}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+156}:\\
\;\;\;\;\mathsf{fma}\left(0.0625 \cdot z, t, \mathsf{fma}\left(x, y, c\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2 + c\\
\end{array}
if (/.f64 (*.f64 a b) #s(literal 4 binary64)) < -1e248Initial program 97.7%
Taylor expanded in a around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.5%
Applied rewrites74.5%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
associate-+l+N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lower-fma.f6474.8%
Applied rewrites74.8%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6427.8%
Applied rewrites27.8%
if -1e248 < (/.f64 (*.f64 a b) #s(literal 4 binary64)) < 2e156Initial program 97.7%
Taylor expanded in a around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.5%
Applied rewrites74.5%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
associate-+l+N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lower-fma.f6474.8%
Applied rewrites74.8%
if 2e156 < (/.f64 (*.f64 a b) #s(literal 4 binary64)) Initial program 97.7%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6448.8%
Applied rewrites48.8%
(FPCore (x y z t a b c)
:precision binary64
(let* ((t_1 (fma 0.0625 (* t z) (* x y))) (t_2 (+ (* x y) (/ (* z t) 16.0))))
(if (<= t_2 -5e+125)
t_1
(if (<= t_2 5e+205)
(+ (* -0.25 (* a b)) c)
(if (<= t_2 INFINITY) t_1 (* x y))))))double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = fma(0.0625, (t * z), (x * y));
double t_2 = (x * y) + ((z * t) / 16.0);
double tmp;
if (t_2 <= -5e+125) {
tmp = t_1;
} else if (t_2 <= 5e+205) {
tmp = (-0.25 * (a * b)) + c;
} else if (t_2 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = x * y;
}
return tmp;
}
function code(x, y, z, t, a, b, c) t_1 = fma(0.0625, Float64(t * z), Float64(x * y)) t_2 = Float64(Float64(x * y) + Float64(Float64(z * t) / 16.0)) tmp = 0.0 if (t_2 <= -5e+125) tmp = t_1; elseif (t_2 <= 5e+205) tmp = Float64(Float64(-0.25 * Float64(a * b)) + c); elseif (t_2 <= Inf) tmp = t_1; else tmp = Float64(x * y); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(0.0625 * N[(t * z), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] + N[(N[(z * t), $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -5e+125], t$95$1, If[LessEqual[t$95$2, 5e+205], N[(N[(-0.25 * N[(a * b), $MachinePrecision]), $MachinePrecision] + c), $MachinePrecision], If[LessEqual[t$95$2, Infinity], t$95$1, N[(x * y), $MachinePrecision]]]]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(0.0625, t \cdot z, x \cdot y\right)\\
t_2 := x \cdot y + \frac{z \cdot t}{16}\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{+125}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+205}:\\
\;\;\;\;-0.25 \cdot \left(a \cdot b\right) + c\\
\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
if (+.f64 (*.f64 x y) (/.f64 (*.f64 z t) #s(literal 16 binary64))) < -4.9999999999999996e125 or 5.0000000000000002e205 < (+.f64 (*.f64 x y) (/.f64 (*.f64 z t) #s(literal 16 binary64))) < +inf.0Initial program 97.7%
Taylor expanded in a around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.5%
Applied rewrites74.5%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
associate-+l+N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lower-fma.f6474.8%
Applied rewrites74.8%
Taylor expanded in x around 0
Applied rewrites49.5%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6453.1%
Applied rewrites53.1%
if -4.9999999999999996e125 < (+.f64 (*.f64 x y) (/.f64 (*.f64 z t) #s(literal 16 binary64))) < 5.0000000000000002e205Initial program 97.7%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6448.8%
Applied rewrites48.8%
if +inf.0 < (+.f64 (*.f64 x y) (/.f64 (*.f64 z t) #s(literal 16 binary64))) Initial program 97.7%
Taylor expanded in a around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.5%
Applied rewrites74.5%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
associate-+l+N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lower-fma.f6474.8%
Applied rewrites74.8%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6427.8%
Applied rewrites27.8%
Taylor expanded in x around inf
lower-*.f6428.4%
Applied rewrites28.4%
(FPCore (x y z t a b c)
:precision binary64
(if (<= (* x y) -3.7e+111)
(* x y)
(if (<= (* x y) -3.7e-305)
(+ (* -0.25 (* a b)) c)
(if (<= (* x y) 9.5e+215) (fma (* 0.0625 z) t c) (* x y)))))double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if ((x * y) <= -3.7e+111) {
tmp = x * y;
} else if ((x * y) <= -3.7e-305) {
tmp = (-0.25 * (a * b)) + c;
} else if ((x * y) <= 9.5e+215) {
tmp = fma((0.0625 * z), t, c);
} else {
tmp = x * y;
}
return tmp;
}
function code(x, y, z, t, a, b, c) tmp = 0.0 if (Float64(x * y) <= -3.7e+111) tmp = Float64(x * y); elseif (Float64(x * y) <= -3.7e-305) tmp = Float64(Float64(-0.25 * Float64(a * b)) + c); elseif (Float64(x * y) <= 9.5e+215) tmp = fma(Float64(0.0625 * z), t, c); else tmp = Float64(x * y); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_] := If[LessEqual[N[(x * y), $MachinePrecision], -3.7e+111], N[(x * y), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], -3.7e-305], N[(N[(-0.25 * N[(a * b), $MachinePrecision]), $MachinePrecision] + c), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 9.5e+215], N[(N[(0.0625 * z), $MachinePrecision] * t + c), $MachinePrecision], N[(x * y), $MachinePrecision]]]]
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -3.7 \cdot 10^{+111}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \cdot y \leq -3.7 \cdot 10^{-305}:\\
\;\;\;\;-0.25 \cdot \left(a \cdot b\right) + c\\
\mathbf{elif}\;x \cdot y \leq 9.5 \cdot 10^{+215}:\\
\;\;\;\;\mathsf{fma}\left(0.0625 \cdot z, t, c\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
if (*.f64 x y) < -3.7000000000000003e111 or 9.5000000000000004e215 < (*.f64 x y) Initial program 97.7%
Taylor expanded in a around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.5%
Applied rewrites74.5%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
associate-+l+N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lower-fma.f6474.8%
Applied rewrites74.8%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6427.8%
Applied rewrites27.8%
Taylor expanded in x around inf
lower-*.f6428.4%
Applied rewrites28.4%
if -3.7000000000000003e111 < (*.f64 x y) < -3.6999999999999998e-305Initial program 97.7%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6448.8%
Applied rewrites48.8%
if -3.6999999999999998e-305 < (*.f64 x y) < 9.5000000000000004e215Initial program 97.7%
Taylor expanded in a around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.5%
Applied rewrites74.5%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
associate-+l+N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lower-fma.f6474.8%
Applied rewrites74.8%
Taylor expanded in x around 0
Applied rewrites49.5%
(FPCore (x y z t a b c) :precision binary64 (if (<= (* x y) -1.05e+155) (* x y) (if (<= (* x y) 9.5e+215) (fma (* 0.0625 z) t c) (* x y))))
double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if ((x * y) <= -1.05e+155) {
tmp = x * y;
} else if ((x * y) <= 9.5e+215) {
tmp = fma((0.0625 * z), t, c);
} else {
tmp = x * y;
}
return tmp;
}
function code(x, y, z, t, a, b, c) tmp = 0.0 if (Float64(x * y) <= -1.05e+155) tmp = Float64(x * y); elseif (Float64(x * y) <= 9.5e+215) tmp = fma(Float64(0.0625 * z), t, c); else tmp = Float64(x * y); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_] := If[LessEqual[N[(x * y), $MachinePrecision], -1.05e+155], N[(x * y), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 9.5e+215], N[(N[(0.0625 * z), $MachinePrecision] * t + c), $MachinePrecision], N[(x * y), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1.05 \cdot 10^{+155}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \cdot y \leq 9.5 \cdot 10^{+215}:\\
\;\;\;\;\mathsf{fma}\left(0.0625 \cdot z, t, c\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
if (*.f64 x y) < -1.05e155 or 9.5000000000000004e215 < (*.f64 x y) Initial program 97.7%
Taylor expanded in a around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.5%
Applied rewrites74.5%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
associate-+l+N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lower-fma.f6474.8%
Applied rewrites74.8%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6427.8%
Applied rewrites27.8%
Taylor expanded in x around inf
lower-*.f6428.4%
Applied rewrites28.4%
if -1.05e155 < (*.f64 x y) < 9.5000000000000004e215Initial program 97.7%
Taylor expanded in a around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.5%
Applied rewrites74.5%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
associate-+l+N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lower-fma.f6474.8%
Applied rewrites74.8%
Taylor expanded in x around 0
Applied rewrites49.5%
(FPCore (x y z t a b c)
:precision binary64
(if (<= (* x y) -3.7e+111)
(* x y)
(if (<= (* x y) -3.7e-305)
(* -0.25 (* a b))
(if (<= (* x y) 2.8e+183) (* 0.0625 (* t z)) (* x y)))))double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if ((x * y) <= -3.7e+111) {
tmp = x * y;
} else if ((x * y) <= -3.7e-305) {
tmp = -0.25 * (a * b);
} else if ((x * y) <= 2.8e+183) {
tmp = 0.0625 * (t * z);
} else {
tmp = x * y;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c)
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), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if ((x * y) <= (-3.7d+111)) then
tmp = x * y
else if ((x * y) <= (-3.7d-305)) then
tmp = (-0.25d0) * (a * b)
else if ((x * y) <= 2.8d+183) then
tmp = 0.0625d0 * (t * z)
else
tmp = x * y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if ((x * y) <= -3.7e+111) {
tmp = x * y;
} else if ((x * y) <= -3.7e-305) {
tmp = -0.25 * (a * b);
} else if ((x * y) <= 2.8e+183) {
tmp = 0.0625 * (t * z);
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z, t, a, b, c): tmp = 0 if (x * y) <= -3.7e+111: tmp = x * y elif (x * y) <= -3.7e-305: tmp = -0.25 * (a * b) elif (x * y) <= 2.8e+183: tmp = 0.0625 * (t * z) else: tmp = x * y return tmp
function code(x, y, z, t, a, b, c) tmp = 0.0 if (Float64(x * y) <= -3.7e+111) tmp = Float64(x * y); elseif (Float64(x * y) <= -3.7e-305) tmp = Float64(-0.25 * Float64(a * b)); elseif (Float64(x * y) <= 2.8e+183) tmp = Float64(0.0625 * Float64(t * z)); else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c) tmp = 0.0; if ((x * y) <= -3.7e+111) tmp = x * y; elseif ((x * y) <= -3.7e-305) tmp = -0.25 * (a * b); elseif ((x * y) <= 2.8e+183) tmp = 0.0625 * (t * z); else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_] := If[LessEqual[N[(x * y), $MachinePrecision], -3.7e+111], N[(x * y), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], -3.7e-305], N[(-0.25 * N[(a * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 2.8e+183], N[(0.0625 * N[(t * z), $MachinePrecision]), $MachinePrecision], N[(x * y), $MachinePrecision]]]]
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -3.7 \cdot 10^{+111}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \cdot y \leq -3.7 \cdot 10^{-305}:\\
\;\;\;\;-0.25 \cdot \left(a \cdot b\right)\\
\mathbf{elif}\;x \cdot y \leq 2.8 \cdot 10^{+183}:\\
\;\;\;\;0.0625 \cdot \left(t \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
if (*.f64 x y) < -3.7000000000000003e111 or 2.8000000000000002e183 < (*.f64 x y) Initial program 97.7%
Taylor expanded in a around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.5%
Applied rewrites74.5%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
associate-+l+N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lower-fma.f6474.8%
Applied rewrites74.8%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6427.8%
Applied rewrites27.8%
Taylor expanded in x around inf
lower-*.f6428.4%
Applied rewrites28.4%
if -3.7000000000000003e111 < (*.f64 x y) < -3.6999999999999998e-305Initial program 97.7%
Taylor expanded in a around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.5%
Applied rewrites74.5%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
associate-+l+N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lower-fma.f6474.8%
Applied rewrites74.8%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6427.8%
Applied rewrites27.8%
if -3.6999999999999998e-305 < (*.f64 x y) < 2.8000000000000002e183Initial program 97.7%
Taylor expanded in a around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.5%
Applied rewrites74.5%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
associate-+l+N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lower-fma.f6474.8%
Applied rewrites74.8%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6427.8%
Applied rewrites27.8%
Taylor expanded in z around inf
lower-*.f64N/A
lower-*.f6428.4%
Applied rewrites28.4%
(FPCore (x y z t a b c) :precision binary64 (if (<= (* x y) -3.7e+111) (* x y) (if (<= (* x y) 1.6e+40) (* -0.25 (* a b)) (* x y))))
double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if ((x * y) <= -3.7e+111) {
tmp = x * y;
} else if ((x * y) <= 1.6e+40) {
tmp = -0.25 * (a * b);
} else {
tmp = x * y;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c)
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), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if ((x * y) <= (-3.7d+111)) then
tmp = x * y
else if ((x * y) <= 1.6d+40) then
tmp = (-0.25d0) * (a * b)
else
tmp = x * y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if ((x * y) <= -3.7e+111) {
tmp = x * y;
} else if ((x * y) <= 1.6e+40) {
tmp = -0.25 * (a * b);
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z, t, a, b, c): tmp = 0 if (x * y) <= -3.7e+111: tmp = x * y elif (x * y) <= 1.6e+40: tmp = -0.25 * (a * b) else: tmp = x * y return tmp
function code(x, y, z, t, a, b, c) tmp = 0.0 if (Float64(x * y) <= -3.7e+111) tmp = Float64(x * y); elseif (Float64(x * y) <= 1.6e+40) tmp = Float64(-0.25 * Float64(a * b)); else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c) tmp = 0.0; if ((x * y) <= -3.7e+111) tmp = x * y; elseif ((x * y) <= 1.6e+40) tmp = -0.25 * (a * b); else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_] := If[LessEqual[N[(x * y), $MachinePrecision], -3.7e+111], N[(x * y), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 1.6e+40], N[(-0.25 * N[(a * b), $MachinePrecision]), $MachinePrecision], N[(x * y), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -3.7 \cdot 10^{+111}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \cdot y \leq 1.6 \cdot 10^{+40}:\\
\;\;\;\;-0.25 \cdot \left(a \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
if (*.f64 x y) < -3.7000000000000003e111 or 1.5999999999999999e40 < (*.f64 x y) Initial program 97.7%
Taylor expanded in a around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.5%
Applied rewrites74.5%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
associate-+l+N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lower-fma.f6474.8%
Applied rewrites74.8%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6427.8%
Applied rewrites27.8%
Taylor expanded in x around inf
lower-*.f6428.4%
Applied rewrites28.4%
if -3.7000000000000003e111 < (*.f64 x y) < 1.5999999999999999e40Initial program 97.7%
Taylor expanded in a around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.5%
Applied rewrites74.5%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
associate-+l+N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lower-fma.f6474.8%
Applied rewrites74.8%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6427.8%
Applied rewrites27.8%
(FPCore (x y z t a b c) :precision binary64 (* x y))
double code(double x, double y, double z, double t, double a, double b, double c) {
return x * 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, a, b, c)
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), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = x * y
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
return x * y;
}
def code(x, y, z, t, a, b, c): return x * y
function code(x, y, z, t, a, b, c) return Float64(x * y) end
function tmp = code(x, y, z, t, a, b, c) tmp = x * y; end
code[x_, y_, z_, t_, a_, b_, c_] := N[(x * y), $MachinePrecision]
x \cdot y
Initial program 97.7%
Taylor expanded in a around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6474.5%
Applied rewrites74.5%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
associate-+l+N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lower-fma.f6474.8%
Applied rewrites74.8%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6427.8%
Applied rewrites27.8%
Taylor expanded in x around inf
lower-*.f6428.4%
Applied rewrites28.4%
herbie shell --seed 2025204
(FPCore (x y z t a b c)
:name "Diagrams.Solve.Polynomial:quartForm from diagrams-solve-0.1, C"
:precision binary64
(+ (- (+ (* x y) (/ (* z t) 16.0)) (/ (* a b) 4.0)) c))