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

Percentage Accurate: 91.5% → 94.9%
Time: 3.9s
Alternatives: 6
Speedup: 0.7×

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 6 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.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: 94.9% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 93.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. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left(\mathsf{neg}\left(\color{blue}{4 \cdot y}\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. distribute-lft-neg-inN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\left(\mathsf{neg}\left(4\right)\right) \cdot y\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. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\left(\mathsf{neg}\left(4\right)\right) \cdot y\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) \]
      18. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\left(\color{blue}{-4} \cdot y\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 rewrites98.3%

      \[\leadsto \color{blue}{\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)} \]

    if 1.0000000000000001e172 < (*.f64 y #s(literal 4 binary64))

    1. Initial program 71.4%

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 95.4% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \cdot z \leq 10^{+297}:\\ \;\;\;\;x \cdot x - \left(z \cdot z - t\right) \cdot \left(4 \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-z\right) \cdot \left(-4 \cdot y\right)}{\frac{-1}{z}}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= (* z z) 1e+297)
   (- (* x x) (* (- (* z z) t) (* 4.0 y)))
   (/ (* (- z) (* -4.0 y)) (/ -1.0 z))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((z * z) <= 1e+297) {
		tmp = (x * x) - (((z * z) - t) * (4.0 * y));
	} else {
		tmp = (-z * (-4.0 * y)) / (-1.0 / z);
	}
	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 * z) <= 1d+297) then
        tmp = (x * x) - (((z * z) - t) * (4.0d0 * y))
    else
        tmp = (-z * ((-4.0d0) * y)) / ((-1.0d0) / z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((z * z) <= 1e+297) {
		tmp = (x * x) - (((z * z) - t) * (4.0 * y));
	} else {
		tmp = (-z * (-4.0 * y)) / (-1.0 / z);
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (z * z) <= 1e+297:
		tmp = (x * x) - (((z * z) - t) * (4.0 * y))
	else:
		tmp = (-z * (-4.0 * y)) / (-1.0 / z)
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (Float64(z * z) <= 1e+297)
		tmp = Float64(Float64(x * x) - Float64(Float64(Float64(z * z) - t) * Float64(4.0 * y)));
	else
		tmp = Float64(Float64(Float64(-z) * Float64(-4.0 * y)) / Float64(-1.0 / z));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((z * z) <= 1e+297)
		tmp = (x * x) - (((z * z) - t) * (4.0 * y));
	else
		tmp = (-z * (-4.0 * y)) / (-1.0 / z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 1e+297], N[(N[(x * x), $MachinePrecision] - N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * N[(4.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-z) * N[(-4.0 * y), $MachinePrecision]), $MachinePrecision] / N[(-1.0 / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 96.8%

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. Add Preprocessing

    if 1e297 < (*.f64 z z)

    1. Initial program 76.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. *-commutativeN/A

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

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

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

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

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

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

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

        \[\leadsto \left(\left(z \cdot y\right) \cdot z\right) \cdot -4 \]
      2. Step-by-step derivation
        1. Applied rewrites84.4%

          \[\leadsto \frac{y}{{z}^{-2}} \cdot -4 \]
        2. Step-by-step derivation
          1. Applied rewrites95.8%

            \[\leadsto \frac{-\left(-4 \cdot y\right) \cdot z}{\color{blue}{\frac{-1}{z}}} \]
        3. Recombined 2 regimes into one program.
        4. Final simplification96.5%

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

        Alternative 3: 95.4% accurate, 0.7× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \cdot z \leq 10^{+297}:\\ \;\;\;\;x \cdot x - \left(z \cdot z - t\right) \cdot \left(4 \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(z \cdot y\right) \cdot z\right) \cdot -4\\ \end{array} \end{array} \]
        (FPCore (x y z t)
         :precision binary64
         (if (<= (* z z) 1e+297)
           (- (* x x) (* (- (* z z) t) (* 4.0 y)))
           (* (* (* z y) z) -4.0)))
        double code(double x, double y, double z, double t) {
        	double tmp;
        	if ((z * z) <= 1e+297) {
        		tmp = (x * x) - (((z * z) - t) * (4.0 * y));
        	} else {
        		tmp = ((z * y) * z) * -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 * z) <= 1d+297) then
                tmp = (x * x) - (((z * z) - t) * (4.0d0 * y))
            else
                tmp = ((z * y) * z) * (-4.0d0)
            end if
            code = tmp
        end function
        
        public static double code(double x, double y, double z, double t) {
        	double tmp;
        	if ((z * z) <= 1e+297) {
        		tmp = (x * x) - (((z * z) - t) * (4.0 * y));
        	} else {
        		tmp = ((z * y) * z) * -4.0;
        	}
        	return tmp;
        }
        
        def code(x, y, z, t):
        	tmp = 0
        	if (z * z) <= 1e+297:
        		tmp = (x * x) - (((z * z) - t) * (4.0 * y))
        	else:
        		tmp = ((z * y) * z) * -4.0
        	return tmp
        
        function code(x, y, z, t)
        	tmp = 0.0
        	if (Float64(z * z) <= 1e+297)
        		tmp = Float64(Float64(x * x) - Float64(Float64(Float64(z * z) - t) * Float64(4.0 * y)));
        	else
        		tmp = Float64(Float64(Float64(z * y) * z) * -4.0);
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, y, z, t)
        	tmp = 0.0;
        	if ((z * z) <= 1e+297)
        		tmp = (x * x) - (((z * z) - t) * (4.0 * y));
        	else
        		tmp = ((z * y) * z) * -4.0;
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 1e+297], N[(N[(x * x), $MachinePrecision] - N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * N[(4.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z * y), $MachinePrecision] * z), $MachinePrecision] * -4.0), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;z \cdot z \leq 10^{+297}:\\
        \;\;\;\;x \cdot x - \left(z \cdot z - t\right) \cdot \left(4 \cdot y\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;\left(\left(z \cdot y\right) \cdot z\right) \cdot -4\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if (*.f64 z z) < 1e297

          1. Initial program 96.8%

            \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
          2. Add Preprocessing

          if 1e297 < (*.f64 z z)

          1. Initial program 76.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. *-commutativeN/A

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

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

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

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

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

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

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

              \[\leadsto \left(\left(z \cdot y\right) \cdot z\right) \cdot -4 \]
          7. Recombined 2 regimes into one program.
          8. Final simplification96.5%

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

          Alternative 4: 83.3% accurate, 1.0× speedup?

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

            1. Initial program 96.7%

              \[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. *-commutativeN/A

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

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

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

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

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

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

            if 4.99999999999999973e272 < (*.f64 z z)

            1. Initial program 77.7%

              \[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. *-commutativeN/A

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

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

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

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

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

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

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

                \[\leadsto \left(\left(z \cdot y\right) \cdot z\right) \cdot -4 \]
            7. Recombined 2 regimes into one program.
            8. Add Preprocessing

            Alternative 5: 59.3% accurate, 1.0× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+22}:\\ \;\;\;\;\left(t \cdot y\right) \cdot 4\\ \mathbf{else}:\\ \;\;\;\;\left(\left(z \cdot y\right) \cdot z\right) \cdot -4\\ \end{array} \end{array} \]
            (FPCore (x y z t)
             :precision binary64
             (if (<= (* z z) 2e+22) (* (* t y) 4.0) (* (* (* z y) z) -4.0)))
            double code(double x, double y, double z, double t) {
            	double tmp;
            	if ((z * z) <= 2e+22) {
            		tmp = (t * y) * 4.0;
            	} else {
            		tmp = ((z * y) * z) * -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 * z) <= 2d+22) then
                    tmp = (t * y) * 4.0d0
                else
                    tmp = ((z * y) * z) * (-4.0d0)
                end if
                code = tmp
            end function
            
            public static double code(double x, double y, double z, double t) {
            	double tmp;
            	if ((z * z) <= 2e+22) {
            		tmp = (t * y) * 4.0;
            	} else {
            		tmp = ((z * y) * z) * -4.0;
            	}
            	return tmp;
            }
            
            def code(x, y, z, t):
            	tmp = 0
            	if (z * z) <= 2e+22:
            		tmp = (t * y) * 4.0
            	else:
            		tmp = ((z * y) * z) * -4.0
            	return tmp
            
            function code(x, y, z, t)
            	tmp = 0.0
            	if (Float64(z * z) <= 2e+22)
            		tmp = Float64(Float64(t * y) * 4.0);
            	else
            		tmp = Float64(Float64(Float64(z * y) * z) * -4.0);
            	end
            	return tmp
            end
            
            function tmp_2 = code(x, y, z, t)
            	tmp = 0.0;
            	if ((z * z) <= 2e+22)
            		tmp = (t * y) * 4.0;
            	else
            		tmp = ((z * y) * z) * -4.0;
            	end
            	tmp_2 = tmp;
            end
            
            code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 2e+22], N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision], N[(N[(N[(z * y), $MachinePrecision] * z), $MachinePrecision] * -4.0), $MachinePrecision]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+22}:\\
            \;\;\;\;\left(t \cdot y\right) \cdot 4\\
            
            \mathbf{else}:\\
            \;\;\;\;\left(\left(z \cdot y\right) \cdot z\right) \cdot -4\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if (*.f64 z z) < 2e22

              1. Initial program 98.6%

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

                \[\leadsto \color{blue}{4 \cdot \left(t \cdot y\right)} \]
              4. Step-by-step derivation
                1. *-commutativeN/A

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

                  \[\leadsto \color{blue}{\left(t \cdot y\right) \cdot 4} \]
                3. lower-*.f6455.3

                  \[\leadsto \color{blue}{\left(t \cdot y\right)} \cdot 4 \]
              5. Applied rewrites55.3%

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

              if 2e22 < (*.f64 z z)

              1. Initial program 82.3%

                \[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. *-commutativeN/A

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

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

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

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

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

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

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

                  \[\leadsto \left(\left(z \cdot y\right) \cdot z\right) \cdot -4 \]
              7. Recombined 2 regimes into one program.
              8. Add Preprocessing

              Alternative 6: 31.7% accurate, 2.5× speedup?

              \[\begin{array}{l} \\ \left(t \cdot y\right) \cdot 4 \end{array} \]
              (FPCore (x y z t) :precision binary64 (* (* t y) 4.0))
              double code(double x, double y, double z, double t) {
              	return (t * y) * 4.0;
              }
              
              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 = (t * y) * 4.0d0
              end function
              
              public static double code(double x, double y, double z, double t) {
              	return (t * y) * 4.0;
              }
              
              def code(x, y, z, t):
              	return (t * y) * 4.0
              
              function code(x, y, z, t)
              	return Float64(Float64(t * y) * 4.0)
              end
              
              function tmp = code(x, y, z, t)
              	tmp = (t * y) * 4.0;
              end
              
              code[x_, y_, z_, t_] := N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision]
              
              \begin{array}{l}
              
              \\
              \left(t \cdot y\right) \cdot 4
              \end{array}
              
              Derivation
              1. Initial program 91.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 inf

                \[\leadsto \color{blue}{4 \cdot \left(t \cdot y\right)} \]
              4. Step-by-step derivation
                1. *-commutativeN/A

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

                  \[\leadsto \color{blue}{\left(t \cdot y\right) \cdot 4} \]
                3. lower-*.f6436.2

                  \[\leadsto \color{blue}{\left(t \cdot y\right)} \cdot 4 \]
              5. Applied rewrites36.2%

                \[\leadsto \color{blue}{\left(t \cdot y\right) \cdot 4} \]
              6. Add Preprocessing

              Developer Target 1: 91.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 2024308 
              (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))))