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

Percentage Accurate: 90.6% → 95.5%
Time: 8.1s
Alternatives: 8
Speedup: 0.7×

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.6% 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: 95.5% accurate, 0.1× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (*.f64 z z) t) < 3.9999999999999998e291

    1. Initial program 98.3%

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

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

        \[\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-in99.4%

        \[\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-in99.4%

        \[\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-eval99.4%

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

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

    if 3.9999999999999998e291 < (-.f64 (*.f64 z z) t)

    1. Initial program 71.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, y \cdot \left(\left(z \cdot z\right) \cdot -4\right)\right)} \]
    5. Step-by-step derivation
      1. fma-udef73.0%

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

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

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

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

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

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

Alternative 2: 49.1% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := y \cdot \left(t \cdot 4\right)\\ t_2 := z \cdot \left(y \cdot \left(z \cdot -4\right)\right)\\ \mathbf{if}\;x \leq 4.5 \cdot 10^{-248}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 6.4 \cdot 10^{-146}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2 \cdot 10^{-131}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 4.7 \cdot 10^{-104}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 9.8 \cdot 10^{-26} \lor \neg \left(x \leq 2.2 \cdot 10^{+60}\right) \land x \leq 5.4 \cdot 10^{+107}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* y (* t 4.0))) (t_2 (* z (* y (* z -4.0)))))
   (if (<= x 4.5e-248)
     t_2
     (if (<= x 6.4e-146)
       t_1
       (if (<= x 2e-131)
         t_2
         (if (<= x 4.7e-104)
           t_1
           (if (or (<= x 9.8e-26) (and (not (<= x 2.2e+60)) (<= x 5.4e+107)))
             t_2
             (* x x))))))))
double code(double x, double y, double z, double t) {
	double t_1 = y * (t * 4.0);
	double t_2 = z * (y * (z * -4.0));
	double tmp;
	if (x <= 4.5e-248) {
		tmp = t_2;
	} else if (x <= 6.4e-146) {
		tmp = t_1;
	} else if (x <= 2e-131) {
		tmp = t_2;
	} else if (x <= 4.7e-104) {
		tmp = t_1;
	} else if ((x <= 9.8e-26) || (!(x <= 2.2e+60) && (x <= 5.4e+107))) {
		tmp = t_2;
	} 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 * (t * 4.0d0)
    t_2 = z * (y * (z * (-4.0d0)))
    if (x <= 4.5d-248) then
        tmp = t_2
    else if (x <= 6.4d-146) then
        tmp = t_1
    else if (x <= 2d-131) then
        tmp = t_2
    else if (x <= 4.7d-104) then
        tmp = t_1
    else if ((x <= 9.8d-26) .or. (.not. (x <= 2.2d+60)) .and. (x <= 5.4d+107)) then
        tmp = t_2
    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 * (t * 4.0);
	double t_2 = z * (y * (z * -4.0));
	double tmp;
	if (x <= 4.5e-248) {
		tmp = t_2;
	} else if (x <= 6.4e-146) {
		tmp = t_1;
	} else if (x <= 2e-131) {
		tmp = t_2;
	} else if (x <= 4.7e-104) {
		tmp = t_1;
	} else if ((x <= 9.8e-26) || (!(x <= 2.2e+60) && (x <= 5.4e+107))) {
		tmp = t_2;
	} else {
		tmp = x * x;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = y * (t * 4.0)
	t_2 = z * (y * (z * -4.0))
	tmp = 0
	if x <= 4.5e-248:
		tmp = t_2
	elif x <= 6.4e-146:
		tmp = t_1
	elif x <= 2e-131:
		tmp = t_2
	elif x <= 4.7e-104:
		tmp = t_1
	elif (x <= 9.8e-26) or (not (x <= 2.2e+60) and (x <= 5.4e+107)):
		tmp = t_2
	else:
		tmp = x * x
	return tmp
function code(x, y, z, t)
	t_1 = Float64(y * Float64(t * 4.0))
	t_2 = Float64(z * Float64(y * Float64(z * -4.0)))
	tmp = 0.0
	if (x <= 4.5e-248)
		tmp = t_2;
	elseif (x <= 6.4e-146)
		tmp = t_1;
	elseif (x <= 2e-131)
		tmp = t_2;
	elseif (x <= 4.7e-104)
		tmp = t_1;
	elseif ((x <= 9.8e-26) || (!(x <= 2.2e+60) && (x <= 5.4e+107)))
		tmp = t_2;
	else
		tmp = Float64(x * x);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = y * (t * 4.0);
	t_2 = z * (y * (z * -4.0));
	tmp = 0.0;
	if (x <= 4.5e-248)
		tmp = t_2;
	elseif (x <= 6.4e-146)
		tmp = t_1;
	elseif (x <= 2e-131)
		tmp = t_2;
	elseif (x <= 4.7e-104)
		tmp = t_1;
	elseif ((x <= 9.8e-26) || (~((x <= 2.2e+60)) && (x <= 5.4e+107)))
		tmp = t_2;
	else
		tmp = x * x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(t * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(z * N[(y * N[(z * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 4.5e-248], t$95$2, If[LessEqual[x, 6.4e-146], t$95$1, If[LessEqual[x, 2e-131], t$95$2, If[LessEqual[x, 4.7e-104], t$95$1, If[Or[LessEqual[x, 9.8e-26], And[N[Not[LessEqual[x, 2.2e+60]], $MachinePrecision], LessEqual[x, 5.4e+107]]], t$95$2, N[(x * x), $MachinePrecision]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 6.4 \cdot 10^{-146}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 2 \cdot 10^{-131}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;x \leq 4.7 \cdot 10^{-104}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 9.8 \cdot 10^{-26} \lor \neg \left(x \leq 2.2 \cdot 10^{+60}\right) \land x \leq 5.4 \cdot 10^{+107}:\\
\;\;\;\;t_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 4.4999999999999996e-248 or 6.3999999999999998e-146 < x < 2e-131 or 4.7e-104 < x < 9.7999999999999998e-26 or 2.19999999999999996e60 < x < 5.4000000000000003e107

    1. Initial program 93.2%

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

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

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

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

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

      \[\leadsto \color{blue}{y \cdot \left(\left(z \cdot z\right) \cdot -4\right)} \]
    5. Taylor expanded in y around 0 43.7%

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

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

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

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

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

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

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

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

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

    if 4.4999999999999996e-248 < x < 6.3999999999999998e-146 or 2e-131 < x < 4.7e-104

    1. Initial program 91.1%

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

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

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

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

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

    if 9.7999999999999998e-26 < x < 2.19999999999999996e60 or 5.4000000000000003e107 < x

    1. Initial program 84.5%

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

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

        \[\leadsto \color{blue}{x \cdot x} \]
    4. Simplified75.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 4.5 \cdot 10^{-248}:\\ \;\;\;\;z \cdot \left(y \cdot \left(z \cdot -4\right)\right)\\ \mathbf{elif}\;x \leq 6.4 \cdot 10^{-146}:\\ \;\;\;\;y \cdot \left(t \cdot 4\right)\\ \mathbf{elif}\;x \leq 2 \cdot 10^{-131}:\\ \;\;\;\;z \cdot \left(y \cdot \left(z \cdot -4\right)\right)\\ \mathbf{elif}\;x \leq 4.7 \cdot 10^{-104}:\\ \;\;\;\;y \cdot \left(t \cdot 4\right)\\ \mathbf{elif}\;x \leq 9.8 \cdot 10^{-26} \lor \neg \left(x \leq 2.2 \cdot 10^{+60}\right) \land x \leq 5.4 \cdot 10^{+107}:\\ \;\;\;\;z \cdot \left(y \cdot \left(z \cdot -4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]

Alternative 3: 77.0% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot x \leq 1.8 \cdot 10^{-46} \lor \neg \left(x \cdot x \leq 2.2 \cdot 10^{+110}\right) \land x \cdot x \leq 7.5 \cdot 10^{+216}:\\ \;\;\;\;\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 (or (<= (* x x) 1.8e-46)
         (and (not (<= (* x x) 2.2e+110)) (<= (* x x) 7.5e+216)))
   (* (- (* z z) t) (* y -4.0))
   (* x x)))
double code(double x, double y, double z, double t) {
	double tmp;
	if (((x * x) <= 1.8e-46) || (!((x * x) <= 2.2e+110) && ((x * x) <= 7.5e+216))) {
		tmp = ((z * z) - t) * (y * -4.0);
	} else {
		tmp = x * x;
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (((x * x) <= 1.8d-46) .or. (.not. ((x * x) <= 2.2d+110)) .and. ((x * x) <= 7.5d+216)) then
        tmp = ((z * z) - t) * (y * (-4.0d0))
    else
        tmp = x * x
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (((x * x) <= 1.8e-46) || (!((x * x) <= 2.2e+110) && ((x * x) <= 7.5e+216))) {
		tmp = ((z * z) - t) * (y * -4.0);
	} else {
		tmp = x * x;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if ((x * x) <= 1.8e-46) or (not ((x * x) <= 2.2e+110) and ((x * x) <= 7.5e+216)):
		tmp = ((z * z) - t) * (y * -4.0)
	else:
		tmp = x * x
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if ((Float64(x * x) <= 1.8e-46) || (!(Float64(x * x) <= 2.2e+110) && (Float64(x * x) <= 7.5e+216)))
		tmp = Float64(Float64(Float64(z * z) - t) * Float64(y * -4.0));
	else
		tmp = Float64(x * x);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (((x * x) <= 1.8e-46) || (~(((x * x) <= 2.2e+110)) && ((x * x) <= 7.5e+216)))
		tmp = ((z * z) - t) * (y * -4.0);
	else
		tmp = x * x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x * x), $MachinePrecision], 1.8e-46], And[N[Not[LessEqual[N[(x * x), $MachinePrecision], 2.2e+110]], $MachinePrecision], LessEqual[N[(x * x), $MachinePrecision], 7.5e+216]]], N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * N[(y * -4.0), $MachinePrecision]), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 1.8 \cdot 10^{-46} \lor \neg \left(x \cdot x \leq 2.2 \cdot 10^{+110}\right) \land x \cdot x \leq 7.5 \cdot 10^{+216}:\\
\;\;\;\;\left(z \cdot z - t\right) \cdot \left(y \cdot -4\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x x) < 1.8e-46 or 2.19999999999999992e110 < (*.f64 x x) < 7.4999999999999994e216

    1. Initial program 96.6%

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

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

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

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

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

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

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

    if 1.8e-46 < (*.f64 x x) < 2.19999999999999992e110 or 7.4999999999999994e216 < (*.f64 x x)

    1. Initial program 84.6%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x \leq 1.8 \cdot 10^{-46} \lor \neg \left(x \cdot x \leq 2.2 \cdot 10^{+110}\right) \land x \cdot x \leq 7.5 \cdot 10^{+216}:\\ \;\;\;\;\left(z \cdot z - t\right) \cdot \left(y \cdot -4\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]

Alternative 4: 44.0% accurate, 0.7× 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 \leq 6 \cdot 10^{-147}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{-131}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 3.6 \cdot 10^{-103}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{-25} \lor \neg \left(x \leq 2 \cdot 10^{+61}\right) \land x \leq 4.5 \cdot 10^{+107}:\\ \;\;\;\;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 6e-147)
     t_2
     (if (<= x 1.65e-131)
       t_1
       (if (<= x 3.6e-103)
         t_2
         (if (or (<= x 3.2e-25) (and (not (<= x 2e+61)) (<= x 4.5e+107)))
           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 <= 6e-147) {
		tmp = t_2;
	} else if (x <= 1.65e-131) {
		tmp = t_1;
	} else if (x <= 3.6e-103) {
		tmp = t_2;
	} else if ((x <= 3.2e-25) || (!(x <= 2e+61) && (x <= 4.5e+107))) {
		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 <= 6d-147) then
        tmp = t_2
    else if (x <= 1.65d-131) then
        tmp = t_1
    else if (x <= 3.6d-103) then
        tmp = t_2
    else if ((x <= 3.2d-25) .or. (.not. (x <= 2d+61)) .and. (x <= 4.5d+107)) 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 <= 6e-147) {
		tmp = t_2;
	} else if (x <= 1.65e-131) {
		tmp = t_1;
	} else if (x <= 3.6e-103) {
		tmp = t_2;
	} else if ((x <= 3.2e-25) || (!(x <= 2e+61) && (x <= 4.5e+107))) {
		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 <= 6e-147:
		tmp = t_2
	elif x <= 1.65e-131:
		tmp = t_1
	elif x <= 3.6e-103:
		tmp = t_2
	elif (x <= 3.2e-25) or (not (x <= 2e+61) and (x <= 4.5e+107)):
		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 (x <= 6e-147)
		tmp = t_2;
	elseif (x <= 1.65e-131)
		tmp = t_1;
	elseif (x <= 3.6e-103)
		tmp = t_2;
	elseif ((x <= 3.2e-25) || (!(x <= 2e+61) && (x <= 4.5e+107)))
		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 <= 6e-147)
		tmp = t_2;
	elseif (x <= 1.65e-131)
		tmp = t_1;
	elseif (x <= 3.6e-103)
		tmp = t_2;
	elseif ((x <= 3.2e-25) || (~((x <= 2e+61)) && (x <= 4.5e+107)))
		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[x, 6e-147], t$95$2, If[LessEqual[x, 1.65e-131], t$95$1, If[LessEqual[x, 3.6e-103], t$95$2, If[Or[LessEqual[x, 3.2e-25], And[N[Not[LessEqual[x, 2e+61]], $MachinePrecision], LessEqual[x, 4.5e+107]]], 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 \leq 6 \cdot 10^{-147}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;x \leq 1.65 \cdot 10^{-131}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 3.6 \cdot 10^{-103}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;x \leq 3.2 \cdot 10^{-25} \lor \neg \left(x \leq 2 \cdot 10^{+61}\right) \land x \leq 4.5 \cdot 10^{+107}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 6.0000000000000004e-147 or 1.6500000000000001e-131 < x < 3.5999999999999998e-103

    1. Initial program 92.0%

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

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

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

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

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

    if 6.0000000000000004e-147 < x < 1.6500000000000001e-131 or 3.5999999999999998e-103 < x < 3.2000000000000001e-25 or 1.9999999999999999e61 < x < 4.5e107

    1. Initial program 97.3%

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

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

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

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

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

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

    if 3.2000000000000001e-25 < x < 1.9999999999999999e61 or 4.5e107 < x

    1. Initial program 84.5%

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

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

        \[\leadsto \color{blue}{x \cdot x} \]
    4. Simplified75.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 6 \cdot 10^{-147}:\\ \;\;\;\;y \cdot \left(t \cdot 4\right)\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{-131}:\\ \;\;\;\;y \cdot \left(\left(z \cdot z\right) \cdot -4\right)\\ \mathbf{elif}\;x \leq 3.6 \cdot 10^{-103}:\\ \;\;\;\;y \cdot \left(t \cdot 4\right)\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{-25} \lor \neg \left(x \leq 2 \cdot 10^{+61}\right) \land x \leq 4.5 \cdot 10^{+107}:\\ \;\;\;\;y \cdot \left(\left(z \cdot z\right) \cdot -4\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]

Alternative 5: 95.0% accurate, 0.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (*.f64 z z) t) < 3.9999999999999998e291

    1. Initial program 98.3%

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

    if 3.9999999999999998e291 < (-.f64 (*.f64 z z) t)

    1. Initial program 71.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, y \cdot \left(\left(z \cdot z\right) \cdot -4\right)\right)} \]
    5. Step-by-step derivation
      1. fma-udef73.0%

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

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

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

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

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

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

Alternative 6: 86.2% accurate, 0.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x x) < 1.00000000000000002e-46

    1. Initial program 96.6%

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

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

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

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

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

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

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

    if 1.00000000000000002e-46 < (*.f64 x x)

    1. Initial program 86.5%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, y \cdot \left(\left(z \cdot z\right) \cdot -4\right)\right)} \]
    5. Step-by-step derivation
      1. fma-udef78.8%

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

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

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

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

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

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

Alternative 7: 59.5% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot x \leq 1.8 \cdot 10^{-46}:\\ \;\;\;\;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) 1.8e-46) (* y (* t 4.0)) (* x x)))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((x * x) <= 1.8e-46) {
		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) <= 1.8d-46) 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) <= 1.8e-46) {
		tmp = y * (t * 4.0);
	} else {
		tmp = x * x;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (x * x) <= 1.8e-46:
		tmp = y * (t * 4.0)
	else:
		tmp = x * x
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (Float64(x * x) <= 1.8e-46)
		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) <= 1.8e-46)
		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], 1.8e-46], N[(y * N[(t * 4.0), $MachinePrecision]), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 1.8 \cdot 10^{-46}:\\
\;\;\;\;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) < 1.8e-46

    1. Initial program 96.6%

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

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

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

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

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

    if 1.8e-46 < (*.f64 x x)

    1. Initial program 86.5%

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

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

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

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

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

Alternative 8: 41.9% 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 90.8%

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

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

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

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

    \[\leadsto x \cdot x \]

Developer target: 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 2023275 
(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))))