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

Percentage Accurate: 90.5% → 96.0%
Time: 11.7s
Alternatives: 8
Speedup: 0.8×

Specification

?
\[\begin{array}{l} \\ x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \end{array} \]
(FPCore (x y z t) :precision binary64 (- (* x x) (* (* y 4.0) (- (* z z) t))))
double code(double x, double y, double z, double t) {
	return (x * x) - ((y * 4.0) * ((z * z) - t));
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = (x * x) - ((y * 4.0d0) * ((z * z) - t))
end function
public static double code(double x, double y, double z, double t) {
	return (x * x) - ((y * 4.0) * ((z * z) - t));
}
def code(x, y, z, t):
	return (x * x) - ((y * 4.0) * ((z * z) - t))
function code(x, y, z, t)
	return Float64(Float64(x * x) - Float64(Float64(y * 4.0) * Float64(Float64(z * z) - t)))
end
function tmp = code(x, y, z, t)
	tmp = (x * x) - ((y * 4.0) * ((z * z) - t));
end
code[x_, y_, z_, t_] := N[(N[(x * x), $MachinePrecision] - N[(N[(y * 4.0), $MachinePrecision] * N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 8 alternatives:

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

Initial Program: 90.5% accurate, 1.0× speedup?

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

\\
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\end{array}

Alternative 1: 96.0% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 98.3%

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]

    if 2.0000000000000002e252 < (*.f64 z z)

    1. Initial program 79.9%

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

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

        \[\leadsto x \cdot x - \color{blue}{\frac{\left(y \cdot 4\right) \cdot \left({\left(z \cdot z\right)}^{3} - {t}^{3}\right)}{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)}} \]
      3. add-sqr-sqrt0.0%

        \[\leadsto x \cdot x - \frac{\color{blue}{\left(\sqrt{y \cdot 4} \cdot \sqrt{y \cdot 4}\right)} \cdot \left({\left(z \cdot z\right)}^{3} - {t}^{3}\right)}{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)} \]
      4. sqrt-unprod0.0%

        \[\leadsto x \cdot x - \frac{\color{blue}{\sqrt{\left(y \cdot 4\right) \cdot \left(y \cdot 4\right)}} \cdot \left({\left(z \cdot z\right)}^{3} - {t}^{3}\right)}{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)} \]
      5. swap-sqr0.0%

        \[\leadsto x \cdot x - \frac{\sqrt{\color{blue}{\left(y \cdot y\right) \cdot \left(4 \cdot 4\right)}} \cdot \left({\left(z \cdot z\right)}^{3} - {t}^{3}\right)}{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)} \]
      6. metadata-eval0.0%

        \[\leadsto x \cdot x - \frac{\sqrt{\left(y \cdot y\right) \cdot \color{blue}{16}} \cdot \left({\left(z \cdot z\right)}^{3} - {t}^{3}\right)}{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)} \]
      7. metadata-eval0.0%

        \[\leadsto x \cdot x - \frac{\sqrt{\left(y \cdot y\right) \cdot \color{blue}{\left(-4 \cdot -4\right)}} \cdot \left({\left(z \cdot z\right)}^{3} - {t}^{3}\right)}{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)} \]
      8. swap-sqr0.0%

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

        \[\leadsto x \cdot x - \frac{\color{blue}{\left(\sqrt{y \cdot -4} \cdot \sqrt{y \cdot -4}\right)} \cdot \left({\left(z \cdot z\right)}^{3} - {t}^{3}\right)}{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)} \]
      10. add-sqr-sqrt0.0%

        \[\leadsto x \cdot x - \frac{\color{blue}{\left(y \cdot -4\right)} \cdot \left({\left(z \cdot z\right)}^{3} - {t}^{3}\right)}{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)} \]
      11. associate-/l*0.0%

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

      \[\leadsto x \cdot x - \color{blue}{\frac{y \cdot 4}{\frac{1}{{z}^{2} - t}}} \]
    4. Taylor expanded in z around inf 79.9%

      \[\leadsto x \cdot x - \frac{y \cdot 4}{\color{blue}{\frac{1}{{z}^{2}}}} \]
    5. Step-by-step derivation
      1. div-inv79.9%

        \[\leadsto x \cdot x - \color{blue}{\left(y \cdot 4\right) \cdot \frac{1}{\frac{1}{{z}^{2}}}} \]
      2. remove-double-div79.9%

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

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

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

        \[\leadsto x \cdot x - \color{blue}{z \cdot \left(\left(y \cdot 4\right) \cdot z\right)} \]
      6. associate-*l*90.3%

        \[\leadsto x \cdot x - z \cdot \color{blue}{\left(y \cdot \left(4 \cdot z\right)\right)} \]
      7. associate-*r*90.3%

        \[\leadsto x \cdot x - \color{blue}{\left(z \cdot y\right) \cdot \left(4 \cdot z\right)} \]
    6. Applied egg-rr90.3%

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

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

Alternative 2: 92.7% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(x, x, \left(z \cdot z - t\right) \cdot \left(y \cdot -4\right)\right) \end{array} \]
(FPCore (x y z t) :precision binary64 (fma x x (* (- (* z z) t) (* y -4.0))))
double code(double x, double y, double z, double t) {
	return fma(x, x, (((z * z) - t) * (y * -4.0)));
}
function code(x, y, z, t)
	return fma(x, x, Float64(Float64(Float64(z * z) - t) * Float64(y * -4.0)))
end
code[x_, y_, z_, t_] := N[(x * x + N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(x, x, \left(z \cdot z - t\right) \cdot \left(y \cdot -4\right)\right)
\end{array}
Derivation
  1. Initial program 93.0%

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

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

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

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

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

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

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

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

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

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

Alternative 3: 74.3% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 8.00000000000000053e-37

    1. Initial program 94.4%

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

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

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

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

    if 8.00000000000000053e-37 < z

    1. Initial program 89.7%

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

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

        \[\leadsto x \cdot x - \color{blue}{\frac{\left(y \cdot 4\right) \cdot \left({\left(z \cdot z\right)}^{3} - {t}^{3}\right)}{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)}} \]
      3. add-sqr-sqrt6.7%

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

        \[\leadsto x \cdot x - \frac{\color{blue}{\sqrt{\left(y \cdot 4\right) \cdot \left(y \cdot 4\right)}} \cdot \left({\left(z \cdot z\right)}^{3} - {t}^{3}\right)}{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)} \]
      5. swap-sqr10.9%

        \[\leadsto x \cdot x - \frac{\sqrt{\color{blue}{\left(y \cdot y\right) \cdot \left(4 \cdot 4\right)}} \cdot \left({\left(z \cdot z\right)}^{3} - {t}^{3}\right)}{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)} \]
      6. metadata-eval10.9%

        \[\leadsto x \cdot x - \frac{\sqrt{\left(y \cdot y\right) \cdot \color{blue}{16}} \cdot \left({\left(z \cdot z\right)}^{3} - {t}^{3}\right)}{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)} \]
      7. metadata-eval10.9%

        \[\leadsto x \cdot x - \frac{\sqrt{\left(y \cdot y\right) \cdot \color{blue}{\left(-4 \cdot -4\right)}} \cdot \left({\left(z \cdot z\right)}^{3} - {t}^{3}\right)}{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)} \]
      8. swap-sqr10.9%

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

        \[\leadsto x \cdot x - \frac{\color{blue}{\left(\sqrt{y \cdot -4} \cdot \sqrt{y \cdot -4}\right)} \cdot \left({\left(z \cdot z\right)}^{3} - {t}^{3}\right)}{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)} \]
      10. add-sqr-sqrt10.7%

        \[\leadsto x \cdot x - \frac{\color{blue}{\left(y \cdot -4\right)} \cdot \left({\left(z \cdot z\right)}^{3} - {t}^{3}\right)}{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)} \]
      11. associate-/l*10.7%

        \[\leadsto x \cdot x - \color{blue}{\frac{y \cdot -4}{\frac{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)}{{\left(z \cdot z\right)}^{3} - {t}^{3}}}} \]
    3. Applied egg-rr89.7%

      \[\leadsto x \cdot x - \color{blue}{\frac{y \cdot 4}{\frac{1}{{z}^{2} - t}}} \]
    4. Taylor expanded in z around inf 85.6%

      \[\leadsto x \cdot x - \frac{y \cdot 4}{\color{blue}{\frac{1}{{z}^{2}}}} \]
    5. Step-by-step derivation
      1. div-inv85.5%

        \[\leadsto x \cdot x - \color{blue}{\left(y \cdot 4\right) \cdot \frac{1}{\frac{1}{{z}^{2}}}} \]
      2. remove-double-div85.6%

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

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

        \[\leadsto x \cdot x - \color{blue}{\left(\left(y \cdot 4\right) \cdot z\right) \cdot z} \]
      5. associate-*l*93.1%

        \[\leadsto x \cdot x - \color{blue}{\left(y \cdot \left(4 \cdot z\right)\right)} \cdot z \]
      6. associate-*l*85.6%

        \[\leadsto x \cdot x - \color{blue}{y \cdot \left(\left(4 \cdot z\right) \cdot z\right)} \]
    6. Applied egg-rr85.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 8 \cdot 10^{-37}:\\ \;\;\;\;x \cdot x - -4 \cdot \left(t \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x - y \cdot \left(z \cdot \left(z \cdot 4\right)\right)\\ \end{array} \]

Alternative 4: 77.2% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 8.00000000000000053e-37

    1. Initial program 94.4%

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

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

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

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

    if 8.00000000000000053e-37 < z

    1. Initial program 89.7%

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

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

        \[\leadsto x \cdot x - \color{blue}{\frac{\left(y \cdot 4\right) \cdot \left({\left(z \cdot z\right)}^{3} - {t}^{3}\right)}{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)}} \]
      3. add-sqr-sqrt6.7%

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

        \[\leadsto x \cdot x - \frac{\color{blue}{\sqrt{\left(y \cdot 4\right) \cdot \left(y \cdot 4\right)}} \cdot \left({\left(z \cdot z\right)}^{3} - {t}^{3}\right)}{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)} \]
      5. swap-sqr10.9%

        \[\leadsto x \cdot x - \frac{\sqrt{\color{blue}{\left(y \cdot y\right) \cdot \left(4 \cdot 4\right)}} \cdot \left({\left(z \cdot z\right)}^{3} - {t}^{3}\right)}{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)} \]
      6. metadata-eval10.9%

        \[\leadsto x \cdot x - \frac{\sqrt{\left(y \cdot y\right) \cdot \color{blue}{16}} \cdot \left({\left(z \cdot z\right)}^{3} - {t}^{3}\right)}{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)} \]
      7. metadata-eval10.9%

        \[\leadsto x \cdot x - \frac{\sqrt{\left(y \cdot y\right) \cdot \color{blue}{\left(-4 \cdot -4\right)}} \cdot \left({\left(z \cdot z\right)}^{3} - {t}^{3}\right)}{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)} \]
      8. swap-sqr10.9%

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

        \[\leadsto x \cdot x - \frac{\color{blue}{\left(\sqrt{y \cdot -4} \cdot \sqrt{y \cdot -4}\right)} \cdot \left({\left(z \cdot z\right)}^{3} - {t}^{3}\right)}{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)} \]
      10. add-sqr-sqrt10.7%

        \[\leadsto x \cdot x - \frac{\color{blue}{\left(y \cdot -4\right)} \cdot \left({\left(z \cdot z\right)}^{3} - {t}^{3}\right)}{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)} \]
      11. associate-/l*10.7%

        \[\leadsto x \cdot x - \color{blue}{\frac{y \cdot -4}{\frac{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)}{{\left(z \cdot z\right)}^{3} - {t}^{3}}}} \]
    3. Applied egg-rr89.7%

      \[\leadsto x \cdot x - \color{blue}{\frac{y \cdot 4}{\frac{1}{{z}^{2} - t}}} \]
    4. Taylor expanded in z around inf 85.6%

      \[\leadsto x \cdot x - \frac{y \cdot 4}{\color{blue}{\frac{1}{{z}^{2}}}} \]
    5. Step-by-step derivation
      1. div-inv85.5%

        \[\leadsto x \cdot x - \color{blue}{\left(y \cdot 4\right) \cdot \frac{1}{\frac{1}{{z}^{2}}}} \]
      2. remove-double-div85.6%

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

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

        \[\leadsto x \cdot x - \color{blue}{\left(\left(y \cdot 4\right) \cdot z\right) \cdot z} \]
      5. *-commutative93.1%

        \[\leadsto x \cdot x - \color{blue}{z \cdot \left(\left(y \cdot 4\right) \cdot z\right)} \]
      6. associate-*l*93.1%

        \[\leadsto x \cdot x - z \cdot \color{blue}{\left(y \cdot \left(4 \cdot z\right)\right)} \]
      7. associate-*r*93.1%

        \[\leadsto x \cdot x - \color{blue}{\left(z \cdot y\right) \cdot \left(4 \cdot z\right)} \]
    6. Applied egg-rr93.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 8 \cdot 10^{-37}:\\ \;\;\;\;x \cdot x - -4 \cdot \left(t \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x - \left(z \cdot y\right) \cdot \left(z \cdot 4\right)\\ \end{array} \]

Alternative 5: 65.8% accurate, 1.2× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 1.89999999999999989e102

    1. Initial program 95.2%

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

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

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

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

    if 1.89999999999999989e102 < z

    1. Initial program 82.7%

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

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

        \[\leadsto x \cdot x - \color{blue}{\frac{\left(y \cdot 4\right) \cdot \left({\left(z \cdot z\right)}^{3} - {t}^{3}\right)}{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)}} \]
      3. add-sqr-sqrt0.0%

        \[\leadsto x \cdot x - \frac{\color{blue}{\left(\sqrt{y \cdot 4} \cdot \sqrt{y \cdot 4}\right)} \cdot \left({\left(z \cdot z\right)}^{3} - {t}^{3}\right)}{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)} \]
      4. sqrt-unprod0.0%

        \[\leadsto x \cdot x - \frac{\color{blue}{\sqrt{\left(y \cdot 4\right) \cdot \left(y \cdot 4\right)}} \cdot \left({\left(z \cdot z\right)}^{3} - {t}^{3}\right)}{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)} \]
      5. swap-sqr0.0%

        \[\leadsto x \cdot x - \frac{\sqrt{\color{blue}{\left(y \cdot y\right) \cdot \left(4 \cdot 4\right)}} \cdot \left({\left(z \cdot z\right)}^{3} - {t}^{3}\right)}{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)} \]
      6. metadata-eval0.0%

        \[\leadsto x \cdot x - \frac{\sqrt{\left(y \cdot y\right) \cdot \color{blue}{16}} \cdot \left({\left(z \cdot z\right)}^{3} - {t}^{3}\right)}{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)} \]
      7. metadata-eval0.0%

        \[\leadsto x \cdot x - \frac{\sqrt{\left(y \cdot y\right) \cdot \color{blue}{\left(-4 \cdot -4\right)}} \cdot \left({\left(z \cdot z\right)}^{3} - {t}^{3}\right)}{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)} \]
      8. swap-sqr0.0%

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

        \[\leadsto x \cdot x - \frac{\color{blue}{\left(\sqrt{y \cdot -4} \cdot \sqrt{y \cdot -4}\right)} \cdot \left({\left(z \cdot z\right)}^{3} - {t}^{3}\right)}{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)} \]
      10. add-sqr-sqrt0.0%

        \[\leadsto x \cdot x - \frac{\color{blue}{\left(y \cdot -4\right)} \cdot \left({\left(z \cdot z\right)}^{3} - {t}^{3}\right)}{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)} \]
      11. associate-/l*0.0%

        \[\leadsto x \cdot x - \color{blue}{\frac{y \cdot -4}{\frac{\left(z \cdot z\right) \cdot \left(z \cdot z\right) + \left(t \cdot t + \left(z \cdot z\right) \cdot t\right)}{{\left(z \cdot z\right)}^{3} - {t}^{3}}}} \]
    3. Applied egg-rr82.8%

      \[\leadsto x \cdot x - \color{blue}{\frac{y \cdot 4}{\frac{1}{{z}^{2} - t}}} \]
    4. Taylor expanded in z around 0 16.5%

      \[\leadsto x \cdot x - \frac{y \cdot 4}{\color{blue}{\frac{-1}{t}}} \]
    5. Step-by-step derivation
      1. clear-num16.5%

        \[\leadsto x \cdot x - \color{blue}{\frac{1}{\frac{\frac{-1}{t}}{y \cdot 4}}} \]
      2. metadata-eval16.5%

        \[\leadsto x \cdot x - \frac{\color{blue}{\frac{2}{2}}}{\frac{\frac{-1}{t}}{y \cdot 4}} \]
      3. associate-/r/16.5%

        \[\leadsto x \cdot x - \color{blue}{\frac{\frac{2}{2}}{\frac{-1}{t}} \cdot \left(y \cdot 4\right)} \]
      4. associate-/r/16.5%

        \[\leadsto x \cdot x - \color{blue}{\left(\frac{\frac{2}{2}}{-1} \cdot t\right)} \cdot \left(y \cdot 4\right) \]
      5. metadata-eval16.5%

        \[\leadsto x \cdot x - \left(\frac{\color{blue}{1}}{-1} \cdot t\right) \cdot \left(y \cdot 4\right) \]
      6. metadata-eval16.5%

        \[\leadsto x \cdot x - \left(\color{blue}{-1} \cdot t\right) \cdot \left(y \cdot 4\right) \]
      7. neg-mul-116.5%

        \[\leadsto x \cdot x - \color{blue}{\left(-t\right)} \cdot \left(y \cdot 4\right) \]
      8. add-sqr-sqrt9.1%

        \[\leadsto x \cdot x - \color{blue}{\left(\sqrt{-t} \cdot \sqrt{-t}\right)} \cdot \left(y \cdot 4\right) \]
      9. sqrt-unprod25.0%

        \[\leadsto x \cdot x - \color{blue}{\sqrt{\left(-t\right) \cdot \left(-t\right)}} \cdot \left(y \cdot 4\right) \]
      10. sqr-neg25.0%

        \[\leadsto x \cdot x - \sqrt{\color{blue}{t \cdot t}} \cdot \left(y \cdot 4\right) \]
      11. sqrt-unprod12.6%

        \[\leadsto x \cdot x - \color{blue}{\left(\sqrt{t} \cdot \sqrt{t}\right)} \cdot \left(y \cdot 4\right) \]
      12. add-sqr-sqrt15.5%

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

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

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

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

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

Alternative 6: 66.0% accurate, 1.4× speedup?

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

\\
x \cdot x - -4 \cdot \left(t \cdot y\right)
\end{array}
Derivation
  1. Initial program 93.0%

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

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

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

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

    \[\leadsto x \cdot x - -4 \cdot \left(t \cdot y\right) \]

Alternative 7: 31.1% accurate, 1.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 1.89999999999999989e102

    1. Initial program 95.2%

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

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

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

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

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

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

    if 1.89999999999999989e102 < z

    1. Initial program 82.7%

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

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

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

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

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

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

        \[\leadsto \color{blue}{t \cdot \left(y \cdot 4\right)} \]
      3. add-sqr-sqrt0.6%

        \[\leadsto \color{blue}{\left(\sqrt{t} \cdot \sqrt{t}\right)} \cdot \left(y \cdot 4\right) \]
      4. sqrt-unprod3.3%

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

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

        \[\leadsto \color{blue}{\left(\sqrt{-t} \cdot \sqrt{-t}\right)} \cdot \left(y \cdot 4\right) \]
      7. add-sqr-sqrt6.5%

        \[\leadsto \color{blue}{\left(-t\right)} \cdot \left(y \cdot 4\right) \]
      8. neg-mul-16.5%

        \[\leadsto \color{blue}{\left(-1 \cdot t\right)} \cdot \left(y \cdot 4\right) \]
      9. metadata-eval6.5%

        \[\leadsto \left(\color{blue}{\frac{1}{-1}} \cdot t\right) \cdot \left(y \cdot 4\right) \]
      10. metadata-eval6.5%

        \[\leadsto \left(\frac{\color{blue}{\frac{2}{2}}}{-1} \cdot t\right) \cdot \left(y \cdot 4\right) \]
      11. associate-/r/6.5%

        \[\leadsto \color{blue}{\frac{\frac{2}{2}}{\frac{-1}{t}}} \cdot \left(y \cdot 4\right) \]
      12. associate-/r/6.5%

        \[\leadsto \color{blue}{\frac{\frac{2}{2}}{\frac{\frac{-1}{t}}{y \cdot 4}}} \]
      13. metadata-eval6.5%

        \[\leadsto \frac{\color{blue}{1}}{\frac{\frac{-1}{t}}{y \cdot 4}} \]
      14. clear-num6.5%

        \[\leadsto \color{blue}{\frac{y \cdot 4}{\frac{-1}{t}}} \]
      15. div-inv6.5%

        \[\leadsto \frac{y \cdot 4}{\color{blue}{-1 \cdot \frac{1}{t}}} \]
      16. associate-/r*6.5%

        \[\leadsto \color{blue}{\frac{\frac{y \cdot 4}{-1}}{\frac{1}{t}}} \]
      17. associate-/l*6.5%

        \[\leadsto \frac{\color{blue}{\frac{y}{\frac{-1}{4}}}}{\frac{1}{t}} \]
      18. metadata-eval6.5%

        \[\leadsto \frac{\frac{y}{\color{blue}{-0.25}}}{\frac{1}{t}} \]
      19. metadata-eval6.5%

        \[\leadsto \frac{\frac{y}{-0.25}}{\frac{\color{blue}{--1}}{t}} \]
      20. add-sqr-sqrt6.0%

        \[\leadsto \frac{\frac{y}{-0.25}}{\frac{--1}{\color{blue}{\sqrt{t} \cdot \sqrt{t}}}} \]
      21. sqrt-unprod18.4%

        \[\leadsto \frac{\frac{y}{-0.25}}{\frac{--1}{\color{blue}{\sqrt{t \cdot t}}}} \]
      22. sqr-neg18.4%

        \[\leadsto \frac{\frac{y}{-0.25}}{\frac{--1}{\sqrt{\color{blue}{\left(-t\right) \cdot \left(-t\right)}}}} \]
      23. sqrt-unprod7.0%

        \[\leadsto \frac{\frac{y}{-0.25}}{\frac{--1}{\color{blue}{\sqrt{-t} \cdot \sqrt{-t}}}} \]
      24. add-sqr-sqrt7.6%

        \[\leadsto \frac{\frac{y}{-0.25}}{\frac{--1}{\color{blue}{-t}}} \]
      25. frac-2neg7.6%

        \[\leadsto \frac{\frac{y}{-0.25}}{\color{blue}{\frac{-1}{t}}} \]
    6. Applied egg-rr7.6%

      \[\leadsto \color{blue}{\frac{\frac{y}{-0.25}}{\frac{-1}{t}}} \]
    7. Step-by-step derivation
      1. associate-/r/7.6%

        \[\leadsto \color{blue}{\frac{\frac{y}{-0.25}}{-1} \cdot t} \]
      2. associate-/l/7.6%

        \[\leadsto \color{blue}{\frac{y}{-1 \cdot -0.25}} \cdot t \]
      3. metadata-eval7.6%

        \[\leadsto \frac{y}{\color{blue}{0.25}} \cdot t \]
      4. metadata-eval7.6%

        \[\leadsto \frac{y}{\color{blue}{\frac{1}{4}}} \cdot t \]
      5. associate-/l*7.6%

        \[\leadsto \color{blue}{\frac{y \cdot 4}{1}} \cdot t \]
      6. /-rgt-identity7.6%

        \[\leadsto \color{blue}{\left(y \cdot 4\right)} \cdot t \]
      7. add-sqr-sqrt4.5%

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

        \[\leadsto \color{blue}{\sqrt{\left(y \cdot 4\right) \cdot \left(y \cdot 4\right)}} \cdot t \]
      9. swap-sqr13.5%

        \[\leadsto \sqrt{\color{blue}{\left(y \cdot y\right) \cdot \left(4 \cdot 4\right)}} \cdot t \]
      10. metadata-eval13.5%

        \[\leadsto \sqrt{\left(y \cdot y\right) \cdot \color{blue}{16}} \cdot t \]
      11. metadata-eval13.5%

        \[\leadsto \sqrt{\left(y \cdot y\right) \cdot \color{blue}{\left(-4 \cdot -4\right)}} \cdot t \]
      12. swap-sqr13.5%

        \[\leadsto \sqrt{\color{blue}{\left(y \cdot -4\right) \cdot \left(y \cdot -4\right)}} \cdot t \]
      13. metadata-eval13.5%

        \[\leadsto \sqrt{\left(y \cdot \color{blue}{\frac{1}{-0.25}}\right) \cdot \left(y \cdot -4\right)} \cdot t \]
      14. div-inv13.5%

        \[\leadsto \sqrt{\color{blue}{\frac{y}{-0.25}} \cdot \left(y \cdot -4\right)} \cdot t \]
      15. metadata-eval13.5%

        \[\leadsto \sqrt{\frac{y}{-0.25} \cdot \left(y \cdot \color{blue}{\frac{1}{-0.25}}\right)} \cdot t \]
      16. div-inv13.5%

        \[\leadsto \sqrt{\frac{y}{-0.25} \cdot \color{blue}{\frac{y}{-0.25}}} \cdot t \]
      17. sqrt-unprod2.8%

        \[\leadsto \color{blue}{\left(\sqrt{\frac{y}{-0.25}} \cdot \sqrt{\frac{y}{-0.25}}\right)} \cdot t \]
      18. add-sqr-sqrt6.5%

        \[\leadsto \color{blue}{\frac{y}{-0.25}} \cdot t \]
      19. div-inv6.5%

        \[\leadsto \color{blue}{\left(y \cdot \frac{1}{-0.25}\right)} \cdot t \]
      20. metadata-eval6.5%

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

        \[\leadsto \color{blue}{\left(-4 \cdot y\right)} \cdot t \]
      22. associate-*r*6.5%

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

        \[\leadsto -4 \cdot \color{blue}{\left(t \cdot y\right)} \]
      24. associate-*r*6.5%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 1.9 \cdot 10^{+102}:\\ \;\;\;\;y \cdot \left(t \cdot 4\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(t \cdot -4\right)\\ \end{array} \]

Alternative 8: 31.4% accurate, 2.6× speedup?

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

\\
y \cdot \left(t \cdot 4\right)
\end{array}
Derivation
  1. Initial program 93.0%

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

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

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

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

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

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

    \[\leadsto y \cdot \left(t \cdot 4\right) \]

Developer target: 90.5% accurate, 1.0× speedup?

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

\\
x \cdot x - 4 \cdot \left(y \cdot \left(z \cdot z - t\right)\right)
\end{array}

Reproduce

?
herbie shell --seed 2023301 
(FPCore (x y z t)
  :name "Graphics.Rasterific.Shading:$sradialGradientWithFocusShader from Rasterific-0.6.1, B"
  :precision binary64

  :herbie-target
  (- (* x x) (* 4.0 (* y (- (* z z) t))))

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