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

Percentage Accurate: 91.0% → 93.3%
Time: 11.1s
Alternatives: 6
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 6 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: 91.0% 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.3% accurate, 0.1× speedup?

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

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

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


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

    1. Initial program 95.2%

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

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

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

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

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

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

      \[\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 9.9999999999999996e297 < (*.f64 x x)

    1. Initial program 82.1%

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

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

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

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

      \[\leadsto \color{blue}{x \cdot x} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 49.4% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq 8.5 \cdot 10^{-268}:\\
\;\;\;\;x \cdot x\\

\mathbf{elif}\;z \leq 2.25 \cdot 10^{+18}:\\
\;\;\;\;4 \cdot \left(t \cdot y\right)\\

\mathbf{elif}\;z \leq 6.2 \cdot 10^{+59}:\\
\;\;\;\;x \cdot x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < 8.50000000000000052e-268 or 2.25e18 < z < 6.20000000000000029e59

    1. Initial program 91.9%

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

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

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

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

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

    if 8.50000000000000052e-268 < z < 2.25e18

    1. Initial program 96.6%

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

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

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

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

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

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

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

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

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

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

    if 6.20000000000000029e59 < z

    1. Initial program 89.0%

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

        \[\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-in89.0%

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

        \[\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-in89.0%

        \[\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-eval89.0%

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

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

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

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

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

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

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

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

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

Alternative 3: 93.3% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 95.2%

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

    if 9.9999999999999996e297 < (*.f64 x x)

    1. Initial program 82.1%

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

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

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

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

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

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

Alternative 4: 82.0% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 98.7%

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

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

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

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

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

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

    if 2.50000000000000006e143 < (*.f64 z z)

    1. Initial program 82.4%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 44.9% accurate, 1.3× speedup?

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

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

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


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

    1. Initial program 93.3%

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

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

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

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

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

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

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

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

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

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

    if 2.64999999999999996e45 < x

    1. Initial program 88.6%

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

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

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

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

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

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

Alternative 6: 41.0% accurate, 4.3× speedup?

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

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

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

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

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

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

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

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

  :alt
  (! :herbie-platform default (- (* x x) (* 4 (* y (- (* z z) t)))))

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