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

Percentage Accurate: 91.0% → 98.0%
Time: 8.7s
Alternatives: 8
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 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.0% 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: 98.0% accurate, 0.3× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x x) < 5e51

    1. Initial program 94.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. +-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 rewrites99.9%

      \[\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 5e51 < (*.f64 x x)

    1. Initial program 87.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. +-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 rewrites90.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)} \]
    5. Taylor expanded in x around inf

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

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

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

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

        \[\leadsto \color{blue}{\left(\left(1 + \left(-4 \cdot \frac{y \cdot {z}^{2}}{{x}^{2}} + 4 \cdot \frac{t \cdot y}{{x}^{2}}\right)\right) \cdot x\right) \cdot x} \]
    7. Applied rewrites95.6%

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

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

Alternative 2: 84.1% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_1 := \left(4 \cdot y\right) \cdot \left(z \cdot z - t\right)\\
t_2 := \mathsf{fma}\left(z \cdot y, z, \left(-t\right) \cdot y\right) \cdot -4\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+243}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+273}:\\
\;\;\;\;\mathsf{fma}\left(t \cdot y, 4, x \cdot x\right)\\

\mathbf{else}:\\
\;\;\;\;t\_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (*.f64 y #s(literal 4 binary64)) (-.f64 (*.f64 z z) t)) < -2.0000000000000001e243 or 4.99999999999999961e273 < (*.f64 (*.f64 y #s(literal 4 binary64)) (-.f64 (*.f64 z z) t))

    1. Initial program 79.1%

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

      \[\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. sub-negN/A

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

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

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

        \[\leadsto \left(\color{blue}{\mathsf{fma}\left(z, z, -1 \cdot t\right)} \cdot y\right) \cdot -4 \]
      9. mul-1-negN/A

        \[\leadsto \left(\mathsf{fma}\left(z, z, \color{blue}{\mathsf{neg}\left(t\right)}\right) \cdot y\right) \cdot -4 \]
      10. lower-neg.f6484.1

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

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(z, z, -t\right) \cdot y\right) \cdot -4} \]
    6. Step-by-step derivation
      1. Applied rewrites90.3%

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

      if -2.0000000000000001e243 < (*.f64 (*.f64 y #s(literal 4 binary64)) (-.f64 (*.f64 z z) t)) < 4.99999999999999961e273

      1. Initial program 99.9%

        \[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)} \]
    7. Recombined 2 regimes into one program.
    8. Final simplification88.7%

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

    Alternative 3: 63.6% accurate, 0.6× speedup?

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

      1. Initial program 94.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 4 \cdot \color{blue}{\left(y \cdot t\right)} \]
        2. associate-*r*N/A

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

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

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

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

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

      if -4.9999999999999999e-17 < (-.f64 (*.f64 z z) t) < 2.0000000000000001e149

      1. Initial program 99.9%

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

        \[\leadsto \color{blue}{{x}^{2}} \]
      4. Step-by-step derivation
        1. unpow2N/A

          \[\leadsto \color{blue}{x \cdot x} \]
        2. lower-*.f6470.8

          \[\leadsto \color{blue}{x \cdot x} \]
      5. Applied rewrites70.8%

        \[\leadsto \color{blue}{x \cdot x} \]

      if 2.0000000000000001e149 < (-.f64 (*.f64 z z) t)

      1. Initial program 81.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. lower-*.f64N/A

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

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

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

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

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

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

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

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

      Alternative 4: 60.6% accurate, 0.6× speedup?

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

        1. Initial program 94.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 4 \cdot \color{blue}{\left(y \cdot t\right)} \]
          2. associate-*r*N/A

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

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

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

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

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

        if -4.9999999999999999e-17 < (-.f64 (*.f64 z z) t) < 2.0000000000000001e149

        1. Initial program 99.9%

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

          \[\leadsto \color{blue}{{x}^{2}} \]
        4. Step-by-step derivation
          1. unpow2N/A

            \[\leadsto \color{blue}{x \cdot x} \]
          2. lower-*.f6470.8

            \[\leadsto \color{blue}{x \cdot x} \]
        5. Applied rewrites70.8%

          \[\leadsto \color{blue}{x \cdot x} \]

        if 2.0000000000000001e149 < (-.f64 (*.f64 z z) t)

        1. Initial program 81.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. lower-*.f64N/A

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

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

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

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

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

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

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

      Alternative 5: 92.9% accurate, 0.7× speedup?

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

        1. Initial program 91.6%

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

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

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

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

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

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

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

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

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

        if +inf.0 < (*.f64 z z)

        1. Initial program 91.6%

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

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

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

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

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

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

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

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

        Alternative 6: 84.8% accurate, 1.0× speedup?

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

          1. Initial program 97.6%

            \[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-*.f6488.2

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

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

          if 4.99999999999999961e133 < (*.f64 z z)

          1. Initial program 80.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. lower-*.f64N/A

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

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

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

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

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

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

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

          Alternative 7: 46.0% accurate, 1.6× speedup?

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

            1. Initial program 92.7%

              \[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 4 \cdot \color{blue}{\left(y \cdot t\right)} \]
              2. associate-*r*N/A

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

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

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

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

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

            if 1.1600000000000001e-5 < x

            1. Initial program 88.9%

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

              \[\leadsto \color{blue}{{x}^{2}} \]
            4. Step-by-step derivation
              1. unpow2N/A

                \[\leadsto \color{blue}{x \cdot x} \]
              2. lower-*.f6469.6

                \[\leadsto \color{blue}{x \cdot x} \]
            5. Applied rewrites69.6%

              \[\leadsto \color{blue}{x \cdot x} \]
          3. Recombined 2 regimes into one program.
          4. Final simplification47.6%

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

          Alternative 8: 40.9% accurate, 4.5× speedup?

          \[\begin{array}{l} \\ x \cdot x \end{array} \]
          (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}
          
          Derivation
          1. Initial program 91.6%

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

            \[\leadsto \color{blue}{{x}^{2}} \]
          4. Step-by-step derivation
            1. unpow2N/A

              \[\leadsto \color{blue}{x \cdot x} \]
            2. lower-*.f6445.3

              \[\leadsto \color{blue}{x \cdot x} \]
          5. Applied rewrites45.3%

            \[\leadsto \color{blue}{x \cdot x} \]
          6. Add Preprocessing

          Developer Target 1: 91.0% 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 2024256 
          (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))))