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

Percentage Accurate: 90.2% → 97.5%
Time: 13.6s
Alternatives: 10
Speedup: 0.9×

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.2% accurate, 1.0× speedup?

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

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

Alternative 1: 97.5% accurate, 0.1× speedup?

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

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

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


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

    1. Initial program 98.8%

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

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

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

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

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

    if 1.99999999999999995e195 < (*.f64 z z)

    1. Initial program 68.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 97.0% accurate, 0.1× speedup?

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

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

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


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

    1. Initial program 98.8%

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]

    if 1.99999999999999995e195 < (*.f64 z z)

    1. Initial program 68.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 77.4% accurate, 0.9× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < 2.70000000000000003e35

    1. Initial program 90.8%

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

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

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

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

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

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

    if 2.70000000000000003e35 < z < 4.9999999999999998e213

    1. Initial program 79.1%

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

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

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

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

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

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

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

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

    if 4.9999999999999998e213 < z

    1. Initial program 77.6%

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

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

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

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

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

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

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

        \[\leadsto -\color{blue}{\left(z \cdot z\right) \cdot \left(y \cdot 4\right)} \]
      7. associate-*l*95.4%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 2.7 \cdot 10^{+35}:\\ \;\;\;\;x \cdot x - t \cdot \left(y \cdot -4\right)\\ \mathbf{elif}\;z \leq 5 \cdot 10^{+213}:\\ \;\;\;\;x \cdot x - z \cdot \left(z \cdot \left(y \cdot 4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\ \end{array} \]

Alternative 4: 93.0% accurate, 0.9× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < 1.45999999999999998e103

    1. Initial program 91.2%

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]

    if 1.45999999999999998e103 < z < 2.59999999999999993e214

    1. Initial program 71.0%

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

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

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

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

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

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

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

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

    if 2.59999999999999993e214 < z

    1. Initial program 77.6%

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

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

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

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

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

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

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

        \[\leadsto -\color{blue}{\left(z \cdot z\right) \cdot \left(y \cdot 4\right)} \]
      7. associate-*l*95.4%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 1.46 \cdot 10^{+103}:\\ \;\;\;\;x \cdot x + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\ \mathbf{elif}\;z \leq 2.6 \cdot 10^{+214}:\\ \;\;\;\;x \cdot x - z \cdot \left(z \cdot \left(y \cdot 4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\ \end{array} \]

Alternative 5: 50.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := 4 \cdot \left(t \cdot y\right)\\ t_2 := z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\ \mathbf{if}\;x \leq 3.2 \cdot 10^{-201}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 2.5 \cdot 10^{-121}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 5.4 \cdot 10^{-83}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 13:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* 4.0 (* t y))) (t_2 (* z (* z (* y -4.0)))))
   (if (<= x 3.2e-201)
     t_2
     (if (<= x 2.5e-121)
       t_1
       (if (<= x 5.4e-83) t_2 (if (<= x 13.0) t_1 (* x x)))))))
double code(double x, double y, double z, double t) {
	double t_1 = 4.0 * (t * y);
	double t_2 = z * (z * (y * -4.0));
	double tmp;
	if (x <= 3.2e-201) {
		tmp = t_2;
	} else if (x <= 2.5e-121) {
		tmp = t_1;
	} else if (x <= 5.4e-83) {
		tmp = t_2;
	} else if (x <= 13.0) {
		tmp = t_1;
	} 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) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = 4.0d0 * (t * y)
    t_2 = z * (z * (y * (-4.0d0)))
    if (x <= 3.2d-201) then
        tmp = t_2
    else if (x <= 2.5d-121) then
        tmp = t_1
    else if (x <= 5.4d-83) then
        tmp = t_2
    else if (x <= 13.0d0) then
        tmp = t_1
    else
        tmp = x * x
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = 4.0 * (t * y);
	double t_2 = z * (z * (y * -4.0));
	double tmp;
	if (x <= 3.2e-201) {
		tmp = t_2;
	} else if (x <= 2.5e-121) {
		tmp = t_1;
	} else if (x <= 5.4e-83) {
		tmp = t_2;
	} else if (x <= 13.0) {
		tmp = t_1;
	} else {
		tmp = x * x;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = 4.0 * (t * y)
	t_2 = z * (z * (y * -4.0))
	tmp = 0
	if x <= 3.2e-201:
		tmp = t_2
	elif x <= 2.5e-121:
		tmp = t_1
	elif x <= 5.4e-83:
		tmp = t_2
	elif x <= 13.0:
		tmp = t_1
	else:
		tmp = x * x
	return tmp
function code(x, y, z, t)
	t_1 = Float64(4.0 * Float64(t * y))
	t_2 = Float64(z * Float64(z * Float64(y * -4.0)))
	tmp = 0.0
	if (x <= 3.2e-201)
		tmp = t_2;
	elseif (x <= 2.5e-121)
		tmp = t_1;
	elseif (x <= 5.4e-83)
		tmp = t_2;
	elseif (x <= 13.0)
		tmp = t_1;
	else
		tmp = Float64(x * x);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = 4.0 * (t * y);
	t_2 = z * (z * (y * -4.0));
	tmp = 0.0;
	if (x <= 3.2e-201)
		tmp = t_2;
	elseif (x <= 2.5e-121)
		tmp = t_1;
	elseif (x <= 5.4e-83)
		tmp = t_2;
	elseif (x <= 13.0)
		tmp = t_1;
	else
		tmp = x * x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(4.0 * N[(t * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(z * N[(z * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 3.2e-201], t$95$2, If[LessEqual[x, 2.5e-121], t$95$1, If[LessEqual[x, 5.4e-83], t$95$2, If[LessEqual[x, 13.0], t$95$1, N[(x * x), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := 4 \cdot \left(t \cdot y\right)\\
t_2 := z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\
\mathbf{if}\;x \leq 3.2 \cdot 10^{-201}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;x \leq 2.5 \cdot 10^{-121}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 5.4 \cdot 10^{-83}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;x \leq 13:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 3.2000000000000001e-201 or 2.49999999999999995e-121 < x < 5.39999999999999982e-83

    1. Initial program 89.2%

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

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

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

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

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

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

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

        \[\leadsto -\color{blue}{\left(z \cdot z\right) \cdot \left(y \cdot 4\right)} \]
      7. associate-*l*41.9%

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

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

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

        \[\leadsto z \cdot \left(z \cdot \color{blue}{\left(y \cdot \left(-4\right)\right)}\right) \]
      11. metadata-eval41.9%

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

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

    if 3.2000000000000001e-201 < x < 2.49999999999999995e-121 or 5.39999999999999982e-83 < x < 13

    1. Initial program 96.1%

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

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

    if 13 < x

    1. Initial program 81.8%

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

      \[\leadsto \color{blue}{{x}^{2}} \]
    3. Step-by-step derivation
      1. unpow280.2%

        \[\leadsto \color{blue}{x \cdot x} \]
    4. Simplified80.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 3.2 \cdot 10^{-201}:\\ \;\;\;\;z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\ \mathbf{elif}\;x \leq 2.5 \cdot 10^{-121}:\\ \;\;\;\;4 \cdot \left(t \cdot y\right)\\ \mathbf{elif}\;x \leq 5.4 \cdot 10^{-83}:\\ \;\;\;\;z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\ \mathbf{elif}\;x \leq 13:\\ \;\;\;\;4 \cdot \left(t \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]

Alternative 6: 80.4% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 94.7%

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

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

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

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

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

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

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

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

    if 1.52e115 < (*.f64 x x)

    1. Initial program 79.7%

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

      \[\leadsto \color{blue}{{x}^{2}} \]
    3. Step-by-step derivation
      1. unpow279.1%

        \[\leadsto \color{blue}{x \cdot x} \]
    4. Simplified79.1%

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

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

Alternative 7: 74.9% accurate, 1.2× speedup?

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

    1. Initial program 90.8%

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

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

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

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

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

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

    if 1.2e55 < z

    1. Initial program 78.5%

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

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

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

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

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

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

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

        \[\leadsto -\color{blue}{\left(z \cdot z\right) \cdot \left(y \cdot 4\right)} \]
      7. associate-*l*83.8%

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

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

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

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

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

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

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

Alternative 8: 48.4% accurate, 1.4× speedup?

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

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

\mathbf{elif}\;x \leq 14.2:\\
\;\;\;\;4 \cdot \left(t \cdot y\right)\\

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


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

    1. Initial program 89.3%

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

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

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

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

    if 1.3499999999999999e-202 < x < 14.199999999999999

    1. Initial program 94.0%

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

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

    if 14.199999999999999 < x

    1. Initial program 81.8%

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

      \[\leadsto \color{blue}{{x}^{2}} \]
    3. Step-by-step derivation
      1. unpow280.2%

        \[\leadsto \color{blue}{x \cdot x} \]
    4. Simplified80.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.35 \cdot 10^{-202}:\\ \;\;\;\;-4 \cdot \left(\left(z \cdot z\right) \cdot y\right)\\ \mathbf{elif}\;x \leq 14.2:\\ \;\;\;\;4 \cdot \left(t \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]

Alternative 9: 45.2% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 13.5:\\ \;\;\;\;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 13.5) (* 4.0 (* t y)) (* x x)))
double code(double x, double y, double z, double t) {
	double tmp;
	if (x <= 13.5) {
		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 <= 13.5d0) 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 <= 13.5) {
		tmp = 4.0 * (t * y);
	} else {
		tmp = x * x;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if x <= 13.5:
		tmp = 4.0 * (t * y)
	else:
		tmp = x * x
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (x <= 13.5)
		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 <= 13.5)
		tmp = 4.0 * (t * y);
	else
		tmp = x * x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[x, 13.5], N[(4.0 * N[(t * y), $MachinePrecision]), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 13.5:\\
\;\;\;\;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 x < 13.5

    1. Initial program 90.1%

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

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

    if 13.5 < x

    1. Initial program 81.8%

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

      \[\leadsto \color{blue}{{x}^{2}} \]
    3. Step-by-step derivation
      1. unpow280.2%

        \[\leadsto \color{blue}{x \cdot x} \]
    4. Simplified80.2%

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

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

Alternative 10: 41.1% 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 88.2%

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

    \[\leadsto \color{blue}{{x}^{2}} \]
  3. Step-by-step derivation
    1. unpow244.2%

      \[\leadsto \color{blue}{x \cdot x} \]
  4. Simplified44.2%

    \[\leadsto \color{blue}{x \cdot x} \]
  5. Final simplification44.2%

    \[\leadsto x \cdot x \]

Developer target: 90.2% accurate, 1.0× speedup?

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

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

Reproduce

?
herbie shell --seed 2023278 
(FPCore (x y z t)
  :name "Graphics.Rasterific.Shading:$sradialGradientWithFocusShader from Rasterific-0.6.1, B"
  :precision binary64

  :herbie-target
  (- (* x x) (* 4.0 (* y (- (* z z) t))))

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