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

Percentage Accurate: 90.9% → 92.9%
Time: 10.5s
Alternatives: 10
Speedup: 0.5×

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

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

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

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

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

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

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

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

Alternative 2: 93.2% accurate, 0.1× 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}:\\ \;\;\;\;\mathsf{fma}\left(x, x, 4 \cdot \left(t \cdot y\right)\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 (fma x x (* 4.0 (* t y))))))
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 = fma(x, x, (4.0 * (t * y)));
	}
	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 = fma(x, x, Float64(4.0 * Float64(t * y)));
	end
	return 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[(x * x + N[(4.0 * N[(t * y), $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}:\\
\;\;\;\;\mathsf{fma}\left(x, x, 4 \cdot \left(t \cdot y\right)\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 97.6%

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x, x, \left(\color{blue}{4} \cdot t\right) \cdot y\right) \]
      7. associate-*r*60.0%

        \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{4 \cdot \left(t \cdot y\right)}\right) \]
    7. Applied egg-rr60.0%

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

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

Alternative 3: 92.8% 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}:\\ \;\;\;\;\left(z \cdot z\right) \cdot \left(y \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 (* (* z z) (* y -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 = (z * z) * (y * -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 = (z * z) * (y * -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 = (z * z) * (y * -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(z * z) * Float64(y * -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 = (z * z) * (y * -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[(z * z), $MachinePrecision] * N[(y * -4.0), $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}:\\
\;\;\;\;\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 (*.f64 x x) (*.f64 (*.f64 y #s(literal 4 binary64)) (-.f64 (*.f64 z z) t))) < +inf.0

    1. Initial program 97.6%

      \[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. Step-by-step derivation
      1. fma-neg60.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 94.3% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 98.3%

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

    if 2.00000000000000007e282 < (*.f64 z z)

    1. Initial program 82.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 82.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot x - t \cdot \left(4 \cdot \left(y \cdot \left(\color{blue}{z} \cdot \frac{z}{t}\right) - y\right)\right) \]
      2. associate-*r*87.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. associate-*r/90.4%

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

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

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

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

Alternative 5: 94.1% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 98.3%

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

    if 5e287 < (*.f64 z z)

    1. Initial program 82.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 45.3% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;z \leq 1.8 \cdot 10^{-57}:\\
\;\;\;\;x \cdot x\\

\mathbf{elif}\;z \leq 3.5 \cdot 10^{+18}:\\
\;\;\;\;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 4 regimes
  2. if z < 3.0999999999999999e-200

    1. Initial program 94.8%

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

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

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

    if 3.0999999999999999e-200 < z < 1.8000000000000001e-57

    1. Initial program 100.0%

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

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

      \[\leadsto x \cdot x - \color{blue}{0} \]
    5. Step-by-step derivation
      1. --rgt-identity55.0%

        \[\leadsto \color{blue}{x \cdot x} \]
    6. Applied egg-rr55.0%

      \[\leadsto \color{blue}{x \cdot x} \]

    if 1.8000000000000001e-57 < z < 3.5e18

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

    if 3.5e18 < z

    1. Initial program 86.5%

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

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

        \[\leadsto \mathsf{fma}\left(x, x, \left(z \cdot z - t\right) \cdot \left(y \cdot \color{blue}{-4}\right)\right) \]
    3. Simplified88.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. Taylor expanded in z around inf 66.2%

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

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

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

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

        \[\leadsto \left(y \cdot -4\right) \cdot \color{blue}{\left(z \cdot z\right)} \]
    9. Applied egg-rr66.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 3.1 \cdot 10^{-200}:\\ \;\;\;\;y \cdot \left(t \cdot 4\right)\\ \mathbf{elif}\;z \leq 1.8 \cdot 10^{-57}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;z \leq 3.5 \cdot 10^{+18}:\\ \;\;\;\;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 7: 82.2% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{+120}:\\
\;\;\;\;x \cdot x - 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) < 5.00000000000000019e120

    1. Initial program 99.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 90.9%

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

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

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

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

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

    if 5.00000000000000019e120 < (*.f64 z z)

    1. Initial program 84.8%

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

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

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

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

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

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

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

        \[\leadsto \left(y \cdot -4\right) \cdot \color{blue}{\left(z \cdot z\right)} \]
    9. Applied egg-rr81.5%

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

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

Alternative 8: 59.3% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 0.00295:\\
\;\;\;\;y \cdot \left(t \cdot 4\right)\\

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


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

    1. Initial program 96.8%

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

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

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

    if 0.00294999999999999993 < (*.f64 x x)

    1. Initial program 91.2%

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

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

      \[\leadsto x \cdot x - \color{blue}{0} \]
    5. Step-by-step derivation
      1. --rgt-identity66.8%

        \[\leadsto \color{blue}{x \cdot x} \]
    6. Applied egg-rr66.8%

      \[\leadsto \color{blue}{x \cdot x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification58.6%

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

Alternative 9: 59.3% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 0.001:\\
\;\;\;\;4 \cdot \left(t \cdot y\right)\\

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


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

    1. Initial program 96.8%

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

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

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

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

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

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

    if 1e-3 < (*.f64 x x)

    1. Initial program 91.2%

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

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

      \[\leadsto x \cdot x - \color{blue}{0} \]
    5. Step-by-step derivation
      1. --rgt-identity66.8%

        \[\leadsto \color{blue}{x \cdot x} \]
    6. Applied egg-rr66.8%

      \[\leadsto \color{blue}{x \cdot x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification58.6%

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

Alternative 10: 40.7% accurate, 4.3× speedup?

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

\\
x \cdot x
\end{array}
Derivation
  1. Initial program 93.8%

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

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

    \[\leadsto x \cdot x - \color{blue}{0} \]
  5. Step-by-step derivation
    1. --rgt-identity41.8%

      \[\leadsto \color{blue}{x \cdot x} \]
  6. Applied egg-rr41.8%

    \[\leadsto \color{blue}{x \cdot x} \]
  7. Add Preprocessing

Developer Target 1: 90.9% 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 2024132 
(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))))