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

Percentage Accurate: 91.1% → 97.4%
Time: 9.8s
Alternatives: 8
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 8 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: 91.1% 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.4% accurate, 0.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (*.f64 z z) t) < 1.00000000000000006e290

    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. 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-eval98.3

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

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

    if 1.00000000000000006e290 < (-.f64 (*.f64 z z) t)

    1. Initial program 54.9%

      \[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-eval65.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 rewrites65.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 90.3% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;z \cdot z \leq 2 \cdot 10^{+301}:\\
\;\;\;\;\mathsf{fma}\left(y, \left(z \cdot z\right) \cdot -4, x \cdot x\right)\\

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


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

    1. Initial program 98.4%

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0

      \[\leadsto \color{blue}{{x}^{2} - -4 \cdot \left(t \cdot y\right)} \]
    4. Step-by-step derivation
      1. cancel-sign-sub-invN/A

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

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

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

        \[\leadsto \color{blue}{\left(4 \cdot t\right) \cdot y} + {x}^{2} \]
      5. *-commutativeN/A

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

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

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

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{t \cdot 4}, {x}^{2}\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{fma}\left(y, t \cdot 4, \color{blue}{x \cdot x}\right) \]
      10. lower-*.f6492.3

        \[\leadsto \mathsf{fma}\left(y, t \cdot 4, \color{blue}{x \cdot x}\right) \]
    5. Applied rewrites92.3%

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

    if 1.00000000000000002e64 < (*.f64 z z) < 2.00000000000000011e301

    1. Initial program 96.3%

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. Add Preprocessing
    3. Taylor expanded in t around 0

      \[\leadsto \color{blue}{{x}^{2} - 4 \cdot \left(y \cdot {z}^{2}\right)} \]
    4. Step-by-step derivation
      1. cancel-sign-sub-invN/A

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

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

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

        \[\leadsto \color{blue}{\left(-4 \cdot y\right) \cdot {z}^{2}} + {x}^{2} \]
      5. *-commutativeN/A

        \[\leadsto \color{blue}{\left(y \cdot -4\right)} \cdot {z}^{2} + {x}^{2} \]
      6. associate-*l*N/A

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

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

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{-4 \cdot {z}^{2}}, {x}^{2}\right) \]
      9. unpow2N/A

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

        \[\leadsto \mathsf{fma}\left(y, -4 \cdot \color{blue}{\left(z \cdot z\right)}, {x}^{2}\right) \]
      11. unpow2N/A

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

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

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

    if 2.00000000000000011e301 < (*.f64 z z)

    1. Initial program 71.5%

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf

      \[\leadsto \color{blue}{-4 \cdot \left(y \cdot {z}^{2}\right)} \]
    4. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \color{blue}{\left(-4 \cdot y\right) \cdot {z}^{2}} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{\left(y \cdot -4\right)} \cdot {z}^{2} \]
      3. associate-*l*N/A

        \[\leadsto \color{blue}{y \cdot \left(-4 \cdot {z}^{2}\right)} \]
      4. lower-*.f64N/A

        \[\leadsto \color{blue}{y \cdot \left(-4 \cdot {z}^{2}\right)} \]
      5. lower-*.f64N/A

        \[\leadsto y \cdot \color{blue}{\left(-4 \cdot {z}^{2}\right)} \]
      6. unpow2N/A

        \[\leadsto y \cdot \left(-4 \cdot \color{blue}{\left(z \cdot z\right)}\right) \]
      7. lower-*.f6476.7

        \[\leadsto y \cdot \left(-4 \cdot \color{blue}{\left(z \cdot z\right)}\right) \]
    5. Applied rewrites76.7%

      \[\leadsto \color{blue}{y \cdot \left(-4 \cdot \left(z \cdot z\right)\right)} \]
    6. Step-by-step derivation
      1. Applied rewrites88.5%

        \[\leadsto \left(\left(y \cdot -4\right) \cdot z\right) \cdot \color{blue}{z} \]
    7. Recombined 3 regimes into one program.
    8. Final simplification90.3%

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

    Developer Target 1: 91.2% 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 2024223 
    (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))))