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

Percentage Accurate: 90.7% → 96.3%
Time: 11.8s
Alternatives: 8
Speedup: 0.6×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 8 alternatives:

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

Initial Program: 90.7% accurate, 1.0× speedup?

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

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

Alternative 1: 96.3% accurate, 0.1× speedup?

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

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

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


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

    1. Initial program 98.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.00000000000000003e282 < (*.f64 z z)

    1. Initial program 71.4%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(\sqrt[3]{y \cdot \left(-4 \cdot {z}^{2}\right)}\right)}^{3}} \]
    10. Step-by-step derivation
      1. rem-cube-cbrt79.2%

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

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

        \[\leadsto \left(y \cdot \color{blue}{\left(-4\right)}\right) \cdot {z}^{2} \]
      4. distribute-rgt-neg-in79.2%

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

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

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

        \[\leadsto \left(\color{blue}{\left(y \cdot \left(-4\right)\right)} \cdot z\right) \cdot z \]
      8. metadata-eval92.1%

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

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

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

Alternative 2: 95.6% accurate, 0.1× speedup?

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

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

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


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

    1. Initial program 98.9%

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

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

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

    if 1.00000000000000003e282 < (*.f64 z z)

    1. Initial program 71.4%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(\sqrt[3]{y \cdot \left(-4 \cdot {z}^{2}\right)}\right)}^{3}} \]
    10. Step-by-step derivation
      1. rem-cube-cbrt79.2%

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

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

        \[\leadsto \left(y \cdot \color{blue}{\left(-4\right)}\right) \cdot {z}^{2} \]
      4. distribute-rgt-neg-in79.2%

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

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

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

        \[\leadsto \left(\color{blue}{\left(y \cdot \left(-4\right)\right)} \cdot z\right) \cdot z \]
      8. metadata-eval92.1%

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

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

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

Alternative 3: 95.2% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 98.9%

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

    if 1.00000000000000003e282 < (*.f64 z z)

    1. Initial program 71.4%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(\sqrt[3]{y \cdot \left(-4 \cdot {z}^{2}\right)}\right)}^{3}} \]
    10. Step-by-step derivation
      1. rem-cube-cbrt79.2%

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

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

        \[\leadsto \left(y \cdot \color{blue}{\left(-4\right)}\right) \cdot {z}^{2} \]
      4. distribute-rgt-neg-in79.2%

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

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

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

        \[\leadsto \left(\color{blue}{\left(y \cdot \left(-4\right)\right)} \cdot z\right) \cdot z \]
      8. metadata-eval92.1%

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

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

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

Alternative 4: 80.5% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 96.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 96.3%

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

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

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

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

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

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

        \[\leadsto -1 \cdot \left(\left(y \cdot 4\right) \cdot \color{blue}{\left(z \cdot z\right)}\right) + -1 \cdot \left(-4 \cdot \left(t \cdot y\right)\right) \]
      6. add-sqr-sqrt36.9%

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

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

        \[\leadsto \color{blue}{\left(-1 \cdot \left(y \cdot 4\right)\right) \cdot \left(\left(z \cdot \sqrt{z}\right) \cdot \sqrt{z}\right)} + -1 \cdot \left(-4 \cdot \left(t \cdot y\right)\right) \]
      9. neg-mul-137.0%

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

        \[\leadsto \color{blue}{\left(y \cdot \left(-4\right)\right)} \cdot \left(\left(z \cdot \sqrt{z}\right) \cdot \sqrt{z}\right) + -1 \cdot \left(-4 \cdot \left(t \cdot y\right)\right) \]
      11. metadata-eval37.0%

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

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

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

        \[\leadsto y \cdot \left(\color{blue}{\left(z \cdot \left(\sqrt{z} \cdot \sqrt{z}\right)\right)} \cdot -4\right) + -1 \cdot \left(-4 \cdot \left(t \cdot y\right)\right) \]
      15. add-sqr-sqrt87.9%

        \[\leadsto y \cdot \left(\left(z \cdot \color{blue}{z}\right) \cdot -4\right) + -1 \cdot \left(-4 \cdot \left(t \cdot y\right)\right) \]
      16. unpow287.9%

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

        \[\leadsto y \cdot \left({z}^{2} \cdot -4\right) + \color{blue}{\left(-1 \cdot -4\right) \cdot \left(t \cdot y\right)} \]
    6. Applied egg-rr87.9%

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

        \[\leadsto y \cdot \left(\color{blue}{\left(z \cdot z\right)} \cdot -4\right) + 4 \cdot \left(y \cdot t\right) \]
    8. Applied egg-rr87.9%

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

    if 1.3e74 < (*.f64 x x)

    1. Initial program 88.7%

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

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

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

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

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

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

Alternative 5: 46.1% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;x \leq 1.2 \cdot 10^{+37}:\\
\;\;\;\;z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 1.14999999999999998e-82

    1. Initial program 95.0%

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

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

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

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

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

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

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

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

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

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

    if 1.14999999999999998e-82 < x < 1.2e37

    1. Initial program 92.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(\sqrt[3]{y \cdot \left(-4 \cdot {z}^{2}\right)}\right)}^{3}} \]
    10. Step-by-step derivation
      1. rem-cube-cbrt53.0%

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

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

        \[\leadsto \left(y \cdot \color{blue}{\left(-4\right)}\right) \cdot {z}^{2} \]
      4. distribute-rgt-neg-in53.0%

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

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

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

        \[\leadsto \left(\color{blue}{\left(y \cdot \left(-4\right)\right)} \cdot z\right) \cdot z \]
      8. metadata-eval60.3%

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

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

    if 1.2e37 < x

    1. Initial program 88.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 88.8%

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

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

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

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

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

Alternative 6: 76.2% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq 10^{+64}:\\ \;\;\;\;x \cdot x - y \cdot \left(t \cdot -4\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= z 1e+64) (- (* 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 <= 1e+64) {
		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 <= 1d+64) 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 <= 1e+64) {
		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 <= 1e+64:
		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 (z <= 1e+64)
		tmp = Float64(Float64(x * x) - Float64(y * Float64(t * -4.0)));
	else
		tmp = Float64(z * Float64(z * Float64(y * -4.0)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (z <= 1e+64)
		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[z, 1e+64], N[(N[(x * x), $MachinePrecision] - N[(y * N[(t * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(z * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

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

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

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

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

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

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

    if 1.00000000000000002e64 < 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. fma-neg86.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-in86.9%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(\sqrt[3]{y \cdot \left(-4 \cdot {z}^{2}\right)}\right)}^{3}} \]
    10. Step-by-step derivation
      1. rem-cube-cbrt74.6%

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

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

        \[\leadsto \left(y \cdot \color{blue}{\left(-4\right)}\right) \cdot {z}^{2} \]
      4. distribute-rgt-neg-in74.6%

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

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

        \[\leadsto \color{blue}{\left(\left(-y \cdot 4\right) \cdot z\right) \cdot z} \]
      7. distribute-rgt-neg-in78.7%

        \[\leadsto \left(\color{blue}{\left(y \cdot \left(-4\right)\right)} \cdot z\right) \cdot z \]
      8. metadata-eval78.7%

        \[\leadsto \left(\left(y \cdot \color{blue}{-4}\right) \cdot z\right) \cdot z \]
    11. Applied egg-rr78.7%

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

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

Alternative 7: 45.4% accurate, 1.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 7.8 \cdot 10^{+17}:\\
\;\;\;\;4 \cdot \left(y \cdot t\right)\\

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


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

    1. Initial program 94.5%

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

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

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

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

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

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

    if 7.8e17 < x

    1. Initial program 89.9%

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

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

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

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

      \[\leadsto \color{blue}{x \cdot x} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 8: 40.8% 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.5%

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

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

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

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

Developer Target 1: 90.8% 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 2024145 
(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))))