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

Percentage Accurate: 91.0% → 95.5%
Time: 3.0s
Alternatives: 6
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));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z, t)
use fmin_fmax_functions
    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}

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 6 alternatives:

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

Initial Program: 91.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \end{array} \]
(FPCore (x y z t) :precision binary64 (- (* x x) (* (* y 4.0) (- (* z z) t))))
double code(double x, double y, double z, double t) {
	return (x * x) - ((y * 4.0) * ((z * z) - t));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

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

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

Alternative 1: 95.5% accurate, 0.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 6.19999999999999977e246

    1. Initial program 91.0%

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. 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. fp-cancel-sub-sign-invN/A

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

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(z \cdot z - t\right) + x \cdot x} \]
      5. 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 \]
      6. sub-flipN/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 \]
      7. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(\mathsf{neg}\left(z\right)\right) \cdot \left(y \cdot 4\right)\right) \cdot z + \left(\color{blue}{\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(\mathsf{neg}\left(t\right)\right)} + x \cdot x\right) \]
    3. Applied rewrites94.7%

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

    if 6.19999999999999977e246 < y

    1. Initial program 91.0%

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. 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 - \color{blue}{\left(y \cdot 4\right)} \cdot \left(z \cdot z - t\right) \]
      4. associate-*l*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 93.8% accurate, 0.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 3.4000000000000001e-96

    1. Initial program 91.0%

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. 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. fp-cancel-sub-sign-invN/A

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

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(z \cdot z - t\right) + x \cdot x} \]
      5. 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 \]
      6. sub-flipN/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 \]
      7. distribute-rgt-inN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(\mathsf{neg}\left(z\right)\right) \cdot \left(y \cdot 4\right)\right) \cdot z + \left(\color{blue}{\left(\mathsf{neg}\left(y \cdot 4\right)\right) \cdot \left(\mathsf{neg}\left(t\right)\right)} + x \cdot x\right) \]
    3. Applied rewrites94.7%

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

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

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

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

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

    if 3.4000000000000001e-96 < x < 9.9999999999999991e211

    1. Initial program 91.0%

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. 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 - \color{blue}{\left(y \cdot 4\right)} \cdot \left(z \cdot z - t\right) \]
      4. associate-*l*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.9999999999999991e211 < x

    1. Initial program 91.0%

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. 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 - \color{blue}{\left(y \cdot 4\right)} \cdot \left(z \cdot z - t\right) \]
      4. associate-*l*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \left(t \cdot y\right) \cdot 4 + \color{blue}{x \cdot x} \]
        5. sqr-abs-revN/A

          \[\leadsto \left(t \cdot y\right) \cdot 4 + \color{blue}{\left|x\right| \cdot \left|x\right|} \]
        6. sqr-neg-revN/A

          \[\leadsto \left(t \cdot y\right) \cdot 4 + \color{blue}{\left(\mathsf{neg}\left(\left|x\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|x\right|\right)\right)} \]
        7. fp-cancel-sign-sub-invN/A

          \[\leadsto \color{blue}{\left(t \cdot y\right) \cdot 4 - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|x\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|x\right|\right)\right)} \]
        8. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

          \[\leadsto \left(t \cdot 4\right) \cdot y + \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|x\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right)\right)}\right)\right) \]
        16. sqr-neg-revN/A

          \[\leadsto \left(t \cdot 4\right) \cdot y + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{\left|x\right| \cdot \left|x\right|}\right)\right)\right)\right) \]
        17. sqr-abs-revN/A

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

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

          \[\leadsto \left(t \cdot 4\right) \cdot y + \color{blue}{x \cdot x} \]
      3. Applied rewrites68.1%

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

    Alternative 3: 79.3% accurate, 0.8× speedup?

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

      1. Initial program 91.0%

        \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
      2. 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 - \color{blue}{\left(y \cdot 4\right)} \cdot \left(z \cdot z - t\right) \]
        4. associate-*l*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if 9.9999999999999991e211 < x

      1. Initial program 91.0%

        \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
      2. 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 - \color{blue}{\left(y \cdot 4\right)} \cdot \left(z \cdot z - t\right) \]
        4. associate-*l*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \left(t \cdot y\right) \cdot 4 + \color{blue}{x \cdot x} \]
          5. sqr-abs-revN/A

            \[\leadsto \left(t \cdot y\right) \cdot 4 + \color{blue}{\left|x\right| \cdot \left|x\right|} \]
          6. sqr-neg-revN/A

            \[\leadsto \left(t \cdot y\right) \cdot 4 + \color{blue}{\left(\mathsf{neg}\left(\left|x\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|x\right|\right)\right)} \]
          7. fp-cancel-sign-sub-invN/A

            \[\leadsto \color{blue}{\left(t \cdot y\right) \cdot 4 - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|x\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|x\right|\right)\right)} \]
          8. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

            \[\leadsto \left(t \cdot 4\right) \cdot y + \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|x\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right)\right)}\right)\right) \]
          16. sqr-neg-revN/A

            \[\leadsto \left(t \cdot 4\right) \cdot y + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{\left|x\right| \cdot \left|x\right|}\right)\right)\right)\right) \]
          17. sqr-abs-revN/A

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

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

            \[\leadsto \left(t \cdot 4\right) \cdot y + \color{blue}{x \cdot x} \]
        3. Applied rewrites68.1%

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

      Alternative 4: 68.1% accurate, 1.5× speedup?

      \[\begin{array}{l} \\ \mathsf{fma}\left(t \cdot 4, y, x \cdot x\right) \end{array} \]
      (FPCore (x y z t) :precision binary64 (fma (* t 4.0) y (* x x)))
      double code(double x, double y, double z, double t) {
      	return fma((t * 4.0), y, (x * x));
      }
      
      function code(x, y, z, t)
      	return fma(Float64(t * 4.0), y, Float64(x * x))
      end
      
      code[x_, y_, z_, t_] := N[(N[(t * 4.0), $MachinePrecision] * y + N[(x * x), $MachinePrecision]), $MachinePrecision]
      
      \begin{array}{l}
      
      \\
      \mathsf{fma}\left(t \cdot 4, y, x \cdot x\right)
      \end{array}
      
      Derivation
      1. Initial program 91.0%

        \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
      2. 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 - \color{blue}{\left(y \cdot 4\right)} \cdot \left(z \cdot z - t\right) \]
        4. associate-*l*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \left(t \cdot y\right) \cdot 4 + \color{blue}{x \cdot x} \]
          5. sqr-abs-revN/A

            \[\leadsto \left(t \cdot y\right) \cdot 4 + \color{blue}{\left|x\right| \cdot \left|x\right|} \]
          6. sqr-neg-revN/A

            \[\leadsto \left(t \cdot y\right) \cdot 4 + \color{blue}{\left(\mathsf{neg}\left(\left|x\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|x\right|\right)\right)} \]
          7. fp-cancel-sign-sub-invN/A

            \[\leadsto \color{blue}{\left(t \cdot y\right) \cdot 4 - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|x\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|x\right|\right)\right)} \]
          8. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

            \[\leadsto \left(t \cdot 4\right) \cdot y + \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|x\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|x\right|\right)\right)\right)\right)}\right)\right) \]
          16. sqr-neg-revN/A

            \[\leadsto \left(t \cdot 4\right) \cdot y + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{\left|x\right| \cdot \left|x\right|}\right)\right)\right)\right) \]
          17. sqr-abs-revN/A

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

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

            \[\leadsto \left(t \cdot 4\right) \cdot y + \color{blue}{x \cdot x} \]
        3. Applied rewrites68.1%

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

        Alternative 5: 67.6% accurate, 1.5× speedup?

        \[\begin{array}{l} \\ \mathsf{fma}\left(x, x, \left(t \cdot y\right) \cdot 4\right) \end{array} \]
        (FPCore (x y z t) :precision binary64 (fma x x (* (* t y) 4.0)))
        double code(double x, double y, double z, double t) {
        	return fma(x, x, ((t * y) * 4.0));
        }
        
        function code(x, y, z, t)
        	return fma(x, x, Float64(Float64(t * y) * 4.0))
        end
        
        code[x_, y_, z_, t_] := N[(x * x + N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]
        
        \begin{array}{l}
        
        \\
        \mathsf{fma}\left(x, x, \left(t \cdot y\right) \cdot 4\right)
        \end{array}
        
        Derivation
        1. Initial program 91.0%

          \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
        2. 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 - \color{blue}{\left(y \cdot 4\right)} \cdot \left(z \cdot z - t\right) \]
          4. associate-*l*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          Alternative 6: 31.7% accurate, 2.6× speedup?

          \[\begin{array}{l} \\ 4 \cdot \left(t \cdot y\right) \end{array} \]
          (FPCore (x y z t) :precision binary64 (* 4.0 (* t y)))
          double code(double x, double y, double z, double t) {
          	return 4.0 * (t * y);
          }
          
          module fmin_fmax_functions
              implicit none
              private
              public fmax
              public fmin
          
              interface fmax
                  module procedure fmax88
                  module procedure fmax44
                  module procedure fmax84
                  module procedure fmax48
              end interface
              interface fmin
                  module procedure fmin88
                  module procedure fmin44
                  module procedure fmin84
                  module procedure fmin48
              end interface
          contains
              real(8) function fmax88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(4) function fmax44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(8) function fmax84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmax48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
              end function
              real(8) function fmin88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(4) function fmin44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(8) function fmin84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmin48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
              end function
          end module
          
          real(8) function code(x, y, z, t)
          use fmin_fmax_functions
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              real(8), intent (in) :: z
              real(8), intent (in) :: t
              code = 4.0d0 * (t * y)
          end function
          
          public static double code(double x, double y, double z, double t) {
          	return 4.0 * (t * y);
          }
          
          def code(x, y, z, t):
          	return 4.0 * (t * y)
          
          function code(x, y, z, t)
          	return Float64(4.0 * Float64(t * y))
          end
          
          function tmp = code(x, y, z, t)
          	tmp = 4.0 * (t * y);
          end
          
          code[x_, y_, z_, t_] := N[(4.0 * N[(t * y), $MachinePrecision]), $MachinePrecision]
          
          \begin{array}{l}
          
          \\
          4 \cdot \left(t \cdot y\right)
          \end{array}
          
          Derivation
          1. Initial program 91.0%

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

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

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

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

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

          Reproduce

          ?
          herbie shell --seed 2025149 
          (FPCore (x y z t)
            :name "Graphics.Rasterific.Shading:$sradialGradientWithFocusShader from Rasterific-0.6.1, B"
            :precision binary64
            (- (* x x) (* (* y 4.0) (- (* z z) t))))