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

Percentage Accurate: 91.0% → 93.6%
Time: 10.4s
Alternatives: 6
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 6 alternatives:

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

Initial Program: 91.0% accurate, 1.0× speedup?

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

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

Alternative 1: 93.6% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := z \cdot z - t\\ \mathbf{if}\;\left(y \cdot 4\right) \cdot t\_1 \leq -\infty:\\ \;\;\;\;x \cdot x + t \cdot \left(y \cdot \left(\frac{-1}{0.25 \cdot \frac{\frac{t}{z}}{z}} - -4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, x, t\_1 \cdot \left(y \cdot -4\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- (* z z) t)))
   (if (<= (* (* y 4.0) t_1) (- INFINITY))
     (+ (* x x) (* t (* y (- (/ -1.0 (* 0.25 (/ (/ t z) z))) -4.0))))
     (fma x x (* t_1 (* y -4.0))))))
double code(double x, double y, double z, double t) {
	double t_1 = (z * z) - t;
	double tmp;
	if (((y * 4.0) * t_1) <= -((double) INFINITY)) {
		tmp = (x * x) + (t * (y * ((-1.0 / (0.25 * ((t / z) / z))) - -4.0)));
	} else {
		tmp = fma(x, x, (t_1 * (y * -4.0)));
	}
	return tmp;
}
function code(x, y, z, t)
	t_1 = Float64(Float64(z * z) - t)
	tmp = 0.0
	if (Float64(Float64(y * 4.0) * t_1) <= Float64(-Inf))
		tmp = Float64(Float64(x * x) + Float64(t * Float64(y * Float64(Float64(-1.0 / Float64(0.25 * Float64(Float64(t / z) / z))) - -4.0))));
	else
		tmp = fma(x, x, Float64(t_1 * Float64(y * -4.0)));
	end
	return tmp
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision]}, If[LessEqual[N[(N[(y * 4.0), $MachinePrecision] * t$95$1), $MachinePrecision], (-Infinity)], N[(N[(x * x), $MachinePrecision] + N[(t * N[(y * N[(N[(-1.0 / N[(0.25 * N[(N[(t / z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * x + N[(t$95$1 * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := z \cdot z - t\\
\mathbf{if}\;\left(y \cdot 4\right) \cdot t\_1 \leq -\infty:\\
\;\;\;\;x \cdot x + t \cdot \left(y \cdot \left(\frac{-1}{0.25 \cdot \frac{\frac{t}{z}}{z}} - -4\right)\right)\\

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


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

    1. Initial program 86.4%

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

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

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

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

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

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

        \[\leadsto x \cdot x - t \cdot \left(y \cdot -4 + \color{blue}{\frac{\left(y \cdot 4\right) \cdot {z}^{2}}{t}}\right) \]
      6. associate-*l*86.4%

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

        \[\leadsto x \cdot x - t \cdot \left(y \cdot -4 + \color{blue}{y \cdot \frac{4 \cdot {z}^{2}}{t}}\right) \]
      8. distribute-lft-out86.4%

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

      \[\leadsto x \cdot x - \color{blue}{t \cdot \left(y \cdot \left(-4 + \frac{4 \cdot {z}^{2}}{t}\right)\right)} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt86.4%

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{\color{blue}{\sqrt{4 \cdot {z}^{2}} \cdot \sqrt{4 \cdot {z}^{2}}}}{t}\right)\right) \]
      2. *-un-lft-identity86.4%

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

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

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

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

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{\color{blue}{{z}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{4}}{1} \cdot \frac{\sqrt{4 \cdot {z}^{2}}}{t}\right)\right) \]
      7. metadata-eval55.0%

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

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

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

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

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

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{z \cdot 2}{1} \cdot \frac{\color{blue}{{z}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{4}}{t}\right)\right) \]
      13. metadata-eval94.7%

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

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{z \cdot 2}{1} \cdot \frac{\color{blue}{z} \cdot \sqrt{4}}{t}\right)\right) \]
      15. metadata-eval94.7%

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

      \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \color{blue}{\frac{z \cdot 2}{1} \cdot \frac{z \cdot 2}{t}}\right)\right) \]
    8. Step-by-step derivation
      1. clear-num94.7%

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

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{1}{\frac{1}{z \cdot 2}} \cdot \color{blue}{\frac{1}{\frac{t}{z \cdot 2}}}\right)\right) \]
      3. frac-times94.8%

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

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{\color{blue}{1}}{\frac{1}{z \cdot 2} \cdot \frac{t}{z \cdot 2}}\right)\right) \]
      5. *-un-lft-identity94.8%

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{1}{\frac{1}{z \cdot 2} \cdot \frac{\color{blue}{1 \cdot t}}{z \cdot 2}}\right)\right) \]
      6. *-commutative94.8%

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{1}{\frac{1}{z \cdot 2} \cdot \frac{1 \cdot t}{\color{blue}{2 \cdot z}}}\right)\right) \]
      7. times-frac94.8%

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

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{1}{\frac{1}{z \cdot 2} \cdot \left(\color{blue}{0.5} \cdot \frac{t}{z}\right)}\right)\right) \]
    9. Applied egg-rr94.8%

      \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \color{blue}{\frac{1}{\frac{1}{z \cdot 2} \cdot \left(0.5 \cdot \frac{t}{z}\right)}}\right)\right) \]
    10. Step-by-step derivation
      1. inv-pow94.8%

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

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + {\color{blue}{\left(\frac{1 \cdot \left(0.5 \cdot \frac{t}{z}\right)}{z \cdot 2}\right)}}^{-1}\right)\right) \]
      3. *-un-lft-identity94.8%

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + {\left(\frac{\color{blue}{0.5 \cdot \frac{t}{z}}}{z \cdot 2}\right)}^{-1}\right)\right) \]
    11. Applied egg-rr94.8%

      \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \color{blue}{{\left(\frac{0.5 \cdot \frac{t}{z}}{z \cdot 2}\right)}^{-1}}\right)\right) \]
    12. Step-by-step derivation
      1. unpow-194.8%

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \color{blue}{\frac{1}{\frac{0.5 \cdot \frac{t}{z}}{z \cdot 2}}}\right)\right) \]
      2. *-commutative94.8%

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{1}{\frac{0.5 \cdot \frac{t}{z}}{\color{blue}{2 \cdot z}}}\right)\right) \]
      3. times-frac94.8%

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{1}{\color{blue}{\frac{0.5}{2} \cdot \frac{\frac{t}{z}}{z}}}\right)\right) \]
      4. metadata-eval94.8%

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{1}{\color{blue}{0.25} \cdot \frac{\frac{t}{z}}{z}}\right)\right) \]
    13. Simplified94.8%

      \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \color{blue}{\frac{1}{0.25 \cdot \frac{\frac{t}{z}}{z}}}\right)\right) \]

    if -inf.0 < (*.f64 (*.f64 y #s(literal 4 binary64)) (-.f64 (*.f64 z z) t))

    1. Initial program 90.1%

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

        \[\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-in93.6%

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

        \[\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-in93.6%

        \[\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-eval93.6%

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

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

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

Alternative 2: 93.2% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot x + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\ \mathbf{if}\;t\_1 \leq \infty:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot x - -4 \cdot \left(y \cdot t\right)\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (+ (* x x) (* (* y 4.0) (- t (* z z))))))
   (if (<= t_1 INFINITY) t_1 (- (* x x) (* -4.0 (* y t))))))
double code(double x, double y, double z, double t) {
	double t_1 = (x * x) + ((y * 4.0) * (t - (z * z)));
	double tmp;
	if (t_1 <= ((double) INFINITY)) {
		tmp = t_1;
	} else {
		tmp = (x * x) - (-4.0 * (y * t));
	}
	return tmp;
}
public static double code(double x, double y, double z, double t) {
	double t_1 = (x * x) + ((y * 4.0) * (t - (z * z)));
	double tmp;
	if (t_1 <= Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else {
		tmp = (x * x) - (-4.0 * (y * t));
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = (x * x) + ((y * 4.0) * (t - (z * z)))
	tmp = 0
	if t_1 <= math.inf:
		tmp = t_1
	else:
		tmp = (x * x) - (-4.0 * (y * t))
	return tmp
function code(x, y, z, t)
	t_1 = Float64(Float64(x * x) + Float64(Float64(y * 4.0) * Float64(t - Float64(z * z))))
	tmp = 0.0
	if (t_1 <= Inf)
		tmp = t_1;
	else
		tmp = Float64(Float64(x * x) - Float64(-4.0 * Float64(y * t)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = (x * x) + ((y * 4.0) * (t - (z * z)));
	tmp = 0.0;
	if (t_1 <= Inf)
		tmp = t_1;
	else
		tmp = (x * x) - (-4.0 * (y * t));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] + N[(N[(y * 4.0), $MachinePrecision] * N[(t - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], t$95$1, N[(N[(x * x), $MachinePrecision] - N[(-4.0 * N[(y * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot x + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\
\mathbf{if}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (*.f64 x x) (*.f64 (*.f64 y #s(literal 4 binary64)) (-.f64 (*.f64 z z) t))) < +inf.0

    1. Initial program 94.1%

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

    if +inf.0 < (-.f64 (*.f64 x x) (*.f64 (*.f64 y #s(literal 4 binary64)) (-.f64 (*.f64 z z) t)))

    1. Initial program 0.0%

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

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

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

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

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

Alternative 3: 91.7% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 92.7%

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

    if 5.00000000000000018e153 < z

    1. Initial program 60.8%

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

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

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

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

        \[\leadsto x \cdot x - t \cdot \left(y \cdot -4 + \color{blue}{\left(4 \cdot y\right) \cdot \frac{{z}^{2}}{t}}\right) \]
      4. *-commutative60.8%

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

        \[\leadsto x \cdot x - t \cdot \left(y \cdot -4 + \color{blue}{\frac{\left(y \cdot 4\right) \cdot {z}^{2}}{t}}\right) \]
      6. associate-*l*60.8%

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

        \[\leadsto x \cdot x - t \cdot \left(y \cdot -4 + \color{blue}{y \cdot \frac{4 \cdot {z}^{2}}{t}}\right) \]
      8. distribute-lft-out60.8%

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

      \[\leadsto x \cdot x - \color{blue}{t \cdot \left(y \cdot \left(-4 + \frac{4 \cdot {z}^{2}}{t}\right)\right)} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt60.8%

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{\color{blue}{\sqrt{4 \cdot {z}^{2}} \cdot \sqrt{4 \cdot {z}^{2}}}}{t}\right)\right) \]
      2. *-un-lft-identity60.8%

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{\sqrt{4 \cdot {z}^{2}} \cdot \sqrt{4 \cdot {z}^{2}}}{\color{blue}{1 \cdot t}}\right)\right) \]
      3. times-frac60.8%

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

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

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

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{\color{blue}{{z}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{4}}{1} \cdot \frac{\sqrt{4 \cdot {z}^{2}}}{t}\right)\right) \]
      7. metadata-eval60.8%

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

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{\color{blue}{z} \cdot \sqrt{4}}{1} \cdot \frac{\sqrt{4 \cdot {z}^{2}}}{t}\right)\right) \]
      9. metadata-eval60.8%

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

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

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

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{z \cdot 2}{1} \cdot \frac{\color{blue}{{z}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{4}}{t}\right)\right) \]
      13. metadata-eval78.1%

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

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{z \cdot 2}{1} \cdot \frac{\color{blue}{z} \cdot \sqrt{4}}{t}\right)\right) \]
      15. metadata-eval78.1%

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

      \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \color{blue}{\frac{z \cdot 2}{1} \cdot \frac{z \cdot 2}{t}}\right)\right) \]
    8. Step-by-step derivation
      1. clear-num78.1%

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \color{blue}{\frac{1}{\frac{1}{z \cdot 2}}} \cdot \frac{z \cdot 2}{t}\right)\right) \]
      2. clear-num78.0%

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

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

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{\color{blue}{1}}{\frac{1}{z \cdot 2} \cdot \frac{t}{z \cdot 2}}\right)\right) \]
      5. *-un-lft-identity78.0%

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{1}{\frac{1}{z \cdot 2} \cdot \frac{\color{blue}{1 \cdot t}}{z \cdot 2}}\right)\right) \]
      6. *-commutative78.0%

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{1}{\frac{1}{z \cdot 2} \cdot \frac{1 \cdot t}{\color{blue}{2 \cdot z}}}\right)\right) \]
      7. times-frac78.0%

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{1}{\frac{1}{z \cdot 2} \cdot \color{blue}{\left(\frac{1}{2} \cdot \frac{t}{z}\right)}}\right)\right) \]
      8. metadata-eval78.0%

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{1}{\frac{1}{z \cdot 2} \cdot \left(\color{blue}{0.5} \cdot \frac{t}{z}\right)}\right)\right) \]
    9. Applied egg-rr78.0%

      \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \color{blue}{\frac{1}{\frac{1}{z \cdot 2} \cdot \left(0.5 \cdot \frac{t}{z}\right)}}\right)\right) \]
    10. Step-by-step derivation
      1. inv-pow78.0%

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

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + {\color{blue}{\left(\frac{1 \cdot \left(0.5 \cdot \frac{t}{z}\right)}{z \cdot 2}\right)}}^{-1}\right)\right) \]
      3. *-un-lft-identity78.1%

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + {\left(\frac{\color{blue}{0.5 \cdot \frac{t}{z}}}{z \cdot 2}\right)}^{-1}\right)\right) \]
    11. Applied egg-rr78.1%

      \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \color{blue}{{\left(\frac{0.5 \cdot \frac{t}{z}}{z \cdot 2}\right)}^{-1}}\right)\right) \]
    12. Step-by-step derivation
      1. unpow-178.1%

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \color{blue}{\frac{1}{\frac{0.5 \cdot \frac{t}{z}}{z \cdot 2}}}\right)\right) \]
      2. *-commutative78.1%

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{1}{\frac{0.5 \cdot \frac{t}{z}}{\color{blue}{2 \cdot z}}}\right)\right) \]
      3. times-frac78.1%

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

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{1}{\color{blue}{0.25} \cdot \frac{\frac{t}{z}}{z}}\right)\right) \]
    13. Simplified78.1%

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

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

Alternative 4: 91.0% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 93.4%

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

    if 6.20000000000000008e105 < z

    1. Initial program 60.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 60.7%

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

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

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

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

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

        \[\leadsto x \cdot x - t \cdot \left(y \cdot -4 + \color{blue}{\frac{\left(y \cdot 4\right) \cdot {z}^{2}}{t}}\right) \]
      6. associate-*l*60.7%

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

        \[\leadsto x \cdot x - t \cdot \left(y \cdot -4 + \color{blue}{y \cdot \frac{4 \cdot {z}^{2}}{t}}\right) \]
      8. distribute-lft-out60.6%

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

      \[\leadsto x \cdot x - \color{blue}{t \cdot \left(y \cdot \left(-4 + \frac{4 \cdot {z}^{2}}{t}\right)\right)} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt60.6%

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{\color{blue}{\sqrt{4 \cdot {z}^{2}} \cdot \sqrt{4 \cdot {z}^{2}}}}{t}\right)\right) \]
      2. *-un-lft-identity60.6%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{z \cdot 2}{1} \cdot \frac{\color{blue}{{z}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{4}}{t}\right)\right) \]
      13. metadata-eval75.2%

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

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{z \cdot 2}{1} \cdot \frac{\color{blue}{z} \cdot \sqrt{4}}{t}\right)\right) \]
      15. metadata-eval75.2%

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

      \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \color{blue}{\frac{z \cdot 2}{1} \cdot \frac{z \cdot 2}{t}}\right)\right) \]
    8. Step-by-step derivation
      1. clear-num75.2%

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \color{blue}{\frac{1}{\frac{1}{z \cdot 2}}} \cdot \frac{z \cdot 2}{t}\right)\right) \]
      2. clear-num75.2%

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{1}{\frac{1}{z \cdot 2}} \cdot \color{blue}{\frac{1}{\frac{t}{z \cdot 2}}}\right)\right) \]
      3. frac-times75.2%

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

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{\color{blue}{1}}{\frac{1}{z \cdot 2} \cdot \frac{t}{z \cdot 2}}\right)\right) \]
      5. *-un-lft-identity75.2%

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

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

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

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{1}{\frac{1}{z \cdot 2} \cdot \left(\color{blue}{0.5} \cdot \frac{t}{z}\right)}\right)\right) \]
    9. Applied egg-rr75.2%

      \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \color{blue}{\frac{1}{\frac{1}{z \cdot 2} \cdot \left(0.5 \cdot \frac{t}{z}\right)}}\right)\right) \]
    10. Step-by-step derivation
      1. pow175.2%

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

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

        \[\leadsto x \cdot x - {\left(\left(t \cdot y\right) \cdot \left(-4 + \color{blue}{\frac{\frac{1}{\frac{1}{z \cdot 2}}}{0.5 \cdot \frac{t}{z}}}\right)\right)}^{1} \]
      4. inv-pow74.9%

        \[\leadsto x \cdot x - {\left(\left(t \cdot y\right) \cdot \left(-4 + \frac{\frac{1}{\color{blue}{{\left(z \cdot 2\right)}^{-1}}}}{0.5 \cdot \frac{t}{z}}\right)\right)}^{1} \]
      5. pow-flip74.9%

        \[\leadsto x \cdot x - {\left(\left(t \cdot y\right) \cdot \left(-4 + \frac{\color{blue}{{\left(z \cdot 2\right)}^{\left(--1\right)}}}{0.5 \cdot \frac{t}{z}}\right)\right)}^{1} \]
      6. metadata-eval74.9%

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

        \[\leadsto x \cdot x - {\left(\left(t \cdot y\right) \cdot \left(-4 + \frac{\color{blue}{z \cdot 2}}{0.5 \cdot \frac{t}{z}}\right)\right)}^{1} \]
    11. Applied egg-rr74.9%

      \[\leadsto x \cdot x - \color{blue}{{\left(\left(t \cdot y\right) \cdot \left(-4 + \frac{z \cdot 2}{0.5 \cdot \frac{t}{z}}\right)\right)}^{1}} \]
    12. Step-by-step derivation
      1. unpow174.9%

        \[\leadsto x \cdot x - \color{blue}{\left(t \cdot y\right) \cdot \left(-4 + \frac{z \cdot 2}{0.5 \cdot \frac{t}{z}}\right)} \]
      2. associate-*l*75.1%

        \[\leadsto x \cdot x - \color{blue}{t \cdot \left(y \cdot \left(-4 + \frac{z \cdot 2}{0.5 \cdot \frac{t}{z}}\right)\right)} \]
      3. *-commutative75.1%

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \frac{\color{blue}{2 \cdot z}}{0.5 \cdot \frac{t}{z}}\right)\right) \]
      4. times-frac75.1%

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

        \[\leadsto x \cdot x - t \cdot \left(y \cdot \left(-4 + \color{blue}{4} \cdot \frac{z}{\frac{t}{z}}\right)\right) \]
    13. Simplified75.1%

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

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

Alternative 5: 67.9% accurate, 1.4× speedup?

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

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

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

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

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

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

Alternative 6: 32.1% accurate, 2.6× speedup?

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

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

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

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

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

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

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

Developer target: 91.0% accurate, 1.0× speedup?

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

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

Reproduce

?
herbie shell --seed 2024060 
(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))))