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

Percentage Accurate: 90.5% → 96.8%
Time: 10.9s
Alternatives: 10
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 10 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.5% 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: 96.8% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 99.4%

      \[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. *-commutativeN/A

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(z, z, \mathsf{neg}\left(t\right)\right), \mathsf{neg}\left(\color{blue}{y \cdot 4}\right), x \cdot x\right) \]
      18. distribute-rgt-neg-inN/A

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

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(z, z, \mathsf{neg}\left(t\right)\right), \color{blue}{y \cdot \left(\mathsf{neg}\left(4\right)\right)}, x \cdot x\right) \]
      20. metadata-eval99.9

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

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

    if 1.99999999999999991e271 < (*.f64 z z)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot x - \color{blue}{\left(z \cdot \left(z \cdot y\right)\right)} \cdot 4 \]
      12. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 87.0% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+41}:\\ \;\;\;\;\mathsf{fma}\left(y, t \cdot 4, x \cdot x\right)\\ \mathbf{elif}\;z \cdot z \leq 10^{+235}:\\ \;\;\;\;y \cdot \mathsf{fma}\left(z, z \cdot -4, 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 z) 2e+41)
   (fma y (* t 4.0) (* x x))
   (if (<= (* z z) 1e+235)
     (* y (fma z (* z -4.0) (* t 4.0)))
     (* -4.0 (* z (* z y))))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((z * z) <= 2e+41) {
		tmp = fma(y, (t * 4.0), (x * x));
	} else if ((z * z) <= 1e+235) {
		tmp = y * fma(z, (z * -4.0), (t * 4.0));
	} else {
		tmp = -4.0 * (z * (z * y));
	}
	return tmp;
}
function code(x, y, z, t)
	tmp = 0.0
	if (Float64(z * z) <= 2e+41)
		tmp = fma(y, Float64(t * 4.0), Float64(x * x));
	elseif (Float64(z * z) <= 1e+235)
		tmp = Float64(y * fma(z, Float64(z * -4.0), Float64(t * 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], 2e+41], N[(y * N[(t * 4.0), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * z), $MachinePrecision], 1e+235], N[(y * N[(z * N[(z * -4.0), $MachinePrecision] + 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 \cdot z \leq 2 \cdot 10^{+41}:\\
\;\;\;\;\mathsf{fma}\left(y, t \cdot 4, x \cdot x\right)\\

\mathbf{elif}\;z \cdot z \leq 10^{+235}:\\
\;\;\;\;y \cdot \mathsf{fma}\left(z, z \cdot -4, 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 3 regimes
  2. if (*.f64 z z) < 2.00000000000000001e41

    1. Initial program 100.0%

      \[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-*.f6495.9

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

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

    if 2.00000000000000001e41 < (*.f64 z z) < 1.0000000000000001e235

    1. Initial program 99.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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\left(z \cdot z\right) \cdot y, -4, \color{blue}{4 \cdot \left(t \cdot y\right)}\right) \]
    8. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

        \[\leadsto y \cdot \left(\left(z \cdot z\right) \cdot -4\right) + \color{blue}{y \cdot \left(t \cdot 4\right)} \]
      8. distribute-lft-outN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.0000000000000001e235 < (*.f64 z z)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 87.0% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+41}:\\ \;\;\;\;\mathsf{fma}\left(y, t \cdot 4, x \cdot x\right)\\ \mathbf{elif}\;z \cdot z \leq 10^{+241}:\\ \;\;\;\;\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 z) 2e+41)
   (fma y (* t 4.0) (* x x))
   (if (<= (* z z) 1e+241)
     (* (- (* 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) <= 2e+41) {
		tmp = fma(y, (t * 4.0), (x * x));
	} else if ((z * z) <= 1e+241) {
		tmp = ((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) <= 2e+41)
		tmp = fma(y, Float64(t * 4.0), Float64(x * x));
	elseif (Float64(z * z) <= 1e+241)
		tmp = 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], 2e+41], N[(y * N[(t * 4.0), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * z), $MachinePrecision], 1e+241], N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * N[(y * -4.0), $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 2 \cdot 10^{+41}:\\
\;\;\;\;\mathsf{fma}\left(y, t \cdot 4, x \cdot x\right)\\

\mathbf{elif}\;z \cdot z \leq 10^{+241}:\\
\;\;\;\;\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 3 regimes
  2. if (*.f64 z z) < 2.00000000000000001e41

    1. Initial program 100.0%

      \[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-*.f6495.9

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

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

    if 2.00000000000000001e41 < (*.f64 z z) < 1.0000000000000001e241

    1. Initial program 99.7%

      \[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. associate-*r*N/A

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

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

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

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

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

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

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

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

    if 1.0000000000000001e241 < (*.f64 z z)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+41}:\\ \;\;\;\;\mathsf{fma}\left(y, t \cdot 4, x \cdot x\right)\\ \mathbf{elif}\;z \cdot z \leq 10^{+241}:\\ \;\;\;\;\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 4: 39.6% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (*.f64 y #s(literal 4 binary64)) (-.f64 (*.f64 z z) t)) < 2.00000000000000011e301

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

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

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

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

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

    if 2.00000000000000011e301 < (*.f64 (*.f64 y #s(literal 4 binary64)) (-.f64 (*.f64 z z) t))

    1. Initial program 77.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. associate-*r*N/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-4 \cdot \left(t \cdot y\right)} \]
    8. 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. lower-*.f6412.9

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

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

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

Alternative 5: 51.3% accurate, 0.8× speedup?

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

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

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

\mathbf{elif}\;z \leq 9 \cdot 10^{+20}:\\
\;\;\;\;x \cdot x\\

\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 < 3.6000000000000002e-200 or 3.50000000000000019e-97 < z < 9e20

    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 x around inf

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

        \[\leadsto \color{blue}{x \cdot x} \]
      2. lower-*.f6450.9

        \[\leadsto \color{blue}{x \cdot x} \]
    5. Applied rewrites50.9%

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

    if 3.6000000000000002e-200 < z < 3.50000000000000019e-97

    1. Initial program 99.9%

      \[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-*.f6460.6

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

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

    if 9e20 < z

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 49.7% accurate, 0.8× speedup?

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

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

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

\mathbf{elif}\;z \leq 9 \cdot 10^{+20}:\\
\;\;\;\;x \cdot x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < 3.6000000000000002e-200 or 3.50000000000000019e-97 < z < 9e20

    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 x around inf

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

        \[\leadsto \color{blue}{x \cdot x} \]
      2. lower-*.f6450.9

        \[\leadsto \color{blue}{x \cdot x} \]
    5. Applied rewrites50.9%

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

    if 3.6000000000000002e-200 < z < 3.50000000000000019e-97

    1. Initial program 99.9%

      \[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-*.f6460.6

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

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

    if 9e20 < z

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

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

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

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

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

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

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

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

Alternative 7: 90.2% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 100.0%

      \[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-*.f6495.8

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

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

    if 1.99999999999999995e38 < (*.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. Taylor expanded in z around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot x - \color{blue}{\left(z \cdot \left(z \cdot y\right)\right)} \cdot 4 \]
      12. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 85.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \cdot z \leq 10^{+100}:\\ \;\;\;\;\mathsf{fma}\left(y, t \cdot 4, x \cdot x\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) 1e+100) (fma y (* t 4.0) (* x x)) (* -4.0 (* z (* z y)))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((z * z) <= 1e+100) {
		tmp = fma(y, (t * 4.0), (x * x));
	} else {
		tmp = -4.0 * (z * (z * y));
	}
	return tmp;
}
function code(x, y, z, t)
	tmp = 0.0
	if (Float64(z * z) <= 1e+100)
		tmp = fma(y, Float64(t * 4.0), Float64(x * x));
	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], 1e+100], N[(y * N[(t * 4.0), $MachinePrecision] + N[(x * x), $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 10^{+100}:\\
\;\;\;\;\mathsf{fma}\left(y, t \cdot 4, x \cdot x\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) < 1.00000000000000002e100

    1. Initial program 100.0%

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

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

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

    if 1.00000000000000002e100 < (*.f64 z z)

    1. Initial program 82.9%

      \[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. lower-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 45.0% accurate, 1.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.2 \cdot 10^{-38}:\\
\;\;\;\;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.20000000000000011e-38

    1. Initial program 95.8%

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

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

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

    if 1.20000000000000011e-38 < x

    1. Initial program 86.8%

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

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

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

Alternative 10: 40.7% 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 93.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-*.f6443.1

      \[\leadsto \color{blue}{x \cdot x} \]
  5. Applied rewrites43.1%

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

Developer Target 1: 90.5% 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 2024219 
(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))))