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

Percentage Accurate: 90.9% → 93.0%
Time: 7.9s
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.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.0% 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 93.6%

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

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

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

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

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

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

Alternative 2: 57.9% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := y \cdot \left(\left(z \cdot z\right) \cdot -4\right)\\ t_2 := y \cdot \left(t \cdot 4\right)\\ \mathbf{if}\;x \cdot x \leq 2.7 \cdot 10^{-126}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \cdot x \leq 2.7 \cdot 10^{+78}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot x \leq 5.3 \cdot 10^{+101}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \cdot x \leq 4.5 \cdot 10^{+196}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* y (* (* z z) -4.0))) (t_2 (* y (* t 4.0))))
   (if (<= (* x x) 2.7e-126)
     t_2
     (if (<= (* x x) 2.7e+78)
       t_1
       (if (<= (* x x) 5.3e+101)
         t_2
         (if (<= (* x x) 4.5e+196) t_1 (* x x)))))))
double code(double x, double y, double z, double t) {
	double t_1 = y * ((z * z) * -4.0);
	double t_2 = y * (t * 4.0);
	double tmp;
	if ((x * x) <= 2.7e-126) {
		tmp = t_2;
	} else if ((x * x) <= 2.7e+78) {
		tmp = t_1;
	} else if ((x * x) <= 5.3e+101) {
		tmp = t_2;
	} else if ((x * x) <= 4.5e+196) {
		tmp = t_1;
	} else {
		tmp = x * x;
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = y * ((z * z) * (-4.0d0))
    t_2 = y * (t * 4.0d0)
    if ((x * x) <= 2.7d-126) then
        tmp = t_2
    else if ((x * x) <= 2.7d+78) then
        tmp = t_1
    else if ((x * x) <= 5.3d+101) then
        tmp = t_2
    else if ((x * x) <= 4.5d+196) then
        tmp = t_1
    else
        tmp = x * x
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = y * ((z * z) * -4.0);
	double t_2 = y * (t * 4.0);
	double tmp;
	if ((x * x) <= 2.7e-126) {
		tmp = t_2;
	} else if ((x * x) <= 2.7e+78) {
		tmp = t_1;
	} else if ((x * x) <= 5.3e+101) {
		tmp = t_2;
	} else if ((x * x) <= 4.5e+196) {
		tmp = t_1;
	} else {
		tmp = x * x;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = y * ((z * z) * -4.0)
	t_2 = y * (t * 4.0)
	tmp = 0
	if (x * x) <= 2.7e-126:
		tmp = t_2
	elif (x * x) <= 2.7e+78:
		tmp = t_1
	elif (x * x) <= 5.3e+101:
		tmp = t_2
	elif (x * x) <= 4.5e+196:
		tmp = t_1
	else:
		tmp = x * x
	return tmp
function code(x, y, z, t)
	t_1 = Float64(y * Float64(Float64(z * z) * -4.0))
	t_2 = Float64(y * Float64(t * 4.0))
	tmp = 0.0
	if (Float64(x * x) <= 2.7e-126)
		tmp = t_2;
	elseif (Float64(x * x) <= 2.7e+78)
		tmp = t_1;
	elseif (Float64(x * x) <= 5.3e+101)
		tmp = t_2;
	elseif (Float64(x * x) <= 4.5e+196)
		tmp = t_1;
	else
		tmp = Float64(x * x);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = y * ((z * z) * -4.0);
	t_2 = y * (t * 4.0);
	tmp = 0.0;
	if ((x * x) <= 2.7e-126)
		tmp = t_2;
	elseif ((x * x) <= 2.7e+78)
		tmp = t_1;
	elseif ((x * x) <= 5.3e+101)
		tmp = t_2;
	elseif ((x * x) <= 4.5e+196)
		tmp = t_1;
	else
		tmp = x * x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(N[(z * z), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(y * N[(t * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 2.7e-126], t$95$2, If[LessEqual[N[(x * x), $MachinePrecision], 2.7e+78], t$95$1, If[LessEqual[N[(x * x), $MachinePrecision], 5.3e+101], t$95$2, If[LessEqual[N[(x * x), $MachinePrecision], 4.5e+196], t$95$1, N[(x * x), $MachinePrecision]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \cdot x \leq 2.7 \cdot 10^{+78}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \cdot x \leq 5.3 \cdot 10^{+101}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;x \cdot x \leq 4.5 \cdot 10^{+196}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x x) < 2.69999999999999995e-126 or 2.70000000000000004e78 < (*.f64 x x) < 5.30000000000000006e101

    1. Initial program 93.8%

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

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

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

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

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

    if 2.69999999999999995e-126 < (*.f64 x x) < 2.70000000000000004e78 or 5.30000000000000006e101 < (*.f64 x x) < 4.49999999999999978e196

    1. Initial program 98.5%

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

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

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

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

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

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

    if 4.49999999999999978e196 < (*.f64 x x)

    1. Initial program 89.7%

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

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

        \[\leadsto \color{blue}{x \cdot x} \]
    4. Simplified87.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x \leq 2.7 \cdot 10^{-126}:\\ \;\;\;\;y \cdot \left(t \cdot 4\right)\\ \mathbf{elif}\;x \cdot x \leq 2.7 \cdot 10^{+78}:\\ \;\;\;\;y \cdot \left(\left(z \cdot z\right) \cdot -4\right)\\ \mathbf{elif}\;x \cdot x \leq 5.3 \cdot 10^{+101}:\\ \;\;\;\;y \cdot \left(t \cdot 4\right)\\ \mathbf{elif}\;x \cdot x \leq 4.5 \cdot 10^{+196}:\\ \;\;\;\;y \cdot \left(\left(z \cdot z\right) \cdot -4\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]

Alternative 3: 92.9% accurate, 0.6× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (*.f64 y 4) (-.f64 (*.f64 z z) t)) < 1.00000000000000007e294

    1. Initial program 97.8%

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

    if 1.00000000000000007e294 < (*.f64 (*.f64 y 4) (-.f64 (*.f64 z z) t))

    1. Initial program 70.6%

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

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

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

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

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

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

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

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

Alternative 4: 80.4% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 95.6%

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

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

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

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

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

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

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

    if 2.9500000000000001e200 < (*.f64 x x)

    1. Initial program 89.7%

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

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

        \[\leadsto \color{blue}{x \cdot x} \]
    4. Simplified87.6%

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

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

Alternative 5: 83.0% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 98.1%

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

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

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

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

    if 1.75e103 < (*.f64 z z)

    1. Initial program 85.6%

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

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

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

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

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

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

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

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

Alternative 6: 58.1% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 7.2 \cdot 10^{+101}:\\
\;\;\;\;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 (*.f64 x x) < 7.20000000000000058e101

    1. Initial program 94.9%

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

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

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

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

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

    if 7.20000000000000058e101 < (*.f64 x x)

    1. Initial program 91.8%

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

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

        \[\leadsto \color{blue}{x \cdot x} \]
    4. Simplified77.8%

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

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

Alternative 7: 41.5% accurate, 4.3× speedup?

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

\\
x \cdot x
\end{array}
Derivation
  1. Initial program 93.6%

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

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

      \[\leadsto \color{blue}{x \cdot x} \]
  4. Simplified42.6%

    \[\leadsto \color{blue}{x \cdot x} \]
  5. Final simplification42.6%

    \[\leadsto x \cdot x \]

Developer target: 90.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 2023271 
(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))))