
(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 9 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
(let* ((t_1 (* 1.0 (- z_m))))
(if (<= z_m 5e+124)
(fma (* -4.0 (fma t_1 t_1 (* -1.0 t))) y (* x x))
(-
(* x x)
(*
(fma (* (* (/ z_m t) -1.0) (* (/ (* -1.0 z_m) 1.0) y)) 4.0 (* y -4.0))
t)))))z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double t_1 = 1.0 * -z_m;
double tmp;
if (z_m <= 5e+124) {
tmp = fma((-4.0 * fma(t_1, t_1, (-1.0 * t))), y, (x * x));
} else {
tmp = (x * x) - (fma((((z_m / t) * -1.0) * (((-1.0 * z_m) / 1.0) * y)), 4.0, (y * -4.0)) * t);
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) t_1 = Float64(1.0 * Float64(-z_m)) tmp = 0.0 if (z_m <= 5e+124) tmp = fma(Float64(-4.0 * fma(t_1, t_1, Float64(-1.0 * t))), y, Float64(x * x)); else tmp = Float64(Float64(x * x) - Float64(fma(Float64(Float64(Float64(z_m / t) * -1.0) * Float64(Float64(Float64(-1.0 * z_m) / 1.0) * y)), 4.0, Float64(y * -4.0)) * t)); end return tmp end
z_m = N[Abs[z], $MachinePrecision]
code[x_, y_, z$95$m_, t_] := Block[{t$95$1 = N[(1.0 * (-z$95$m)), $MachinePrecision]}, If[LessEqual[z$95$m, 5e+124], N[(N[(-4.0 * N[(t$95$1 * t$95$1 + N[(-1.0 * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] - N[(N[(N[(N[(N[(z$95$m / t), $MachinePrecision] * -1.0), $MachinePrecision] * N[(N[(N[(-1.0 * z$95$m), $MachinePrecision] / 1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] * 4.0 + N[(y * -4.0), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
t_1 := 1 \cdot \left(-z\_m\right)\\
\mathbf{if}\;z\_m \leq 5 \cdot 10^{+124}:\\
\;\;\;\;\mathsf{fma}\left(-4 \cdot \mathsf{fma}\left(t\_1, t\_1, -1 \cdot t\right), y, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x - \mathsf{fma}\left(\left(\frac{z\_m}{t} \cdot -1\right) \cdot \left(\frac{-1 \cdot z\_m}{1} \cdot y\right), 4, y \cdot -4\right) \cdot t\\
\end{array}
\end{array}
if z < 4.9999999999999996e124Initial program 98.1%
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
*-commutativeN/A
pow2N/A
associate-*r*N/A
pow2N/A
Applied rewrites99.4%
if 4.9999999999999996e124 < z Initial program 74.3%
lift--.f64N/A
lift-*.f64N/A
pow2N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
flip-+N/A
lower-/.f64N/A
Applied rewrites7.6%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
pow2N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.9
Applied rewrites70.9%
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
frac-2negN/A
pow2N/A
distribute-lft-neg-outN/A
mul-1-negN/A
mul-1-negN/A
*-commutativeN/A
frac-timesN/A
lift-/.f64N/A
lift-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6476.4
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6476.4
Applied rewrites76.4%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-/l*N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lower-*.f64N/A
frac-2negN/A
metadata-evalN/A
lower-/.f64N/A
mul-1-negN/A
lower-*.f6482.8
Applied rewrites82.8%
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
:precision binary64
(if (<= z_m 5e+124)
(- (* x x) (* (* y 4.0) (- (* z_m z_m) t)))
(-
(* x x)
(*
(fma (* (* (/ z_m t) -1.0) (* (/ (* -1.0 z_m) 1.0) y)) 4.0 (* y -4.0))
t))))z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 5e+124) {
tmp = (x * x) - ((y * 4.0) * ((z_m * z_m) - t));
} else {
tmp = (x * x) - (fma((((z_m / t) * -1.0) * (((-1.0 * z_m) / 1.0) * y)), 4.0, (y * -4.0)) * t);
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 5e+124) tmp = Float64(Float64(x * x) - Float64(Float64(y * 4.0) * Float64(Float64(z_m * z_m) - t))); else tmp = Float64(Float64(x * x) - Float64(fma(Float64(Float64(Float64(z_m / t) * -1.0) * Float64(Float64(Float64(-1.0 * z_m) / 1.0) * y)), 4.0, Float64(y * -4.0)) * t)); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[z$95$m, 5e+124], N[(N[(x * x), $MachinePrecision] - N[(N[(y * 4.0), $MachinePrecision] * N[(N[(z$95$m * z$95$m), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] - N[(N[(N[(N[(N[(z$95$m / t), $MachinePrecision] * -1.0), $MachinePrecision] * N[(N[(N[(-1.0 * z$95$m), $MachinePrecision] / 1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] * 4.0 + N[(y * -4.0), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 5 \cdot 10^{+124}:\\
\;\;\;\;x \cdot x - \left(y \cdot 4\right) \cdot \left(z\_m \cdot z\_m - t\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x - \mathsf{fma}\left(\left(\frac{z\_m}{t} \cdot -1\right) \cdot \left(\frac{-1 \cdot z\_m}{1} \cdot y\right), 4, y \cdot -4\right) \cdot t\\
\end{array}
\end{array}
if z < 4.9999999999999996e124Initial program 98.1%
if 4.9999999999999996e124 < z Initial program 74.3%
lift--.f64N/A
lift-*.f64N/A
pow2N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
flip-+N/A
lower-/.f64N/A
Applied rewrites7.6%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
pow2N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.9
Applied rewrites70.9%
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
frac-2negN/A
pow2N/A
distribute-lft-neg-outN/A
mul-1-negN/A
mul-1-negN/A
*-commutativeN/A
frac-timesN/A
lift-/.f64N/A
lift-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6476.4
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6476.4
Applied rewrites76.4%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-/l*N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lower-*.f64N/A
frac-2negN/A
metadata-evalN/A
lower-/.f64N/A
mul-1-negN/A
lower-*.f6482.8
Applied rewrites82.8%
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
:precision binary64
(if (<= z_m 1.9e+93)
(- (* x x) (* (* y 4.0) (* (fma (/ (* z_m z_m) t) 1.0 -1.0) t)))
(-
(* x x)
(*
(fma (* (* (/ z_m t) -1.0) (* (/ (* -1.0 z_m) 1.0) y)) 4.0 (* y -4.0))
t))))z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 1.9e+93) {
tmp = (x * x) - ((y * 4.0) * (fma(((z_m * z_m) / t), 1.0, -1.0) * t));
} else {
tmp = (x * x) - (fma((((z_m / t) * -1.0) * (((-1.0 * z_m) / 1.0) * y)), 4.0, (y * -4.0)) * t);
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 1.9e+93) tmp = Float64(Float64(x * x) - Float64(Float64(y * 4.0) * Float64(fma(Float64(Float64(z_m * z_m) / t), 1.0, -1.0) * t))); else tmp = Float64(Float64(x * x) - Float64(fma(Float64(Float64(Float64(z_m / t) * -1.0) * Float64(Float64(Float64(-1.0 * z_m) / 1.0) * y)), 4.0, Float64(y * -4.0)) * t)); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[z$95$m, 1.9e+93], N[(N[(x * x), $MachinePrecision] - N[(N[(y * 4.0), $MachinePrecision] * N[(N[(N[(N[(z$95$m * z$95$m), $MachinePrecision] / t), $MachinePrecision] * 1.0 + -1.0), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] - N[(N[(N[(N[(N[(z$95$m / t), $MachinePrecision] * -1.0), $MachinePrecision] * N[(N[(N[(-1.0 * z$95$m), $MachinePrecision] / 1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] * 4.0 + N[(y * -4.0), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 1.9 \cdot 10^{+93}:\\
\;\;\;\;x \cdot x - \left(y \cdot 4\right) \cdot \left(\mathsf{fma}\left(\frac{z\_m \cdot z\_m}{t}, 1, -1\right) \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x - \mathsf{fma}\left(\left(\frac{z\_m}{t} \cdot -1\right) \cdot \left(\frac{-1 \cdot z\_m}{1} \cdot y\right), 4, y \cdot -4\right) \cdot t\\
\end{array}
\end{array}
if z < 1.8999999999999999e93Initial program 98.3%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
*-rgt-identityN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6495.8
Applied rewrites95.8%
if 1.8999999999999999e93 < z Initial program 77.6%
lift--.f64N/A
lift-*.f64N/A
pow2N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
flip-+N/A
lower-/.f64N/A
Applied rewrites12.6%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
pow2N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6471.4
Applied rewrites71.4%
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
frac-2negN/A
pow2N/A
distribute-lft-neg-outN/A
mul-1-negN/A
mul-1-negN/A
*-commutativeN/A
frac-timesN/A
lift-/.f64N/A
lift-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6476.0
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6476.0
Applied rewrites76.0%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-/l*N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lower-*.f64N/A
frac-2negN/A
metadata-evalN/A
lower-/.f64N/A
mul-1-negN/A
lower-*.f6482.2
Applied rewrites82.2%
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
:precision binary64
(if (<= z_m 1.9e+93)
(- (* x x) (* (* y 4.0) (* (fma (/ (* -1.0 z_m) t) (/ z_m -1.0) -1.0) t)))
(-
(* x x)
(*
(fma (* (* (/ z_m t) -1.0) (* (/ (* -1.0 z_m) 1.0) y)) 4.0 (* y -4.0))
t))))z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 1.9e+93) {
tmp = (x * x) - ((y * 4.0) * (fma(((-1.0 * z_m) / t), (z_m / -1.0), -1.0) * t));
} else {
tmp = (x * x) - (fma((((z_m / t) * -1.0) * (((-1.0 * z_m) / 1.0) * y)), 4.0, (y * -4.0)) * t);
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 1.9e+93) tmp = Float64(Float64(x * x) - Float64(Float64(y * 4.0) * Float64(fma(Float64(Float64(-1.0 * z_m) / t), Float64(z_m / -1.0), -1.0) * t))); else tmp = Float64(Float64(x * x) - Float64(fma(Float64(Float64(Float64(z_m / t) * -1.0) * Float64(Float64(Float64(-1.0 * z_m) / 1.0) * y)), 4.0, Float64(y * -4.0)) * t)); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[z$95$m, 1.9e+93], N[(N[(x * x), $MachinePrecision] - N[(N[(y * 4.0), $MachinePrecision] * N[(N[(N[(N[(-1.0 * z$95$m), $MachinePrecision] / t), $MachinePrecision] * N[(z$95$m / -1.0), $MachinePrecision] + -1.0), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] - N[(N[(N[(N[(N[(z$95$m / t), $MachinePrecision] * -1.0), $MachinePrecision] * N[(N[(N[(-1.0 * z$95$m), $MachinePrecision] / 1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] * 4.0 + N[(y * -4.0), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 1.9 \cdot 10^{+93}:\\
\;\;\;\;x \cdot x - \left(y \cdot 4\right) \cdot \left(\mathsf{fma}\left(\frac{-1 \cdot z\_m}{t}, \frac{z\_m}{-1}, -1\right) \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x - \mathsf{fma}\left(\left(\frac{z\_m}{t} \cdot -1\right) \cdot \left(\frac{-1 \cdot z\_m}{1} \cdot y\right), 4, y \cdot -4\right) \cdot t\\
\end{array}
\end{array}
if z < 1.8999999999999999e93Initial program 98.3%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
*-rgt-identityN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6495.8
Applied rewrites95.8%
lift-fma.f64N/A
lift-*.f64N/A
lift-/.f64N/A
*-rgt-identityN/A
pow2N/A
frac-2negN/A
pow2N/A
distribute-lft-neg-outN/A
*-lft-identityN/A
lift-*.f64N/A
lift-neg.f64N/A
mul-1-negN/A
*-commutativeN/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-neg.f64N/A
lift-*.f64N/A
*-lft-identityN/A
mul-1-negN/A
lower-*.f64N/A
lower-/.f6495.8
Applied rewrites95.8%
if 1.8999999999999999e93 < z Initial program 77.6%
lift--.f64N/A
lift-*.f64N/A
pow2N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
flip-+N/A
lower-/.f64N/A
Applied rewrites12.6%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
pow2N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6471.4
Applied rewrites71.4%
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
frac-2negN/A
pow2N/A
distribute-lft-neg-outN/A
mul-1-negN/A
mul-1-negN/A
*-commutativeN/A
frac-timesN/A
lift-/.f64N/A
lift-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6476.0
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6476.0
Applied rewrites76.0%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-/l*N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lower-*.f64N/A
frac-2negN/A
metadata-evalN/A
lower-/.f64N/A
mul-1-negN/A
lower-*.f6482.2
Applied rewrites82.2%
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
:precision binary64
(if (<= (- (* z_m z_m) t) 1e+186)
(- (* x x) (* (* (* -1.0 y) t) (fma (* (/ z_m t) z_m) -4.0 4.0)))
(-
(* x x)
(*
(fma (* (* (/ z_m t) -1.0) (* (/ (* -1.0 z_m) 1.0) y)) 4.0 (* y -4.0))
t))))z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (((z_m * z_m) - t) <= 1e+186) {
tmp = (x * x) - (((-1.0 * y) * t) * fma(((z_m / t) * z_m), -4.0, 4.0));
} else {
tmp = (x * x) - (fma((((z_m / t) * -1.0) * (((-1.0 * z_m) / 1.0) * y)), 4.0, (y * -4.0)) * t);
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (Float64(Float64(z_m * z_m) - t) <= 1e+186) tmp = Float64(Float64(x * x) - Float64(Float64(Float64(-1.0 * y) * t) * fma(Float64(Float64(z_m / t) * z_m), -4.0, 4.0))); else tmp = Float64(Float64(x * x) - Float64(fma(Float64(Float64(Float64(z_m / t) * -1.0) * Float64(Float64(Float64(-1.0 * z_m) / 1.0) * y)), 4.0, Float64(y * -4.0)) * t)); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[N[(N[(z$95$m * z$95$m), $MachinePrecision] - t), $MachinePrecision], 1e+186], N[(N[(x * x), $MachinePrecision] - N[(N[(N[(-1.0 * y), $MachinePrecision] * t), $MachinePrecision] * N[(N[(N[(z$95$m / t), $MachinePrecision] * z$95$m), $MachinePrecision] * -4.0 + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] - N[(N[(N[(N[(N[(z$95$m / t), $MachinePrecision] * -1.0), $MachinePrecision] * N[(N[(N[(-1.0 * z$95$m), $MachinePrecision] / 1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] * 4.0 + N[(y * -4.0), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \cdot z\_m - t \leq 10^{+186}:\\
\;\;\;\;x \cdot x - \left(\left(-1 \cdot y\right) \cdot t\right) \cdot \mathsf{fma}\left(\frac{z\_m}{t} \cdot z\_m, -4, 4\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x - \mathsf{fma}\left(\left(\frac{z\_m}{t} \cdot -1\right) \cdot \left(\frac{-1 \cdot z\_m}{1} \cdot y\right), 4, y \cdot -4\right) \cdot t\\
\end{array}
\end{array}
if (-.f64 (*.f64 z z) t) < 9.9999999999999998e185Initial program 98.5%
lift--.f64N/A
lift-*.f64N/A
pow2N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
flip-+N/A
lower-/.f64N/A
Applied rewrites82.7%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
pow2N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6493.0
Applied rewrites93.0%
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
frac-2negN/A
pow2N/A
distribute-lft-neg-outN/A
mul-1-negN/A
mul-1-negN/A
*-commutativeN/A
frac-timesN/A
lift-/.f64N/A
lift-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6493.0
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6493.0
Applied rewrites93.0%
Applied rewrites94.5%
if 9.9999999999999998e185 < (-.f64 (*.f64 z z) t) Initial program 80.1%
lift--.f64N/A
lift-*.f64N/A
pow2N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
flip-+N/A
lower-/.f64N/A
Applied rewrites17.4%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
pow2N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6474.6
Applied rewrites74.6%
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
frac-2negN/A
pow2N/A
distribute-lft-neg-outN/A
mul-1-negN/A
mul-1-negN/A
*-commutativeN/A
frac-timesN/A
lift-/.f64N/A
lift-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6478.6
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6478.6
Applied rewrites78.6%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-/l*N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lower-*.f64N/A
frac-2negN/A
metadata-evalN/A
lower-/.f64N/A
mul-1-negN/A
lower-*.f6484.2
Applied rewrites84.2%
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
:precision binary64
(if (<= (- (* z_m z_m) t) 1e+247)
(- (* x x) (* (* (* -1.0 y) t) (fma (* (/ z_m t) z_m) -4.0 4.0)))
(-
(* x x)
(* (fma (* y (/ (* (* (/ z_m t) -1.0) z_m) -1.0)) 4.0 (* y -4.0)) t))))z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (((z_m * z_m) - t) <= 1e+247) {
tmp = (x * x) - (((-1.0 * y) * t) * fma(((z_m / t) * z_m), -4.0, 4.0));
} else {
tmp = (x * x) - (fma((y * ((((z_m / t) * -1.0) * z_m) / -1.0)), 4.0, (y * -4.0)) * t);
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (Float64(Float64(z_m * z_m) - t) <= 1e+247) tmp = Float64(Float64(x * x) - Float64(Float64(Float64(-1.0 * y) * t) * fma(Float64(Float64(z_m / t) * z_m), -4.0, 4.0))); else tmp = Float64(Float64(x * x) - Float64(fma(Float64(y * Float64(Float64(Float64(Float64(z_m / t) * -1.0) * z_m) / -1.0)), 4.0, Float64(y * -4.0)) * t)); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[N[(N[(z$95$m * z$95$m), $MachinePrecision] - t), $MachinePrecision], 1e+247], N[(N[(x * x), $MachinePrecision] - N[(N[(N[(-1.0 * y), $MachinePrecision] * t), $MachinePrecision] * N[(N[(N[(z$95$m / t), $MachinePrecision] * z$95$m), $MachinePrecision] * -4.0 + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] - N[(N[(N[(y * N[(N[(N[(N[(z$95$m / t), $MachinePrecision] * -1.0), $MachinePrecision] * z$95$m), $MachinePrecision] / -1.0), $MachinePrecision]), $MachinePrecision] * 4.0 + N[(y * -4.0), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \cdot z\_m - t \leq 10^{+247}:\\
\;\;\;\;x \cdot x - \left(\left(-1 \cdot y\right) \cdot t\right) \cdot \mathsf{fma}\left(\frac{z\_m}{t} \cdot z\_m, -4, 4\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x - \mathsf{fma}\left(y \cdot \frac{\left(\frac{z\_m}{t} \cdot -1\right) \cdot z\_m}{-1}, 4, y \cdot -4\right) \cdot t\\
\end{array}
\end{array}
if (-.f64 (*.f64 z z) t) < 9.99999999999999952e246Initial program 98.2%
lift--.f64N/A
lift-*.f64N/A
pow2N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
flip-+N/A
lower-/.f64N/A
Applied rewrites78.3%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
pow2N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6491.7
Applied rewrites91.7%
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
frac-2negN/A
pow2N/A
distribute-lft-neg-outN/A
mul-1-negN/A
mul-1-negN/A
*-commutativeN/A
frac-timesN/A
lift-/.f64N/A
lift-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6491.7
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6491.7
Applied rewrites91.7%
Applied rewrites93.0%
if 9.99999999999999952e246 < (-.f64 (*.f64 z z) t) Initial program 76.4%
lift--.f64N/A
lift-*.f64N/A
pow2N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
flip-+N/A
lower-/.f64N/A
Applied rewrites11.9%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
pow2N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6473.2
Applied rewrites73.2%
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
frac-2negN/A
pow2N/A
distribute-lft-neg-outN/A
mul-1-negN/A
mul-1-negN/A
*-commutativeN/A
frac-timesN/A
lift-/.f64N/A
lift-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6478.1
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6478.1
Applied rewrites78.1%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= z_m 3e+265) (- (* x x) (* (* (* -1.0 y) t) (fma (* (/ z_m t) z_m) -4.0 4.0))) (- (* x x) (* (fma (* y (/ (* z_m z_m) t)) 4.0 (* y -4.0)) t))))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 3e+265) {
tmp = (x * x) - (((-1.0 * y) * t) * fma(((z_m / t) * z_m), -4.0, 4.0));
} else {
tmp = (x * x) - (fma((y * ((z_m * z_m) / t)), 4.0, (y * -4.0)) * t);
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 3e+265) tmp = Float64(Float64(x * x) - Float64(Float64(Float64(-1.0 * y) * t) * fma(Float64(Float64(z_m / t) * z_m), -4.0, 4.0))); else tmp = Float64(Float64(x * x) - Float64(fma(Float64(y * Float64(Float64(z_m * z_m) / t)), 4.0, Float64(y * -4.0)) * t)); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[z$95$m, 3e+265], N[(N[(x * x), $MachinePrecision] - N[(N[(N[(-1.0 * y), $MachinePrecision] * t), $MachinePrecision] * N[(N[(N[(z$95$m / t), $MachinePrecision] * z$95$m), $MachinePrecision] * -4.0 + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] - N[(N[(N[(y * N[(N[(z$95$m * z$95$m), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] * 4.0 + N[(y * -4.0), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 3 \cdot 10^{+265}:\\
\;\;\;\;x \cdot x - \left(\left(-1 \cdot y\right) \cdot t\right) \cdot \mathsf{fma}\left(\frac{z\_m}{t} \cdot z\_m, -4, 4\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x - \mathsf{fma}\left(y \cdot \frac{z\_m \cdot z\_m}{t}, 4, y \cdot -4\right) \cdot t\\
\end{array}
\end{array}
if z < 3.00000000000000002e265Initial program 91.7%
lift--.f64N/A
lift-*.f64N/A
pow2N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
flip-+N/A
lower-/.f64N/A
Applied rewrites61.0%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
pow2N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6485.8
Applied rewrites85.8%
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
frac-2negN/A
pow2N/A
distribute-lft-neg-outN/A
mul-1-negN/A
mul-1-negN/A
*-commutativeN/A
frac-timesN/A
lift-/.f64N/A
lift-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6487.5
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6487.5
Applied rewrites87.5%
Applied rewrites87.7%
if 3.00000000000000002e265 < z Initial program 84.0%
lift--.f64N/A
lift-*.f64N/A
pow2N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
flip-+N/A
lower-/.f64N/A
Applied rewrites0.0%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
pow2N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6483.9
Applied rewrites83.9%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (- (* x x) (* (* (* -1.0 y) t) (fma (* (/ z_m t) z_m) -4.0 4.0))))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
return (x * x) - (((-1.0 * y) * t) * fma(((z_m / t) * z_m), -4.0, 4.0));
}
z_m = abs(z) function code(x, y, z_m, t) return Float64(Float64(x * x) - Float64(Float64(Float64(-1.0 * y) * t) * fma(Float64(Float64(z_m / t) * z_m), -4.0, 4.0))) end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := N[(N[(x * x), $MachinePrecision] - N[(N[(N[(-1.0 * y), $MachinePrecision] * t), $MachinePrecision] * N[(N[(N[(z$95$m / t), $MachinePrecision] * z$95$m), $MachinePrecision] * -4.0 + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
x \cdot x - \left(\left(-1 \cdot y\right) \cdot t\right) \cdot \mathsf{fma}\left(\frac{z\_m}{t} \cdot z\_m, -4, 4\right)
\end{array}
Initial program 91.1%
lift--.f64N/A
lift-*.f64N/A
pow2N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
flip-+N/A
lower-/.f64N/A
Applied rewrites56.7%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
associate-/l*N/A
lower-*.f64N/A
pow2N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6485.7
Applied rewrites85.7%
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
frac-2negN/A
pow2N/A
distribute-lft-neg-outN/A
mul-1-negN/A
mul-1-negN/A
*-commutativeN/A
frac-timesN/A
lift-/.f64N/A
lift-*.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6487.3
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6487.3
Applied rewrites87.3%
Applied rewrites86.9%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (let* ((t_1 (* 1.0 (- z_m)))) (fma (* (* x x) -4.0) (* (fma t_1 t_1 (* -1.0 t)) (/ y (* x x))) (* x x))))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double t_1 = 1.0 * -z_m;
return fma(((x * x) * -4.0), (fma(t_1, t_1, (-1.0 * t)) * (y / (x * x))), (x * x));
}
z_m = abs(z) function code(x, y, z_m, t) t_1 = Float64(1.0 * Float64(-z_m)) return fma(Float64(Float64(x * x) * -4.0), Float64(fma(t_1, t_1, Float64(-1.0 * t)) * Float64(y / Float64(x * x))), Float64(x * x)) end
z_m = N[Abs[z], $MachinePrecision]
code[x_, y_, z$95$m_, t_] := Block[{t$95$1 = N[(1.0 * (-z$95$m)), $MachinePrecision]}, N[(N[(N[(x * x), $MachinePrecision] * -4.0), $MachinePrecision] * N[(N[(t$95$1 * t$95$1 + N[(-1.0 * t), $MachinePrecision]), $MachinePrecision] * N[(y / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
t_1 := 1 \cdot \left(-z\_m\right)\\
\mathsf{fma}\left(\left(x \cdot x\right) \cdot -4, \mathsf{fma}\left(t\_1, t\_1, -1 \cdot t\right) \cdot \frac{y}{x \cdot x}, x \cdot x\right)
\end{array}
\end{array}
Initial program 91.1%
Taylor expanded in x around inf
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
*-rgt-identityN/A
lower-fma.f64N/A
Applied rewrites43.8%
herbie shell --seed 2025093
(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))))