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

Percentage Accurate: 90.6% → 97.5%
Time: 3.4s
Alternatives: 9
Speedup: 1.0×

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 9 alternatives:

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

Initial Program: 90.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \end{array} \]
(FPCore (x y z t) :precision binary64 (- (* x x) (* (* y 4.0) (- (* z z) t))))
double code(double x, double y, double z, double t) {
	return (x * x) - ((y * 4.0) * ((z * z) - t));
}
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: 97.5% accurate, 0.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < 2.0000000000000001e69

    1. Initial program 90.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{\left(y \cdot t + \left(y \cdot \left(-z\right)\right) \cdot z\right)} \cdot 4\right) \]
      3. add-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.0000000000000001e69 < t

    1. Initial program 90.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 97.1% accurate, 0.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < 2.10000000000000015e69

    1. Initial program 90.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{\left(y \cdot t + \left(y \cdot \left(-z\right)\right) \cdot z\right)} \cdot 4\right) \]
      3. add-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.10000000000000015e69 < t

    1. Initial program 90.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 95.1% accurate, 0.9× speedup?

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

\\
\mathsf{fma}\left(x, x, \left(t \cdot y - \left(z \cdot y\right) \cdot z\right) \cdot 4\right)
\end{array}
Derivation
  1. Initial program 90.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{\left(y \cdot t + \left(y \cdot \left(-z\right)\right) \cdot z\right)} \cdot 4\right) \]
    3. add-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 92.7% accurate, 1.0× speedup?

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

\\
\mathsf{fma}\left(x, x, \left(z \cdot z - t\right) \cdot \left(-4 \cdot y\right)\right)
\end{array}
Derivation
  1. Initial program 90.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 92.7% accurate, 1.0× speedup?

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

\\
\mathsf{fma}\left(x, x, \left(\left(t - z \cdot z\right) \cdot y\right) \cdot 4\right)
\end{array}
Derivation
  1. Initial program 90.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 66.8% accurate, 1.5× speedup?

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

\\
\mathsf{fma}\left(4 \cdot t, y, x \cdot x\right)
\end{array}
Derivation
  1. Initial program 90.6%

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

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

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

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

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

      \[\leadsto x \cdot x - \color{blue}{\left(y \cdot 4\right) \cdot \left(-1 \cdot 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(-1 \cdot t\right)} \]
    4. +-commutativeN/A

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(4\right)\right) \cdot \left(-1 \cdot t\right)}, y, x \cdot x\right) \]
    13. metadata-eval66.8

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

      \[\leadsto \mathsf{fma}\left(-4 \cdot \left(-1 \cdot \color{blue}{t}\right), y, x \cdot x\right) \]
    15. mul-1-negN/A

      \[\leadsto \mathsf{fma}\left(-4 \cdot \left(\mathsf{neg}\left(t\right)\right), y, x \cdot x\right) \]
    16. lift-neg.f6466.8

      \[\leadsto \mathsf{fma}\left(-4 \cdot \left(-t\right), y, x \cdot x\right) \]
  6. Applied rewrites66.8%

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

    \[\leadsto \mathsf{fma}\left(\color{blue}{4 \cdot t}, y, x \cdot x\right) \]
  8. Step-by-step derivation
    1. lower-*.f6466.8

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

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

Alternative 7: 66.3% 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 90.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 8: 32.1% accurate, 2.6× speedup?

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

      \[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-*.f6432.1

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

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

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

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

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

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

        \[\leadsto \left(y \cdot 4\right) \cdot t \]
      6. lift-*.f64N/A

        \[\leadsto \left(y \cdot 4\right) \cdot t \]
      7. lower-*.f6432.1

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

        \[\leadsto \left(y \cdot 4\right) \cdot t \]
      9. *-commutativeN/A

        \[\leadsto \left(4 \cdot y\right) \cdot t \]
      10. lower-*.f6432.1

        \[\leadsto \left(4 \cdot y\right) \cdot t \]
    6. Applied rewrites32.1%

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

    Alternative 9: 32.1% 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 90.6%

      \[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-*.f6432.1

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

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

    Reproduce

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