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

Percentage Accurate: 89.9% → 93.6%
Time: 10.2s
Alternatives: 7
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 7 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: 89.9% accurate, 1.0× speedup?

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

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

Alternative 1: 93.6% accurate, 0.1× speedup?

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

\mathbf{else}:\\
\;\;\;\;x \cdot x - 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 < 7.6e195

    1. Initial program 94.0%

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

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

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

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

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

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

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

    if 7.6e195 < z

    1. Initial program 77.7%

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot x - \color{blue}{\frac{1}{\frac{1}{y \cdot 4}}} \cdot {\left(\sqrt[3]{{z}^{2}}\right)}^{3} \]
      2. rem-cube-cbrt77.7%

        \[\leadsto x \cdot x - \frac{1}{\frac{1}{y \cdot 4}} \cdot \color{blue}{{z}^{2}} \]
      3. associate-*l/77.7%

        \[\leadsto x \cdot x - \color{blue}{\frac{1 \cdot {z}^{2}}{\frac{1}{y \cdot 4}}} \]
      4. *-un-lft-identity77.7%

        \[\leadsto x \cdot x - \frac{\color{blue}{{z}^{2}}}{\frac{1}{y \cdot 4}} \]
      5. *-commutative77.7%

        \[\leadsto x \cdot x - \frac{{z}^{2}}{\frac{1}{\color{blue}{4 \cdot y}}} \]
      6. associate-/r*77.7%

        \[\leadsto x \cdot x - \frac{{z}^{2}}{\color{blue}{\frac{\frac{1}{4}}{y}}} \]
      7. metadata-eval77.7%

        \[\leadsto x \cdot x - \frac{{z}^{2}}{\frac{\color{blue}{0.25}}{y}} \]
    8. Applied egg-rr77.7%

      \[\leadsto x \cdot x - \color{blue}{\frac{{z}^{2}}{\frac{0.25}{y}}} \]
    9. Step-by-step derivation
      1. pow277.7%

        \[\leadsto x \cdot x - \frac{\color{blue}{z \cdot z}}{\frac{0.25}{y}} \]
      2. clear-num77.7%

        \[\leadsto x \cdot x - \color{blue}{\frac{1}{\frac{\frac{0.25}{y}}{z \cdot z}}} \]
      3. associate-/r/77.7%

        \[\leadsto x \cdot x - \color{blue}{\frac{1}{\frac{0.25}{y}} \cdot \left(z \cdot z\right)} \]
      4. clear-num77.7%

        \[\leadsto x \cdot x - \color{blue}{\frac{y}{0.25}} \cdot \left(z \cdot z\right) \]
      5. div-inv77.7%

        \[\leadsto x \cdot x - \color{blue}{\left(y \cdot \frac{1}{0.25}\right)} \cdot \left(z \cdot z\right) \]
      6. metadata-eval77.7%

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

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

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

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

Alternative 2: 84.1% accurate, 0.9× speedup?

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

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


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

    1. Initial program 99.1%

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

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

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

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

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

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

    if 1.6e21 < (*.f64 z z)

    1. Initial program 86.8%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 89.7% accurate, 0.9× speedup?

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

\mathbf{else}:\\
\;\;\;\;x \cdot x - 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) < 1e20

    1. Initial program 99.1%

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

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

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

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

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

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

    if 1e20 < (*.f64 z z)

    1. Initial program 86.8%

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot x - \color{blue}{\frac{1}{\frac{1}{y \cdot 4}}} \cdot {\left(\sqrt[3]{{z}^{2}}\right)}^{3} \]
      2. rem-cube-cbrt82.5%

        \[\leadsto x \cdot x - \frac{1}{\frac{1}{y \cdot 4}} \cdot \color{blue}{{z}^{2}} \]
      3. associate-*l/82.5%

        \[\leadsto x \cdot x - \color{blue}{\frac{1 \cdot {z}^{2}}{\frac{1}{y \cdot 4}}} \]
      4. *-un-lft-identity82.5%

        \[\leadsto x \cdot x - \frac{\color{blue}{{z}^{2}}}{\frac{1}{y \cdot 4}} \]
      5. *-commutative82.5%

        \[\leadsto x \cdot x - \frac{{z}^{2}}{\frac{1}{\color{blue}{4 \cdot y}}} \]
      6. associate-/r*82.5%

        \[\leadsto x \cdot x - \frac{{z}^{2}}{\color{blue}{\frac{\frac{1}{4}}{y}}} \]
      7. metadata-eval82.5%

        \[\leadsto x \cdot x - \frac{{z}^{2}}{\frac{\color{blue}{0.25}}{y}} \]
    8. Applied egg-rr82.5%

      \[\leadsto x \cdot x - \color{blue}{\frac{{z}^{2}}{\frac{0.25}{y}}} \]
    9. Step-by-step derivation
      1. pow282.5%

        \[\leadsto x \cdot x - \frac{\color{blue}{z \cdot z}}{\frac{0.25}{y}} \]
      2. clear-num82.5%

        \[\leadsto x \cdot x - \color{blue}{\frac{1}{\frac{\frac{0.25}{y}}{z \cdot z}}} \]
      3. associate-/r/82.5%

        \[\leadsto x \cdot x - \color{blue}{\frac{1}{\frac{0.25}{y}} \cdot \left(z \cdot z\right)} \]
      4. clear-num82.5%

        \[\leadsto x \cdot x - \color{blue}{\frac{y}{0.25}} \cdot \left(z \cdot z\right) \]
      5. div-inv82.5%

        \[\leadsto x \cdot x - \color{blue}{\left(y \cdot \frac{1}{0.25}\right)} \cdot \left(z \cdot z\right) \]
      6. metadata-eval82.5%

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

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

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

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

Alternative 4: 95.1% accurate, 0.9× speedup?

\[\begin{array}{l} z = |z|\\ \\ \begin{array}{l} \mathbf{if}\;z \leq 1.45 \cdot 10^{+104}:\\ \;\;\;\;x \cdot x + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x - z \cdot \left(z \cdot \left(y \cdot 4\right)\right)\\ \end{array} \end{array} \]
NOTE: z should be positive before calling this function
(FPCore (x y z t)
 :precision binary64
 (if (<= z 1.45e+104)
   (+ (* x x) (* (* y 4.0) (- t (* z z))))
   (- (* x x) (* z (* z (* y 4.0))))))
z = abs(z);
double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= 1.45e+104) {
		tmp = (x * x) + ((y * 4.0) * (t - (z * z)));
	} else {
		tmp = (x * x) - (z * (z * (y * 4.0)));
	}
	return tmp;
}
NOTE: z should be positive before calling this function
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.45d+104) then
        tmp = (x * x) + ((y * 4.0d0) * (t - (z * z)))
    else
        tmp = (x * x) - (z * (z * (y * 4.0d0)))
    end if
    code = tmp
end function
z = Math.abs(z);
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= 1.45e+104) {
		tmp = (x * x) + ((y * 4.0) * (t - (z * z)));
	} else {
		tmp = (x * x) - (z * (z * (y * 4.0)));
	}
	return tmp;
}
z = abs(z)
def code(x, y, z, t):
	tmp = 0
	if z <= 1.45e+104:
		tmp = (x * x) + ((y * 4.0) * (t - (z * z)))
	else:
		tmp = (x * x) - (z * (z * (y * 4.0)))
	return tmp
z = abs(z)
function code(x, y, z, t)
	tmp = 0.0
	if (z <= 1.45e+104)
		tmp = Float64(Float64(x * x) + Float64(Float64(y * 4.0) * Float64(t - Float64(z * z))));
	else
		tmp = Float64(Float64(x * x) - Float64(z * Float64(z * Float64(y * 4.0))));
	end
	return tmp
end
z = abs(z)
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (z <= 1.45e+104)
		tmp = (x * x) + ((y * 4.0) * (t - (z * z)));
	else
		tmp = (x * x) - (z * (z * (y * 4.0)));
	end
	tmp_2 = tmp;
end
NOTE: z should be positive before calling this function
code[x_, y_, z_, t_] := If[LessEqual[z, 1.45e+104], N[(N[(x * x), $MachinePrecision] + N[(N[(y * 4.0), $MachinePrecision] * N[(t - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] - N[(z * N[(z * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z = |z|\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.45 \cdot 10^{+104}:\\
\;\;\;\;x \cdot x + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\

\mathbf{else}:\\
\;\;\;\;x \cdot x - 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.4499999999999999e104

    1. Initial program 95.3%

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

    if 1.4499999999999999e104 < z

    1. Initial program 80.1%

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot x - \color{blue}{\frac{1}{\frac{1}{y \cdot 4}}} \cdot {\left(\sqrt[3]{{z}^{2}}\right)}^{3} \]
      2. rem-cube-cbrt80.1%

        \[\leadsto x \cdot x - \frac{1}{\frac{1}{y \cdot 4}} \cdot \color{blue}{{z}^{2}} \]
      3. associate-*l/80.2%

        \[\leadsto x \cdot x - \color{blue}{\frac{1 \cdot {z}^{2}}{\frac{1}{y \cdot 4}}} \]
      4. *-un-lft-identity80.2%

        \[\leadsto x \cdot x - \frac{\color{blue}{{z}^{2}}}{\frac{1}{y \cdot 4}} \]
      5. *-commutative80.2%

        \[\leadsto x \cdot x - \frac{{z}^{2}}{\frac{1}{\color{blue}{4 \cdot y}}} \]
      6. associate-/r*80.2%

        \[\leadsto x \cdot x - \frac{{z}^{2}}{\color{blue}{\frac{\frac{1}{4}}{y}}} \]
      7. metadata-eval80.2%

        \[\leadsto x \cdot x - \frac{{z}^{2}}{\frac{\color{blue}{0.25}}{y}} \]
    8. Applied egg-rr80.2%

      \[\leadsto x \cdot x - \color{blue}{\frac{{z}^{2}}{\frac{0.25}{y}}} \]
    9. Step-by-step derivation
      1. pow280.2%

        \[\leadsto x \cdot x - \frac{\color{blue}{z \cdot z}}{\frac{0.25}{y}} \]
      2. clear-num80.2%

        \[\leadsto x \cdot x - \color{blue}{\frac{1}{\frac{\frac{0.25}{y}}{z \cdot z}}} \]
      3. associate-/r/80.1%

        \[\leadsto x \cdot x - \color{blue}{\frac{1}{\frac{0.25}{y}} \cdot \left(z \cdot z\right)} \]
      4. clear-num80.1%

        \[\leadsto x \cdot x - \color{blue}{\frac{y}{0.25}} \cdot \left(z \cdot z\right) \]
      5. div-inv80.1%

        \[\leadsto x \cdot x - \color{blue}{\left(y \cdot \frac{1}{0.25}\right)} \cdot \left(z \cdot z\right) \]
      6. metadata-eval80.1%

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

        \[\leadsto x \cdot x - \color{blue}{\left(\left(y \cdot 4\right) \cdot z\right) \cdot z} \]
    10. Applied egg-rr86.6%

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

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

Alternative 5: 66.8% accurate, 1.4× speedup?

\[\begin{array}{l} z = |z|\\ \\ x \cdot x - y \cdot \left(t \cdot -4\right) \end{array} \]
NOTE: z should be positive before calling this function
(FPCore (x y z t) :precision binary64 (- (* x x) (* y (* t -4.0))))
z = abs(z);
double code(double x, double y, double z, double t) {
	return (x * x) - (y * (t * -4.0));
}
NOTE: z should be positive before calling this function
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = (x * x) - (y * (t * (-4.0d0)))
end function
z = Math.abs(z);
public static double code(double x, double y, double z, double t) {
	return (x * x) - (y * (t * -4.0));
}
z = abs(z)
def code(x, y, z, t):
	return (x * x) - (y * (t * -4.0))
z = abs(z)
function code(x, y, z, t)
	return Float64(Float64(x * x) - Float64(y * Float64(t * -4.0)))
end
z = abs(z)
function tmp = code(x, y, z, t)
	tmp = (x * x) - (y * (t * -4.0));
end
NOTE: z should be positive before calling this function
code[x_, y_, z_, t_] := N[(N[(x * x), $MachinePrecision] - N[(y * N[(t * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z = |z|\\
\\
x \cdot x - y \cdot \left(t \cdot -4\right)
\end{array}
Derivation
  1. Initial program 92.6%

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

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

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

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

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

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

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

Alternative 6: 31.5% accurate, 2.6× speedup?

\[\begin{array}{l} z = |z|\\ \\ 4 \cdot \left(t \cdot y\right) \end{array} \]
NOTE: z should be positive before calling this function
(FPCore (x y z t) :precision binary64 (* 4.0 (* t y)))
z = abs(z);
double code(double x, double y, double z, double t) {
	return 4.0 * (t * y);
}
NOTE: z should be positive before calling this function
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 = 4.0d0 * (t * y)
end function
z = Math.abs(z);
public static double code(double x, double y, double z, double t) {
	return 4.0 * (t * y);
}
z = abs(z)
def code(x, y, z, t):
	return 4.0 * (t * y)
z = abs(z)
function code(x, y, z, t)
	return Float64(4.0 * Float64(t * y))
end
z = abs(z)
function tmp = code(x, y, z, t)
	tmp = 4.0 * (t * y);
end
NOTE: z should be positive before calling this function
code[x_, y_, z_, t_] := N[(4.0 * N[(t * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z = |z|\\
\\
4 \cdot \left(t \cdot y\right)
\end{array}
Derivation
  1. Initial program 92.6%

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

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

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

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

    \[\leadsto 4 \cdot \left(t \cdot y\right) \]

Alternative 7: 31.4% accurate, 2.6× speedup?

\[\begin{array}{l} z = |z|\\ \\ y \cdot \left(t \cdot 4\right) \end{array} \]
NOTE: z should be positive before calling this function
(FPCore (x y z t) :precision binary64 (* y (* t 4.0)))
z = abs(z);
double code(double x, double y, double z, double t) {
	return y * (t * 4.0);
}
NOTE: z should be positive before calling this function
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = y * (t * 4.0d0)
end function
z = Math.abs(z);
public static double code(double x, double y, double z, double t) {
	return y * (t * 4.0);
}
z = abs(z)
def code(x, y, z, t):
	return y * (t * 4.0)
z = abs(z)
function code(x, y, z, t)
	return Float64(y * Float64(t * 4.0))
end
z = abs(z)
function tmp = code(x, y, z, t)
	tmp = y * (t * 4.0);
end
NOTE: z should be positive before calling this function
code[x_, y_, z_, t_] := N[(y * N[(t * 4.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z = |z|\\
\\
y \cdot \left(t \cdot 4\right)
\end{array}
Derivation
  1. Initial program 92.6%

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

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

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

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

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

    \[\leadsto y \cdot \left(t \cdot 4\right) \]

Developer target: 89.9% accurate, 1.0× speedup?

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

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

Reproduce

?
herbie shell --seed 2023306 
(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))))