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

Percentage Accurate: 91.0% → 97.6%
Time: 11.6s
Alternatives: 8
Speedup: 0.4×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 8 alternatives:

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

Initial Program: 91.0% accurate, 1.0× speedup?

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

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

Alternative 1: 97.6% accurate, 0.0× speedup?

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

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

\mathbf{elif}\;y \cdot 4 \leq 10^{-54}:\\
\;\;\;\;x \cdot x - \left(-4 \cdot \left(y \cdot t\right) + 4 \cdot {\left({\left(\sqrt[3]{z}\right)}^{2} \cdot \sqrt[3]{y}\right)}^{3}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 y 4) < -4e21

    1. Initial program 93.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4e21 < (*.f64 y 4) < 1e-54

    1. Initial program 82.4%

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

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

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

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

      \[\leadsto x \cdot x - \left(-4 \cdot \left(t \cdot y\right) + 4 \cdot \color{blue}{{\left(\sqrt[3]{y \cdot {z}^{2}}\right)}^{3}}\right) \]
    6. Step-by-step derivation
      1. cbrt-prod82.3%

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

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

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

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

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

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

    if 1e-54 < (*.f64 y 4)

    1. Initial program 93.4%

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. Step-by-step derivation
      1. fma-neg98.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-in98.6%

        \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{\left(-y \cdot 4\right) \cdot \left(z \cdot z - t\right)}\right) \]
      3. *-commutative98.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-in98.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-eval98.6%

        \[\leadsto \mathsf{fma}\left(x, x, \left(z \cdot z - t\right) \cdot \left(y \cdot \color{blue}{-4}\right)\right) \]
    3. Simplified98.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 3 regimes into one program.
  4. Final simplification98.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot 4 \leq -4 \cdot 10^{+21}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot 4, t - z \cdot z, x \cdot x\right)\\ \mathbf{elif}\;y \cdot 4 \leq 10^{-54}:\\ \;\;\;\;x \cdot x - \left(-4 \cdot \left(y \cdot t\right) + 4 \cdot {\left({\left(\sqrt[3]{z}\right)}^{2} \cdot \sqrt[3]{y}\right)}^{3}\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: 95.5% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \cdot 4 \leq 10^{-292}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot 4, t - z \cdot z, x \cdot x\right)\\ \mathbf{elif}\;y \cdot 4 \leq 10^{-22}:\\ \;\;\;\;x \cdot x - \left({\left(\left(z \cdot 2\right) \cdot \sqrt{y}\right)}^{2} + y \cdot \left(t \cdot -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} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= (* y 4.0) 1e-292)
   (fma (* y 4.0) (- t (* z z)) (* x x))
   (if (<= (* y 4.0) 1e-22)
     (- (* x x) (+ (pow (* (* z 2.0) (sqrt y)) 2.0) (* y (* t -4.0))))
     (fma x x (* (- (* z z) t) (* y -4.0))))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((y * 4.0) <= 1e-292) {
		tmp = fma((y * 4.0), (t - (z * z)), (x * x));
	} else if ((y * 4.0) <= 1e-22) {
		tmp = (x * x) - (pow(((z * 2.0) * sqrt(y)), 2.0) + (y * (t * -4.0)));
	} else {
		tmp = fma(x, x, (((z * z) - t) * (y * -4.0)));
	}
	return tmp;
}
function code(x, y, z, t)
	tmp = 0.0
	if (Float64(y * 4.0) <= 1e-292)
		tmp = fma(Float64(y * 4.0), Float64(t - Float64(z * z)), Float64(x * x));
	elseif (Float64(y * 4.0) <= 1e-22)
		tmp = Float64(Float64(x * x) - Float64((Float64(Float64(z * 2.0) * sqrt(y)) ^ 2.0) + Float64(y * Float64(t * -4.0))));
	else
		tmp = fma(x, x, Float64(Float64(Float64(z * z) - t) * Float64(y * -4.0)));
	end
	return tmp
end
code[x_, y_, z_, t_] := If[LessEqual[N[(y * 4.0), $MachinePrecision], 1e-292], N[(N[(y * 4.0), $MachinePrecision] * N[(t - N[(z * z), $MachinePrecision]), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y * 4.0), $MachinePrecision], 1e-22], N[(N[(x * x), $MachinePrecision] - N[(N[Power[N[(N[(z * 2.0), $MachinePrecision] * N[Sqrt[y], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(y * N[(t * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * x + N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;y \cdot 4 \leq 10^{-22}:\\
\;\;\;\;x \cdot x - \left({\left(\left(z \cdot 2\right) \cdot \sqrt{y}\right)}^{2} + y \cdot \left(t \cdot -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}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 y 4) < 1.0000000000000001e-292

    1. Initial program 91.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.0000000000000001e-292 < (*.f64 y 4) < 1e-22

    1. Initial program 76.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1e-22 < (*.f64 y 4)

    1. Initial program 92.7%

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

        \[\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-in98.5%

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

        \[\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-in98.5%

        \[\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-eval98.5%

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

      \[\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 3 regimes into one program.
  4. Final simplification95.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot 4 \leq 10^{-292}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot 4, t - z \cdot z, x \cdot x\right)\\ \mathbf{elif}\;y \cdot 4 \leq 10^{-22}:\\ \;\;\;\;x \cdot x - \left({\left(\left(z \cdot 2\right) \cdot \sqrt{y}\right)}^{2} + y \cdot \left(t \cdot -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 3: 92.7% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot x + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right) \leq -\infty:\\ \;\;\;\;y \cdot \left(t \cdot \left(--4\right)\right) - {\left(\left(z \cdot 2\right) \cdot \sqrt{y}\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, x, \left(z \cdot z - t\right) \cdot \left(y \cdot -4\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= (+ (* x x) (* (* y 4.0) (- t (* z z)))) (- INFINITY))
   (- (* y (* t (- -4.0))) (pow (* (* z 2.0) (sqrt y)) 2.0))
   (fma x x (* (- (* z z) t) (* y -4.0)))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (((x * x) + ((y * 4.0) * (t - (z * z)))) <= -((double) INFINITY)) {
		tmp = (y * (t * -(-4.0))) - pow(((z * 2.0) * sqrt(y)), 2.0);
	} else {
		tmp = fma(x, x, (((z * z) - t) * (y * -4.0)));
	}
	return tmp;
}
function code(x, y, z, t)
	tmp = 0.0
	if (Float64(Float64(x * x) + Float64(Float64(y * 4.0) * Float64(t - Float64(z * z)))) <= Float64(-Inf))
		tmp = Float64(Float64(y * Float64(t * Float64(-(-4.0)))) - (Float64(Float64(z * 2.0) * sqrt(y)) ^ 2.0));
	else
		tmp = fma(x, x, Float64(Float64(Float64(z * z) - t) * Float64(y * -4.0)));
	end
	return tmp
end
code[x_, y_, z_, t_] := If[LessEqual[N[(N[(x * x), $MachinePrecision] + N[(N[(y * 4.0), $MachinePrecision] * N[(t - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-Infinity)], N[(N[(y * N[(t * (--4.0)), $MachinePrecision]), $MachinePrecision] - N[Power[N[(N[(z * 2.0), $MachinePrecision] * N[Sqrt[y], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(x * x + N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 75.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -1 \cdot \mathsf{fma}\left(2 \cdot \left(z \cdot \sqrt{y}\right), 2 \cdot \left(\color{blue}{\left(\sqrt{z} \cdot \sqrt{z}\right)} \cdot \sqrt{y}\right), -4 \cdot \left(t \cdot y\right)\right) \]
      17. add-sqr-sqrt90.8%

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

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

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

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

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

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

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

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

    if -inf.0 < (-.f64 (*.f64 x x) (*.f64 (*.f64 y 4) (-.f64 (*.f64 z z) t)))

    1. Initial program 90.3%

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. Step-by-step derivation
      1. fma-neg92.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-in92.6%

        \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{\left(-y \cdot 4\right) \cdot \left(z \cdot z - t\right)}\right) \]
      3. *-commutative92.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-in92.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-eval92.6%

        \[\leadsto \mathsf{fma}\left(x, x, \left(z \cdot z - t\right) \cdot \left(y \cdot \color{blue}{-4}\right)\right) \]
    3. Simplified92.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 simplification92.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right) \leq -\infty:\\ \;\;\;\;y \cdot \left(t \cdot \left(--4\right)\right) - {\left(\left(z \cdot 2\right) \cdot \sqrt{y}\right)}^{2}\\ \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 4: 93.1% 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 88.3%

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

      \[\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-in90.2%

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

      \[\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-in90.2%

      \[\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-eval90.2%

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

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

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

Alternative 5: 93.6% accurate, 0.1× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{x}^{2}\\


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

    1. Initial program 91.3%

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

    if 5.00000000000000009e305 < (*.f64 x x)

    1. Initial program 80.8%

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

      \[\leadsto \color{blue}{{x}^{2}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification91.8%

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

Alternative 6: 92.9% 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 - y \cdot \left(t \cdot -4\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) (* y (* t -4.0))))))
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) - (y * (t * -4.0));
	}
	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) - (y * (t * -4.0));
	}
	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) - (y * (t * -4.0))
	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(y * Float64(t * -4.0)));
	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) - (y * (t * -4.0));
	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[(y * N[(t * -4.0), $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 - y \cdot \left(t \cdot -4\right)\\


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

    1. Initial program 93.4%

      \[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 4) (-.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 42.9%

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

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

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

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

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

    \[\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 - y \cdot \left(t \cdot -4\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 66.4% accurate, 1.4× speedup?

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

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

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

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

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

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

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

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

Alternative 8: 31.6% accurate, 2.6× speedup?

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

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

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

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

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

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

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

    \[\leadsto \left(y \cdot 4\right) \cdot t \]
  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 2024018 
(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))))