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

Percentage Accurate: 91.1% → 94.1%
Time: 12.1s
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.1% accurate, 1.0× speedup?

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

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

Alternative 1: 94.1% accurate, 0.1× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} \mathbf{if}\;x\_m \leq 4 \cdot 10^{+224}:\\ \;\;\;\;\mathsf{fma}\left(x\_m, x\_m, \left(z \cdot z - t\right) \cdot \left(y \cdot -4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot 4, t, x\_m \cdot x\_m\right)\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m y z t)
 :precision binary64
 (if (<= x_m 4e+224)
   (fma x_m x_m (* (- (* z z) t) (* y -4.0)))
   (fma (* y 4.0) t (* x_m x_m))))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
	double tmp;
	if (x_m <= 4e+224) {
		tmp = fma(x_m, x_m, (((z * z) - t) * (y * -4.0)));
	} else {
		tmp = fma((y * 4.0), t, (x_m * x_m));
	}
	return tmp;
}
x_m = abs(x)
function code(x_m, y, z, t)
	tmp = 0.0
	if (x_m <= 4e+224)
		tmp = fma(x_m, x_m, Float64(Float64(Float64(z * z) - t) * Float64(y * -4.0)));
	else
		tmp = fma(Float64(y * 4.0), t, Float64(x_m * x_m));
	end
	return tmp
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_, z_, t_] := If[LessEqual[x$95$m, 4e+224], N[(x$95$m * x$95$m + N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * 4.0), $MachinePrecision] * t + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 3.99999999999999988e224

    1. Initial program 91.0%

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

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

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

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

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

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

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

    if 3.99999999999999988e224 < x

    1. Initial program 64.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot 4, t - z \cdot z, x \cdot x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in t around inf 100.0%

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

Alternative 2: 92.5% accurate, 0.1× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} \mathbf{if}\;x\_m \leq 1.2 \cdot 10^{+150}:\\ \;\;\;\;x\_m \cdot x\_m + t \cdot \left(4 \cdot \left(y - \frac{z \cdot y}{\frac{t}{z}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot 4, t, x\_m \cdot x\_m\right)\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m y z t)
 :precision binary64
 (if (<= x_m 1.2e+150)
   (+ (* x_m x_m) (* t (* 4.0 (- y (/ (* z y) (/ t z))))))
   (fma (* y 4.0) t (* x_m x_m))))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
	double tmp;
	if (x_m <= 1.2e+150) {
		tmp = (x_m * x_m) + (t * (4.0 * (y - ((z * y) / (t / z)))));
	} else {
		tmp = fma((y * 4.0), t, (x_m * x_m));
	}
	return tmp;
}
x_m = abs(x)
function code(x_m, y, z, t)
	tmp = 0.0
	if (x_m <= 1.2e+150)
		tmp = Float64(Float64(x_m * x_m) + Float64(t * Float64(4.0 * Float64(y - Float64(Float64(z * y) / Float64(t / z))))));
	else
		tmp = fma(Float64(y * 4.0), t, Float64(x_m * x_m));
	end
	return tmp
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_, z_, t_] := If[LessEqual[x$95$m, 1.2e+150], N[(N[(x$95$m * x$95$m), $MachinePrecision] + N[(t * N[(4.0 * N[(y - N[(N[(z * y), $MachinePrecision] / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * 4.0), $MachinePrecision] * t + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.20000000000000001e150

    1. Initial program 92.0%

      \[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 89.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. +-commutative89.8%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x \cdot x - t \cdot \left(4 \cdot \left(y \cdot \frac{\color{blue}{z \cdot z}}{t} - y\right)\right) \]
    8. Step-by-step derivation
      1. associate-*r/91.0%

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

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

        \[\leadsto x \cdot x - t \cdot \left(4 \cdot \left(\left(y \cdot z\right) \cdot \color{blue}{\frac{1}{\frac{t}{z}}} - y\right)\right) \]
      4. un-div-inv92.7%

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

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

    if 1.20000000000000001e150 < x

    1. Initial program 73.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot 4, t - z \cdot z, x \cdot x\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in t around inf 89.2%

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

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

Alternative 3: 94.9% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1\\

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


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

    1. Initial program 87.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x \cdot x - t \cdot \left(4 \cdot \left(y \cdot \frac{\color{blue}{z \cdot z}}{t} - y\right)\right) \]
    8. Step-by-step derivation
      1. associate-*r/95.0%

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

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

        \[\leadsto x \cdot x - t \cdot \left(4 \cdot \left(\left(y \cdot z\right) \cdot \color{blue}{\frac{1}{\frac{t}{z}}} - y\right)\right) \]
      4. un-div-inv99.9%

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

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

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

    1. Initial program 98.5%

      \[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. Step-by-step derivation
      1. add-sqr-sqrt0.0%

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

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

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

        \[\leadsto x \cdot x - \sqrt{\left(y \cdot y\right) \cdot \color{blue}{16}} \cdot \left(z \cdot z - t\right) \]
      5. metadata-eval25.0%

        \[\leadsto x \cdot x - \sqrt{\left(y \cdot y\right) \cdot \color{blue}{\left(-4 \cdot -4\right)}} \cdot \left(z \cdot z - t\right) \]
      6. swap-sqr25.0%

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

        \[\leadsto x \cdot x - \color{blue}{\left(\sqrt{y \cdot -4} \cdot \sqrt{y \cdot -4}\right)} \cdot \left(z \cdot z - t\right) \]
      8. add-sqr-sqrt65.0%

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

        \[\leadsto x \cdot x - \left(y \cdot \color{blue}{\left(-4\right)}\right) \cdot \left(z \cdot z - t\right) \]
      10. distribute-rgt-neg-in65.0%

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

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

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

Alternative 4: 93.7% accurate, 0.4× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} t_1 := x\_m \cdot x\_m + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\ \mathbf{if}\;t\_1 \leq \infty:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;x\_m \cdot x\_m + \left(z \cdot z - t\right) \cdot \left(y \cdot 4\right)\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m y z t)
 :precision binary64
 (let* ((t_1 (+ (* x_m x_m) (* (* y 4.0) (- t (* z z))))))
   (if (<= t_1 INFINITY) t_1 (+ (* x_m x_m) (* (- (* z z) t) (* y 4.0))))))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
	double t_1 = (x_m * x_m) + ((y * 4.0) * (t - (z * z)));
	double tmp;
	if (t_1 <= ((double) INFINITY)) {
		tmp = t_1;
	} else {
		tmp = (x_m * x_m) + (((z * z) - t) * (y * 4.0));
	}
	return tmp;
}
x_m = Math.abs(x);
public static double code(double x_m, double y, double z, double t) {
	double t_1 = (x_m * x_m) + ((y * 4.0) * (t - (z * z)));
	double tmp;
	if (t_1 <= Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else {
		tmp = (x_m * x_m) + (((z * z) - t) * (y * 4.0));
	}
	return tmp;
}
x_m = math.fabs(x)
def code(x_m, y, z, t):
	t_1 = (x_m * x_m) + ((y * 4.0) * (t - (z * z)))
	tmp = 0
	if t_1 <= math.inf:
		tmp = t_1
	else:
		tmp = (x_m * x_m) + (((z * z) - t) * (y * 4.0))
	return tmp
x_m = abs(x)
function code(x_m, y, z, t)
	t_1 = Float64(Float64(x_m * x_m) + 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_m * x_m) + Float64(Float64(Float64(z * z) - t) * Float64(y * 4.0)));
	end
	return tmp
end
x_m = abs(x);
function tmp_2 = code(x_m, y, z, t)
	t_1 = (x_m * x_m) + ((y * 4.0) * (t - (z * z)));
	tmp = 0.0;
	if (t_1 <= Inf)
		tmp = t_1;
	else
		tmp = (x_m * x_m) + (((z * z) - t) * (y * 4.0));
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x$95$m * x$95$m), $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$95$m * x$95$m), $MachinePrecision] + N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x_m = \left|x\right|

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

\mathbf{else}:\\
\;\;\;\;x\_m \cdot x\_m + \left(z \cdot z - t\right) \cdot \left(y \cdot 4\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 96.8%

      \[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. Step-by-step derivation
      1. add-sqr-sqrt0.0%

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

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

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

        \[\leadsto x \cdot x - \sqrt{\left(y \cdot y\right) \cdot \color{blue}{16}} \cdot \left(z \cdot z - t\right) \]
      5. metadata-eval25.0%

        \[\leadsto x \cdot x - \sqrt{\left(y \cdot y\right) \cdot \color{blue}{\left(-4 \cdot -4\right)}} \cdot \left(z \cdot z - t\right) \]
      6. swap-sqr25.0%

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

        \[\leadsto x \cdot x - \color{blue}{\left(\sqrt{y \cdot -4} \cdot \sqrt{y \cdot -4}\right)} \cdot \left(z \cdot z - t\right) \]
      8. add-sqr-sqrt65.0%

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

        \[\leadsto x \cdot x - \left(y \cdot \color{blue}{\left(-4\right)}\right) \cdot \left(z \cdot z - t\right) \]
      10. distribute-rgt-neg-in65.0%

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

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

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

Alternative 5: 93.6% accurate, 0.4× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} t_1 := x\_m \cdot x\_m + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\ \mathbf{if}\;t\_1 \leq \infty:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;x\_m \cdot x\_m + t \cdot \left(y \cdot -4\right)\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m y z t)
 :precision binary64
 (let* ((t_1 (+ (* x_m x_m) (* (* y 4.0) (- t (* z z))))))
   (if (<= t_1 INFINITY) t_1 (+ (* x_m x_m) (* t (* y -4.0))))))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
	double t_1 = (x_m * x_m) + ((y * 4.0) * (t - (z * z)));
	double tmp;
	if (t_1 <= ((double) INFINITY)) {
		tmp = t_1;
	} else {
		tmp = (x_m * x_m) + (t * (y * -4.0));
	}
	return tmp;
}
x_m = Math.abs(x);
public static double code(double x_m, double y, double z, double t) {
	double t_1 = (x_m * x_m) + ((y * 4.0) * (t - (z * z)));
	double tmp;
	if (t_1 <= Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else {
		tmp = (x_m * x_m) + (t * (y * -4.0));
	}
	return tmp;
}
x_m = math.fabs(x)
def code(x_m, y, z, t):
	t_1 = (x_m * x_m) + ((y * 4.0) * (t - (z * z)))
	tmp = 0
	if t_1 <= math.inf:
		tmp = t_1
	else:
		tmp = (x_m * x_m) + (t * (y * -4.0))
	return tmp
x_m = abs(x)
function code(x_m, y, z, t)
	t_1 = Float64(Float64(x_m * x_m) + 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_m * x_m) + Float64(t * Float64(y * -4.0)));
	end
	return tmp
end
x_m = abs(x);
function tmp_2 = code(x_m, y, z, t)
	t_1 = (x_m * x_m) + ((y * 4.0) * (t - (z * z)));
	tmp = 0.0;
	if (t_1 <= Inf)
		tmp = t_1;
	else
		tmp = (x_m * x_m) + (t * (y * -4.0));
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x$95$m * x$95$m), $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$95$m * x$95$m), $MachinePrecision] + N[(t * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x_m = \left|x\right|

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

\mathbf{else}:\\
\;\;\;\;x\_m \cdot x\_m + t \cdot \left(y \cdot -4\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 96.8%

      \[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. Step-by-step derivation
      1. add-sqr-sqrt0.0%

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

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

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

        \[\leadsto x \cdot x - \sqrt{\left(y \cdot y\right) \cdot \color{blue}{16}} \cdot \left(z \cdot z - t\right) \]
      5. metadata-eval25.0%

        \[\leadsto x \cdot x - \sqrt{\left(y \cdot y\right) \cdot \color{blue}{\left(-4 \cdot -4\right)}} \cdot \left(z \cdot z - t\right) \]
      6. swap-sqr25.0%

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

        \[\leadsto x \cdot x - \color{blue}{\left(\sqrt{y \cdot -4} \cdot \sqrt{y \cdot -4}\right)} \cdot \left(z \cdot z - t\right) \]
      8. add-sqr-sqrt65.0%

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

        \[\leadsto x \cdot x - \left(y \cdot \color{blue}{\left(-4\right)}\right) \cdot \left(z \cdot z - t\right) \]
      10. distribute-rgt-neg-in65.0%

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

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

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

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

      \[\leadsto x \cdot x - \left(-y \cdot 4\right) \cdot \color{blue}{\left(-t\right)} \]
    8. Taylor expanded in y around 0 60.0%

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

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

      \[\leadsto x \cdot x - \color{blue}{\left(y \cdot -4\right)} \cdot \left(-t\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification93.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 + t \cdot \left(y \cdot -4\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 81.5% accurate, 0.8× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} \mathbf{if}\;z \cdot z \leq 4.6 \cdot 10^{+203}:\\ \;\;\;\;x\_m \cdot x\_m - y \cdot \left(t \cdot -4\right)\\ \mathbf{else}:\\ \;\;\;\;\left(z \cdot z\right) \cdot \left(y \cdot -4\right)\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m y z t)
 :precision binary64
 (if (<= (* z z) 4.6e+203)
   (- (* x_m x_m) (* y (* t -4.0)))
   (* (* z z) (* y -4.0))))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
	double tmp;
	if ((z * z) <= 4.6e+203) {
		tmp = (x_m * x_m) - (y * (t * -4.0));
	} else {
		tmp = (z * z) * (y * -4.0);
	}
	return tmp;
}
x_m = abs(x)
real(8) function code(x_m, y, z, t)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((z * z) <= 4.6d+203) then
        tmp = (x_m * x_m) - (y * (t * (-4.0d0)))
    else
        tmp = (z * z) * (y * (-4.0d0))
    end if
    code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y, double z, double t) {
	double tmp;
	if ((z * z) <= 4.6e+203) {
		tmp = (x_m * x_m) - (y * (t * -4.0));
	} else {
		tmp = (z * z) * (y * -4.0);
	}
	return tmp;
}
x_m = math.fabs(x)
def code(x_m, y, z, t):
	tmp = 0
	if (z * z) <= 4.6e+203:
		tmp = (x_m * x_m) - (y * (t * -4.0))
	else:
		tmp = (z * z) * (y * -4.0)
	return tmp
x_m = abs(x)
function code(x_m, y, z, t)
	tmp = 0.0
	if (Float64(z * z) <= 4.6e+203)
		tmp = Float64(Float64(x_m * x_m) - Float64(y * Float64(t * -4.0)));
	else
		tmp = Float64(Float64(z * z) * Float64(y * -4.0));
	end
	return tmp
end
x_m = abs(x);
function tmp_2 = code(x_m, y, z, t)
	tmp = 0.0;
	if ((z * z) <= 4.6e+203)
		tmp = (x_m * x_m) - (y * (t * -4.0));
	else
		tmp = (z * z) * (y * -4.0);
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 4.6e+203], N[(N[(x$95$m * x$95$m), $MachinePrecision] - N[(y * N[(t * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z * z), $MachinePrecision] * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|

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

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


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

    1. Initial program 95.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 82.4%

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

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

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

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

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

    if 4.5999999999999998e203 < (*.f64 z z)

    1. Initial program 78.8%

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

        \[\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-in83.1%

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

        \[\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-in83.1%

        \[\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-eval83.1%

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

      \[\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. Taylor expanded in z around inf 75.3%

      \[\leadsto \color{blue}{-4 \cdot \left(y \cdot {z}^{2}\right)} \]
    6. Step-by-step derivation
      1. associate-*r*75.3%

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

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

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

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

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

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

Alternative 7: 55.9% accurate, 0.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 z z) < 9.19999999999999992e-44

    1. Initial program 95.3%

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

        \[\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-in96.3%

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

        \[\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-in96.3%

        \[\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-eval96.3%

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

      \[\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. Taylor expanded in t around inf 46.6%

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

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

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

    if 9.19999999999999992e-44 < (*.f64 z z)

    1. Initial program 84.7%

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

        \[\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-in88.8%

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

        \[\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-in88.8%

        \[\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-eval88.8%

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

      \[\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. Taylor expanded in z around inf 58.4%

      \[\leadsto \color{blue}{-4 \cdot \left(y \cdot {z}^{2}\right)} \]
    6. Step-by-step derivation
      1. associate-*r*58.4%

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

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

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

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

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

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

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

Alternative 8: 31.9% accurate, 2.6× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ 4 \cdot \left(t \cdot y\right) \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m y z t) :precision binary64 (* 4.0 (* t y)))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
	return 4.0 * (t * y);
}
x_m = abs(x)
real(8) function code(x_m, y, z, t)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = 4.0d0 * (t * y)
end function
x_m = Math.abs(x);
public static double code(double x_m, double y, double z, double t) {
	return 4.0 * (t * y);
}
x_m = math.fabs(x)
def code(x_m, y, z, t):
	return 4.0 * (t * y)
x_m = abs(x)
function code(x_m, y, z, t)
	return Float64(4.0 * Float64(t * y))
end
x_m = abs(x);
function tmp = code(x_m, y, z, t)
	tmp = 4.0 * (t * y);
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_, z_, t_] := N[(4.0 * N[(t * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|

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

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

      \[\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-in91.9%

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

      \[\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-in91.9%

      \[\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-eval91.9%

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

    \[\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. Taylor expanded in t around inf 30.5%

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

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

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

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

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

  :alt
  (! :herbie-platform default (- (* x x) (* 4 (* y (- (* z z) t)))))

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