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

Percentage Accurate: 90.5% → 93.4%
Time: 10.8s
Alternatives: 7
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 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: 90.5% 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.4% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 94.2%

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

    if 3.9999999999999998e298 < (*.f64 x x)

    1. Initial program 87.7%

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

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

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

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

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

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

Alternative 2: 92.8% accurate, 0.1× speedup?

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

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

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

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

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

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

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

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

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

Alternative 3: 44.1% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_1 := 4 \cdot \left(t \cdot y\right)\\
\mathbf{if}\;z \leq 6.5 \cdot 10^{-276}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq 5.8 \cdot 10^{-109}:\\
\;\;\;\;x \cdot x\\

\mathbf{elif}\;z \leq 5.8 \cdot 10^{+44}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < 6.49999999999999981e-276 or 5.8e-109 < z < 5.8000000000000004e44

    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. fmm-def95.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-in95.2%

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

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

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

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

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

    if 6.49999999999999981e-276 < z < 5.8e-109

    1. Initial program 97.3%

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

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

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

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

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

    if 5.8000000000000004e44 < z

    1. Initial program 85.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 81.6% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 98.8%

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

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

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

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

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

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

    if 7.5000000000000004e158 < (*.f64 z z)

    1. Initial program 80.5%

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 46.0% accurate, 1.3× speedup?

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

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

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


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

    1. Initial program 93.8%

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutative93.8%

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot x - \left(z \cdot z - t\right) \cdot \color{blue}{\left(y \cdot -4\right)} \]
      10. add-cube-cbrt29.8%

        \[\leadsto x \cdot x - \color{blue}{\left(\sqrt[3]{\left(z \cdot z - t\right) \cdot \left(y \cdot -4\right)} \cdot \sqrt[3]{\left(z \cdot z - t\right) \cdot \left(y \cdot -4\right)}\right) \cdot \sqrt[3]{\left(z \cdot z - t\right) \cdot \left(y \cdot -4\right)}} \]
      11. pow329.8%

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

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

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(--4\right)} \cdot t\right) \cdot y \]
      6. distribute-lft-neg-in33.5%

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

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

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

        \[\leadsto \color{blue}{y \cdot \left(--4 \cdot t\right)} \]
      10. distribute-lft-neg-in33.5%

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

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

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

    if 2.60000000000000007e54 < x

    1. Initial program 86.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 86.8%

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

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

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

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

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

Alternative 6: 46.0% accurate, 1.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.8 \cdot 10^{+54}:\\
\;\;\;\;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 < 1.8000000000000001e54

    1. Initial program 93.8%

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

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

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

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

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

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

    if 1.8000000000000001e54 < x

    1. Initial program 86.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 86.8%

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

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

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

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

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

Alternative 7: 41.6% 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 92.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 92.8%

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

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

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

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

Developer Target 1: 90.6% 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 2024184 
(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))))