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

Percentage Accurate: 90.3% → 94.7%
Time: 12.9s
Alternatives: 7
Speedup: 0.6×

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 7 alternatives:

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

Initial Program: 90.3% 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.7% accurate, 0.1× speedup?

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

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

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


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

    1. Initial program 96.9%

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. Step-by-step derivation
      1. cancel-sign-sub-inv96.9%

        \[\leadsto \color{blue}{x \cdot x + \left(-y \cdot 4\right) \cdot \left(z \cdot z - t\right)} \]
      2. distribute-lft-neg-out96.9%

        \[\leadsto x \cdot x + \color{blue}{\left(\left(-y\right) \cdot 4\right)} \cdot \left(z \cdot z - t\right) \]
      3. +-commutative96.9%

        \[\leadsto \color{blue}{\left(\left(-y\right) \cdot 4\right) \cdot \left(z \cdot z - t\right) + x \cdot x} \]
      4. distribute-lft-neg-out96.9%

        \[\leadsto \color{blue}{\left(-y \cdot 4\right)} \cdot \left(z \cdot z - t\right) + x \cdot x \]
      5. distribute-lft-neg-in96.9%

        \[\leadsto \color{blue}{\left(-\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\right)} + x \cdot x \]
      6. distribute-rgt-neg-in96.9%

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

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

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

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

        \[\leadsto \mathsf{fma}\left(y \cdot 4, \color{blue}{\left(-\left(-t\right)\right) + \left(-z \cdot z\right)}, x \cdot x\right) \]
      11. remove-double-neg99.4%

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

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

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

    if 9.9999999999999994e304 < (*.f64 z z)

    1. Initial program 61.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 0 57.9%

      \[\leadsto x \cdot x - \color{blue}{\left(-4 \cdot \left(t \cdot y\right) + 4 \cdot \left(y \cdot {z}^{2}\right)\right)} \]
    4. Taylor expanded in x around 0 63.0%

      \[\leadsto \color{blue}{-1 \cdot \left(-4 \cdot \left(t \cdot y\right) + 4 \cdot \left(y \cdot {z}^{2}\right)\right)} \]
    5. Step-by-step derivation
      1. +-commutative63.0%

        \[\leadsto -1 \cdot \color{blue}{\left(4 \cdot \left(y \cdot {z}^{2}\right) + -4 \cdot \left(t \cdot y\right)\right)} \]
      2. add-sqr-sqrt19.4%

        \[\leadsto -1 \cdot \left(\color{blue}{\sqrt{4 \cdot \left(y \cdot {z}^{2}\right)} \cdot \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)}} + -4 \cdot \left(t \cdot y\right)\right) \]
      3. *-commutative19.4%

        \[\leadsto -1 \cdot \left(\sqrt{4 \cdot \left(y \cdot {z}^{2}\right)} \cdot \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)} + \color{blue}{\left(t \cdot y\right) \cdot -4}\right) \]
      4. *-commutative19.4%

        \[\leadsto -1 \cdot \left(\sqrt{4 \cdot \left(y \cdot {z}^{2}\right)} \cdot \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)} + \color{blue}{\left(y \cdot t\right)} \cdot -4\right) \]
      5. associate-*r*19.4%

        \[\leadsto -1 \cdot \left(\sqrt{4 \cdot \left(y \cdot {z}^{2}\right)} \cdot \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)} + \color{blue}{y \cdot \left(t \cdot -4\right)}\right) \]
      6. fma-define19.4%

        \[\leadsto -1 \cdot \color{blue}{\mathsf{fma}\left(\sqrt{4 \cdot \left(y \cdot {z}^{2}\right)}, \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)}, y \cdot \left(t \cdot -4\right)\right)} \]
      7. sqrt-prod19.4%

        \[\leadsto -1 \cdot \mathsf{fma}\left(\color{blue}{\sqrt{4} \cdot \sqrt{y \cdot {z}^{2}}}, \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)}, y \cdot \left(t \cdot -4\right)\right) \]
      8. metadata-eval19.4%

        \[\leadsto -1 \cdot \mathsf{fma}\left(\color{blue}{2} \cdot \sqrt{y \cdot {z}^{2}}, \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)}, y \cdot \left(t \cdot -4\right)\right) \]
      9. *-commutative19.4%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \sqrt{\color{blue}{{z}^{2} \cdot y}}, \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)}, y \cdot \left(t \cdot -4\right)\right) \]
      10. sqrt-prod19.4%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \color{blue}{\left(\sqrt{{z}^{2}} \cdot \sqrt{y}\right)}, \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)}, y \cdot \left(t \cdot -4\right)\right) \]
      11. sqrt-pow110.5%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left(\color{blue}{{z}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{y}\right), \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)}, y \cdot \left(t \cdot -4\right)\right) \]
      12. metadata-eval10.5%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left({z}^{\color{blue}{1}} \cdot \sqrt{y}\right), \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)}, y \cdot \left(t \cdot -4\right)\right) \]
      13. pow110.5%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left(\color{blue}{z} \cdot \sqrt{y}\right), \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)}, y \cdot \left(t \cdot -4\right)\right) \]
      14. sqrt-prod10.5%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left(z \cdot \sqrt{y}\right), \color{blue}{\sqrt{4} \cdot \sqrt{y \cdot {z}^{2}}}, y \cdot \left(t \cdot -4\right)\right) \]
      15. metadata-eval10.5%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left(z \cdot \sqrt{y}\right), \color{blue}{2} \cdot \sqrt{y \cdot {z}^{2}}, y \cdot \left(t \cdot -4\right)\right) \]
      16. *-commutative10.5%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left(z \cdot \sqrt{y}\right), 2 \cdot \sqrt{\color{blue}{{z}^{2} \cdot y}}, y \cdot \left(t \cdot -4\right)\right) \]
      17. sqrt-prod10.5%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left(z \cdot \sqrt{y}\right), 2 \cdot \color{blue}{\left(\sqrt{{z}^{2}} \cdot \sqrt{y}\right)}, y \cdot \left(t \cdot -4\right)\right) \]
      18. sqrt-pow132.2%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left(z \cdot \sqrt{y}\right), 2 \cdot \left(\color{blue}{{z}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{y}\right), y \cdot \left(t \cdot -4\right)\right) \]
      19. metadata-eval32.2%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left(z \cdot \sqrt{y}\right), 2 \cdot \left({z}^{\color{blue}{1}} \cdot \sqrt{y}\right), y \cdot \left(t \cdot -4\right)\right) \]
      20. pow132.2%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left(z \cdot \sqrt{y}\right), 2 \cdot \left(\color{blue}{z} \cdot \sqrt{y}\right), y \cdot \left(t \cdot -4\right)\right) \]
      21. associate-*r*32.2%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left(z \cdot \sqrt{y}\right), 2 \cdot \left(z \cdot \sqrt{y}\right), \color{blue}{\left(y \cdot t\right) \cdot -4}\right) \]
    6. Applied egg-rr32.2%

      \[\leadsto -1 \cdot \color{blue}{\mathsf{fma}\left(2 \cdot \left(z \cdot \sqrt{y}\right), 2 \cdot \left(z \cdot \sqrt{y}\right), -4 \cdot \left(y \cdot t\right)\right)} \]
    7. Step-by-step derivation
      1. fma-undefine30.5%

        \[\leadsto -1 \cdot \color{blue}{\left(\left(2 \cdot \left(z \cdot \sqrt{y}\right)\right) \cdot \left(2 \cdot \left(z \cdot \sqrt{y}\right)\right) + -4 \cdot \left(y \cdot t\right)\right)} \]
      2. swap-sqr30.5%

        \[\leadsto -1 \cdot \left(\color{blue}{\left(2 \cdot 2\right) \cdot \left(\left(z \cdot \sqrt{y}\right) \cdot \left(z \cdot \sqrt{y}\right)\right)} + -4 \cdot \left(y \cdot t\right)\right) \]
      3. metadata-eval30.5%

        \[\leadsto -1 \cdot \left(\color{blue}{4} \cdot \left(\left(z \cdot \sqrt{y}\right) \cdot \left(z \cdot \sqrt{y}\right)\right) + -4 \cdot \left(y \cdot t\right)\right) \]
      4. unpow230.5%

        \[\leadsto -1 \cdot \left(4 \cdot \color{blue}{{\left(z \cdot \sqrt{y}\right)}^{2}} + -4 \cdot \left(y \cdot t\right)\right) \]
      5. associate-*r*30.5%

        \[\leadsto -1 \cdot \left(4 \cdot {\left(z \cdot \sqrt{y}\right)}^{2} + \color{blue}{\left(-4 \cdot y\right) \cdot t}\right) \]
      6. *-commutative30.5%

        \[\leadsto -1 \cdot \left(4 \cdot {\left(z \cdot \sqrt{y}\right)}^{2} + \color{blue}{\left(y \cdot -4\right)} \cdot t\right) \]
    8. Simplified30.5%

      \[\leadsto -1 \cdot \color{blue}{\left(4 \cdot {\left(z \cdot \sqrt{y}\right)}^{2} + \left(y \cdot -4\right) \cdot t\right)} \]
    9. Step-by-step derivation
      1. unpow230.5%

        \[\leadsto -1 \cdot \left(4 \cdot \color{blue}{\left(\left(z \cdot \sqrt{y}\right) \cdot \left(z \cdot \sqrt{y}\right)\right)} + \left(y \cdot -4\right) \cdot t\right) \]
      2. *-commutative30.5%

        \[\leadsto -1 \cdot \left(4 \cdot \left(\color{blue}{\left(\sqrt{y} \cdot z\right)} \cdot \left(z \cdot \sqrt{y}\right)\right) + \left(y \cdot -4\right) \cdot t\right) \]
      3. *-commutative30.5%

        \[\leadsto -1 \cdot \left(4 \cdot \left(\left(\sqrt{y} \cdot z\right) \cdot \color{blue}{\left(\sqrt{y} \cdot z\right)}\right) + \left(y \cdot -4\right) \cdot t\right) \]
      4. swap-sqr19.4%

        \[\leadsto -1 \cdot \left(4 \cdot \color{blue}{\left(\left(\sqrt{y} \cdot \sqrt{y}\right) \cdot \left(z \cdot z\right)\right)} + \left(y \cdot -4\right) \cdot t\right) \]
      5. add-sqr-sqrt63.0%

        \[\leadsto -1 \cdot \left(4 \cdot \left(\color{blue}{y} \cdot \left(z \cdot z\right)\right) + \left(y \cdot -4\right) \cdot t\right) \]
      6. associate-*r*83.1%

        \[\leadsto -1 \cdot \left(4 \cdot \color{blue}{\left(\left(y \cdot z\right) \cdot z\right)} + \left(y \cdot -4\right) \cdot t\right) \]
    10. Applied egg-rr83.1%

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

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

Alternative 2: 94.2% accurate, 0.1× speedup?

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

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

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


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

    1. Initial program 96.9%

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. Step-by-step derivation
      1. fmm-def97.4%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, -\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\right)} \]
      2. distribute-lft-neg-in97.4%

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

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

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

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

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

    if 9.9999999999999994e304 < (*.f64 z z)

    1. Initial program 61.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 0 57.9%

      \[\leadsto x \cdot x - \color{blue}{\left(-4 \cdot \left(t \cdot y\right) + 4 \cdot \left(y \cdot {z}^{2}\right)\right)} \]
    4. Taylor expanded in x around 0 63.0%

      \[\leadsto \color{blue}{-1 \cdot \left(-4 \cdot \left(t \cdot y\right) + 4 \cdot \left(y \cdot {z}^{2}\right)\right)} \]
    5. Step-by-step derivation
      1. +-commutative63.0%

        \[\leadsto -1 \cdot \color{blue}{\left(4 \cdot \left(y \cdot {z}^{2}\right) + -4 \cdot \left(t \cdot y\right)\right)} \]
      2. add-sqr-sqrt19.4%

        \[\leadsto -1 \cdot \left(\color{blue}{\sqrt{4 \cdot \left(y \cdot {z}^{2}\right)} \cdot \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)}} + -4 \cdot \left(t \cdot y\right)\right) \]
      3. *-commutative19.4%

        \[\leadsto -1 \cdot \left(\sqrt{4 \cdot \left(y \cdot {z}^{2}\right)} \cdot \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)} + \color{blue}{\left(t \cdot y\right) \cdot -4}\right) \]
      4. *-commutative19.4%

        \[\leadsto -1 \cdot \left(\sqrt{4 \cdot \left(y \cdot {z}^{2}\right)} \cdot \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)} + \color{blue}{\left(y \cdot t\right)} \cdot -4\right) \]
      5. associate-*r*19.4%

        \[\leadsto -1 \cdot \left(\sqrt{4 \cdot \left(y \cdot {z}^{2}\right)} \cdot \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)} + \color{blue}{y \cdot \left(t \cdot -4\right)}\right) \]
      6. fma-define19.4%

        \[\leadsto -1 \cdot \color{blue}{\mathsf{fma}\left(\sqrt{4 \cdot \left(y \cdot {z}^{2}\right)}, \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)}, y \cdot \left(t \cdot -4\right)\right)} \]
      7. sqrt-prod19.4%

        \[\leadsto -1 \cdot \mathsf{fma}\left(\color{blue}{\sqrt{4} \cdot \sqrt{y \cdot {z}^{2}}}, \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)}, y \cdot \left(t \cdot -4\right)\right) \]
      8. metadata-eval19.4%

        \[\leadsto -1 \cdot \mathsf{fma}\left(\color{blue}{2} \cdot \sqrt{y \cdot {z}^{2}}, \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)}, y \cdot \left(t \cdot -4\right)\right) \]
      9. *-commutative19.4%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \sqrt{\color{blue}{{z}^{2} \cdot y}}, \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)}, y \cdot \left(t \cdot -4\right)\right) \]
      10. sqrt-prod19.4%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \color{blue}{\left(\sqrt{{z}^{2}} \cdot \sqrt{y}\right)}, \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)}, y \cdot \left(t \cdot -4\right)\right) \]
      11. sqrt-pow110.5%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left(\color{blue}{{z}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{y}\right), \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)}, y \cdot \left(t \cdot -4\right)\right) \]
      12. metadata-eval10.5%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left({z}^{\color{blue}{1}} \cdot \sqrt{y}\right), \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)}, y \cdot \left(t \cdot -4\right)\right) \]
      13. pow110.5%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left(\color{blue}{z} \cdot \sqrt{y}\right), \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)}, y \cdot \left(t \cdot -4\right)\right) \]
      14. sqrt-prod10.5%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left(z \cdot \sqrt{y}\right), \color{blue}{\sqrt{4} \cdot \sqrt{y \cdot {z}^{2}}}, y \cdot \left(t \cdot -4\right)\right) \]
      15. metadata-eval10.5%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left(z \cdot \sqrt{y}\right), \color{blue}{2} \cdot \sqrt{y \cdot {z}^{2}}, y \cdot \left(t \cdot -4\right)\right) \]
      16. *-commutative10.5%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left(z \cdot \sqrt{y}\right), 2 \cdot \sqrt{\color{blue}{{z}^{2} \cdot y}}, y \cdot \left(t \cdot -4\right)\right) \]
      17. sqrt-prod10.5%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left(z \cdot \sqrt{y}\right), 2 \cdot \color{blue}{\left(\sqrt{{z}^{2}} \cdot \sqrt{y}\right)}, y \cdot \left(t \cdot -4\right)\right) \]
      18. sqrt-pow132.2%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left(z \cdot \sqrt{y}\right), 2 \cdot \left(\color{blue}{{z}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{y}\right), y \cdot \left(t \cdot -4\right)\right) \]
      19. metadata-eval32.2%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left(z \cdot \sqrt{y}\right), 2 \cdot \left({z}^{\color{blue}{1}} \cdot \sqrt{y}\right), y \cdot \left(t \cdot -4\right)\right) \]
      20. pow132.2%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left(z \cdot \sqrt{y}\right), 2 \cdot \left(\color{blue}{z} \cdot \sqrt{y}\right), y \cdot \left(t \cdot -4\right)\right) \]
      21. associate-*r*32.2%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left(z \cdot \sqrt{y}\right), 2 \cdot \left(z \cdot \sqrt{y}\right), \color{blue}{\left(y \cdot t\right) \cdot -4}\right) \]
    6. Applied egg-rr32.2%

      \[\leadsto -1 \cdot \color{blue}{\mathsf{fma}\left(2 \cdot \left(z \cdot \sqrt{y}\right), 2 \cdot \left(z \cdot \sqrt{y}\right), -4 \cdot \left(y \cdot t\right)\right)} \]
    7. Step-by-step derivation
      1. fma-undefine30.5%

        \[\leadsto -1 \cdot \color{blue}{\left(\left(2 \cdot \left(z \cdot \sqrt{y}\right)\right) \cdot \left(2 \cdot \left(z \cdot \sqrt{y}\right)\right) + -4 \cdot \left(y \cdot t\right)\right)} \]
      2. swap-sqr30.5%

        \[\leadsto -1 \cdot \left(\color{blue}{\left(2 \cdot 2\right) \cdot \left(\left(z \cdot \sqrt{y}\right) \cdot \left(z \cdot \sqrt{y}\right)\right)} + -4 \cdot \left(y \cdot t\right)\right) \]
      3. metadata-eval30.5%

        \[\leadsto -1 \cdot \left(\color{blue}{4} \cdot \left(\left(z \cdot \sqrt{y}\right) \cdot \left(z \cdot \sqrt{y}\right)\right) + -4 \cdot \left(y \cdot t\right)\right) \]
      4. unpow230.5%

        \[\leadsto -1 \cdot \left(4 \cdot \color{blue}{{\left(z \cdot \sqrt{y}\right)}^{2}} + -4 \cdot \left(y \cdot t\right)\right) \]
      5. associate-*r*30.5%

        \[\leadsto -1 \cdot \left(4 \cdot {\left(z \cdot \sqrt{y}\right)}^{2} + \color{blue}{\left(-4 \cdot y\right) \cdot t}\right) \]
      6. *-commutative30.5%

        \[\leadsto -1 \cdot \left(4 \cdot {\left(z \cdot \sqrt{y}\right)}^{2} + \color{blue}{\left(y \cdot -4\right)} \cdot t\right) \]
    8. Simplified30.5%

      \[\leadsto -1 \cdot \color{blue}{\left(4 \cdot {\left(z \cdot \sqrt{y}\right)}^{2} + \left(y \cdot -4\right) \cdot t\right)} \]
    9. Step-by-step derivation
      1. unpow230.5%

        \[\leadsto -1 \cdot \left(4 \cdot \color{blue}{\left(\left(z \cdot \sqrt{y}\right) \cdot \left(z \cdot \sqrt{y}\right)\right)} + \left(y \cdot -4\right) \cdot t\right) \]
      2. *-commutative30.5%

        \[\leadsto -1 \cdot \left(4 \cdot \left(\color{blue}{\left(\sqrt{y} \cdot z\right)} \cdot \left(z \cdot \sqrt{y}\right)\right) + \left(y \cdot -4\right) \cdot t\right) \]
      3. *-commutative30.5%

        \[\leadsto -1 \cdot \left(4 \cdot \left(\left(\sqrt{y} \cdot z\right) \cdot \color{blue}{\left(\sqrt{y} \cdot z\right)}\right) + \left(y \cdot -4\right) \cdot t\right) \]
      4. swap-sqr19.4%

        \[\leadsto -1 \cdot \left(4 \cdot \color{blue}{\left(\left(\sqrt{y} \cdot \sqrt{y}\right) \cdot \left(z \cdot z\right)\right)} + \left(y \cdot -4\right) \cdot t\right) \]
      5. add-sqr-sqrt63.0%

        \[\leadsto -1 \cdot \left(4 \cdot \left(\color{blue}{y} \cdot \left(z \cdot z\right)\right) + \left(y \cdot -4\right) \cdot t\right) \]
      6. associate-*r*83.1%

        \[\leadsto -1 \cdot \left(4 \cdot \color{blue}{\left(\left(y \cdot z\right) \cdot z\right)} + \left(y \cdot -4\right) \cdot t\right) \]
    10. Applied egg-rr83.1%

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

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

Alternative 3: 93.5% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 96.9%

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

    if 9.9999999999999994e304 < (*.f64 z z)

    1. Initial program 61.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 0 57.9%

      \[\leadsto x \cdot x - \color{blue}{\left(-4 \cdot \left(t \cdot y\right) + 4 \cdot \left(y \cdot {z}^{2}\right)\right)} \]
    4. Taylor expanded in x around 0 63.0%

      \[\leadsto \color{blue}{-1 \cdot \left(-4 \cdot \left(t \cdot y\right) + 4 \cdot \left(y \cdot {z}^{2}\right)\right)} \]
    5. Step-by-step derivation
      1. +-commutative63.0%

        \[\leadsto -1 \cdot \color{blue}{\left(4 \cdot \left(y \cdot {z}^{2}\right) + -4 \cdot \left(t \cdot y\right)\right)} \]
      2. add-sqr-sqrt19.4%

        \[\leadsto -1 \cdot \left(\color{blue}{\sqrt{4 \cdot \left(y \cdot {z}^{2}\right)} \cdot \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)}} + -4 \cdot \left(t \cdot y\right)\right) \]
      3. *-commutative19.4%

        \[\leadsto -1 \cdot \left(\sqrt{4 \cdot \left(y \cdot {z}^{2}\right)} \cdot \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)} + \color{blue}{\left(t \cdot y\right) \cdot -4}\right) \]
      4. *-commutative19.4%

        \[\leadsto -1 \cdot \left(\sqrt{4 \cdot \left(y \cdot {z}^{2}\right)} \cdot \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)} + \color{blue}{\left(y \cdot t\right)} \cdot -4\right) \]
      5. associate-*r*19.4%

        \[\leadsto -1 \cdot \left(\sqrt{4 \cdot \left(y \cdot {z}^{2}\right)} \cdot \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)} + \color{blue}{y \cdot \left(t \cdot -4\right)}\right) \]
      6. fma-define19.4%

        \[\leadsto -1 \cdot \color{blue}{\mathsf{fma}\left(\sqrt{4 \cdot \left(y \cdot {z}^{2}\right)}, \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)}, y \cdot \left(t \cdot -4\right)\right)} \]
      7. sqrt-prod19.4%

        \[\leadsto -1 \cdot \mathsf{fma}\left(\color{blue}{\sqrt{4} \cdot \sqrt{y \cdot {z}^{2}}}, \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)}, y \cdot \left(t \cdot -4\right)\right) \]
      8. metadata-eval19.4%

        \[\leadsto -1 \cdot \mathsf{fma}\left(\color{blue}{2} \cdot \sqrt{y \cdot {z}^{2}}, \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)}, y \cdot \left(t \cdot -4\right)\right) \]
      9. *-commutative19.4%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \sqrt{\color{blue}{{z}^{2} \cdot y}}, \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)}, y \cdot \left(t \cdot -4\right)\right) \]
      10. sqrt-prod19.4%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \color{blue}{\left(\sqrt{{z}^{2}} \cdot \sqrt{y}\right)}, \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)}, y \cdot \left(t \cdot -4\right)\right) \]
      11. sqrt-pow110.5%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left(\color{blue}{{z}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{y}\right), \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)}, y \cdot \left(t \cdot -4\right)\right) \]
      12. metadata-eval10.5%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left({z}^{\color{blue}{1}} \cdot \sqrt{y}\right), \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)}, y \cdot \left(t \cdot -4\right)\right) \]
      13. pow110.5%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left(\color{blue}{z} \cdot \sqrt{y}\right), \sqrt{4 \cdot \left(y \cdot {z}^{2}\right)}, y \cdot \left(t \cdot -4\right)\right) \]
      14. sqrt-prod10.5%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left(z \cdot \sqrt{y}\right), \color{blue}{\sqrt{4} \cdot \sqrt{y \cdot {z}^{2}}}, y \cdot \left(t \cdot -4\right)\right) \]
      15. metadata-eval10.5%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left(z \cdot \sqrt{y}\right), \color{blue}{2} \cdot \sqrt{y \cdot {z}^{2}}, y \cdot \left(t \cdot -4\right)\right) \]
      16. *-commutative10.5%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left(z \cdot \sqrt{y}\right), 2 \cdot \sqrt{\color{blue}{{z}^{2} \cdot y}}, y \cdot \left(t \cdot -4\right)\right) \]
      17. sqrt-prod10.5%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left(z \cdot \sqrt{y}\right), 2 \cdot \color{blue}{\left(\sqrt{{z}^{2}} \cdot \sqrt{y}\right)}, y \cdot \left(t \cdot -4\right)\right) \]
      18. sqrt-pow132.2%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left(z \cdot \sqrt{y}\right), 2 \cdot \left(\color{blue}{{z}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{y}\right), y \cdot \left(t \cdot -4\right)\right) \]
      19. metadata-eval32.2%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left(z \cdot \sqrt{y}\right), 2 \cdot \left({z}^{\color{blue}{1}} \cdot \sqrt{y}\right), y \cdot \left(t \cdot -4\right)\right) \]
      20. pow132.2%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left(z \cdot \sqrt{y}\right), 2 \cdot \left(\color{blue}{z} \cdot \sqrt{y}\right), y \cdot \left(t \cdot -4\right)\right) \]
      21. associate-*r*32.2%

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left(z \cdot \sqrt{y}\right), 2 \cdot \left(z \cdot \sqrt{y}\right), \color{blue}{\left(y \cdot t\right) \cdot -4}\right) \]
    6. Applied egg-rr32.2%

      \[\leadsto -1 \cdot \color{blue}{\mathsf{fma}\left(2 \cdot \left(z \cdot \sqrt{y}\right), 2 \cdot \left(z \cdot \sqrt{y}\right), -4 \cdot \left(y \cdot t\right)\right)} \]
    7. Step-by-step derivation
      1. fma-undefine30.5%

        \[\leadsto -1 \cdot \color{blue}{\left(\left(2 \cdot \left(z \cdot \sqrt{y}\right)\right) \cdot \left(2 \cdot \left(z \cdot \sqrt{y}\right)\right) + -4 \cdot \left(y \cdot t\right)\right)} \]
      2. swap-sqr30.5%

        \[\leadsto -1 \cdot \left(\color{blue}{\left(2 \cdot 2\right) \cdot \left(\left(z \cdot \sqrt{y}\right) \cdot \left(z \cdot \sqrt{y}\right)\right)} + -4 \cdot \left(y \cdot t\right)\right) \]
      3. metadata-eval30.5%

        \[\leadsto -1 \cdot \left(\color{blue}{4} \cdot \left(\left(z \cdot \sqrt{y}\right) \cdot \left(z \cdot \sqrt{y}\right)\right) + -4 \cdot \left(y \cdot t\right)\right) \]
      4. unpow230.5%

        \[\leadsto -1 \cdot \left(4 \cdot \color{blue}{{\left(z \cdot \sqrt{y}\right)}^{2}} + -4 \cdot \left(y \cdot t\right)\right) \]
      5. associate-*r*30.5%

        \[\leadsto -1 \cdot \left(4 \cdot {\left(z \cdot \sqrt{y}\right)}^{2} + \color{blue}{\left(-4 \cdot y\right) \cdot t}\right) \]
      6. *-commutative30.5%

        \[\leadsto -1 \cdot \left(4 \cdot {\left(z \cdot \sqrt{y}\right)}^{2} + \color{blue}{\left(y \cdot -4\right)} \cdot t\right) \]
    8. Simplified30.5%

      \[\leadsto -1 \cdot \color{blue}{\left(4 \cdot {\left(z \cdot \sqrt{y}\right)}^{2} + \left(y \cdot -4\right) \cdot t\right)} \]
    9. Step-by-step derivation
      1. unpow230.5%

        \[\leadsto -1 \cdot \left(4 \cdot \color{blue}{\left(\left(z \cdot \sqrt{y}\right) \cdot \left(z \cdot \sqrt{y}\right)\right)} + \left(y \cdot -4\right) \cdot t\right) \]
      2. *-commutative30.5%

        \[\leadsto -1 \cdot \left(4 \cdot \left(\color{blue}{\left(\sqrt{y} \cdot z\right)} \cdot \left(z \cdot \sqrt{y}\right)\right) + \left(y \cdot -4\right) \cdot t\right) \]
      3. *-commutative30.5%

        \[\leadsto -1 \cdot \left(4 \cdot \left(\left(\sqrt{y} \cdot z\right) \cdot \color{blue}{\left(\sqrt{y} \cdot z\right)}\right) + \left(y \cdot -4\right) \cdot t\right) \]
      4. swap-sqr19.4%

        \[\leadsto -1 \cdot \left(4 \cdot \color{blue}{\left(\left(\sqrt{y} \cdot \sqrt{y}\right) \cdot \left(z \cdot z\right)\right)} + \left(y \cdot -4\right) \cdot t\right) \]
      5. add-sqr-sqrt63.0%

        \[\leadsto -1 \cdot \left(4 \cdot \left(\color{blue}{y} \cdot \left(z \cdot z\right)\right) + \left(y \cdot -4\right) \cdot t\right) \]
      6. associate-*r*83.1%

        \[\leadsto -1 \cdot \left(4 \cdot \color{blue}{\left(\left(y \cdot z\right) \cdot z\right)} + \left(y \cdot -4\right) \cdot t\right) \]
    10. Applied egg-rr83.1%

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

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

Alternative 4: 93.1% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot x \leq 1.16 \cdot 10^{+305}:\\ \;\;\;\;x \cdot x + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= (* x x) 1.16e+305) (+ (* x x) (* (* y 4.0) (- t (* z z)))) (* x x)))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((x * x) <= 1.16e+305) {
		tmp = (x * x) + ((y * 4.0) * (t - (z * z)));
	} else {
		tmp = x * x;
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((x * x) <= 1.16d+305) then
        tmp = (x * x) + ((y * 4.0d0) * (t - (z * z)))
    else
        tmp = x * x
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((x * x) <= 1.16e+305) {
		tmp = (x * x) + ((y * 4.0) * (t - (z * z)));
	} else {
		tmp = x * x;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (x * x) <= 1.16e+305:
		tmp = (x * x) + ((y * 4.0) * (t - (z * z)))
	else:
		tmp = x * x
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (Float64(x * x) <= 1.16e+305)
		tmp = Float64(Float64(x * x) + Float64(Float64(y * 4.0) * Float64(t - Float64(z * z))));
	else
		tmp = Float64(x * x);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((x * x) <= 1.16e+305)
		tmp = (x * x) + ((y * 4.0) * (t - (z * z)));
	else
		tmp = x * x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[N[(x * x), $MachinePrecision], 1.16e+305], N[(N[(x * x), $MachinePrecision] + N[(N[(y * 4.0), $MachinePrecision] * N[(t - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;x \cdot x\\


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

    1. Initial program 92.8%

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

    if 1.1600000000000001e305 < (*.f64 x x)

    1. Initial program 75.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 75.6%

      \[\leadsto x \cdot x - \color{blue}{4 \cdot \left(y \cdot \left({z}^{2} - t\right)\right)} \]
    4. Simplified93.4%

      \[\leadsto x \cdot x - \color{blue}{0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification92.9%

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

Alternative 5: 45.2% accurate, 1.3× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;x \cdot x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.02e-14

    1. Initial program 90.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 42.3%

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

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

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

    if 1.02e-14 < x

    1. Initial program 83.7%

      \[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 83.7%

      \[\leadsto x \cdot x - \color{blue}{4 \cdot \left(y \cdot \left({z}^{2} - t\right)\right)} \]
    4. Simplified71.6%

      \[\leadsto x \cdot x - \color{blue}{0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification50.5%

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

Alternative 6: 66.8% accurate, 1.4× speedup?

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

\\
x \cdot x - y \cdot \left(t \cdot -4\right)
\end{array}
Derivation
  1. Initial program 88.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 69.5%

    \[\leadsto x \cdot x - \color{blue}{-4 \cdot \left(t \cdot y\right)} \]
  4. Step-by-step derivation
    1. *-commutative69.5%

      \[\leadsto x \cdot x - \color{blue}{\left(t \cdot y\right) \cdot -4} \]
    2. *-commutative69.5%

      \[\leadsto x \cdot x - \color{blue}{\left(y \cdot t\right)} \cdot -4 \]
    3. associate-*l*69.5%

      \[\leadsto x \cdot x - \color{blue}{y \cdot \left(t \cdot -4\right)} \]
  5. Simplified69.5%

    \[\leadsto x \cdot x - \color{blue}{y \cdot \left(t \cdot -4\right)} \]
  6. Final simplification69.5%

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

Alternative 7: 31.6% accurate, 2.6× speedup?

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

\\
4 \cdot \left(y \cdot t\right)
\end{array}
Derivation
  1. Initial program 88.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 34.5%

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

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

    \[\leadsto \color{blue}{4 \cdot \left(y \cdot t\right)} \]
  6. Final simplification34.5%

    \[\leadsto 4 \cdot \left(y \cdot t\right) \]
  7. Add Preprocessing

Developer target: 90.3% 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 2024095 
(FPCore (x y z t)
  :name "Graphics.Rasterific.Shading:$sradialGradientWithFocusShader from Rasterific-0.6.1, B"
  :precision binary64

  :alt
  (- (* x x) (* 4.0 (* y (- (* z z) t))))

  (- (* x x) (* (* y 4.0) (- (* z z) t))))