
(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));
}
real(8) function code(x, y, z, t)
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}
Sampling outcomes in binary64 precision:
Herbie found 12 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));
}
real(8) function code(x, y, z, t)
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}
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fma x x (* -4.0 (* (- (* z z) t) y)))))
(if (<= (* 4.0 y) -5e-11)
t_1
(if (<= (* 4.0 y) 5e-22)
(fma (* (* -4.0 y) z) z (fma (* (- t) y) -4.0 (* x x)))
t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma(x, x, (-4.0 * (((z * z) - t) * y)));
double tmp;
if ((4.0 * y) <= -5e-11) {
tmp = t_1;
} else if ((4.0 * y) <= 5e-22) {
tmp = fma(((-4.0 * y) * z), z, fma((-t * y), -4.0, (x * x)));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(x, x, Float64(-4.0 * Float64(Float64(Float64(z * z) - t) * y))) tmp = 0.0 if (Float64(4.0 * y) <= -5e-11) tmp = t_1; elseif (Float64(4.0 * y) <= 5e-22) tmp = fma(Float64(Float64(-4.0 * y) * z), z, fma(Float64(Float64(-t) * y), -4.0, Float64(x * x))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * x + N[(-4.0 * N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(4.0 * y), $MachinePrecision], -5e-11], t$95$1, If[LessEqual[N[(4.0 * y), $MachinePrecision], 5e-22], N[(N[(N[(-4.0 * y), $MachinePrecision] * z), $MachinePrecision] * z + N[(N[((-t) * y), $MachinePrecision] * -4.0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(x, x, -4 \cdot \left(\left(z \cdot z - t\right) \cdot y\right)\right)\\
\mathbf{if}\;4 \cdot y \leq -5 \cdot 10^{-11}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;4 \cdot y \leq 5 \cdot 10^{-22}:\\
\;\;\;\;\mathsf{fma}\left(\left(-4 \cdot y\right) \cdot z, z, \mathsf{fma}\left(\left(-t\right) \cdot y, -4, x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 y #s(literal 4 binary64)) < -5.00000000000000018e-11 or 4.99999999999999954e-22 < (*.f64 y #s(literal 4 binary64)) Initial program 94.3%
lift--.f64N/A
sub-negN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-*.f64N/A
metadata-eval99.2
Applied rewrites99.2%
if -5.00000000000000018e-11 < (*.f64 y #s(literal 4 binary64)) < 4.99999999999999954e-22Initial program 89.8%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
associate-+l+N/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-evalN/A
Applied rewrites99.9%
Final simplification99.5%
(FPCore (x y z t) :precision binary64 (if (<= (- (* x x) (* (- (* z z) t) (* 4.0 y))) -2e+200) (* (* t y) -4.0) (* x x)))
double code(double x, double y, double z, double t) {
double tmp;
if (((x * x) - (((z * z) - t) * (4.0 * y))) <= -2e+200) {
tmp = (t * y) * -4.0;
} else {
tmp = x * x;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (((x * x) - (((z * z) - t) * (4.0d0 * y))) <= (-2d+200)) then
tmp = (t * y) * (-4.0d0)
else
tmp = x * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (((x * x) - (((z * z) - t) * (4.0 * y))) <= -2e+200) {
tmp = (t * y) * -4.0;
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((x * x) - (((z * z) - t) * (4.0 * y))) <= -2e+200: tmp = (t * y) * -4.0 else: tmp = x * x return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(Float64(x * x) - Float64(Float64(Float64(z * z) - t) * Float64(4.0 * y))) <= -2e+200) tmp = Float64(Float64(t * y) * -4.0); else tmp = Float64(x * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((x * x) - (((z * z) - t) * (4.0 * y))) <= -2e+200) tmp = (t * y) * -4.0; else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(N[(x * x), $MachinePrecision] - N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * N[(4.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2e+200], N[(N[(t * y), $MachinePrecision] * -4.0), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x - \left(z \cdot z - t\right) \cdot \left(4 \cdot y\right) \leq -2 \cdot 10^{+200}:\\
\;\;\;\;\left(t \cdot y\right) \cdot -4\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if (-.f64 (*.f64 x x) (*.f64 (*.f64 y #s(literal 4 binary64)) (-.f64 (*.f64 z z) t))) < -1.9999999999999999e200Initial program 83.3%
lift--.f64N/A
sub-negN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-*.f64N/A
metadata-eval83.3
Applied rewrites83.3%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-negN/A
lift-neg.f64N/A
distribute-lft-inN/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-neg.f64N/A
neg-sub0N/A
flip3--N/A
metadata-evalN/A
neg-sub0N/A
distribute-neg-fracN/A
Applied rewrites70.9%
Taylor expanded in t around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6410.5
Applied rewrites10.5%
if -1.9999999999999999e200 < (-.f64 (*.f64 x x) (*.f64 (*.f64 y #s(literal 4 binary64)) (-.f64 (*.f64 z z) t))) Initial program 93.8%
Taylor expanded in y around 0
unpow2N/A
lower-*.f6450.3
Applied rewrites50.3%
Final simplification43.3%
(FPCore (x y z t)
:precision binary64
(if (<= (* z z) 5e-37)
(fma x x (* (* t y) 4.0))
(if (<= (* z z) 4e+296)
(* (* (fma z z (- t)) y) -4.0)
(* (* -4.0 z) (* z y)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 5e-37) {
tmp = fma(x, x, ((t * y) * 4.0));
} else if ((z * z) <= 4e+296) {
tmp = (fma(z, z, -t) * y) * -4.0;
} else {
tmp = (-4.0 * z) * (z * y);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 5e-37) tmp = fma(x, x, Float64(Float64(t * y) * 4.0)); elseif (Float64(z * z) <= 4e+296) tmp = Float64(Float64(fma(z, z, Float64(-t)) * y) * -4.0); else tmp = Float64(Float64(-4.0 * z) * Float64(z * y)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 5e-37], N[(x * x + N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * z), $MachinePrecision], 4e+296], N[(N[(N[(z * z + (-t)), $MachinePrecision] * y), $MachinePrecision] * -4.0), $MachinePrecision], N[(N[(-4.0 * z), $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{-37}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(t \cdot y\right) \cdot 4\right)\\
\mathbf{elif}\;z \cdot z \leq 4 \cdot 10^{+296}:\\
\;\;\;\;\left(\mathsf{fma}\left(z, z, -t\right) \cdot y\right) \cdot -4\\
\mathbf{else}:\\
\;\;\;\;\left(-4 \cdot z\right) \cdot \left(z \cdot y\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 4.9999999999999997e-37Initial program 97.6%
lift--.f64N/A
sub-negN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-*.f64N/A
metadata-eval99.2
Applied rewrites99.2%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6498.1
Applied rewrites98.1%
if 4.9999999999999997e-37 < (*.f64 z z) < 3.99999999999999993e296Initial program 99.8%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
sub-negN/A
unpow2N/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f6478.7
Applied rewrites78.7%
if 3.99999999999999993e296 < (*.f64 z z) Initial program 75.1%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6480.8
Applied rewrites80.8%
Applied rewrites86.9%
Final simplification90.5%
(FPCore (x y z t)
:precision binary64
(if (<= z 2.7e-279)
(* x x)
(if (<= z 6.5e-209)
(* t (* 4.0 y))
(if (<= z 1.2e-17) (* x x) (* (* -4.0 z) (* z y))))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= 2.7e-279) {
tmp = x * x;
} else if (z <= 6.5e-209) {
tmp = t * (4.0 * y);
} else if (z <= 1.2e-17) {
tmp = x * x;
} else {
tmp = (-4.0 * z) * (z * y);
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= 2.7d-279) then
tmp = x * x
else if (z <= 6.5d-209) then
tmp = t * (4.0d0 * y)
else if (z <= 1.2d-17) then
tmp = x * x
else
tmp = ((-4.0d0) * z) * (z * y)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= 2.7e-279) {
tmp = x * x;
} else if (z <= 6.5e-209) {
tmp = t * (4.0 * y);
} else if (z <= 1.2e-17) {
tmp = x * x;
} else {
tmp = (-4.0 * z) * (z * y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= 2.7e-279: tmp = x * x elif z <= 6.5e-209: tmp = t * (4.0 * y) elif z <= 1.2e-17: tmp = x * x else: tmp = (-4.0 * z) * (z * y) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= 2.7e-279) tmp = Float64(x * x); elseif (z <= 6.5e-209) tmp = Float64(t * Float64(4.0 * y)); elseif (z <= 1.2e-17) tmp = Float64(x * x); else tmp = Float64(Float64(-4.0 * z) * Float64(z * y)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= 2.7e-279) tmp = x * x; elseif (z <= 6.5e-209) tmp = t * (4.0 * y); elseif (z <= 1.2e-17) tmp = x * x; else tmp = (-4.0 * z) * (z * y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, 2.7e-279], N[(x * x), $MachinePrecision], If[LessEqual[z, 6.5e-209], N[(t * N[(4.0 * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.2e-17], N[(x * x), $MachinePrecision], N[(N[(-4.0 * z), $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 2.7 \cdot 10^{-279}:\\
\;\;\;\;x \cdot x\\
\mathbf{elif}\;z \leq 6.5 \cdot 10^{-209}:\\
\;\;\;\;t \cdot \left(4 \cdot y\right)\\
\mathbf{elif}\;z \leq 1.2 \cdot 10^{-17}:\\
\;\;\;\;x \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(-4 \cdot z\right) \cdot \left(z \cdot y\right)\\
\end{array}
\end{array}
if z < 2.7000000000000001e-279 or 6.50000000000000042e-209 < z < 1.19999999999999993e-17Initial program 93.5%
Taylor expanded in y around 0
unpow2N/A
lower-*.f6448.3
Applied rewrites48.3%
if 2.7000000000000001e-279 < z < 6.50000000000000042e-209Initial program 90.9%
Taylor expanded in t around inf
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6482.7
Applied rewrites82.7%
if 1.19999999999999993e-17 < z Initial program 87.5%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6471.2
Applied rewrites71.2%
Applied rewrites78.6%
Final simplification57.1%
(FPCore (x y z t)
:precision binary64
(if (<= z 2.7e-279)
(* x x)
(if (<= z 6.5e-209)
(* t (* 4.0 y))
(if (<= z 1.2e-17) (* x x) (* (* (* z z) y) -4.0)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= 2.7e-279) {
tmp = x * x;
} else if (z <= 6.5e-209) {
tmp = t * (4.0 * y);
} else if (z <= 1.2e-17) {
tmp = x * x;
} else {
tmp = ((z * z) * y) * -4.0;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= 2.7d-279) then
tmp = x * x
else if (z <= 6.5d-209) then
tmp = t * (4.0d0 * y)
else if (z <= 1.2d-17) then
tmp = x * x
else
tmp = ((z * z) * y) * (-4.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= 2.7e-279) {
tmp = x * x;
} else if (z <= 6.5e-209) {
tmp = t * (4.0 * y);
} else if (z <= 1.2e-17) {
tmp = x * x;
} else {
tmp = ((z * z) * y) * -4.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= 2.7e-279: tmp = x * x elif z <= 6.5e-209: tmp = t * (4.0 * y) elif z <= 1.2e-17: tmp = x * x else: tmp = ((z * z) * y) * -4.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= 2.7e-279) tmp = Float64(x * x); elseif (z <= 6.5e-209) tmp = Float64(t * Float64(4.0 * y)); elseif (z <= 1.2e-17) tmp = Float64(x * x); else tmp = Float64(Float64(Float64(z * z) * y) * -4.0); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= 2.7e-279) tmp = x * x; elseif (z <= 6.5e-209) tmp = t * (4.0 * y); elseif (z <= 1.2e-17) tmp = x * x; else tmp = ((z * z) * y) * -4.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, 2.7e-279], N[(x * x), $MachinePrecision], If[LessEqual[z, 6.5e-209], N[(t * N[(4.0 * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.2e-17], N[(x * x), $MachinePrecision], N[(N[(N[(z * z), $MachinePrecision] * y), $MachinePrecision] * -4.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 2.7 \cdot 10^{-279}:\\
\;\;\;\;x \cdot x\\
\mathbf{elif}\;z \leq 6.5 \cdot 10^{-209}:\\
\;\;\;\;t \cdot \left(4 \cdot y\right)\\
\mathbf{elif}\;z \leq 1.2 \cdot 10^{-17}:\\
\;\;\;\;x \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(\left(z \cdot z\right) \cdot y\right) \cdot -4\\
\end{array}
\end{array}
if z < 2.7000000000000001e-279 or 6.50000000000000042e-209 < z < 1.19999999999999993e-17Initial program 93.5%
Taylor expanded in y around 0
unpow2N/A
lower-*.f6448.3
Applied rewrites48.3%
if 2.7000000000000001e-279 < z < 6.50000000000000042e-209Initial program 90.9%
Taylor expanded in t around inf
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6482.7
Applied rewrites82.7%
if 1.19999999999999993e-17 < z Initial program 87.5%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6471.2
Applied rewrites71.2%
Final simplification55.3%
(FPCore (x y z t) :precision binary64 (if (<= z 5e+149) (fma x x (* -4.0 (* (- (* z z) t) y))) (fma x x (* (fma (* z y) z (* t y)) -4.0))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= 5e+149) {
tmp = fma(x, x, (-4.0 * (((z * z) - t) * y)));
} else {
tmp = fma(x, x, (fma((z * y), z, (t * y)) * -4.0));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (z <= 5e+149) tmp = fma(x, x, Float64(-4.0 * Float64(Float64(Float64(z * z) - t) * y))); else tmp = fma(x, x, Float64(fma(Float64(z * y), z, Float64(t * y)) * -4.0)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, 5e+149], N[(x * x + N[(-4.0 * N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * x + N[(N[(N[(z * y), $MachinePrecision] * z + N[(t * y), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 5 \cdot 10^{+149}:\\
\;\;\;\;\mathsf{fma}\left(x, x, -4 \cdot \left(\left(z \cdot z - t\right) \cdot y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \mathsf{fma}\left(z \cdot y, z, t \cdot y\right) \cdot -4\right)\\
\end{array}
\end{array}
if z < 4.9999999999999999e149Initial program 94.2%
lift--.f64N/A
sub-negN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-*.f64N/A
metadata-eval96.0
Applied rewrites96.0%
if 4.9999999999999999e149 < z Initial program 77.4%
lift--.f64N/A
sub-negN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-*.f64N/A
metadata-eval83.3
Applied rewrites83.3%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-negN/A
lift-neg.f64N/A
distribute-lft-inN/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-neg.f64N/A
neg-sub0N/A
flip3--N/A
metadata-evalN/A
neg-sub0N/A
distribute-neg-fracN/A
Applied rewrites91.0%
Final simplification95.4%
(FPCore (x y z t) :precision binary64 (if (<= z 1.2e-17) (fma x x (* (* t y) 4.0)) (if (<= z 5e+149) (* (- t (* z z)) (* 4.0 y)) (* (* -4.0 z) (* z y)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= 1.2e-17) {
tmp = fma(x, x, ((t * y) * 4.0));
} else if (z <= 5e+149) {
tmp = (t - (z * z)) * (4.0 * y);
} else {
tmp = (-4.0 * z) * (z * y);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (z <= 1.2e-17) tmp = fma(x, x, Float64(Float64(t * y) * 4.0)); elseif (z <= 5e+149) tmp = Float64(Float64(t - Float64(z * z)) * Float64(4.0 * y)); else tmp = Float64(Float64(-4.0 * z) * Float64(z * y)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, 1.2e-17], N[(x * x + N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5e+149], N[(N[(t - N[(z * z), $MachinePrecision]), $MachinePrecision] * N[(4.0 * y), $MachinePrecision]), $MachinePrecision], N[(N[(-4.0 * z), $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.2 \cdot 10^{-17}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(t \cdot y\right) \cdot 4\right)\\
\mathbf{elif}\;z \leq 5 \cdot 10^{+149}:\\
\;\;\;\;\left(t - z \cdot z\right) \cdot \left(4 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-4 \cdot z\right) \cdot \left(z \cdot y\right)\\
\end{array}
\end{array}
if z < 1.19999999999999993e-17Initial program 93.4%
lift--.f64N/A
sub-negN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-*.f64N/A
metadata-eval95.5
Applied rewrites95.5%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6478.7
Applied rewrites78.7%
if 1.19999999999999993e-17 < z < 4.9999999999999999e149Initial program 99.8%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
sub-negN/A
unpow2N/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f6475.2
Applied rewrites75.2%
Applied rewrites75.3%
if 4.9999999999999999e149 < z Initial program 77.4%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6483.3
Applied rewrites83.3%
Applied rewrites96.9%
Final simplification80.7%
(FPCore (x y z t) :precision binary64 (if (<= z 1.25e+150) (fma x x (* -4.0 (* (- (* z z) t) y))) (* (* -4.0 z) (* z y))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= 1.25e+150) {
tmp = fma(x, x, (-4.0 * (((z * z) - t) * y)));
} else {
tmp = (-4.0 * z) * (z * y);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (z <= 1.25e+150) tmp = fma(x, x, Float64(-4.0 * Float64(Float64(Float64(z * z) - t) * y))); else tmp = Float64(Float64(-4.0 * z) * Float64(z * y)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, 1.25e+150], N[(x * x + N[(-4.0 * N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-4.0 * z), $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.25 \cdot 10^{+150}:\\
\;\;\;\;\mathsf{fma}\left(x, x, -4 \cdot \left(\left(z \cdot z - t\right) \cdot y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-4 \cdot z\right) \cdot \left(z \cdot y\right)\\
\end{array}
\end{array}
if z < 1.25000000000000002e150Initial program 94.2%
lift--.f64N/A
sub-negN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-*.f64N/A
metadata-eval96.0
Applied rewrites96.0%
if 1.25000000000000002e150 < z Initial program 77.4%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6483.3
Applied rewrites83.3%
Applied rewrites96.9%
Final simplification96.1%
(FPCore (x y z t) :precision binary64 (if (<= (* z z) 1e+110) (fma x x (* (* t y) 4.0)) (* (* -4.0 z) (* z y))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 1e+110) {
tmp = fma(x, x, ((t * y) * 4.0));
} else {
tmp = (-4.0 * z) * (z * y);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 1e+110) tmp = fma(x, x, Float64(Float64(t * y) * 4.0)); else tmp = Float64(Float64(-4.0 * z) * Float64(z * y)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 1e+110], N[(x * x + N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[(N[(-4.0 * z), $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 10^{+110}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(t \cdot y\right) \cdot 4\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-4 \cdot z\right) \cdot \left(z \cdot y\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 1e110Initial program 98.0%
lift--.f64N/A
sub-negN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-*.f64N/A
metadata-eval99.3
Applied rewrites99.3%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6491.5
Applied rewrites91.5%
if 1e110 < (*.f64 z z) Initial program 83.2%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6478.7
Applied rewrites78.7%
Applied rewrites82.7%
Final simplification87.9%
(FPCore (x y z t) :precision binary64 (if (<= (* z z) 1e+110) (fma (* t y) 4.0 (* x x)) (* (* -4.0 z) (* z y))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 1e+110) {
tmp = fma((t * y), 4.0, (x * x));
} else {
tmp = (-4.0 * z) * (z * y);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 1e+110) tmp = fma(Float64(t * y), 4.0, Float64(x * x)); else tmp = Float64(Float64(-4.0 * z) * Float64(z * y)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 1e+110], N[(N[(t * y), $MachinePrecision] * 4.0 + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(-4.0 * z), $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 10^{+110}:\\
\;\;\;\;\mathsf{fma}\left(t \cdot y, 4, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-4 \cdot z\right) \cdot \left(z \cdot y\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 1e110Initial program 98.0%
Taylor expanded in z around 0
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6490.2
Applied rewrites90.2%
if 1e110 < (*.f64 z z) Initial program 83.2%
Taylor expanded in z around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6478.7
Applied rewrites78.7%
Applied rewrites82.7%
Final simplification87.1%
(FPCore (x y z t) :precision binary64 (if (<= (* x x) 45000000000000.0) (* t (* 4.0 y)) (* x x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 45000000000000.0) {
tmp = t * (4.0 * y);
} else {
tmp = x * x;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((x * x) <= 45000000000000.0d0) then
tmp = t * (4.0d0 * y)
else
tmp = x * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 45000000000000.0) {
tmp = t * (4.0 * y);
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x * x) <= 45000000000000.0: tmp = t * (4.0 * y) else: tmp = x * x return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x * x) <= 45000000000000.0) tmp = Float64(t * Float64(4.0 * y)); else tmp = Float64(x * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x * x) <= 45000000000000.0) tmp = t * (4.0 * y); else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x * x), $MachinePrecision], 45000000000000.0], N[(t * N[(4.0 * y), $MachinePrecision]), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 45000000000000:\\
\;\;\;\;t \cdot \left(4 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if (*.f64 x x) < 4.5e13Initial program 93.8%
Taylor expanded in t around inf
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6449.9
Applied rewrites49.9%
if 4.5e13 < (*.f64 x x) Initial program 89.8%
Taylor expanded in y around 0
unpow2N/A
lower-*.f6475.0
Applied rewrites75.0%
Final simplification61.5%
(FPCore (x y z t) :precision binary64 (* x x))
double code(double x, double y, double z, double t) {
return x * x;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x * x
end function
public static double code(double x, double y, double z, double t) {
return x * x;
}
def code(x, y, z, t): return x * x
function code(x, y, z, t) return Float64(x * x) end
function tmp = code(x, y, z, t) tmp = x * x; end
code[x_, y_, z_, t_] := N[(x * x), $MachinePrecision]
\begin{array}{l}
\\
x \cdot x
\end{array}
Initial program 92.0%
Taylor expanded in y around 0
unpow2N/A
lower-*.f6441.7
Applied rewrites41.7%
(FPCore (x y z t) :precision binary64 (- (* x x) (* 4.0 (* y (- (* z z) t)))))
double code(double x, double y, double z, double t) {
return (x * x) - (4.0 * (y * ((z * z) - t)));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x * x) - (4.0d0 * (y * ((z * z) - t)))
end function
public static double code(double x, double y, double z, double t) {
return (x * x) - (4.0 * (y * ((z * z) - t)));
}
def code(x, y, z, t): return (x * x) - (4.0 * (y * ((z * z) - t)))
function code(x, y, z, t) return Float64(Float64(x * x) - Float64(4.0 * Float64(y * Float64(Float64(z * z) - t)))) end
function tmp = code(x, y, z, t) tmp = (x * x) - (4.0 * (y * ((z * z) - t))); end
code[x_, y_, z_, t_] := N[(N[(x * x), $MachinePrecision] - N[(4.0 * N[(y * N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot x - 4 \cdot \left(y \cdot \left(z \cdot z - t\right)\right)
\end{array}
herbie shell --seed 2024273
(FPCore (x y z t)
:name "Graphics.Rasterific.Shading:$sradialGradientWithFocusShader from Rasterific-0.6.1, B"
:precision binary64
:alt
(! :herbie-platform default (- (* x x) (* 4 (* y (- (* z z) t)))))
(- (* x x) (* (* y 4.0) (- (* z z) t))))