
(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 2e+146) (fma (- (* z_m z_m) t) (* -4.0 y) (* x x)) (fma x x (* (* (* y z_m) z_m) -4.0))))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 2e+146) {
tmp = fma(((z_m * z_m) - t), (-4.0 * y), (x * x));
} else {
tmp = fma(x, x, (((y * z_m) * z_m) * -4.0));
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 2e+146) tmp = fma(Float64(Float64(z_m * z_m) - t), Float64(-4.0 * y), Float64(x * x)); else tmp = fma(x, x, Float64(Float64(Float64(y * z_m) * 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, 2e+146], N[(N[(N[(z$95$m * z$95$m), $MachinePrecision] - t), $MachinePrecision] * N[(-4.0 * y), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(x * x + N[(N[(N[(y * z$95$m), $MachinePrecision] * z$95$m), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 2 \cdot 10^{+146}:\\
\;\;\;\;\mathsf{fma}\left(z\_m \cdot z\_m - t, -4 \cdot y, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(\left(y \cdot z\_m\right) \cdot z\_m\right) \cdot -4\right)\\
\end{array}
\end{array}
if z < 1.99999999999999987e146Initial 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
metadata-evalN/A
+-commutativeN/A
associate-*r*N/A
pow2N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites91.7%
if 1.99999999999999987e146 < z Initial 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.9
Applied rewrites92.9%
Taylor expanded in z around inf
pow2N/A
lift-*.f6467.2
Applied rewrites67.2%
Taylor expanded in z around inf
associate-*l*N/A
pow2N/A
distribute-rgt-out--N/A
pow2N/A
*-commutativeN/A
pow2N/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f6472.5
Applied rewrites72.5%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= z_m 7.2e+142) (fma x x (* (* -4.0 y) (- (* z_m z_m) t))) (fma x x (* (* (* y z_m) z_m) -4.0))))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 7.2e+142) {
tmp = fma(x, x, ((-4.0 * y) * ((z_m * z_m) - t)));
} else {
tmp = fma(x, x, (((y * z_m) * z_m) * -4.0));
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 7.2e+142) tmp = fma(x, x, Float64(Float64(-4.0 * y) * Float64(Float64(z_m * z_m) - t))); else tmp = fma(x, x, Float64(Float64(Float64(y * z_m) * 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, 7.2e+142], N[(x * x + N[(N[(-4.0 * y), $MachinePrecision] * N[(N[(z$95$m * z$95$m), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * x + N[(N[(N[(y * z$95$m), $MachinePrecision] * z$95$m), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 7.2 \cdot 10^{+142}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(-4 \cdot y\right) \cdot \left(z\_m \cdot z\_m - t\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(\left(y \cdot z\_m\right) \cdot z\_m\right) \cdot -4\right)\\
\end{array}
\end{array}
if z < 7.2000000000000003e142Initial 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.9
Applied rewrites92.9%
if 7.2000000000000003e142 < z Initial 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.9
Applied rewrites92.9%
Taylor expanded in z around inf
pow2N/A
lift-*.f6467.2
Applied rewrites67.2%
Taylor expanded in z around inf
associate-*l*N/A
pow2N/A
distribute-rgt-out--N/A
pow2N/A
*-commutativeN/A
pow2N/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f6472.5
Applied rewrites72.5%
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
:precision binary64
(if (<= z_m 1.75e-28)
(fma (- t) (* y -4.0) (* x x))
(if (<= z_m 2e+22)
(* (* -4.0 y) (- (* z_m z_m) t))
(fma x x (* (* (* y z_m) z_m) -4.0)))))z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 1.75e-28) {
tmp = fma(-t, (y * -4.0), (x * x));
} else if (z_m <= 2e+22) {
tmp = (-4.0 * y) * ((z_m * z_m) - t);
} else {
tmp = fma(x, x, (((y * z_m) * z_m) * -4.0));
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 1.75e-28) tmp = fma(Float64(-t), Float64(y * -4.0), Float64(x * x)); elseif (z_m <= 2e+22) tmp = Float64(Float64(-4.0 * y) * Float64(Float64(z_m * z_m) - t)); else tmp = fma(x, x, Float64(Float64(Float64(y * z_m) * 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, 1.75e-28], N[((-t) * N[(y * -4.0), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z$95$m, 2e+22], N[(N[(-4.0 * y), $MachinePrecision] * N[(N[(z$95$m * z$95$m), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision], N[(x * x + N[(N[(N[(y * z$95$m), $MachinePrecision] * z$95$m), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 1.75 \cdot 10^{-28}:\\
\;\;\;\;\mathsf{fma}\left(-t, y \cdot -4, x \cdot x\right)\\
\mathbf{elif}\;z\_m \leq 2 \cdot 10^{+22}:\\
\;\;\;\;\left(-4 \cdot y\right) \cdot \left(z\_m \cdot z\_m - t\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(\left(y \cdot z\_m\right) \cdot z\_m\right) \cdot -4\right)\\
\end{array}
\end{array}
if z < 1.75e-28Initial 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.9
Applied rewrites92.9%
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
pow2N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6491.7
Applied rewrites91.7%
Taylor expanded in z around 0
mul-1-negN/A
lift-neg.f6468.3
Applied rewrites68.3%
if 1.75e-28 < z < 2e22Initial program 90.7%
Taylor expanded in x around 0
associate-*r*N/A
pow2N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-*.f6463.2
Applied rewrites63.2%
if 2e22 < z Initial 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.9
Applied rewrites92.9%
Taylor expanded in z around inf
pow2N/A
lift-*.f6467.2
Applied rewrites67.2%
Taylor expanded in z around inf
associate-*l*N/A
pow2N/A
distribute-rgt-out--N/A
pow2N/A
*-commutativeN/A
pow2N/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f6472.5
Applied rewrites72.5%
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
:precision binary64
(if (<= z_m 1.75e-28)
(fma (- t) (* y -4.0) (* x x))
(if (<= z_m 1.82e+155)
(* (* -4.0 y) (- (* z_m z_m) t))
(* (* (* y z_m) z_m) -4.0))))z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 1.75e-28) {
tmp = fma(-t, (y * -4.0), (x * x));
} else if (z_m <= 1.82e+155) {
tmp = (-4.0 * y) * ((z_m * z_m) - t);
} else {
tmp = ((y * z_m) * z_m) * -4.0;
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 1.75e-28) tmp = fma(Float64(-t), Float64(y * -4.0), Float64(x * x)); elseif (z_m <= 1.82e+155) tmp = Float64(Float64(-4.0 * y) * Float64(Float64(z_m * z_m) - t)); else tmp = Float64(Float64(Float64(y * z_m) * 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, 1.75e-28], N[((-t) * N[(y * -4.0), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z$95$m, 1.82e+155], N[(N[(-4.0 * y), $MachinePrecision] * N[(N[(z$95$m * z$95$m), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y * z$95$m), $MachinePrecision] * z$95$m), $MachinePrecision] * -4.0), $MachinePrecision]]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 1.75 \cdot 10^{-28}:\\
\;\;\;\;\mathsf{fma}\left(-t, y \cdot -4, x \cdot x\right)\\
\mathbf{elif}\;z\_m \leq 1.82 \cdot 10^{+155}:\\
\;\;\;\;\left(-4 \cdot y\right) \cdot \left(z\_m \cdot z\_m - t\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(y \cdot z\_m\right) \cdot z\_m\right) \cdot -4\\
\end{array}
\end{array}
if z < 1.75e-28Initial 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.9
Applied rewrites92.9%
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
pow2N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6491.7
Applied rewrites91.7%
Taylor expanded in z around 0
mul-1-negN/A
lift-neg.f6468.3
Applied rewrites68.3%
if 1.75e-28 < z < 1.81999999999999989e155Initial program 90.7%
Taylor expanded in x around 0
associate-*r*N/A
pow2N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-*.f6463.2
Applied rewrites63.2%
if 1.81999999999999989e155 < z Initial program 90.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6436.0
Applied rewrites36.0%
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6439.1
Applied rewrites39.1%
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
:precision binary64
(if (<= z_m 1.75e-28)
(fma x x (* (* t y) 4.0))
(if (<= z_m 1.82e+155)
(* (* -4.0 y) (- (* z_m z_m) t))
(* (* (* y z_m) z_m) -4.0))))z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 1.75e-28) {
tmp = fma(x, x, ((t * y) * 4.0));
} else if (z_m <= 1.82e+155) {
tmp = (-4.0 * y) * ((z_m * z_m) - t);
} else {
tmp = ((y * z_m) * z_m) * -4.0;
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 1.75e-28) tmp = fma(x, x, Float64(Float64(t * y) * 4.0)); elseif (z_m <= 1.82e+155) tmp = Float64(Float64(-4.0 * y) * Float64(Float64(z_m * z_m) - t)); else tmp = Float64(Float64(Float64(y * z_m) * 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, 1.75e-28], N[(x * x + N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z$95$m, 1.82e+155], N[(N[(-4.0 * y), $MachinePrecision] * N[(N[(z$95$m * z$95$m), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y * z$95$m), $MachinePrecision] * z$95$m), $MachinePrecision] * -4.0), $MachinePrecision]]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 1.75 \cdot 10^{-28}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(t \cdot y\right) \cdot 4\right)\\
\mathbf{elif}\;z\_m \leq 1.82 \cdot 10^{+155}:\\
\;\;\;\;\left(-4 \cdot y\right) \cdot \left(z\_m \cdot z\_m - t\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(y \cdot z\_m\right) \cdot z\_m\right) \cdot -4\\
\end{array}
\end{array}
if z < 1.75e-28Initial 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.9
Applied rewrites92.9%
Taylor expanded in z around 0
*-commutativeN/A
lower-*.f64N/A
lift-*.f6468.1
Applied rewrites68.1%
if 1.75e-28 < z < 1.81999999999999989e155Initial program 90.7%
Taylor expanded in x around 0
associate-*r*N/A
pow2N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-*.f6463.2
Applied rewrites63.2%
if 1.81999999999999989e155 < z Initial program 90.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6436.0
Applied rewrites36.0%
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6439.1
Applied rewrites39.1%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= z_m 1.2e+53) (fma x x (* (* t y) 4.0)) (* (* (* y z_m) z_m) -4.0)))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 1.2e+53) {
tmp = fma(x, x, ((t * y) * 4.0));
} else {
tmp = ((y * z_m) * z_m) * -4.0;
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 1.2e+53) tmp = fma(x, x, Float64(Float64(t * y) * 4.0)); else tmp = Float64(Float64(Float64(y * z_m) * 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, 1.2e+53], N[(x * x + N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y * z$95$m), $MachinePrecision] * z$95$m), $MachinePrecision] * -4.0), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 1.2 \cdot 10^{+53}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(t \cdot y\right) \cdot 4\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(y \cdot z\_m\right) \cdot z\_m\right) \cdot -4\\
\end{array}
\end{array}
if z < 1.2e53Initial 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.9
Applied rewrites92.9%
Taylor expanded in z around 0
*-commutativeN/A
lower-*.f64N/A
lift-*.f6468.1
Applied rewrites68.1%
if 1.2e53 < z Initial program 90.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6436.0
Applied rewrites36.0%
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6439.1
Applied rewrites39.1%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= z_m 1.2e+53) (fma (* t y) 4.0 (* x x)) (* (* (* y z_m) z_m) -4.0)))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 1.2e+53) {
tmp = fma((t * y), 4.0, (x * x));
} else {
tmp = ((y * z_m) * z_m) * -4.0;
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 1.2e+53) tmp = fma(Float64(t * y), 4.0, Float64(x * x)); else tmp = Float64(Float64(Float64(y * z_m) * 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, 1.2e+53], N[(N[(t * y), $MachinePrecision] * 4.0 + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y * z$95$m), $MachinePrecision] * z$95$m), $MachinePrecision] * -4.0), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 1.2 \cdot 10^{+53}:\\
\;\;\;\;\mathsf{fma}\left(t \cdot y, 4, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(y \cdot z\_m\right) \cdot z\_m\right) \cdot -4\\
\end{array}
\end{array}
if z < 1.2e53Initial program 90.7%
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-*.f6467.3
Applied rewrites67.3%
if 1.2e53 < z Initial program 90.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6436.0
Applied rewrites36.0%
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6439.1
Applied rewrites39.1%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= x 1.5e-53) (* (* t y) 4.0) (if (<= x 5.5e+56) (* (* (* y z_m) z_m) -4.0) (* x x))))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (x <= 1.5e-53) {
tmp = (t * y) * 4.0;
} else if (x <= 5.5e+56) {
tmp = ((y * z_m) * z_m) * -4.0;
} 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-53) then
tmp = (t * y) * 4.0d0
else if (x <= 5.5d+56) then
tmp = ((y * z_m) * z_m) * (-4.0d0)
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-53) {
tmp = (t * y) * 4.0;
} else if (x <= 5.5e+56) {
tmp = ((y * z_m) * z_m) * -4.0;
} else {
tmp = x * x;
}
return tmp;
}
z_m = math.fabs(z) def code(x, y, z_m, t): tmp = 0 if x <= 1.5e-53: tmp = (t * y) * 4.0 elif x <= 5.5e+56: tmp = ((y * z_m) * z_m) * -4.0 else: tmp = x * x return tmp
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (x <= 1.5e-53) tmp = Float64(Float64(t * y) * 4.0); elseif (x <= 5.5e+56) tmp = Float64(Float64(Float64(y * z_m) * z_m) * -4.0); 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-53) tmp = (t * y) * 4.0; elseif (x <= 5.5e+56) tmp = ((y * z_m) * z_m) * -4.0; 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-53], N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision], If[LessEqual[x, 5.5e+56], N[(N[(N[(y * z$95$m), $MachinePrecision] * z$95$m), $MachinePrecision] * -4.0), $MachinePrecision], N[(x * x), $MachinePrecision]]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.5 \cdot 10^{-53}:\\
\;\;\;\;\left(t \cdot y\right) \cdot 4\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{+56}:\\
\;\;\;\;\left(\left(y \cdot z\_m\right) \cdot z\_m\right) \cdot -4\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if x < 1.5000000000000001e-53Initial program 90.7%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6432.9
Applied rewrites32.9%
if 1.5000000000000001e-53 < x < 5.5000000000000002e56Initial program 90.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6436.0
Applied rewrites36.0%
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6439.1
Applied rewrites39.1%
if 5.5000000000000002e56 < x Initial program 90.7%
Taylor expanded in x around inf
pow2N/A
lift-*.f6441.1
Applied rewrites41.1%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= x 9e+31) (* (* t y) 4.0) (* x x)))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (x <= 9e+31) {
tmp = (t * y) * 4.0;
} 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 <= 9d+31) then
tmp = (t * y) * 4.0d0
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 <= 9e+31) {
tmp = (t * y) * 4.0;
} else {
tmp = x * x;
}
return tmp;
}
z_m = math.fabs(z) def code(x, y, z_m, t): tmp = 0 if x <= 9e+31: tmp = (t * y) * 4.0 else: tmp = x * x return tmp
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (x <= 9e+31) tmp = Float64(Float64(t * y) * 4.0); 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 <= 9e+31) tmp = (t * y) * 4.0; 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, 9e+31], N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 9 \cdot 10^{+31}:\\
\;\;\;\;\left(t \cdot y\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if x < 8.9999999999999992e31Initial program 90.7%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6432.9
Applied rewrites32.9%
if 8.9999999999999992e31 < x Initial program 90.7%
Taylor expanded in x around inf
pow2N/A
lift-*.f6441.1
Applied rewrites41.1%
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.1
Applied rewrites41.1%
herbie shell --seed 2025123
(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))))