
(FPCore (x y z t) :precision binary64 (- (* x x) (* (* y 4.0) (- (* z z) t))))
double code(double x, double y, double z, double t) {
return (x * x) - ((y * 4.0) * ((z * z) - t));
}
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 * x) - ((y * 4.0d0) * ((z * z) - t))
end function
public static double code(double x, double y, double z, double t) {
return (x * x) - ((y * 4.0) * ((z * z) - t));
}
def code(x, y, z, t): return (x * x) - ((y * 4.0) * ((z * z) - t))
function code(x, y, z, t) return Float64(Float64(x * x) - Float64(Float64(y * 4.0) * Float64(Float64(z * z) - t))) end
function tmp = code(x, y, z, t) tmp = (x * x) - ((y * 4.0) * ((z * z) - t)); end
code[x_, y_, z_, t_] := N[(N[(x * x), $MachinePrecision] - N[(N[(y * 4.0), $MachinePrecision] * N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\end{array}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (- (* x x) (* (* y 4.0) (- (* z z) t))))
double code(double x, double y, double z, double t) {
return (x * x) - ((y * 4.0) * ((z * z) - t));
}
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 * x) - ((y * 4.0d0) * ((z * z) - t))
end function
public static double code(double x, double y, double z, double t) {
return (x * x) - ((y * 4.0) * ((z * z) - t));
}
def code(x, y, z, t): return (x * x) - ((y * 4.0) * ((z * z) - t))
function code(x, y, z, t) return Float64(Float64(x * x) - Float64(Float64(y * 4.0) * Float64(Float64(z * z) - t))) end
function tmp = code(x, y, z, t) tmp = (x * x) - ((y * 4.0) * ((z * z) - t)); end
code[x_, y_, z_, t_] := N[(N[(x * x), $MachinePrecision] - N[(N[(y * 4.0), $MachinePrecision] * N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\end{array}
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= z_m 3.4e+148) (fma (- (* z_m z_m) t) (* -4.0 y) (* x x)) (* (* (* z_m y) z_m) -4.0)))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 3.4e+148) {
tmp = fma(((z_m * z_m) - t), (-4.0 * y), (x * x));
} else {
tmp = ((z_m * y) * z_m) * -4.0;
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 3.4e+148) tmp = fma(Float64(Float64(z_m * z_m) - t), Float64(-4.0 * y), Float64(x * x)); else tmp = Float64(Float64(Float64(z_m * y) * z_m) * -4.0); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[z$95$m, 3.4e+148], N[(N[(N[(z$95$m * z$95$m), $MachinePrecision] - t), $MachinePrecision] * N[(-4.0 * y), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z$95$m * y), $MachinePrecision] * z$95$m), $MachinePrecision] * -4.0), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 3.4 \cdot 10^{+148}:\\
\;\;\;\;\mathsf{fma}\left(z\_m \cdot z\_m - t, -4 \cdot y, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(z\_m \cdot y\right) \cdot z\_m\right) \cdot -4\\
\end{array}
\end{array}
if z < 3.4000000000000003e148Initial program 97.6%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
pow2N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
associate-*r*N/A
pow2N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.3%
if 3.4000000000000003e148 < z Initial program 71.1%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6476.0
Applied rewrites76.0%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6487.6
Applied rewrites87.6%
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
:precision binary64
(if (<= z_m 2.3e-33)
(fma (- t) (* -4.0 y) (* x x))
(if (<= z_m 3e+124)
(fma x x (* (* -4.0 y) (* z_m z_m)))
(* (* (* z_m y) z_m) -4.0))))z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 2.3e-33) {
tmp = fma(-t, (-4.0 * y), (x * x));
} else if (z_m <= 3e+124) {
tmp = fma(x, x, ((-4.0 * y) * (z_m * z_m)));
} else {
tmp = ((z_m * y) * z_m) * -4.0;
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 2.3e-33) tmp = fma(Float64(-t), Float64(-4.0 * y), Float64(x * x)); elseif (z_m <= 3e+124) tmp = fma(x, x, Float64(Float64(-4.0 * y) * Float64(z_m * z_m))); else tmp = Float64(Float64(Float64(z_m * y) * z_m) * -4.0); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[z$95$m, 2.3e-33], N[((-t) * N[(-4.0 * y), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z$95$m, 3e+124], N[(x * x + N[(N[(-4.0 * y), $MachinePrecision] * N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z$95$m * y), $MachinePrecision] * z$95$m), $MachinePrecision] * -4.0), $MachinePrecision]]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 2.3 \cdot 10^{-33}:\\
\;\;\;\;\mathsf{fma}\left(-t, -4 \cdot y, x \cdot x\right)\\
\mathbf{elif}\;z\_m \leq 3 \cdot 10^{+124}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(-4 \cdot y\right) \cdot \left(z\_m \cdot z\_m\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(z\_m \cdot y\right) \cdot z\_m\right) \cdot -4\\
\end{array}
\end{array}
if z < 2.29999999999999986e-33Initial program 98.4%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
pow2N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
associate-*r*N/A
pow2N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.6%
Taylor expanded in z around 0
mul-1-negN/A
lower-neg.f6496.6
Applied rewrites96.6%
if 2.29999999999999986e-33 < z < 3e124Initial program 96.6%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
pow2N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
fp-cancel-sub-sign-invN/A
pow2N/A
metadata-evalN/A
lower-fma.f64N/A
associate-*r*N/A
pow2N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-*.f6497.6
Applied rewrites97.6%
Taylor expanded in z around inf
pow2N/A
lift-*.f6477.9
Applied rewrites77.9%
if 3e124 < z Initial program 74.2%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6475.7
Applied rewrites75.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6485.9
Applied rewrites85.9%
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
:precision binary64
(if (<= z_m 2.3e-33)
(fma (- t) (* -4.0 y) (* x x))
(if (<= z_m 1.95e+123)
(fma (* (* z_m z_m) y) -4.0 (* x x))
(* (* (* z_m y) z_m) -4.0))))z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 2.3e-33) {
tmp = fma(-t, (-4.0 * y), (x * x));
} else if (z_m <= 1.95e+123) {
tmp = fma(((z_m * z_m) * y), -4.0, (x * x));
} else {
tmp = ((z_m * y) * z_m) * -4.0;
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 2.3e-33) tmp = fma(Float64(-t), Float64(-4.0 * y), Float64(x * x)); elseif (z_m <= 1.95e+123) tmp = fma(Float64(Float64(z_m * z_m) * y), -4.0, Float64(x * x)); else tmp = Float64(Float64(Float64(z_m * y) * z_m) * -4.0); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[z$95$m, 2.3e-33], N[((-t) * N[(-4.0 * y), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z$95$m, 1.95e+123], N[(N[(N[(z$95$m * z$95$m), $MachinePrecision] * y), $MachinePrecision] * -4.0 + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z$95$m * y), $MachinePrecision] * z$95$m), $MachinePrecision] * -4.0), $MachinePrecision]]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 2.3 \cdot 10^{-33}:\\
\;\;\;\;\mathsf{fma}\left(-t, -4 \cdot y, x \cdot x\right)\\
\mathbf{elif}\;z\_m \leq 1.95 \cdot 10^{+123}:\\
\;\;\;\;\mathsf{fma}\left(\left(z\_m \cdot z\_m\right) \cdot y, -4, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(z\_m \cdot y\right) \cdot z\_m\right) \cdot -4\\
\end{array}
\end{array}
if z < 2.29999999999999986e-33Initial program 98.4%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
pow2N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
associate-*r*N/A
pow2N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.6%
Taylor expanded in z around 0
mul-1-negN/A
lower-neg.f6496.6
Applied rewrites96.6%
if 2.29999999999999986e-33 < z < 1.94999999999999996e123Initial program 96.6%
Taylor expanded in t around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6477.0
Applied rewrites77.0%
if 1.94999999999999996e123 < z Initial program 74.3%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6475.6
Applied rewrites75.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6485.7
Applied rewrites85.7%
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
:precision binary64
(let* ((t_1 (- (* z_m z_m) t)))
(if (<= t_1 INFINITY)
(fma x x (* (* -4.0 y) t_1))
(* (* (* z_m y) z_m) -4.0))))z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double t_1 = (z_m * z_m) - t;
double tmp;
if (t_1 <= ((double) INFINITY)) {
tmp = fma(x, x, ((-4.0 * y) * t_1));
} else {
tmp = ((z_m * y) * z_m) * -4.0;
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) t_1 = Float64(Float64(z_m * z_m) - t) tmp = 0.0 if (t_1 <= Inf) tmp = fma(x, x, Float64(Float64(-4.0 * y) * t_1)); else tmp = Float64(Float64(Float64(z_m * y) * z_m) * -4.0); end return tmp end
z_m = N[Abs[z], $MachinePrecision]
code[x_, y_, z$95$m_, t_] := Block[{t$95$1 = N[(N[(z$95$m * z$95$m), $MachinePrecision] - t), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], N[(x * x + N[(N[(-4.0 * y), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z$95$m * y), $MachinePrecision] * z$95$m), $MachinePrecision] * -4.0), $MachinePrecision]]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
t_1 := z\_m \cdot z\_m - t\\
\mathbf{if}\;t\_1 \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(-4 \cdot y\right) \cdot t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(z\_m \cdot y\right) \cdot z\_m\right) \cdot -4\\
\end{array}
\end{array}
if (-.f64 (*.f64 z z) t) < +inf.0Initial program 90.7%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
pow2N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
fp-cancel-sub-sign-invN/A
pow2N/A
metadata-evalN/A
lower-fma.f64N/A
associate-*r*N/A
pow2N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-*.f6492.6
Applied rewrites92.6%
if +inf.0 < (-.f64 (*.f64 z z) t) Initial program 90.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6436.8
Applied rewrites36.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6439.9
Applied rewrites39.9%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= (* z_m z_m) 1e+134) (fma (- t) (* -4.0 y) (* x x)) (* (* (* z_m y) z_m) -4.0)))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if ((z_m * z_m) <= 1e+134) {
tmp = fma(-t, (-4.0 * y), (x * x));
} else {
tmp = ((z_m * y) * z_m) * -4.0;
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (Float64(z_m * z_m) <= 1e+134) tmp = fma(Float64(-t), Float64(-4.0 * y), Float64(x * x)); else tmp = Float64(Float64(Float64(z_m * y) * z_m) * -4.0); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[N[(z$95$m * z$95$m), $MachinePrecision], 1e+134], N[((-t) * N[(-4.0 * y), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z$95$m * y), $MachinePrecision] * z$95$m), $MachinePrecision] * -4.0), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \cdot z\_m \leq 10^{+134}:\\
\;\;\;\;\mathsf{fma}\left(-t, -4 \cdot y, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(z\_m \cdot y\right) \cdot z\_m\right) \cdot -4\\
\end{array}
\end{array}
if (*.f64 z z) < 9.99999999999999921e133Initial program 98.2%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
pow2N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
associate-*r*N/A
pow2N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.6%
Taylor expanded in z around 0
mul-1-negN/A
lower-neg.f6489.7
Applied rewrites89.7%
if 9.99999999999999921e133 < (*.f64 z z) Initial program 79.0%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6471.5
Applied rewrites71.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6479.2
Applied rewrites79.2%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= (* z_m z_m) 1e+134) (fma x x (* (* t y) 4.0)) (* (* (* z_m y) z_m) -4.0)))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if ((z_m * z_m) <= 1e+134) {
tmp = fma(x, x, ((t * y) * 4.0));
} else {
tmp = ((z_m * y) * z_m) * -4.0;
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (Float64(z_m * z_m) <= 1e+134) tmp = fma(x, x, Float64(Float64(t * y) * 4.0)); else tmp = Float64(Float64(Float64(z_m * y) * z_m) * -4.0); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[N[(z$95$m * z$95$m), $MachinePrecision], 1e+134], N[(x * x + N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z$95$m * y), $MachinePrecision] * z$95$m), $MachinePrecision] * -4.0), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \cdot z\_m \leq 10^{+134}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(t \cdot y\right) \cdot 4\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(z\_m \cdot y\right) \cdot z\_m\right) \cdot -4\\
\end{array}
\end{array}
if (*.f64 z z) < 9.99999999999999921e133Initial program 98.2%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
pow2N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
fp-cancel-sub-sign-invN/A
pow2N/A
metadata-evalN/A
lower-fma.f64N/A
associate-*r*N/A
pow2N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-*.f6498.6
Applied rewrites98.6%
Taylor expanded in z around 0
*-commutativeN/A
lower-*.f64N/A
lower-*.f6488.8
Applied rewrites88.8%
if 9.99999999999999921e133 < (*.f64 z z) Initial program 79.0%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6471.5
Applied rewrites71.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6479.2
Applied rewrites79.2%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= z_m 9.8e+67) (fma (* t y) 4.0 (* x x)) (* (* (* z_m y) z_m) -4.0)))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 9.8e+67) {
tmp = fma((t * y), 4.0, (x * x));
} else {
tmp = ((z_m * y) * z_m) * -4.0;
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 9.8e+67) tmp = fma(Float64(t * y), 4.0, Float64(x * x)); else tmp = Float64(Float64(Float64(z_m * y) * z_m) * -4.0); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[z$95$m, 9.8e+67], N[(N[(t * y), $MachinePrecision] * 4.0 + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z$95$m * y), $MachinePrecision] * z$95$m), $MachinePrecision] * -4.0), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 9.8 \cdot 10^{+67}:\\
\;\;\;\;\mathsf{fma}\left(t \cdot y, 4, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(z\_m \cdot y\right) \cdot z\_m\right) \cdot -4\\
\end{array}
\end{array}
if z < 9.7999999999999998e67Initial program 98.2%
Taylor expanded in z around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6488.4
Applied rewrites88.4%
if 9.7999999999999998e67 < z Initial program 79.0%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6471.7
Applied rewrites71.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6479.5
Applied rewrites79.5%
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
:precision binary64
(let* ((t_1 (* (* 4.0 y) t)))
(if (<= z_m 4.4e-299)
t_1
(if (<= z_m 1.3e-250)
(* x x)
(if (<= z_m 3.3e-197)
t_1
(if (<= z_m 2.8e+39) (* x x) (* (* (* z_m y) z_m) -4.0)))))))z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double t_1 = (4.0 * y) * t;
double tmp;
if (z_m <= 4.4e-299) {
tmp = t_1;
} else if (z_m <= 1.3e-250) {
tmp = x * x;
} else if (z_m <= 3.3e-197) {
tmp = t_1;
} else if (z_m <= 2.8e+39) {
tmp = x * x;
} else {
tmp = ((z_m * y) * z_m) * -4.0;
}
return tmp;
}
z_m = private
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_m, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = (4.0d0 * y) * t
if (z_m <= 4.4d-299) then
tmp = t_1
else if (z_m <= 1.3d-250) then
tmp = x * x
else if (z_m <= 3.3d-197) then
tmp = t_1
else if (z_m <= 2.8d+39) then
tmp = x * x
else
tmp = ((z_m * y) * z_m) * (-4.0d0)
end if
code = tmp
end function
z_m = Math.abs(z);
public static double code(double x, double y, double z_m, double t) {
double t_1 = (4.0 * y) * t;
double tmp;
if (z_m <= 4.4e-299) {
tmp = t_1;
} else if (z_m <= 1.3e-250) {
tmp = x * x;
} else if (z_m <= 3.3e-197) {
tmp = t_1;
} else if (z_m <= 2.8e+39) {
tmp = x * x;
} else {
tmp = ((z_m * y) * z_m) * -4.0;
}
return tmp;
}
z_m = math.fabs(z) def code(x, y, z_m, t): t_1 = (4.0 * y) * t tmp = 0 if z_m <= 4.4e-299: tmp = t_1 elif z_m <= 1.3e-250: tmp = x * x elif z_m <= 3.3e-197: tmp = t_1 elif z_m <= 2.8e+39: tmp = x * x else: tmp = ((z_m * y) * z_m) * -4.0 return tmp
z_m = abs(z) function code(x, y, z_m, t) t_1 = Float64(Float64(4.0 * y) * t) tmp = 0.0 if (z_m <= 4.4e-299) tmp = t_1; elseif (z_m <= 1.3e-250) tmp = Float64(x * x); elseif (z_m <= 3.3e-197) tmp = t_1; elseif (z_m <= 2.8e+39) tmp = Float64(x * x); else tmp = Float64(Float64(Float64(z_m * y) * z_m) * -4.0); end return tmp end
z_m = abs(z); function tmp_2 = code(x, y, z_m, t) t_1 = (4.0 * y) * t; tmp = 0.0; if (z_m <= 4.4e-299) tmp = t_1; elseif (z_m <= 1.3e-250) tmp = x * x; elseif (z_m <= 3.3e-197) tmp = t_1; elseif (z_m <= 2.8e+39) tmp = x * x; else tmp = ((z_m * y) * z_m) * -4.0; end tmp_2 = tmp; end
z_m = N[Abs[z], $MachinePrecision]
code[x_, y_, z$95$m_, t_] := Block[{t$95$1 = N[(N[(4.0 * y), $MachinePrecision] * t), $MachinePrecision]}, If[LessEqual[z$95$m, 4.4e-299], t$95$1, If[LessEqual[z$95$m, 1.3e-250], N[(x * x), $MachinePrecision], If[LessEqual[z$95$m, 3.3e-197], t$95$1, If[LessEqual[z$95$m, 2.8e+39], N[(x * x), $MachinePrecision], N[(N[(N[(z$95$m * y), $MachinePrecision] * z$95$m), $MachinePrecision] * -4.0), $MachinePrecision]]]]]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
t_1 := \left(4 \cdot y\right) \cdot t\\
\mathbf{if}\;z\_m \leq 4.4 \cdot 10^{-299}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z\_m \leq 1.3 \cdot 10^{-250}:\\
\;\;\;\;x \cdot x\\
\mathbf{elif}\;z\_m \leq 3.3 \cdot 10^{-197}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z\_m \leq 2.8 \cdot 10^{+39}:\\
\;\;\;\;x \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(\left(z\_m \cdot y\right) \cdot z\_m\right) \cdot -4\\
\end{array}
\end{array}
if z < 4.3999999999999999e-299 or 1.30000000000000004e-250 < z < 3.2999999999999997e-197Initial program 99.0%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6450.3
Applied rewrites50.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6450.3
Applied rewrites50.3%
if 4.3999999999999999e-299 < z < 1.30000000000000004e-250 or 3.2999999999999997e-197 < z < 2.80000000000000001e39Initial program 98.1%
Taylor expanded in x around inf
pow2N/A
lift-*.f6451.4
Applied rewrites51.4%
if 2.80000000000000001e39 < z Initial program 80.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6468.6
Applied rewrites68.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6475.6
Applied rewrites75.6%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= x 1.5e-32) (* (* 4.0 y) t) (* x x)))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (x <= 1.5e-32) {
tmp = (4.0 * y) * t;
} else {
tmp = x * x;
}
return tmp;
}
z_m = private
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_m, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t
real(8) :: tmp
if (x <= 1.5d-32) then
tmp = (4.0d0 * y) * t
else
tmp = x * x
end if
code = tmp
end function
z_m = Math.abs(z);
public static double code(double x, double y, double z_m, double t) {
double tmp;
if (x <= 1.5e-32) {
tmp = (4.0 * y) * t;
} else {
tmp = x * x;
}
return tmp;
}
z_m = math.fabs(z) def code(x, y, z_m, t): tmp = 0 if x <= 1.5e-32: tmp = (4.0 * y) * t else: tmp = x * x return tmp
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (x <= 1.5e-32) tmp = Float64(Float64(4.0 * y) * t); else tmp = Float64(x * x); end return tmp end
z_m = abs(z); function tmp_2 = code(x, y, z_m, t) tmp = 0.0; if (x <= 1.5e-32) tmp = (4.0 * y) * t; else tmp = x * x; end tmp_2 = tmp; end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[x, 1.5e-32], N[(N[(4.0 * y), $MachinePrecision] * t), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.5 \cdot 10^{-32}:\\
\;\;\;\;\left(4 \cdot y\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if x < 1.5e-32Initial program 91.6%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6437.0
Applied rewrites37.0%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6437.0
Applied rewrites37.0%
if 1.5e-32 < x Initial program 88.4%
Taylor expanded in x around inf
pow2N/A
lift-*.f6467.8
Applied rewrites67.8%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (* x x))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
return x * x;
}
z_m = private
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_m, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t
code = x * x
end function
z_m = Math.abs(z);
public static double code(double x, double y, double z_m, double t) {
return x * x;
}
z_m = math.fabs(z) def code(x, y, z_m, t): return x * x
z_m = abs(z) function code(x, y, z_m, t) return Float64(x * x) end
z_m = abs(z); function tmp = code(x, y, z_m, t) tmp = x * x; end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := N[(x * x), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
x \cdot x
\end{array}
Initial program 90.7%
Taylor expanded in x around inf
pow2N/A
lift-*.f6441.9
Applied rewrites41.9%
herbie shell --seed 2025112
(FPCore (x y z t)
:name "Graphics.Rasterific.Shading:$sradialGradientWithFocusShader from Rasterific-0.6.1, B"
:precision binary64
(- (* x x) (* (* y 4.0) (- (* z z) t))))