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

Percentage Accurate: 90.9% → 94.7%
Time: 10.3s
Alternatives: 9
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 9 alternatives:

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

Initial Program: 90.9% accurate, 1.0× speedup?

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

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

Alternative 1: 94.7% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 97.1%

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

    if 2.0000000000000002e252 < (-.f64 (*.f64 z z) t)

    1. Initial program 74.5%

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{x \cdot x} - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
      2. lift-*.f64N/A

        \[\leadsto x \cdot x - \color{blue}{\left(y \cdot 4\right)} \cdot \left(z \cdot z - t\right) \]
      3. lift-*.f64N/A

        \[\leadsto x \cdot x - \left(y \cdot 4\right) \cdot \left(\color{blue}{z \cdot z} - t\right) \]
      4. lift--.f64N/A

        \[\leadsto x \cdot x - \left(y \cdot 4\right) \cdot \color{blue}{\left(z \cdot z - t\right)} \]
      5. lift-*.f64N/A

        \[\leadsto x \cdot x - \color{blue}{\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)} \]
      6. sub-negN/A

        \[\leadsto \color{blue}{x \cdot x + \left(\mathsf{neg}\left(\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\right)\right)} \]
      7. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\right)\right) + x \cdot x} \]
      8. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)}\right)\right) + x \cdot x \]
      9. distribute-lft-neg-inN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(z \cdot z - t\right)} + x \cdot x \]
      10. lift--.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \color{blue}{\left(z \cdot z - t\right)} + x \cdot x \]
      11. sub-negN/A

        \[\leadsto \left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \color{blue}{\left(z \cdot z + \left(\mathsf{neg}\left(t\right)\right)\right)} + x \cdot x \]
      12. distribute-lft-inN/A

        \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(z \cdot z\right) + \left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(\mathsf{neg}\left(t\right)\right)\right)} + x \cdot x \]
      13. associate-+l+N/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(z \cdot z\right) + \left(\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(\mathsf{neg}\left(t\right)\right) + x \cdot x\right)} \]
      14. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \color{blue}{\left(z \cdot z\right)} + \left(\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(\mathsf{neg}\left(t\right)\right) + x \cdot x\right) \]
      15. associate-*r*N/A

        \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot z\right) \cdot z} + \left(\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(\mathsf{neg}\left(t\right)\right) + x \cdot x\right) \]
      16. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot z, z, \left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(\mathsf{neg}\left(t\right)\right) + x \cdot x\right)} \]
    4. Applied rewrites90.2%

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

      \[\leadsto \mathsf{fma}\left(\left(y \cdot -4\right) \cdot z, z, \color{blue}{{x}^{2}}\right) \]
    6. Step-by-step derivation
      1. unpow2N/A

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

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

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

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

Alternative 2: 78.8% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;z \leq 1.35 \cdot 10^{+155}:\\
\;\;\;\;\mathsf{fma}\left(y, \left(z \cdot z\right) \cdot -4, x \cdot x\right)\\

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


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

    1. Initial program 92.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

      \[\leadsto \color{blue}{{x}^{2} - -4 \cdot \left(t \cdot y\right)} \]
    4. Step-by-step derivation
      1. cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{{x}^{2} + \left(\mathsf{neg}\left(-4\right)\right) \cdot \left(t \cdot y\right)} \]
      2. metadata-evalN/A

        \[\leadsto {x}^{2} + \color{blue}{4} \cdot \left(t \cdot y\right) \]
      3. +-commutativeN/A

        \[\leadsto \color{blue}{4 \cdot \left(t \cdot y\right) + {x}^{2}} \]
      4. associate-*r*N/A

        \[\leadsto \color{blue}{\left(4 \cdot t\right) \cdot y} + {x}^{2} \]
      5. *-commutativeN/A

        \[\leadsto \color{blue}{y \cdot \left(4 \cdot t\right)} + {x}^{2} \]
      6. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, 4 \cdot t, {x}^{2}\right)} \]
      7. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{t \cdot 4}, {x}^{2}\right) \]
      8. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{t \cdot 4}, {x}^{2}\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{fma}\left(y, t \cdot 4, \color{blue}{x \cdot x}\right) \]
      10. lower-*.f6473.8

        \[\leadsto \mathsf{fma}\left(y, t \cdot 4, \color{blue}{x \cdot x}\right) \]
    5. Applied rewrites73.8%

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

    if 2.05000000000000006e-36 < z < 1.34999999999999997e155

    1. Initial program 95.5%

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

      \[\leadsto \color{blue}{{x}^{2} - 4 \cdot \left(y \cdot {z}^{2}\right)} \]
    4. Step-by-step derivation
      1. cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{{x}^{2} + \left(\mathsf{neg}\left(4\right)\right) \cdot \left(y \cdot {z}^{2}\right)} \]
      2. metadata-evalN/A

        \[\leadsto {x}^{2} + \color{blue}{-4} \cdot \left(y \cdot {z}^{2}\right) \]
      3. +-commutativeN/A

        \[\leadsto \color{blue}{-4 \cdot \left(y \cdot {z}^{2}\right) + {x}^{2}} \]
      4. associate-*r*N/A

        \[\leadsto \color{blue}{\left(-4 \cdot y\right) \cdot {z}^{2}} + {x}^{2} \]
      5. *-commutativeN/A

        \[\leadsto \color{blue}{\left(y \cdot -4\right)} \cdot {z}^{2} + {x}^{2} \]
      6. associate-*l*N/A

        \[\leadsto \color{blue}{y \cdot \left(-4 \cdot {z}^{2}\right)} + {x}^{2} \]
      7. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, -4 \cdot {z}^{2}, {x}^{2}\right)} \]
      8. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{-4 \cdot {z}^{2}}, {x}^{2}\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{fma}\left(y, -4 \cdot \color{blue}{\left(z \cdot z\right)}, {x}^{2}\right) \]
      10. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(y, -4 \cdot \color{blue}{\left(z \cdot z\right)}, {x}^{2}\right) \]
      11. unpow2N/A

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

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

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

    if 1.34999999999999997e155 < z

    1. Initial program 67.4%

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

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

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

        \[\leadsto \color{blue}{\left(y \cdot -4\right)} \cdot {z}^{2} \]
      3. associate-*l*N/A

        \[\leadsto \color{blue}{y \cdot \left(-4 \cdot {z}^{2}\right)} \]
      4. lower-*.f64N/A

        \[\leadsto \color{blue}{y \cdot \left(-4 \cdot {z}^{2}\right)} \]
      5. lower-*.f64N/A

        \[\leadsto y \cdot \color{blue}{\left(-4 \cdot {z}^{2}\right)} \]
      6. unpow2N/A

        \[\leadsto y \cdot \left(-4 \cdot \color{blue}{\left(z \cdot z\right)}\right) \]
      7. lower-*.f6470.9

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

      \[\leadsto \color{blue}{y \cdot \left(-4 \cdot \left(z \cdot z\right)\right)} \]
    6. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto y \cdot \color{blue}{\left(\left(-4 \cdot z\right) \cdot z\right)} \]
      2. associate-*r*N/A

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

        \[\leadsto \color{blue}{\left(\left(y \cdot -4\right) \cdot z\right)} \cdot z \]
      4. lift-*.f64N/A

        \[\leadsto \left(\color{blue}{\left(y \cdot -4\right)} \cdot z\right) \cdot z \]
      5. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(\left(y \cdot -4\right) \cdot z\right)} \cdot z \]
      6. lower-*.f6493.0

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

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

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

Alternative 3: 90.9% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 z z) < 5.0000000000000002e-85

    1. Initial program 96.5%

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

      \[\leadsto \color{blue}{{x}^{2} - -4 \cdot \left(t \cdot y\right)} \]
    4. Step-by-step derivation
      1. cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{{x}^{2} + \left(\mathsf{neg}\left(-4\right)\right) \cdot \left(t \cdot y\right)} \]
      2. metadata-evalN/A

        \[\leadsto {x}^{2} + \color{blue}{4} \cdot \left(t \cdot y\right) \]
      3. +-commutativeN/A

        \[\leadsto \color{blue}{4 \cdot \left(t \cdot y\right) + {x}^{2}} \]
      4. associate-*r*N/A

        \[\leadsto \color{blue}{\left(4 \cdot t\right) \cdot y} + {x}^{2} \]
      5. *-commutativeN/A

        \[\leadsto \color{blue}{y \cdot \left(4 \cdot t\right)} + {x}^{2} \]
      6. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, 4 \cdot t, {x}^{2}\right)} \]
      7. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{t \cdot 4}, {x}^{2}\right) \]
      8. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{t \cdot 4}, {x}^{2}\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{fma}\left(y, t \cdot 4, \color{blue}{x \cdot x}\right) \]
      10. lower-*.f6494.9

        \[\leadsto \mathsf{fma}\left(y, t \cdot 4, \color{blue}{x \cdot x}\right) \]
    5. Applied rewrites94.9%

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

    if 5.0000000000000002e-85 < (*.f64 z z)

    1. Initial program 84.7%

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{x \cdot x} - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
      2. lift-*.f64N/A

        \[\leadsto x \cdot x - \color{blue}{\left(y \cdot 4\right)} \cdot \left(z \cdot z - t\right) \]
      3. lift-*.f64N/A

        \[\leadsto x \cdot x - \left(y \cdot 4\right) \cdot \left(\color{blue}{z \cdot z} - t\right) \]
      4. lift--.f64N/A

        \[\leadsto x \cdot x - \left(y \cdot 4\right) \cdot \color{blue}{\left(z \cdot z - t\right)} \]
      5. lift-*.f64N/A

        \[\leadsto x \cdot x - \color{blue}{\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)} \]
      6. sub-negN/A

        \[\leadsto \color{blue}{x \cdot x + \left(\mathsf{neg}\left(\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\right)\right)} \]
      7. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\right)\right) + x \cdot x} \]
      8. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)}\right)\right) + x \cdot x \]
      9. distribute-lft-neg-inN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(z \cdot z - t\right)} + x \cdot x \]
      10. lift--.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \color{blue}{\left(z \cdot z - t\right)} + x \cdot x \]
      11. sub-negN/A

        \[\leadsto \left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \color{blue}{\left(z \cdot z + \left(\mathsf{neg}\left(t\right)\right)\right)} + x \cdot x \]
      12. distribute-lft-inN/A

        \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(z \cdot z\right) + \left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(\mathsf{neg}\left(t\right)\right)\right)} + x \cdot x \]
      13. associate-+l+N/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(z \cdot z\right) + \left(\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(\mathsf{neg}\left(t\right)\right) + x \cdot x\right)} \]
      14. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \color{blue}{\left(z \cdot z\right)} + \left(\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(\mathsf{neg}\left(t\right)\right) + x \cdot x\right) \]
      15. associate-*r*N/A

        \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot z\right) \cdot z} + \left(\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(\mathsf{neg}\left(t\right)\right) + x \cdot x\right) \]
      16. lower-fma.f64N/A

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

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

      \[\leadsto \mathsf{fma}\left(\left(y \cdot -4\right) \cdot z, z, \color{blue}{{x}^{2}}\right) \]
    6. Step-by-step derivation
      1. unpow2N/A

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

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

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

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

Alternative 4: 77.0% accurate, 0.9× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < 4.4999999999999998e66

    1. Initial program 92.5%

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

      \[\leadsto \color{blue}{{x}^{2} - -4 \cdot \left(t \cdot y\right)} \]
    4. Step-by-step derivation
      1. cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{{x}^{2} + \left(\mathsf{neg}\left(-4\right)\right) \cdot \left(t \cdot y\right)} \]
      2. metadata-evalN/A

        \[\leadsto {x}^{2} + \color{blue}{4} \cdot \left(t \cdot y\right) \]
      3. +-commutativeN/A

        \[\leadsto \color{blue}{4 \cdot \left(t \cdot y\right) + {x}^{2}} \]
      4. associate-*r*N/A

        \[\leadsto \color{blue}{\left(4 \cdot t\right) \cdot y} + {x}^{2} \]
      5. *-commutativeN/A

        \[\leadsto \color{blue}{y \cdot \left(4 \cdot t\right)} + {x}^{2} \]
      6. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, 4 \cdot t, {x}^{2}\right)} \]
      7. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{t \cdot 4}, {x}^{2}\right) \]
      8. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{t \cdot 4}, {x}^{2}\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{fma}\left(y, t \cdot 4, \color{blue}{x \cdot x}\right) \]
      10. lower-*.f6473.0

        \[\leadsto \mathsf{fma}\left(y, t \cdot 4, \color{blue}{x \cdot x}\right) \]
    5. Applied rewrites73.0%

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

    if 4.4999999999999998e66 < z < 8.4e155

    1. Initial program 95.4%

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

      \[\leadsto \color{blue}{-4 \cdot \left(y \cdot \left({z}^{2} - t\right)\right)} \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \color{blue}{-4 \cdot \left(y \cdot \left({z}^{2} - t\right)\right)} \]
      2. lower-*.f64N/A

        \[\leadsto -4 \cdot \color{blue}{\left(y \cdot \left({z}^{2} - t\right)\right)} \]
      3. lower--.f64N/A

        \[\leadsto -4 \cdot \left(y \cdot \color{blue}{\left({z}^{2} - t\right)}\right) \]
      4. unpow2N/A

        \[\leadsto -4 \cdot \left(y \cdot \left(\color{blue}{z \cdot z} - t\right)\right) \]
      5. lower-*.f6481.0

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

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

    if 8.4e155 < z

    1. Initial program 67.4%

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

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

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

        \[\leadsto \color{blue}{\left(y \cdot -4\right)} \cdot {z}^{2} \]
      3. associate-*l*N/A

        \[\leadsto \color{blue}{y \cdot \left(-4 \cdot {z}^{2}\right)} \]
      4. lower-*.f64N/A

        \[\leadsto \color{blue}{y \cdot \left(-4 \cdot {z}^{2}\right)} \]
      5. lower-*.f64N/A

        \[\leadsto y \cdot \color{blue}{\left(-4 \cdot {z}^{2}\right)} \]
      6. unpow2N/A

        \[\leadsto y \cdot \left(-4 \cdot \color{blue}{\left(z \cdot z\right)}\right) \]
      7. lower-*.f6470.9

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

      \[\leadsto \color{blue}{y \cdot \left(-4 \cdot \left(z \cdot z\right)\right)} \]
    6. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto y \cdot \color{blue}{\left(\left(-4 \cdot z\right) \cdot z\right)} \]
      2. associate-*r*N/A

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

        \[\leadsto \color{blue}{\left(\left(y \cdot -4\right) \cdot z\right)} \cdot z \]
      4. lift-*.f64N/A

        \[\leadsto \left(\color{blue}{\left(y \cdot -4\right)} \cdot z\right) \cdot z \]
      5. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(\left(y \cdot -4\right) \cdot z\right)} \cdot z \]
      6. lower-*.f6493.0

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

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

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

Alternative 5: 62.0% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+133}:\\
\;\;\;\;x \cdot x\\

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


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

    1. Initial program 96.6%

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

      \[\leadsto \color{blue}{{x}^{2}} \]
    4. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \color{blue}{x \cdot x} \]
      2. lower-*.f6451.8

        \[\leadsto \color{blue}{x \cdot x} \]
    5. Applied rewrites51.8%

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

    if 2e133 < (*.f64 z z)

    1. Initial program 80.8%

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

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

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

        \[\leadsto \color{blue}{\left(y \cdot -4\right)} \cdot {z}^{2} \]
      3. associate-*l*N/A

        \[\leadsto \color{blue}{y \cdot \left(-4 \cdot {z}^{2}\right)} \]
      4. lower-*.f64N/A

        \[\leadsto \color{blue}{y \cdot \left(-4 \cdot {z}^{2}\right)} \]
      5. lower-*.f64N/A

        \[\leadsto y \cdot \color{blue}{\left(-4 \cdot {z}^{2}\right)} \]
      6. unpow2N/A

        \[\leadsto y \cdot \left(-4 \cdot \color{blue}{\left(z \cdot z\right)}\right) \]
      7. lower-*.f6471.0

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

      \[\leadsto \color{blue}{y \cdot \left(-4 \cdot \left(z \cdot z\right)\right)} \]
    6. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto y \cdot \color{blue}{\left(\left(-4 \cdot z\right) \cdot z\right)} \]
      2. associate-*r*N/A

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

        \[\leadsto \color{blue}{\left(\left(y \cdot -4\right) \cdot z\right)} \cdot z \]
      4. lift-*.f64N/A

        \[\leadsto \left(\color{blue}{\left(y \cdot -4\right)} \cdot z\right) \cdot z \]
      5. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(\left(y \cdot -4\right) \cdot z\right)} \cdot z \]
      6. lower-*.f6481.1

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

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

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

Alternative 6: 58.9% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2.1 \cdot 10^{+133}:\\
\;\;\;\;x \cdot x\\

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


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

    1. Initial program 96.6%

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

      \[\leadsto \color{blue}{{x}^{2}} \]
    4. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \color{blue}{x \cdot x} \]
      2. lower-*.f6451.8

        \[\leadsto \color{blue}{x \cdot x} \]
    5. Applied rewrites51.8%

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

    if 2.1e133 < (*.f64 z z)

    1. Initial program 80.8%

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

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

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

        \[\leadsto \color{blue}{\left(y \cdot -4\right)} \cdot {z}^{2} \]
      3. associate-*l*N/A

        \[\leadsto \color{blue}{y \cdot \left(-4 \cdot {z}^{2}\right)} \]
      4. lower-*.f64N/A

        \[\leadsto \color{blue}{y \cdot \left(-4 \cdot {z}^{2}\right)} \]
      5. lower-*.f64N/A

        \[\leadsto y \cdot \color{blue}{\left(-4 \cdot {z}^{2}\right)} \]
      6. unpow2N/A

        \[\leadsto y \cdot \left(-4 \cdot \color{blue}{\left(z \cdot z\right)}\right) \]
      7. lower-*.f6471.0

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

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

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

Alternative 7: 76.4% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 92.5%

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

      \[\leadsto \color{blue}{{x}^{2} - -4 \cdot \left(t \cdot y\right)} \]
    4. Step-by-step derivation
      1. cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{{x}^{2} + \left(\mathsf{neg}\left(-4\right)\right) \cdot \left(t \cdot y\right)} \]
      2. metadata-evalN/A

        \[\leadsto {x}^{2} + \color{blue}{4} \cdot \left(t \cdot y\right) \]
      3. +-commutativeN/A

        \[\leadsto \color{blue}{4 \cdot \left(t \cdot y\right) + {x}^{2}} \]
      4. associate-*r*N/A

        \[\leadsto \color{blue}{\left(4 \cdot t\right) \cdot y} + {x}^{2} \]
      5. *-commutativeN/A

        \[\leadsto \color{blue}{y \cdot \left(4 \cdot t\right)} + {x}^{2} \]
      6. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, 4 \cdot t, {x}^{2}\right)} \]
      7. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{t \cdot 4}, {x}^{2}\right) \]
      8. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{t \cdot 4}, {x}^{2}\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{fma}\left(y, t \cdot 4, \color{blue}{x \cdot x}\right) \]
      10. lower-*.f6473.0

        \[\leadsto \mathsf{fma}\left(y, t \cdot 4, \color{blue}{x \cdot x}\right) \]
    5. Applied rewrites73.0%

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

    if 4.4999999999999998e66 < z

    1. Initial program 78.8%

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

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

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

        \[\leadsto \color{blue}{\left(y \cdot -4\right)} \cdot {z}^{2} \]
      3. associate-*l*N/A

        \[\leadsto \color{blue}{y \cdot \left(-4 \cdot {z}^{2}\right)} \]
      4. lower-*.f64N/A

        \[\leadsto \color{blue}{y \cdot \left(-4 \cdot {z}^{2}\right)} \]
      5. lower-*.f64N/A

        \[\leadsto y \cdot \color{blue}{\left(-4 \cdot {z}^{2}\right)} \]
      6. unpow2N/A

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

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

      \[\leadsto \color{blue}{y \cdot \left(-4 \cdot \left(z \cdot z\right)\right)} \]
    6. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto y \cdot \color{blue}{\left(\left(-4 \cdot z\right) \cdot z\right)} \]
      2. associate-*r*N/A

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

        \[\leadsto \color{blue}{\left(\left(y \cdot -4\right) \cdot z\right)} \cdot z \]
      4. lift-*.f64N/A

        \[\leadsto \left(\color{blue}{\left(y \cdot -4\right)} \cdot z\right) \cdot z \]
      5. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(\left(y \cdot -4\right) \cdot z\right)} \cdot z \]
      6. lower-*.f6483.7

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

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

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

Alternative 8: 45.1% accurate, 1.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.02 \cdot 10^{+49}:\\
\;\;\;\;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 x < 1.02e49

    1. Initial program 90.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

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

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

        \[\leadsto \color{blue}{y \cdot \left(4 \cdot t\right)} \]
      3. lower-*.f64N/A

        \[\leadsto \color{blue}{y \cdot \left(4 \cdot t\right)} \]
      4. *-commutativeN/A

        \[\leadsto y \cdot \color{blue}{\left(t \cdot 4\right)} \]
      5. lower-*.f6437.3

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

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

    if 1.02e49 < x

    1. Initial program 87.2%

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

      \[\leadsto \color{blue}{{x}^{2}} \]
    4. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \color{blue}{x \cdot x} \]
      2. lower-*.f6481.3

        \[\leadsto \color{blue}{x \cdot x} \]
    5. Applied rewrites81.3%

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

Alternative 9: 41.6% accurate, 4.5× 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 89.9%

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

    \[\leadsto \color{blue}{{x}^{2}} \]
  4. Step-by-step derivation
    1. unpow2N/A

      \[\leadsto \color{blue}{x \cdot x} \]
    2. lower-*.f6439.6

      \[\leadsto \color{blue}{x \cdot x} \]
  5. Applied rewrites39.6%

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

Developer Target 1: 90.9% accurate, 1.0× speedup?

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

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

Reproduce

?
herbie shell --seed 2024214 
(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))))