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

Percentage Accurate: 90.6% → 95.9%
Time: 10.5s
Alternatives: 7
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 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.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.9% accurate, 0.1× speedup?

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

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

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


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

    1. Initial program 95.9%

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

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

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

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

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

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

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

    if 4.9999999999999997e304 < (*.f64 z z)

    1. Initial program 59.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-4 \cdot \frac{y \cdot \left({z}^{4} - {t}^{2}\right)}{t + {z}^{2}}} \]
    6. Step-by-step derivation
      1. associate-/l*0.0%

        \[\leadsto -4 \cdot \color{blue}{\frac{y}{\frac{t + {z}^{2}}{{z}^{4} - {t}^{2}}}} \]
      2. +-commutative0.0%

        \[\leadsto -4 \cdot \frac{y}{\frac{\color{blue}{{z}^{2} + t}}{{z}^{4} - {t}^{2}}} \]
      3. unpow20.0%

        \[\leadsto -4 \cdot \frac{y}{\frac{\color{blue}{z \cdot z} + t}{{z}^{4} - {t}^{2}}} \]
      4. fma-udef0.0%

        \[\leadsto -4 \cdot \frac{y}{\frac{\color{blue}{\mathsf{fma}\left(z, z, t\right)}}{{z}^{4} - {t}^{2}}} \]
    7. Simplified0.0%

      \[\leadsto \color{blue}{-4 \cdot \frac{y}{\frac{\mathsf{fma}\left(z, z, t\right)}{{z}^{4} - {t}^{2}}}} \]
    8. Taylor expanded in z around inf 70.0%

      \[\leadsto -4 \cdot \frac{y}{\color{blue}{\frac{1}{{z}^{2}}}} \]
    9. Step-by-step derivation
      1. associate-/r/70.0%

        \[\leadsto -4 \cdot \color{blue}{\left(\frac{y}{1} \cdot {z}^{2}\right)} \]
      2. /-rgt-identity70.0%

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

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

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

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

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

Alternative 2: 45.8% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq 7 \cdot 10^{-27} \lor \neg \left(z \leq 0.013\right) \land z \leq 1.5 \cdot 10^{+59}:\\
\;\;\;\;y \cdot \left(t \cdot 4\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 7.0000000000000003e-27 or 0.0129999999999999994 < z < 1.5e59

    1. Initial program 91.6%

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

      \[\leadsto \color{blue}{4 \cdot \left(t \cdot y\right)} \]
    4. 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)} \]
    5. Simplified40.6%

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

    if 7.0000000000000003e-27 < z < 0.0129999999999999994 or 1.5e59 < z

    1. Initial program 64.2%

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

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

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

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

        \[\leadsto x \cdot x - \left(y \cdot 4\right) \cdot \frac{{z}^{2} \cdot \color{blue}{{z}^{2}} - \left(-t\right) \cdot \left(-t\right)}{z \cdot z - \left(-t\right)} \]
      5. pow-prod-up18.8%

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

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

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

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

      \[\leadsto \color{blue}{-4 \cdot \frac{y \cdot \left({z}^{4} - {t}^{2}\right)}{t + {z}^{2}}} \]
    6. Step-by-step derivation
      1. associate-/l*18.9%

        \[\leadsto -4 \cdot \color{blue}{\frac{y}{\frac{t + {z}^{2}}{{z}^{4} - {t}^{2}}}} \]
      2. +-commutative18.9%

        \[\leadsto -4 \cdot \frac{y}{\frac{\color{blue}{{z}^{2} + t}}{{z}^{4} - {t}^{2}}} \]
      3. unpow218.9%

        \[\leadsto -4 \cdot \frac{y}{\frac{\color{blue}{z \cdot z} + t}{{z}^{4} - {t}^{2}}} \]
      4. fma-udef18.9%

        \[\leadsto -4 \cdot \frac{y}{\frac{\color{blue}{\mathsf{fma}\left(z, z, t\right)}}{{z}^{4} - {t}^{2}}} \]
    7. Simplified18.9%

      \[\leadsto \color{blue}{-4 \cdot \frac{y}{\frac{\mathsf{fma}\left(z, z, t\right)}{{z}^{4} - {t}^{2}}}} \]
    8. Taylor expanded in z around inf 67.2%

      \[\leadsto -4 \cdot \frac{y}{\color{blue}{\frac{1}{{z}^{2}}}} \]
    9. Step-by-step derivation
      1. associate-/r/67.2%

        \[\leadsto -4 \cdot \color{blue}{\left(\frac{y}{1} \cdot {z}^{2}\right)} \]
      2. /-rgt-identity67.2%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 7 \cdot 10^{-27} \lor \neg \left(z \leq 0.013\right) \land z \leq 1.5 \cdot 10^{+59}:\\ \;\;\;\;y \cdot \left(t \cdot 4\right)\\ \mathbf{else}:\\ \;\;\;\;-4 \cdot \left(z \cdot \left(z \cdot y\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 78.0% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;z \leq 5 \cdot 10^{+251}:\\
\;\;\;\;x \cdot x - z \cdot \left(z \cdot \left(y \cdot 4\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < 7.0000000000000003e-27

    1. Initial program 91.2%

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

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

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

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

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

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

    if 7.0000000000000003e-27 < z < 5.0000000000000005e251

    1. Initial program 70.1%

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

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

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

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

        \[\leadsto x \cdot x - \left(y \cdot 4\right) \cdot \frac{{z}^{2} \cdot \color{blue}{{z}^{2}} - \left(-t\right) \cdot \left(-t\right)}{z \cdot z - \left(-t\right)} \]
      5. pow-prod-up36.2%

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

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

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

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

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

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

        \[\leadsto x \cdot x - \frac{1}{\frac{\color{blue}{z \cdot z} - \left(-t\right)}{\left(y \cdot 4\right) \cdot \left({z}^{4} - \left(-t\right) \cdot \left(-t\right)\right)}} \]
      4. fma-neg34.8%

        \[\leadsto x \cdot x - \frac{1}{\frac{\color{blue}{\mathsf{fma}\left(z, z, -\left(-t\right)\right)}}{\left(y \cdot 4\right) \cdot \left({z}^{4} - \left(-t\right) \cdot \left(-t\right)\right)}} \]
      5. remove-double-neg34.8%

        \[\leadsto x \cdot x - \frac{1}{\frac{\mathsf{fma}\left(z, z, \color{blue}{t}\right)}{\left(y \cdot 4\right) \cdot \left({z}^{4} - \left(-t\right) \cdot \left(-t\right)\right)}} \]
      6. *-commutative34.8%

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

        \[\leadsto x \cdot x - \frac{1}{\frac{\mathsf{fma}\left(z, z, t\right)}{\color{blue}{4 \cdot \left(y \cdot \left({z}^{4} - \left(-t\right) \cdot \left(-t\right)\right)\right)}}} \]
      8. metadata-eval34.8%

        \[\leadsto x \cdot x - \frac{1}{\frac{\mathsf{fma}\left(z, z, t\right)}{4 \cdot \left(y \cdot \left({z}^{\color{blue}{\left(2 \cdot 2\right)}} - \left(-t\right) \cdot \left(-t\right)\right)\right)}} \]
      9. pow-sqr34.7%

        \[\leadsto x \cdot x - \frac{1}{\frac{\mathsf{fma}\left(z, z, t\right)}{4 \cdot \left(y \cdot \left(\color{blue}{{z}^{2} \cdot {z}^{2}} - \left(-t\right) \cdot \left(-t\right)\right)\right)}} \]
      10. sqr-neg34.7%

        \[\leadsto x \cdot x - \frac{1}{\frac{\mathsf{fma}\left(z, z, t\right)}{4 \cdot \left(y \cdot \left({z}^{2} \cdot {z}^{2} - \color{blue}{t \cdot t}\right)\right)}} \]
      11. difference-of-squares37.9%

        \[\leadsto x \cdot x - \frac{1}{\frac{\mathsf{fma}\left(z, z, t\right)}{4 \cdot \left(y \cdot \color{blue}{\left(\left({z}^{2} + t\right) \cdot \left({z}^{2} - t\right)\right)}\right)}} \]
      12. remove-double-neg37.9%

        \[\leadsto x \cdot x - \frac{1}{\frac{\mathsf{fma}\left(z, z, t\right)}{4 \cdot \left(y \cdot \left(\left({z}^{2} + \color{blue}{\left(-\left(-t\right)\right)}\right) \cdot \left({z}^{2} - t\right)\right)\right)}} \]
      13. sub-neg37.9%

        \[\leadsto x \cdot x - \frac{1}{\frac{\mathsf{fma}\left(z, z, t\right)}{4 \cdot \left(y \cdot \left(\color{blue}{\left({z}^{2} - \left(-t\right)\right)} \cdot \left({z}^{2} - t\right)\right)\right)}} \]
      14. sub-neg37.9%

        \[\leadsto x \cdot x - \frac{1}{\frac{\mathsf{fma}\left(z, z, t\right)}{4 \cdot \left(y \cdot \left(\left({z}^{2} - \left(-t\right)\right) \cdot \color{blue}{\left({z}^{2} + \left(-t\right)\right)}\right)\right)}} \]
      15. add-sqr-sqrt11.4%

        \[\leadsto x \cdot x - \frac{1}{\frac{\mathsf{fma}\left(z, z, t\right)}{4 \cdot \left(y \cdot \left(\left({z}^{2} - \left(-t\right)\right) \cdot \left({z}^{2} + \color{blue}{\sqrt{-t} \cdot \sqrt{-t}}\right)\right)\right)}} \]
      16. sqrt-prod30.2%

        \[\leadsto x \cdot x - \frac{1}{\frac{\mathsf{fma}\left(z, z, t\right)}{4 \cdot \left(y \cdot \left(\left({z}^{2} - \left(-t\right)\right) \cdot \left({z}^{2} + \color{blue}{\sqrt{\left(-t\right) \cdot \left(-t\right)}}\right)\right)\right)}} \]
      17. sqr-neg30.2%

        \[\leadsto x \cdot x - \frac{1}{\frac{\mathsf{fma}\left(z, z, t\right)}{4 \cdot \left(y \cdot \left(\left({z}^{2} - \left(-t\right)\right) \cdot \left({z}^{2} + \sqrt{\color{blue}{t \cdot t}}\right)\right)\right)}} \]
      18. sqrt-prod18.7%

        \[\leadsto x \cdot x - \frac{1}{\frac{\mathsf{fma}\left(z, z, t\right)}{4 \cdot \left(y \cdot \left(\left({z}^{2} - \left(-t\right)\right) \cdot \left({z}^{2} + \color{blue}{\sqrt{t} \cdot \sqrt{t}}\right)\right)\right)}} \]
      19. add-sqr-sqrt28.4%

        \[\leadsto x \cdot x - \frac{1}{\frac{\mathsf{fma}\left(z, z, t\right)}{4 \cdot \left(y \cdot \left(\left({z}^{2} - \left(-t\right)\right) \cdot \left({z}^{2} + \color{blue}{t}\right)\right)\right)}} \]
    6. Applied egg-rr28.4%

      \[\leadsto x \cdot x - \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(z, z, t\right)}{4 \cdot \left(y \cdot {\left(\mathsf{fma}\left(z, z, t\right)\right)}^{2}\right)}}} \]
    7. Step-by-step derivation
      1. *-lft-identity28.4%

        \[\leadsto x \cdot x - \frac{1}{\frac{\color{blue}{1 \cdot \mathsf{fma}\left(z, z, t\right)}}{4 \cdot \left(y \cdot {\left(\mathsf{fma}\left(z, z, t\right)\right)}^{2}\right)}} \]
      2. times-frac28.4%

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

        \[\leadsto x \cdot x - \frac{1}{\color{blue}{0.25} \cdot \frac{\mathsf{fma}\left(z, z, t\right)}{y \cdot {\left(\mathsf{fma}\left(z, z, t\right)\right)}^{2}}} \]
      4. *-rgt-identity28.4%

        \[\leadsto x \cdot x - \frac{1}{0.25 \cdot \frac{\color{blue}{\mathsf{fma}\left(z, z, t\right) \cdot 1}}{y \cdot {\left(\mathsf{fma}\left(z, z, t\right)\right)}^{2}}} \]
      5. rgt-mult-inverse28.4%

        \[\leadsto x \cdot x - \frac{1}{0.25 \cdot \frac{\mathsf{fma}\left(z, z, t\right) \cdot \color{blue}{\left(\mathsf{fma}\left(z, z, t\right) \cdot \frac{1}{\mathsf{fma}\left(z, z, t\right)}\right)}}{y \cdot {\left(\mathsf{fma}\left(z, z, t\right)\right)}^{2}}} \]
      6. associate-*r*21.9%

        \[\leadsto x \cdot x - \frac{1}{0.25 \cdot \frac{\color{blue}{\left(\mathsf{fma}\left(z, z, t\right) \cdot \mathsf{fma}\left(z, z, t\right)\right) \cdot \frac{1}{\mathsf{fma}\left(z, z, t\right)}}}{y \cdot {\left(\mathsf{fma}\left(z, z, t\right)\right)}^{2}}} \]
      7. unpow221.9%

        \[\leadsto x \cdot x - \frac{1}{0.25 \cdot \frac{\color{blue}{{\left(\mathsf{fma}\left(z, z, t\right)\right)}^{2}} \cdot \frac{1}{\mathsf{fma}\left(z, z, t\right)}}{y \cdot {\left(\mathsf{fma}\left(z, z, t\right)\right)}^{2}}} \]
      8. *-commutative21.9%

        \[\leadsto x \cdot x - \frac{1}{0.25 \cdot \frac{{\left(\mathsf{fma}\left(z, z, t\right)\right)}^{2} \cdot \frac{1}{\mathsf{fma}\left(z, z, t\right)}}{\color{blue}{{\left(\mathsf{fma}\left(z, z, t\right)\right)}^{2} \cdot y}}} \]
      9. times-frac23.3%

        \[\leadsto x \cdot x - \frac{1}{0.25 \cdot \color{blue}{\left(\frac{{\left(\mathsf{fma}\left(z, z, t\right)\right)}^{2}}{{\left(\mathsf{fma}\left(z, z, t\right)\right)}^{2}} \cdot \frac{\frac{1}{\mathsf{fma}\left(z, z, t\right)}}{y}\right)}} \]
      10. *-inverses57.5%

        \[\leadsto x \cdot x - \frac{1}{0.25 \cdot \left(\color{blue}{1} \cdot \frac{\frac{1}{\mathsf{fma}\left(z, z, t\right)}}{y}\right)} \]
    8. Simplified57.5%

      \[\leadsto x \cdot x - \color{blue}{\frac{1}{0.25 \cdot \left(1 \cdot \frac{\frac{1}{\mathsf{fma}\left(z, z, t\right)}}{y}\right)}} \]
    9. Taylor expanded in z around inf 59.3%

      \[\leadsto x \cdot x - \frac{1}{\color{blue}{\frac{0.25}{y \cdot {z}^{2}}}} \]
    10. Step-by-step derivation
      1. associate-/r*59.3%

        \[\leadsto x \cdot x - \frac{1}{\color{blue}{\frac{\frac{0.25}{y}}{{z}^{2}}}} \]
    11. Simplified59.3%

      \[\leadsto x \cdot x - \frac{1}{\color{blue}{\frac{\frac{0.25}{y}}{{z}^{2}}}} \]
    12. Step-by-step derivation
      1. associate-/r/59.4%

        \[\leadsto x \cdot x - \color{blue}{\frac{1}{\frac{0.25}{y}} \cdot {z}^{2}} \]
      2. clear-num59.4%

        \[\leadsto x \cdot x - \color{blue}{\frac{y}{0.25}} \cdot {z}^{2} \]
      3. unpow259.4%

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

        \[\leadsto x \cdot x - \color{blue}{\left(\frac{y}{0.25} \cdot z\right) \cdot z} \]
      5. div-inv82.9%

        \[\leadsto x \cdot x - \left(\color{blue}{\left(y \cdot \frac{1}{0.25}\right)} \cdot z\right) \cdot z \]
      6. metadata-eval82.9%

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

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

    if 5.0000000000000005e251 < z

    1. Initial program 62.9%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-4 \cdot \frac{y \cdot \left({z}^{4} - {t}^{2}\right)}{t + {z}^{2}}} \]
    6. Step-by-step derivation
      1. associate-/l*0.0%

        \[\leadsto -4 \cdot \color{blue}{\frac{y}{\frac{t + {z}^{2}}{{z}^{4} - {t}^{2}}}} \]
      2. +-commutative0.0%

        \[\leadsto -4 \cdot \frac{y}{\frac{\color{blue}{{z}^{2} + t}}{{z}^{4} - {t}^{2}}} \]
      3. unpow20.0%

        \[\leadsto -4 \cdot \frac{y}{\frac{\color{blue}{z \cdot z} + t}{{z}^{4} - {t}^{2}}} \]
      4. fma-udef0.0%

        \[\leadsto -4 \cdot \frac{y}{\frac{\color{blue}{\mathsf{fma}\left(z, z, t\right)}}{{z}^{4} - {t}^{2}}} \]
    7. Simplified0.0%

      \[\leadsto \color{blue}{-4 \cdot \frac{y}{\frac{\mathsf{fma}\left(z, z, t\right)}{{z}^{4} - {t}^{2}}}} \]
    8. Taylor expanded in z around inf 94.2%

      \[\leadsto -4 \cdot \frac{y}{\color{blue}{\frac{1}{{z}^{2}}}} \]
    9. Step-by-step derivation
      1. associate-/r/94.2%

        \[\leadsto -4 \cdot \color{blue}{\left(\frac{y}{1} \cdot {z}^{2}\right)} \]
      2. /-rgt-identity94.2%

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

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

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

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

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

Alternative 4: 92.7% accurate, 0.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 1.95e142

    1. Initial program 92.0%

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

    if 1.95e142 < z

    1. Initial program 49.9%

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

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

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

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

        \[\leadsto x \cdot x - \left(y \cdot 4\right) \cdot \frac{{z}^{2} \cdot \color{blue}{{z}^{2}} - \left(-t\right) \cdot \left(-t\right)}{z \cdot z - \left(-t\right)} \]
      5. pow-prod-up0.1%

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

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

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

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

      \[\leadsto \color{blue}{-4 \cdot \frac{y \cdot \left({z}^{4} - {t}^{2}\right)}{t + {z}^{2}}} \]
    6. Step-by-step derivation
      1. associate-/l*0.1%

        \[\leadsto -4 \cdot \color{blue}{\frac{y}{\frac{t + {z}^{2}}{{z}^{4} - {t}^{2}}}} \]
      2. +-commutative0.1%

        \[\leadsto -4 \cdot \frac{y}{\frac{\color{blue}{{z}^{2} + t}}{{z}^{4} - {t}^{2}}} \]
      3. unpow20.1%

        \[\leadsto -4 \cdot \frac{y}{\frac{\color{blue}{z \cdot z} + t}{{z}^{4} - {t}^{2}}} \]
      4. fma-udef0.1%

        \[\leadsto -4 \cdot \frac{y}{\frac{\color{blue}{\mathsf{fma}\left(z, z, t\right)}}{{z}^{4} - {t}^{2}}} \]
    7. Simplified0.1%

      \[\leadsto \color{blue}{-4 \cdot \frac{y}{\frac{\mathsf{fma}\left(z, z, t\right)}{{z}^{4} - {t}^{2}}}} \]
    8. Taylor expanded in z around inf 64.5%

      \[\leadsto -4 \cdot \frac{y}{\color{blue}{\frac{1}{{z}^{2}}}} \]
    9. Step-by-step derivation
      1. associate-/r/64.5%

        \[\leadsto -4 \cdot \color{blue}{\left(\frac{y}{1} \cdot {z}^{2}\right)} \]
      2. /-rgt-identity64.5%

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

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

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

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

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

Alternative 5: 75.6% accurate, 0.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 1.29999999999999995e95

    1. Initial program 92.2%

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

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

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

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

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

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

    if 1.29999999999999995e95 < z

    1. Initial program 55.3%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-4 \cdot \frac{y \cdot \left({z}^{4} - {t}^{2}\right)}{t + {z}^{2}}} \]
    6. Step-by-step derivation
      1. associate-/l*5.7%

        \[\leadsto -4 \cdot \color{blue}{\frac{y}{\frac{t + {z}^{2}}{{z}^{4} - {t}^{2}}}} \]
      2. +-commutative5.7%

        \[\leadsto -4 \cdot \frac{y}{\frac{\color{blue}{{z}^{2} + t}}{{z}^{4} - {t}^{2}}} \]
      3. unpow25.7%

        \[\leadsto -4 \cdot \frac{y}{\frac{\color{blue}{z \cdot z} + t}{{z}^{4} - {t}^{2}}} \]
      4. fma-udef5.7%

        \[\leadsto -4 \cdot \frac{y}{\frac{\color{blue}{\mathsf{fma}\left(z, z, t\right)}}{{z}^{4} - {t}^{2}}} \]
    7. Simplified5.7%

      \[\leadsto \color{blue}{-4 \cdot \frac{y}{\frac{\mathsf{fma}\left(z, z, t\right)}{{z}^{4} - {t}^{2}}}} \]
    8. Taylor expanded in z around inf 67.8%

      \[\leadsto -4 \cdot \frac{y}{\color{blue}{\frac{1}{{z}^{2}}}} \]
    9. Step-by-step derivation
      1. associate-/r/67.8%

        \[\leadsto -4 \cdot \color{blue}{\left(\frac{y}{1} \cdot {z}^{2}\right)} \]
      2. /-rgt-identity67.8%

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

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

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

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

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

Alternative 6: 6.0% accurate, 2.6× speedup?

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x \cdot x + y \cdot \color{blue}{\left(\left(-t\right) \cdot -4\right)} \]
    4. add-sqr-sqrt30.1%

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

      \[\leadsto x \cdot x + y \cdot \left(\color{blue}{\sqrt{\left(-t\right) \cdot \left(-t\right)}} \cdot -4\right) \]
    6. sqr-neg47.5%

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

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

      \[\leadsto x \cdot x + y \cdot \left(\color{blue}{t} \cdot -4\right) \]
    9. expm1-log1p-u34.9%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x \cdot x + y \cdot \left(t \cdot -4\right)\right)\right)} \]
    10. fma-def34.9%

      \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\color{blue}{\mathsf{fma}\left(x, x, y \cdot \left(t \cdot -4\right)\right)}\right)\right) \]
  7. Applied egg-rr34.9%

    \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(x, x, y \cdot \left(t \cdot -4\right)\right)\right)\right)} \]
  8. Taylor expanded in x around 0 6.5%

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

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

Alternative 7: 32.8% accurate, 2.6× speedup?

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

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

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

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

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

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

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

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

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 2024019 
(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))))