
(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 11 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}
x_m = (fabs.f64 x)
(FPCore (x_m y z t)
:precision binary64
(if (<= x_m 8e-6)
(- (* x_m x_m) (fma (* (* 4.0 y) z) z (* (* 4.0 y) (- t))))
(*
(*
(fma (* -4.0 y) (fma (/ z x_m) (/ z x_m) (/ (- t) (* x_m x_m))) 1.0)
x_m)
x_m)))x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (x_m <= 8e-6) {
tmp = (x_m * x_m) - fma(((4.0 * y) * z), z, ((4.0 * y) * -t));
} else {
tmp = (fma((-4.0 * y), fma((z / x_m), (z / x_m), (-t / (x_m * x_m))), 1.0) * x_m) * x_m;
}
return tmp;
}
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (x_m <= 8e-6) tmp = Float64(Float64(x_m * x_m) - fma(Float64(Float64(4.0 * y) * z), z, Float64(Float64(4.0 * y) * Float64(-t)))); else tmp = Float64(Float64(fma(Float64(-4.0 * y), fma(Float64(z / x_m), Float64(z / x_m), Float64(Float64(-t) / Float64(x_m * x_m))), 1.0) * x_m) * x_m); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := If[LessEqual[x$95$m, 8e-6], N[(N[(x$95$m * x$95$m), $MachinePrecision] - N[(N[(N[(4.0 * y), $MachinePrecision] * z), $MachinePrecision] * z + N[(N[(4.0 * y), $MachinePrecision] * (-t)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(-4.0 * y), $MachinePrecision] * N[(N[(z / x$95$m), $MachinePrecision] * N[(z / x$95$m), $MachinePrecision] + N[((-t) / N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * x$95$m), $MachinePrecision] * x$95$m), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 8 \cdot 10^{-6}:\\
\;\;\;\;x\_m \cdot x\_m - \mathsf{fma}\left(\left(4 \cdot y\right) \cdot z, z, \left(4 \cdot y\right) \cdot \left(-t\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(-4 \cdot y, \mathsf{fma}\left(\frac{z}{x\_m}, \frac{z}{x\_m}, \frac{-t}{x\_m \cdot x\_m}\right), 1\right) \cdot x\_m\right) \cdot x\_m\\
\end{array}
\end{array}
if x < 7.99999999999999964e-6Initial program 94.1%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
pow2N/A
negate-subN/A
mul-1-negN/A
distribute-lft-inN/A
pow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6497.3
Applied rewrites97.3%
if 7.99999999999999964e-6 < x Initial program 87.6%
Taylor expanded in x around inf
*-commutativeN/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites83.2%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
pow2N/A
negate-subN/A
pow2N/A
div-add-revN/A
mul-1-negN/A
associate-*r/N/A
pow2N/A
pow2N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f64N/A
pow2N/A
lift-*.f6498.1
Applied rewrites98.1%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (if (<= y 4.1e-69) (- (* x_m x_m) (fma (* (* 4.0 y) z) z (* (* 4.0 y) (- t)))) (fma x_m x_m (* (- t (* z z)) (* 4.0 y)))))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (y <= 4.1e-69) {
tmp = (x_m * x_m) - fma(((4.0 * y) * z), z, ((4.0 * y) * -t));
} else {
tmp = fma(x_m, x_m, ((t - (z * z)) * (4.0 * y)));
}
return tmp;
}
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (y <= 4.1e-69) tmp = Float64(Float64(x_m * x_m) - fma(Float64(Float64(4.0 * y) * z), z, Float64(Float64(4.0 * y) * Float64(-t)))); else tmp = fma(x_m, x_m, Float64(Float64(t - Float64(z * z)) * Float64(4.0 * y))); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := If[LessEqual[y, 4.1e-69], N[(N[(x$95$m * x$95$m), $MachinePrecision] - N[(N[(N[(4.0 * y), $MachinePrecision] * z), $MachinePrecision] * z + N[(N[(4.0 * y), $MachinePrecision] * (-t)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$95$m * x$95$m + N[(N[(t - N[(z * z), $MachinePrecision]), $MachinePrecision] * N[(4.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.1 \cdot 10^{-69}:\\
\;\;\;\;x\_m \cdot x\_m - \mathsf{fma}\left(\left(4 \cdot y\right) \cdot z, z, \left(4 \cdot y\right) \cdot \left(-t\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x\_m, x\_m, \left(t - z \cdot z\right) \cdot \left(4 \cdot y\right)\right)\\
\end{array}
\end{array}
if y < 4.0999999999999999e-69Initial program 91.3%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
pow2N/A
negate-subN/A
mul-1-negN/A
distribute-lft-inN/A
pow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6496.9
Applied rewrites96.9%
if 4.0999999999999999e-69 < y Initial program 89.6%
lift-*.f64N/A
lift--.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
pow2N/A
lower-fma.f64N/A
pow2N/A
associate-*r*N/A
*-commutativeN/A
metadata-evalN/A
distribute-lft-neg-inN/A
Applied rewrites95.3%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (if (<= z 1.2e+175) (fma x_m x_m (* (- t (* z z)) (* 4.0 y))) (* (* z (* z y)) -4.0)))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (z <= 1.2e+175) {
tmp = fma(x_m, x_m, ((t - (z * z)) * (4.0 * y)));
} else {
tmp = (z * (z * y)) * -4.0;
}
return tmp;
}
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (z <= 1.2e+175) tmp = fma(x_m, x_m, Float64(Float64(t - Float64(z * z)) * Float64(4.0 * y))); else tmp = Float64(Float64(z * Float64(z * y)) * -4.0); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := If[LessEqual[z, 1.2e+175], N[(x$95$m * x$95$m + N[(N[(t - N[(z * z), $MachinePrecision]), $MachinePrecision] * N[(4.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z * N[(z * y), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.2 \cdot 10^{+175}:\\
\;\;\;\;\mathsf{fma}\left(x\_m, x\_m, \left(t - z \cdot z\right) \cdot \left(4 \cdot y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot \left(z \cdot y\right)\right) \cdot -4\\
\end{array}
\end{array}
if z < 1.2e175Initial program 92.9%
lift-*.f64N/A
lift--.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
pow2N/A
lower-fma.f64N/A
pow2N/A
associate-*r*N/A
*-commutativeN/A
metadata-evalN/A
distribute-lft-neg-inN/A
Applied rewrites94.5%
if 1.2e175 < z Initial program 73.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6479.6
Applied rewrites79.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6491.6
Applied rewrites91.6%
x_m = (fabs.f64 x)
(FPCore (x_m y z t)
:precision binary64
(if (<= z 1.5e+19)
(fma x_m x_m (* t (* 4.0 y)))
(if (<= z 1.2e+175)
(fma x_m x_m (* (* (* z z) y) -4.0))
(* (* z (* z y)) -4.0))))x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (z <= 1.5e+19) {
tmp = fma(x_m, x_m, (t * (4.0 * y)));
} else if (z <= 1.2e+175) {
tmp = fma(x_m, x_m, (((z * z) * y) * -4.0));
} else {
tmp = (z * (z * y)) * -4.0;
}
return tmp;
}
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (z <= 1.5e+19) tmp = fma(x_m, x_m, Float64(t * Float64(4.0 * y))); elseif (z <= 1.2e+175) tmp = fma(x_m, x_m, Float64(Float64(Float64(z * z) * y) * -4.0)); else tmp = Float64(Float64(z * Float64(z * y)) * -4.0); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := If[LessEqual[z, 1.5e+19], N[(x$95$m * x$95$m + N[(t * N[(4.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.2e+175], N[(x$95$m * x$95$m + N[(N[(N[(z * z), $MachinePrecision] * y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision], N[(N[(z * N[(z * y), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision]]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.5 \cdot 10^{+19}:\\
\;\;\;\;\mathsf{fma}\left(x\_m, x\_m, t \cdot \left(4 \cdot y\right)\right)\\
\mathbf{elif}\;z \leq 1.2 \cdot 10^{+175}:\\
\;\;\;\;\mathsf{fma}\left(x\_m, x\_m, \left(\left(z \cdot z\right) \cdot y\right) \cdot -4\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot \left(z \cdot y\right)\right) \cdot -4\\
\end{array}
\end{array}
if z < 1.5e19Initial program 93.4%
lift-*.f64N/A
lift--.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
pow2N/A
lower-fma.f64N/A
pow2N/A
associate-*r*N/A
*-commutativeN/A
metadata-evalN/A
distribute-lft-neg-inN/A
Applied rewrites95.0%
Taylor expanded in z around 0
Applied rewrites76.6%
if 1.5e19 < z < 1.2e175Initial program 89.8%
lift-*.f64N/A
lift--.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
pow2N/A
lower-fma.f64N/A
pow2N/A
associate-*r*N/A
*-commutativeN/A
metadata-evalN/A
distribute-lft-neg-inN/A
Applied rewrites91.5%
Taylor expanded in z around inf
*-commutativeN/A
pow2N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f6480.6
Applied rewrites80.6%
if 1.2e175 < z Initial program 73.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6479.6
Applied rewrites79.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6491.6
Applied rewrites91.6%
x_m = (fabs.f64 x)
(FPCore (x_m y z t)
:precision binary64
(if (<= z 1.5e+19)
(fma x_m x_m (* t (* 4.0 y)))
(if (<= z 1.18e+151)
(fma (* (* z z) y) -4.0 (* x_m x_m))
(* (* z (* z y)) -4.0))))x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (z <= 1.5e+19) {
tmp = fma(x_m, x_m, (t * (4.0 * y)));
} else if (z <= 1.18e+151) {
tmp = fma(((z * z) * y), -4.0, (x_m * x_m));
} else {
tmp = (z * (z * y)) * -4.0;
}
return tmp;
}
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (z <= 1.5e+19) tmp = fma(x_m, x_m, Float64(t * Float64(4.0 * y))); elseif (z <= 1.18e+151) tmp = fma(Float64(Float64(z * z) * y), -4.0, Float64(x_m * x_m)); else tmp = Float64(Float64(z * Float64(z * y)) * -4.0); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := If[LessEqual[z, 1.5e+19], N[(x$95$m * x$95$m + N[(t * N[(4.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.18e+151], N[(N[(N[(z * z), $MachinePrecision] * y), $MachinePrecision] * -4.0 + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(z * N[(z * y), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision]]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.5 \cdot 10^{+19}:\\
\;\;\;\;\mathsf{fma}\left(x\_m, x\_m, t \cdot \left(4 \cdot y\right)\right)\\
\mathbf{elif}\;z \leq 1.18 \cdot 10^{+151}:\\
\;\;\;\;\mathsf{fma}\left(\left(z \cdot z\right) \cdot y, -4, x\_m \cdot x\_m\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot \left(z \cdot y\right)\right) \cdot -4\\
\end{array}
\end{array}
if z < 1.5e19Initial program 93.4%
lift-*.f64N/A
lift--.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
pow2N/A
lower-fma.f64N/A
pow2N/A
associate-*r*N/A
*-commutativeN/A
metadata-evalN/A
distribute-lft-neg-inN/A
Applied rewrites95.0%
Taylor expanded in z around 0
Applied rewrites76.6%
if 1.5e19 < z < 1.18000000000000005e151Initial program 95.7%
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-*.f6483.0
Applied rewrites83.0%
if 1.18000000000000005e151 < z Initial program 71.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6476.4
Applied rewrites76.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6489.6
Applied rewrites89.6%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (if (<= z 5.5e+14) (fma x_m x_m (* t (* 4.0 y))) (if (<= z 1.2e+175) (* (- t (* z z)) (* 4.0 y)) (* (* z (* z y)) -4.0))))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (z <= 5.5e+14) {
tmp = fma(x_m, x_m, (t * (4.0 * y)));
} else if (z <= 1.2e+175) {
tmp = (t - (z * z)) * (4.0 * y);
} else {
tmp = (z * (z * y)) * -4.0;
}
return tmp;
}
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (z <= 5.5e+14) tmp = fma(x_m, x_m, Float64(t * Float64(4.0 * y))); elseif (z <= 1.2e+175) tmp = Float64(Float64(t - Float64(z * z)) * Float64(4.0 * y)); else tmp = Float64(Float64(z * Float64(z * y)) * -4.0); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := If[LessEqual[z, 5.5e+14], N[(x$95$m * x$95$m + N[(t * N[(4.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.2e+175], N[(N[(t - N[(z * z), $MachinePrecision]), $MachinePrecision] * N[(4.0 * y), $MachinePrecision]), $MachinePrecision], N[(N[(z * N[(z * y), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision]]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq 5.5 \cdot 10^{+14}:\\
\;\;\;\;\mathsf{fma}\left(x\_m, x\_m, t \cdot \left(4 \cdot y\right)\right)\\
\mathbf{elif}\;z \leq 1.2 \cdot 10^{+175}:\\
\;\;\;\;\left(t - z \cdot z\right) \cdot \left(4 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot \left(z \cdot y\right)\right) \cdot -4\\
\end{array}
\end{array}
if z < 5.5e14Initial program 93.4%
lift-*.f64N/A
lift--.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
pow2N/A
lower-fma.f64N/A
pow2N/A
associate-*r*N/A
*-commutativeN/A
metadata-evalN/A
distribute-lft-neg-inN/A
Applied rewrites95.0%
Taylor expanded in z around 0
Applied rewrites76.6%
if 5.5e14 < z < 1.2e175Initial program 90.0%
Taylor expanded in x around 0
pow2N/A
associate-*r*N/A
*-commutativeN/A
metadata-evalN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
pow2N/A
negate-sub2N/A
lower-*.f64N/A
lower--.f64N/A
pow2N/A
lift-*.f64N/A
lower-*.f6467.6
Applied rewrites67.6%
if 1.2e175 < z Initial program 73.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6479.6
Applied rewrites79.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6491.6
Applied rewrites91.6%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (if (<= z 4.2e+46) (fma x_m x_m (* t (* 4.0 y))) (* (* z (* z y)) -4.0)))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (z <= 4.2e+46) {
tmp = fma(x_m, x_m, (t * (4.0 * y)));
} else {
tmp = (z * (z * y)) * -4.0;
}
return tmp;
}
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (z <= 4.2e+46) tmp = fma(x_m, x_m, Float64(t * Float64(4.0 * y))); else tmp = Float64(Float64(z * Float64(z * y)) * -4.0); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := If[LessEqual[z, 4.2e+46], N[(x$95$m * x$95$m + N[(t * N[(4.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z * N[(z * y), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq 4.2 \cdot 10^{+46}:\\
\;\;\;\;\mathsf{fma}\left(x\_m, x\_m, t \cdot \left(4 \cdot y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot \left(z \cdot y\right)\right) \cdot -4\\
\end{array}
\end{array}
if z < 4.2e46Initial program 93.5%
lift-*.f64N/A
lift--.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
pow2N/A
lower-fma.f64N/A
pow2N/A
associate-*r*N/A
*-commutativeN/A
metadata-evalN/A
distribute-lft-neg-inN/A
Applied rewrites95.1%
Taylor expanded in z around 0
Applied rewrites76.3%
if 4.2e46 < z Initial program 80.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6470.8
Applied rewrites70.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6478.9
Applied rewrites78.9%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (if (<= z 4.2e+46) (fma (* t y) 4.0 (* x_m x_m)) (* (* z (* z y)) -4.0)))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (z <= 4.2e+46) {
tmp = fma((t * y), 4.0, (x_m * x_m));
} else {
tmp = (z * (z * y)) * -4.0;
}
return tmp;
}
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (z <= 4.2e+46) tmp = fma(Float64(t * y), 4.0, Float64(x_m * x_m)); else tmp = Float64(Float64(z * Float64(z * y)) * -4.0); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := If[LessEqual[z, 4.2e+46], N[(N[(t * y), $MachinePrecision] * 4.0 + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(z * N[(z * y), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq 4.2 \cdot 10^{+46}:\\
\;\;\;\;\mathsf{fma}\left(t \cdot y, 4, x\_m \cdot x\_m\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot \left(z \cdot y\right)\right) \cdot -4\\
\end{array}
\end{array}
if z < 4.2e46Initial program 93.5%
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-*.f6475.8
Applied rewrites75.8%
if 4.2e46 < z Initial program 80.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6470.8
Applied rewrites70.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6478.9
Applied rewrites78.9%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (if (<= z 7.8e-180) (* (* t y) 4.0) (if (<= z 5.3e+14) (* x_m x_m) (* (* z (* z y)) -4.0))))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (z <= 7.8e-180) {
tmp = (t * y) * 4.0;
} else if (z <= 5.3e+14) {
tmp = x_m * x_m;
} else {
tmp = (z * (z * y)) * -4.0;
}
return tmp;
}
x_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_m, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= 7.8d-180) then
tmp = (t * y) * 4.0d0
else if (z <= 5.3d+14) then
tmp = x_m * x_m
else
tmp = (z * (z * y)) * (-4.0d0)
end if
code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y, double z, double t) {
double tmp;
if (z <= 7.8e-180) {
tmp = (t * y) * 4.0;
} else if (z <= 5.3e+14) {
tmp = x_m * x_m;
} else {
tmp = (z * (z * y)) * -4.0;
}
return tmp;
}
x_m = math.fabs(x) def code(x_m, y, z, t): tmp = 0 if z <= 7.8e-180: tmp = (t * y) * 4.0 elif z <= 5.3e+14: tmp = x_m * x_m else: tmp = (z * (z * y)) * -4.0 return tmp
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (z <= 7.8e-180) tmp = Float64(Float64(t * y) * 4.0); elseif (z <= 5.3e+14) tmp = Float64(x_m * x_m); else tmp = Float64(Float64(z * Float64(z * y)) * -4.0); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, y, z, t) tmp = 0.0; if (z <= 7.8e-180) tmp = (t * y) * 4.0; elseif (z <= 5.3e+14) tmp = x_m * x_m; else tmp = (z * (z * y)) * -4.0; end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := If[LessEqual[z, 7.8e-180], N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision], If[LessEqual[z, 5.3e+14], N[(x$95$m * x$95$m), $MachinePrecision], N[(N[(z * N[(z * y), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision]]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq 7.8 \cdot 10^{-180}:\\
\;\;\;\;\left(t \cdot y\right) \cdot 4\\
\mathbf{elif}\;z \leq 5.3 \cdot 10^{+14}:\\
\;\;\;\;x\_m \cdot x\_m\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot \left(z \cdot y\right)\right) \cdot -4\\
\end{array}
\end{array}
if z < 7.8000000000000005e-180Initial program 92.0%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6435.8
Applied rewrites35.8%
if 7.8000000000000005e-180 < z < 5.3e14Initial program 98.6%
Taylor expanded in x around inf
pow2N/A
lift-*.f6450.4
Applied rewrites50.4%
if 5.3e14 < z Initial program 82.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6466.4
Applied rewrites66.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6473.5
Applied rewrites73.5%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (if (<= x_m 2e-6) (* (* t y) 4.0) (* x_m x_m)))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (x_m <= 2e-6) {
tmp = (t * y) * 4.0;
} else {
tmp = x_m * x_m;
}
return tmp;
}
x_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_m, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (x_m <= 2d-6) then
tmp = (t * y) * 4.0d0
else
tmp = x_m * x_m
end if
code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y, double z, double t) {
double tmp;
if (x_m <= 2e-6) {
tmp = (t * y) * 4.0;
} else {
tmp = x_m * x_m;
}
return tmp;
}
x_m = math.fabs(x) def code(x_m, y, z, t): tmp = 0 if x_m <= 2e-6: tmp = (t * y) * 4.0 else: tmp = x_m * x_m return tmp
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (x_m <= 2e-6) tmp = Float64(Float64(t * y) * 4.0); else tmp = Float64(x_m * x_m); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, y, z, t) tmp = 0.0; if (x_m <= 2e-6) tmp = (t * y) * 4.0; else tmp = x_m * x_m; end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := If[LessEqual[x$95$m, 2e-6], N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision], N[(x$95$m * x$95$m), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 2 \cdot 10^{-6}:\\
\;\;\;\;\left(t \cdot y\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;x\_m \cdot x\_m\\
\end{array}
\end{array}
if x < 1.99999999999999991e-6Initial program 94.1%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6449.2
Applied rewrites49.2%
if 1.99999999999999991e-6 < x Initial program 87.6%
Taylor expanded in x around inf
pow2N/A
lift-*.f6469.6
Applied rewrites69.6%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (* x_m x_m))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
return x_m * x_m;
}
x_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_m, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x_m * x_m
end function
x_m = Math.abs(x);
public static double code(double x_m, double y, double z, double t) {
return x_m * x_m;
}
x_m = math.fabs(x) def code(x_m, y, z, t): return x_m * x_m
x_m = abs(x) function code(x_m, y, z, t) return Float64(x_m * x_m) end
x_m = abs(x); function tmp = code(x_m, y, z, t) tmp = x_m * x_m; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := N[(x$95$m * x$95$m), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x\_m \cdot x\_m
\end{array}
Initial program 90.8%
Taylor expanded in x around inf
pow2N/A
lift-*.f6441.2
Applied rewrites41.2%
herbie shell --seed 2025110
(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))))