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

Percentage Accurate: 90.7% → 93.9%
Time: 11.4s
Alternatives: 8
Speedup: 0.4×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 8 alternatives:

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

Initial Program: 90.7% accurate, 1.0× speedup?

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

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

Alternative 1: 93.9% accurate, 0.1× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} \mathbf{if}\;x\_m \leq 2 \cdot 10^{+240}:\\ \;\;\;\;\mathsf{fma}\left(x\_m, x\_m, \left(z \cdot z - t\right) \cdot \left(y \cdot -4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;{x\_m}^{2}\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m y z t)
 :precision binary64
 (if (<= x_m 2e+240) (fma x_m x_m (* (- (* z z) t) (* y -4.0))) (pow x_m 2.0)))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
	double tmp;
	if (x_m <= 2e+240) {
		tmp = fma(x_m, x_m, (((z * z) - t) * (y * -4.0)));
	} else {
		tmp = pow(x_m, 2.0);
	}
	return tmp;
}
x_m = abs(x)
function code(x_m, y, z, t)
	tmp = 0.0
	if (x_m <= 2e+240)
		tmp = fma(x_m, x_m, Float64(Float64(Float64(z * z) - t) * Float64(y * -4.0)));
	else
		tmp = x_m ^ 2.0;
	end
	return tmp
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_, z_, t_] := If[LessEqual[x$95$m, 2e+240], N[(x$95$m * x$95$m + N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[x$95$m, 2.0], $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|

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

\mathbf{else}:\\
\;\;\;\;{x\_m}^{2}\\


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

    1. Initial program 92.9%

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

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

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

    if 2.00000000000000003e240 < x

    1. Initial program 78.3%

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

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

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

Alternative 2: 91.8% accurate, 0.1× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \mathsf{fma}\left(y \cdot 4, \mathsf{fma}\left(z, -z, t\right), x\_m \cdot x\_m\right) \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m y z t)
 :precision binary64
 (fma (* y 4.0) (fma z (- z) t) (* x_m x_m)))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
	return fma((y * 4.0), fma(z, -z, t), (x_m * x_m));
}
x_m = abs(x)
function code(x_m, y, z, t)
	return fma(Float64(y * 4.0), fma(z, Float64(-z), t), Float64(x_m * x_m))
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_, z_, t_] := N[(N[(y * 4.0), $MachinePrecision] * N[(z * (-z) + t), $MachinePrecision] + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(y \cdot 4, \color{blue}{0 - \left(z \cdot z - t\right)}, x \cdot x\right) \]
    9. associate-+l-93.6%

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

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

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

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

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

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

Alternative 3: 93.4% accurate, 0.1× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} t_1 := x\_m \cdot x\_m + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\ \mathbf{if}\;t\_1 \leq \infty:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;{x\_m}^{2}\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m y z t)
 :precision binary64
 (let* ((t_1 (+ (* x_m x_m) (* (* y 4.0) (- t (* z z))))))
   (if (<= t_1 INFINITY) t_1 (pow x_m 2.0))))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
	double t_1 = (x_m * x_m) + ((y * 4.0) * (t - (z * z)));
	double tmp;
	if (t_1 <= ((double) INFINITY)) {
		tmp = t_1;
	} else {
		tmp = pow(x_m, 2.0);
	}
	return tmp;
}
x_m = Math.abs(x);
public static double code(double x_m, double y, double z, double t) {
	double t_1 = (x_m * x_m) + ((y * 4.0) * (t - (z * z)));
	double tmp;
	if (t_1 <= Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else {
		tmp = Math.pow(x_m, 2.0);
	}
	return tmp;
}
x_m = math.fabs(x)
def code(x_m, y, z, t):
	t_1 = (x_m * x_m) + ((y * 4.0) * (t - (z * z)))
	tmp = 0
	if t_1 <= math.inf:
		tmp = t_1
	else:
		tmp = math.pow(x_m, 2.0)
	return tmp
x_m = abs(x)
function code(x_m, y, z, t)
	t_1 = Float64(Float64(x_m * x_m) + Float64(Float64(y * 4.0) * Float64(t - Float64(z * z))))
	tmp = 0.0
	if (t_1 <= Inf)
		tmp = t_1;
	else
		tmp = x_m ^ 2.0;
	end
	return tmp
end
x_m = abs(x);
function tmp_2 = code(x_m, y, z, t)
	t_1 = (x_m * x_m) + ((y * 4.0) * (t - (z * z)));
	tmp = 0.0;
	if (t_1 <= Inf)
		tmp = t_1;
	else
		tmp = x_m ^ 2.0;
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x$95$m * x$95$m), $MachinePrecision] + N[(N[(y * 4.0), $MachinePrecision] * N[(t - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], t$95$1, N[Power[x$95$m, 2.0], $MachinePrecision]]]
\begin{array}{l}
x_m = \left|x\right|

\\
\begin{array}{l}
t_1 := x\_m \cdot x\_m + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\
\mathbf{if}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1\\

\mathbf{else}:\\
\;\;\;\;{x\_m}^{2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (*.f64 x x) (*.f64 (*.f64 y #s(literal 4 binary64)) (-.f64 (*.f64 z z) t))) < +inf.0

    1. Initial program 95.3%

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

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

    1. Initial program 0.0%

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

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

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

Alternative 4: 91.8% accurate, 0.1× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \mathsf{fma}\left(y \cdot 4, t - z \cdot z, x\_m \cdot x\_m\right) \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m y z t)
 :precision binary64
 (fma (* y 4.0) (- t (* z z)) (* x_m x_m)))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
	return fma((y * 4.0), (t - (z * z)), (x_m * x_m));
}
x_m = abs(x)
function code(x_m, y, z, t)
	return fma(Float64(y * 4.0), Float64(t - Float64(z * z)), Float64(x_m * x_m))
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_, z_, t_] := N[(N[(y * 4.0), $MachinePrecision] * N[(t - N[(z * z), $MachinePrecision]), $MachinePrecision] + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 80.9% accurate, 0.4× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} \mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+22} \lor \neg \left(z \cdot z \leq 5 \cdot 10^{+38}\right) \land z \cdot z \leq 2 \cdot 10^{+225}:\\ \;\;\;\;x\_m \cdot x\_m - y \cdot \left(t \cdot -4\right)\\ \mathbf{else}:\\ \;\;\;\;\left(z \cdot z\right) \cdot \left(y \cdot -4\right)\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m y z t)
 :precision binary64
 (if (or (<= (* z z) 2e+22) (and (not (<= (* z z) 5e+38)) (<= (* z z) 2e+225)))
   (- (* x_m x_m) (* y (* t -4.0)))
   (* (* z z) (* y -4.0))))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
	double tmp;
	if (((z * z) <= 2e+22) || (!((z * z) <= 5e+38) && ((z * z) <= 2e+225))) {
		tmp = (x_m * x_m) - (y * (t * -4.0));
	} else {
		tmp = (z * z) * (y * -4.0);
	}
	return tmp;
}
x_m = abs(x)
real(8) function code(x_m, y, z, t)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (((z * z) <= 2d+22) .or. (.not. ((z * z) <= 5d+38)) .and. ((z * z) <= 2d+225)) then
        tmp = (x_m * x_m) - (y * (t * (-4.0d0)))
    else
        tmp = (z * z) * (y * (-4.0d0))
    end if
    code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y, double z, double t) {
	double tmp;
	if (((z * z) <= 2e+22) || (!((z * z) <= 5e+38) && ((z * z) <= 2e+225))) {
		tmp = (x_m * x_m) - (y * (t * -4.0));
	} else {
		tmp = (z * z) * (y * -4.0);
	}
	return tmp;
}
x_m = math.fabs(x)
def code(x_m, y, z, t):
	tmp = 0
	if ((z * z) <= 2e+22) or (not ((z * z) <= 5e+38) and ((z * z) <= 2e+225)):
		tmp = (x_m * x_m) - (y * (t * -4.0))
	else:
		tmp = (z * z) * (y * -4.0)
	return tmp
x_m = abs(x)
function code(x_m, y, z, t)
	tmp = 0.0
	if ((Float64(z * z) <= 2e+22) || (!(Float64(z * z) <= 5e+38) && (Float64(z * z) <= 2e+225)))
		tmp = Float64(Float64(x_m * x_m) - Float64(y * Float64(t * -4.0)));
	else
		tmp = Float64(Float64(z * z) * Float64(y * -4.0));
	end
	return tmp
end
x_m = abs(x);
function tmp_2 = code(x_m, y, z, t)
	tmp = 0.0;
	if (((z * z) <= 2e+22) || (~(((z * z) <= 5e+38)) && ((z * z) <= 2e+225)))
		tmp = (x_m * x_m) - (y * (t * -4.0));
	else
		tmp = (z * z) * (y * -4.0);
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_, z_, t_] := If[Or[LessEqual[N[(z * z), $MachinePrecision], 2e+22], And[N[Not[LessEqual[N[(z * z), $MachinePrecision], 5e+38]], $MachinePrecision], LessEqual[N[(z * z), $MachinePrecision], 2e+225]]], N[(N[(x$95$m * x$95$m), $MachinePrecision] - N[(y * N[(t * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z * z), $MachinePrecision] * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|

\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+22} \lor \neg \left(z \cdot z \leq 5 \cdot 10^{+38}\right) \land z \cdot z \leq 2 \cdot 10^{+225}:\\
\;\;\;\;x\_m \cdot x\_m - 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) < 2e22 or 4.9999999999999997e38 < (*.f64 z z) < 1.99999999999999986e225

    1. Initial program 98.2%

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

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

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

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

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

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

    if 2e22 < (*.f64 z z) < 4.9999999999999997e38 or 1.99999999999999986e225 < (*.f64 z z)

    1. Initial program 78.2%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+22} \lor \neg \left(z \cdot z \leq 5 \cdot 10^{+38}\right) \land z \cdot z \leq 2 \cdot 10^{+225}:\\ \;\;\;\;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 6: 92.7% accurate, 0.4× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} t_1 := x\_m \cdot x\_m + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\ \mathbf{if}\;t\_1 \leq \infty:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;x\_m \cdot x\_m - y \cdot \left(t \cdot -4\right)\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m y z t)
 :precision binary64
 (let* ((t_1 (+ (* x_m x_m) (* (* y 4.0) (- t (* z z))))))
   (if (<= t_1 INFINITY) t_1 (- (* x_m x_m) (* y (* t -4.0))))))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
	double t_1 = (x_m * x_m) + ((y * 4.0) * (t - (z * z)));
	double tmp;
	if (t_1 <= ((double) INFINITY)) {
		tmp = t_1;
	} else {
		tmp = (x_m * x_m) - (y * (t * -4.0));
	}
	return tmp;
}
x_m = Math.abs(x);
public static double code(double x_m, double y, double z, double t) {
	double t_1 = (x_m * x_m) + ((y * 4.0) * (t - (z * z)));
	double tmp;
	if (t_1 <= Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else {
		tmp = (x_m * x_m) - (y * (t * -4.0));
	}
	return tmp;
}
x_m = math.fabs(x)
def code(x_m, y, z, t):
	t_1 = (x_m * x_m) + ((y * 4.0) * (t - (z * z)))
	tmp = 0
	if t_1 <= math.inf:
		tmp = t_1
	else:
		tmp = (x_m * x_m) - (y * (t * -4.0))
	return tmp
x_m = abs(x)
function code(x_m, y, z, t)
	t_1 = Float64(Float64(x_m * x_m) + Float64(Float64(y * 4.0) * Float64(t - Float64(z * z))))
	tmp = 0.0
	if (t_1 <= Inf)
		tmp = t_1;
	else
		tmp = Float64(Float64(x_m * x_m) - Float64(y * Float64(t * -4.0)));
	end
	return tmp
end
x_m = abs(x);
function tmp_2 = code(x_m, y, z, t)
	t_1 = (x_m * x_m) + ((y * 4.0) * (t - (z * z)));
	tmp = 0.0;
	if (t_1 <= Inf)
		tmp = t_1;
	else
		tmp = (x_m * x_m) - (y * (t * -4.0));
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x$95$m * x$95$m), $MachinePrecision] + N[(N[(y * 4.0), $MachinePrecision] * N[(t - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], t$95$1, N[(N[(x$95$m * x$95$m), $MachinePrecision] - N[(y * N[(t * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x_m = \left|x\right|

\\
\begin{array}{l}
t_1 := x\_m \cdot x\_m + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\
\mathbf{if}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (*.f64 x x) (*.f64 (*.f64 y #s(literal 4 binary64)) (-.f64 (*.f64 z z) t))) < +inf.0

    1. Initial program 95.3%

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

Alternative 7: 56.3% accurate, 0.9× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} \mathbf{if}\;z \cdot z \leq 2050000000:\\ \;\;\;\;4 \cdot \left(y \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;\left(z \cdot z\right) \cdot \left(y \cdot -4\right)\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m y z t)
 :precision binary64
 (if (<= (* z z) 2050000000.0) (* 4.0 (* y t)) (* (* z z) (* y -4.0))))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
	double tmp;
	if ((z * z) <= 2050000000.0) {
		tmp = 4.0 * (y * t);
	} else {
		tmp = (z * z) * (y * -4.0);
	}
	return tmp;
}
x_m = abs(x)
real(8) function code(x_m, y, z, t)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((z * z) <= 2050000000.0d0) then
        tmp = 4.0d0 * (y * t)
    else
        tmp = (z * z) * (y * (-4.0d0))
    end if
    code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y, double z, double t) {
	double tmp;
	if ((z * z) <= 2050000000.0) {
		tmp = 4.0 * (y * t);
	} else {
		tmp = (z * z) * (y * -4.0);
	}
	return tmp;
}
x_m = math.fabs(x)
def code(x_m, y, z, t):
	tmp = 0
	if (z * z) <= 2050000000.0:
		tmp = 4.0 * (y * t)
	else:
		tmp = (z * z) * (y * -4.0)
	return tmp
x_m = abs(x)
function code(x_m, y, z, t)
	tmp = 0.0
	if (Float64(z * z) <= 2050000000.0)
		tmp = Float64(4.0 * Float64(y * t));
	else
		tmp = Float64(Float64(z * z) * Float64(y * -4.0));
	end
	return tmp
end
x_m = abs(x);
function tmp_2 = code(x_m, y, z, t)
	tmp = 0.0;
	if ((z * z) <= 2050000000.0)
		tmp = 4.0 * (y * t);
	else
		tmp = (z * z) * (y * -4.0);
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 2050000000.0], N[(4.0 * N[(y * t), $MachinePrecision]), $MachinePrecision], N[(N[(z * z), $MachinePrecision] * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|

\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2050000000:\\
\;\;\;\;4 \cdot \left(y \cdot t\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) < 2.05e9

    1. Initial program 100.0%

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

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

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

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

    if 2.05e9 < (*.f64 z z)

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

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

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

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

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

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

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

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

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

Alternative 8: 31.2% accurate, 2.6× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ 4 \cdot \left(y \cdot t\right) \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m y z t) :precision binary64 (* 4.0 (* y t)))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
	return 4.0 * (y * t);
}
x_m = abs(x)
real(8) function code(x_m, y, z, t)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = 4.0d0 * (y * t)
end function
x_m = Math.abs(x);
public static double code(double x_m, double y, double z, double t) {
	return 4.0 * (y * t);
}
x_m = math.fabs(x)
def code(x_m, y, z, t):
	return 4.0 * (y * t)
x_m = abs(x)
function code(x_m, y, z, t)
	return Float64(4.0 * Float64(y * t))
end
x_m = abs(x);
function tmp = code(x_m, y, z, t)
	tmp = 4.0 * (y * t);
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_, z_, t_] := N[(4.0 * N[(y * t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|

\\
4 \cdot \left(y \cdot t\right)
\end{array}
Derivation
  1. Initial program 91.6%

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

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

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

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

    \[\leadsto 4 \cdot \left(y \cdot t\right) \]
  7. Add Preprocessing

Developer target: 90.7% 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 2024077 
(FPCore (x y z t)
  :name "Graphics.Rasterific.Shading:$sradialGradientWithFocusShader from Rasterific-0.6.1, B"
  :precision binary64

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

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