Graphics.Rasterific.Shading:$sradialGradientWithFocusShader from Rasterific-0.6.1, B

Percentage Accurate: 90.5% → 97.5%
Time: 10.1s
Alternatives: 10
Speedup: 0.8×

Specification

?
\[\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 (- (* 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:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 10 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 90.5% accurate, 1.0× speedup?

\[\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 (- (* 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}

Alternative 1: 97.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \cdot z \leq 10^{+289}:\\ \;\;\;\;\frac{1}{\frac{1}{\mathsf{fma}\left(y, \mathsf{fma}\left(z, z, -t\right) \cdot -4, x \cdot x\right)}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z \cdot \left(y \cdot -4\right), z, x \cdot x\right)\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= (* z z) 1e+289)
   (/ 1.0 (/ 1.0 (fma y (* (fma z z (- t)) -4.0) (* x x))))
   (fma (* z (* y -4.0)) z (* x x))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((z * z) <= 1e+289) {
		tmp = 1.0 / (1.0 / fma(y, (fma(z, z, -t) * -4.0), (x * x)));
	} else {
		tmp = fma((z * (y * -4.0)), z, (x * x));
	}
	return tmp;
}
function code(x, y, z, t)
	tmp = 0.0
	if (Float64(z * z) <= 1e+289)
		tmp = Float64(1.0 / Float64(1.0 / fma(y, Float64(fma(z, z, Float64(-t)) * -4.0), Float64(x * x))));
	else
		tmp = fma(Float64(z * Float64(y * -4.0)), z, Float64(x * x));
	end
	return tmp
end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 1e+289], N[(1.0 / N[(1.0 / N[(y * N[(N[(z * z + (-t)), $MachinePrecision] * -4.0), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z * N[(y * -4.0), $MachinePrecision]), $MachinePrecision] * z + N[(x * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 10^{+289}:\\
\;\;\;\;\frac{1}{\frac{1}{\mathsf{fma}\left(y, \mathsf{fma}\left(z, z, -t\right) \cdot -4, x \cdot x\right)}}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot \left(y \cdot -4\right), z, x \cdot x\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 z z) < 1.0000000000000001e289

    1. Initial program 97.7%

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \color{blue}{x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)} \]
      2. flip--N/A

        \[\leadsto \color{blue}{\frac{\left(x \cdot x\right) \cdot \left(x \cdot x\right) - \left(\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\right) \cdot \left(\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\right)}{x \cdot x + \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)}} \]
      3. clear-numN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)}{\left(x \cdot x\right) \cdot \left(x \cdot x\right) - \left(\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\right) \cdot \left(\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\right)}}} \]
      4. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)}{\left(x \cdot x\right) \cdot \left(x \cdot x\right) - \left(\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\right) \cdot \left(\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\right)}}} \]
      5. clear-numN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{\left(x \cdot x\right) \cdot \left(x \cdot x\right) - \left(\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\right) \cdot \left(\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\right)}{x \cdot x + \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)}}}} \]
      6. flip--N/A

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)}}} \]
      7. lift--.f64N/A

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)}}} \]
      8. lower-/.f6497.6

        \[\leadsto \frac{1}{\color{blue}{\frac{1}{x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)}}} \]
      9. lift--.f64N/A

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)}}} \]
      10. sub-negN/A

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{x \cdot x + \left(\mathsf{neg}\left(\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\right)\right)}}} \]
      11. +-commutativeN/A

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\left(\mathsf{neg}\left(\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\right)\right) + x \cdot x}}} \]
    4. Applied rewrites99.8%

      \[\leadsto \color{blue}{\frac{1}{\frac{1}{\mathsf{fma}\left(y, \mathsf{fma}\left(z, z, -t\right) \cdot -4, x \cdot x\right)}}} \]

    if 1.0000000000000001e289 < (*.f64 z z)

    1. Initial program 63.1%

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \color{blue}{x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)} \]
      2. sub-negN/A

        \[\leadsto \color{blue}{x \cdot x + \left(\mathsf{neg}\left(\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\right)\right)} \]
      3. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\right)\right) + x \cdot x} \]
      4. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)}\right)\right) + x \cdot x \]
      5. distribute-lft-neg-inN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(z \cdot z - t\right)} + x \cdot x \]
      6. lift--.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \color{blue}{\left(z \cdot z - t\right)} + x \cdot x \]
      7. sub-negN/A

        \[\leadsto \left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \color{blue}{\left(z \cdot z + \left(\mathsf{neg}\left(t\right)\right)\right)} + x \cdot x \]
      8. distribute-lft-inN/A

        \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(z \cdot z\right) + \left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(\mathsf{neg}\left(t\right)\right)\right)} + x \cdot x \]
      9. associate-+l+N/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(z \cdot z\right) + \left(\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(\mathsf{neg}\left(t\right)\right) + x \cdot x\right)} \]
      10. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \color{blue}{\left(z \cdot z\right)} + \left(\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(\mathsf{neg}\left(t\right)\right) + x \cdot x\right) \]
      11. associate-*r*N/A

        \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot z\right) \cdot z} + \left(\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(\mathsf{neg}\left(t\right)\right) + x \cdot x\right) \]
      12. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot z, z, \left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(\mathsf{neg}\left(t\right)\right) + x \cdot x\right)} \]
      13. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot z}, z, \left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(\mathsf{neg}\left(t\right)\right) + x \cdot x\right) \]
      14. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\mathsf{neg}\left(\color{blue}{y \cdot 4}\right)\right) \cdot z, z, \left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(\mathsf{neg}\left(t\right)\right) + x \cdot x\right) \]
      15. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(y \cdot \left(\mathsf{neg}\left(4\right)\right)\right)} \cdot z, z, \left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(\mathsf{neg}\left(t\right)\right) + x \cdot x\right) \]
      16. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(y \cdot \left(\mathsf{neg}\left(4\right)\right)\right)} \cdot z, z, \left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(\mathsf{neg}\left(t\right)\right) + x \cdot x\right) \]
      17. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\left(y \cdot \color{blue}{-4}\right) \cdot z, z, \left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(\mathsf{neg}\left(t\right)\right) + x \cdot x\right) \]
    4. Applied rewrites91.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(y \cdot -4\right) \cdot z, z, \mathsf{fma}\left(-4, y \cdot \left(-t\right), x \cdot x\right)\right)} \]
    5. Taylor expanded in y around 0

      \[\leadsto \mathsf{fma}\left(\left(y \cdot -4\right) \cdot z, z, \color{blue}{{x}^{2}}\right) \]
    6. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \mathsf{fma}\left(\left(y \cdot -4\right) \cdot z, z, \color{blue}{x \cdot x}\right) \]
      2. lower-*.f6494.4

        \[\leadsto \mathsf{fma}\left(\left(y \cdot -4\right) \cdot z, z, \color{blue}{x \cdot x}\right) \]
    7. Applied rewrites94.4%

      \[\leadsto \mathsf{fma}\left(\left(y \cdot -4\right) \cdot z, z, \color{blue}{x \cdot x}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot z \leq 10^{+289}:\\ \;\;\;\;\frac{1}{\frac{1}{\mathsf{fma}\left(y, \mathsf{fma}\left(z, z, -t\right) \cdot -4, x \cdot x\right)}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z \cdot \left(y \cdot -4\right), z, x \cdot x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 97.1% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \cdot 4 \leq 5 \cdot 10^{+22}:\\ \;\;\;\;\mathsf{fma}\left(z \cdot \left(y \cdot -4\right), z, \mathsf{fma}\left(-4, -y \cdot t, x \cdot x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, x, y \cdot \left(\mathsf{fma}\left(z, z, -t\right) \cdot -4\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= (* y 4.0) 5e+22)
   (fma (* z (* y -4.0)) z (fma -4.0 (- (* y t)) (* x x)))
   (fma x x (* y (* (fma z z (- t)) -4.0)))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((y * 4.0) <= 5e+22) {
		tmp = fma((z * (y * -4.0)), z, fma(-4.0, -(y * t), (x * x)));
	} else {
		tmp = fma(x, x, (y * (fma(z, z, -t) * -4.0)));
	}
	return tmp;
}
function code(x, y, z, t)
	tmp = 0.0
	if (Float64(y * 4.0) <= 5e+22)
		tmp = fma(Float64(z * Float64(y * -4.0)), z, fma(-4.0, Float64(-Float64(y * t)), Float64(x * x)));
	else
		tmp = fma(x, x, Float64(y * Float64(fma(z, z, Float64(-t)) * -4.0)));
	end
	return tmp
end
code[x_, y_, z_, t_] := If[LessEqual[N[(y * 4.0), $MachinePrecision], 5e+22], N[(N[(z * N[(y * -4.0), $MachinePrecision]), $MachinePrecision] * z + N[(-4.0 * (-N[(y * t), $MachinePrecision]) + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * x + N[(y * N[(N[(z * z + (-t)), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \cdot 4 \leq 5 \cdot 10^{+22}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot \left(y \cdot -4\right), z, \mathsf{fma}\left(-4, -y \cdot t, x \cdot x\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, x, y \cdot \left(\mathsf{fma}\left(z, z, -t\right) \cdot -4\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 y #s(literal 4 binary64)) < 4.9999999999999996e22

    1. Initial program 91.0%

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \color{blue}{x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)} \]
      2. sub-negN/A

        \[\leadsto \color{blue}{x \cdot x + \left(\mathsf{neg}\left(\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\right)\right)} \]
      3. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\right)\right) + x \cdot x} \]
      4. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)}\right)\right) + x \cdot x \]
      5. distribute-lft-neg-inN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(z \cdot z - t\right)} + x \cdot x \]
      6. lift--.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \color{blue}{\left(z \cdot z - t\right)} + x \cdot x \]
      7. sub-negN/A

        \[\leadsto \left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \color{blue}{\left(z \cdot z + \left(\mathsf{neg}\left(t\right)\right)\right)} + x \cdot x \]
      8. distribute-lft-inN/A

        \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(z \cdot z\right) + \left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(\mathsf{neg}\left(t\right)\right)\right)} + x \cdot x \]
      9. associate-+l+N/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(z \cdot z\right) + \left(\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(\mathsf{neg}\left(t\right)\right) + x \cdot x\right)} \]
      10. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \color{blue}{\left(z \cdot z\right)} + \left(\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(\mathsf{neg}\left(t\right)\right) + x \cdot x\right) \]
      11. associate-*r*N/A

        \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot z\right) \cdot z} + \left(\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(\mathsf{neg}\left(t\right)\right) + x \cdot x\right) \]
      12. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot z, z, \left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(\mathsf{neg}\left(t\right)\right) + x \cdot x\right)} \]
      13. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot z}, z, \left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(\mathsf{neg}\left(t\right)\right) + x \cdot x\right) \]
      14. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\mathsf{neg}\left(\color{blue}{y \cdot 4}\right)\right) \cdot z, z, \left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(\mathsf{neg}\left(t\right)\right) + x \cdot x\right) \]
      15. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(y \cdot \left(\mathsf{neg}\left(4\right)\right)\right)} \cdot z, z, \left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(\mathsf{neg}\left(t\right)\right) + x \cdot x\right) \]
      16. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(y \cdot \left(\mathsf{neg}\left(4\right)\right)\right)} \cdot z, z, \left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(\mathsf{neg}\left(t\right)\right) + x \cdot x\right) \]
      17. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\left(y \cdot \color{blue}{-4}\right) \cdot z, z, \left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(\mathsf{neg}\left(t\right)\right) + x \cdot x\right) \]
    4. Applied rewrites97.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(y \cdot -4\right) \cdot z, z, \mathsf{fma}\left(-4, y \cdot \left(-t\right), x \cdot x\right)\right)} \]

    if 4.9999999999999996e22 < (*.f64 y #s(literal 4 binary64))

    1. Initial program 88.8%

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \color{blue}{x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)} \]
      2. sub-negN/A

        \[\leadsto \color{blue}{x \cdot x + \left(\mathsf{neg}\left(\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\right)\right)} \]
      3. lift-*.f64N/A

        \[\leadsto \color{blue}{x \cdot x} + \left(\mathsf{neg}\left(\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\right)\right) \]
      4. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, \mathsf{neg}\left(\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\right)\right)} \]
      5. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(x, x, \mathsf{neg}\left(\color{blue}{\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)}\right)\right) \]
      6. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(x, x, \mathsf{neg}\left(\color{blue}{\left(y \cdot 4\right)} \cdot \left(z \cdot z - t\right)\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{fma}\left(x, x, \mathsf{neg}\left(\color{blue}{y \cdot \left(4 \cdot \left(z \cdot z - t\right)\right)}\right)\right) \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(\mathsf{neg}\left(4 \cdot \left(z \cdot z - t\right)\right)\right)}\right) \]
      9. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(\mathsf{neg}\left(4 \cdot \left(z \cdot z - t\right)\right)\right)}\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(x, x, y \cdot \left(\mathsf{neg}\left(\color{blue}{\left(z \cdot z - t\right) \cdot 4}\right)\right)\right) \]
      11. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma}\left(x, x, y \cdot \color{blue}{\left(\left(z \cdot z - t\right) \cdot \left(\mathsf{neg}\left(4\right)\right)\right)}\right) \]
      12. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(x, x, y \cdot \color{blue}{\left(\left(z \cdot z - t\right) \cdot \left(\mathsf{neg}\left(4\right)\right)\right)}\right) \]
      13. lift--.f64N/A

        \[\leadsto \mathsf{fma}\left(x, x, y \cdot \left(\color{blue}{\left(z \cdot z - t\right)} \cdot \left(\mathsf{neg}\left(4\right)\right)\right)\right) \]
      14. sub-negN/A

        \[\leadsto \mathsf{fma}\left(x, x, y \cdot \left(\color{blue}{\left(z \cdot z + \left(\mathsf{neg}\left(t\right)\right)\right)} \cdot \left(\mathsf{neg}\left(4\right)\right)\right)\right) \]
      15. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(x, x, y \cdot \left(\left(\color{blue}{z \cdot z} + \left(\mathsf{neg}\left(t\right)\right)\right) \cdot \left(\mathsf{neg}\left(4\right)\right)\right)\right) \]
      16. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(x, x, y \cdot \left(\color{blue}{\mathsf{fma}\left(z, z, \mathsf{neg}\left(t\right)\right)} \cdot \left(\mathsf{neg}\left(4\right)\right)\right)\right) \]
      17. lower-neg.f64N/A

        \[\leadsto \mathsf{fma}\left(x, x, y \cdot \left(\mathsf{fma}\left(z, z, \color{blue}{\mathsf{neg}\left(t\right)}\right) \cdot \left(\mathsf{neg}\left(4\right)\right)\right)\right) \]
      18. metadata-eval96.1

        \[\leadsto \mathsf{fma}\left(x, x, y \cdot \left(\mathsf{fma}\left(z, z, -t\right) \cdot \color{blue}{-4}\right)\right) \]
    4. Applied rewrites96.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, y \cdot \left(\mathsf{fma}\left(z, z, -t\right) \cdot -4\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot 4 \leq 5 \cdot 10^{+22}:\\ \;\;\;\;\mathsf{fma}\left(z \cdot \left(y \cdot -4\right), z, \mathsf{fma}\left(-4, -y \cdot t, x \cdot x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, x, y \cdot \left(\mathsf{fma}\left(z, z, -t\right) \cdot -4\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Developer Target 1: 90.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x \cdot x - 4 \cdot \left(y \cdot \left(z \cdot z - t\right)\right) \end{array} \]
(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}

Reproduce

?
herbie shell --seed 2024226 
(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))))