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

Percentage Accurate: 90.4% → 97.7%
Time: 3.6s
Alternatives: 7
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}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 7 alternatives:

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

Initial Program: 90.4% 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.7% accurate, 0.9× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ \begin{array}{l} \mathbf{if}\;z\_m \leq 5.1 \cdot 10^{+148}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(z\_m, z\_m, -t\right), -4 \cdot y, x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(y \cdot -4\right) \cdot z\_m, z\_m, x \cdot x\right)\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
 :precision binary64
 (if (<= z_m 5.1e+148)
   (fma (fma z_m z_m (- t)) (* -4.0 y) (* x x))
   (fma (* (* y -4.0) z_m) z_m (* x x))))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
	double tmp;
	if (z_m <= 5.1e+148) {
		tmp = fma(fma(z_m, z_m, -t), (-4.0 * y), (x * x));
	} else {
		tmp = fma(((y * -4.0) * z_m), z_m, (x * x));
	}
	return tmp;
}
z_m = abs(z)
function code(x, y, z_m, t)
	tmp = 0.0
	if (z_m <= 5.1e+148)
		tmp = fma(fma(z_m, z_m, Float64(-t)), Float64(-4.0 * y), Float64(x * x));
	else
		tmp = fma(Float64(Float64(y * -4.0) * z_m), z_m, Float64(x * x));
	end
	return tmp
end
z_m = N[Abs[z], $MachinePrecision]
code[x_, y_, z$95$m_, t_] := If[LessEqual[z$95$m, 5.1e+148], N[(N[(z$95$m * z$95$m + (-t)), $MachinePrecision] * N[(-4.0 * y), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y * -4.0), $MachinePrecision] * z$95$m), $MachinePrecision] * z$95$m + N[(x * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|

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

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


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

    1. Initial program 97.7%

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

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

        \[\leadsto \color{blue}{x \cdot x} - \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. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.09999999999999985e148 < z

    1. Initial program 71.5%

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

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

        \[\leadsto \color{blue}{x \cdot x} - \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. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 61.9% accurate, 0.4× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ \begin{array}{l} t_1 := z\_m \cdot z\_m - t\\ t_2 := \left(t \cdot y\right) \cdot 4\\ \mathbf{if}\;t\_1 \leq -4 \cdot 10^{-13}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_1 \leq 50000000:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;t\_1 \leq 10^{+169}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+203}:\\ \;\;\;\;x \cdot x\\ \mathbf{else}:\\ \;\;\;\;\left(\left(y \cdot z\_m\right) \cdot z\_m\right) \cdot -4\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
 :precision binary64
 (let* ((t_1 (- (* z_m z_m) t)) (t_2 (* (* t y) 4.0)))
   (if (<= t_1 -4e-13)
     t_2
     (if (<= t_1 50000000.0)
       (* x x)
       (if (<= t_1 1e+169)
         t_2
         (if (<= t_1 5e+203) (* x x) (* (* (* y z_m) z_m) -4.0)))))))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
	double t_1 = (z_m * z_m) - t;
	double t_2 = (t * y) * 4.0;
	double tmp;
	if (t_1 <= -4e-13) {
		tmp = t_2;
	} else if (t_1 <= 50000000.0) {
		tmp = x * x;
	} else if (t_1 <= 1e+169) {
		tmp = t_2;
	} else if (t_1 <= 5e+203) {
		tmp = x * x;
	} else {
		tmp = ((y * z_m) * z_m) * -4.0;
	}
	return tmp;
}
z_m =     private
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_m, t)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = (z_m * z_m) - t
    t_2 = (t * y) * 4.0d0
    if (t_1 <= (-4d-13)) then
        tmp = t_2
    else if (t_1 <= 50000000.0d0) then
        tmp = x * x
    else if (t_1 <= 1d+169) then
        tmp = t_2
    else if (t_1 <= 5d+203) then
        tmp = x * x
    else
        tmp = ((y * z_m) * z_m) * (-4.0d0)
    end if
    code = tmp
end function
z_m = Math.abs(z);
public static double code(double x, double y, double z_m, double t) {
	double t_1 = (z_m * z_m) - t;
	double t_2 = (t * y) * 4.0;
	double tmp;
	if (t_1 <= -4e-13) {
		tmp = t_2;
	} else if (t_1 <= 50000000.0) {
		tmp = x * x;
	} else if (t_1 <= 1e+169) {
		tmp = t_2;
	} else if (t_1 <= 5e+203) {
		tmp = x * x;
	} else {
		tmp = ((y * z_m) * z_m) * -4.0;
	}
	return tmp;
}
z_m = math.fabs(z)
def code(x, y, z_m, t):
	t_1 = (z_m * z_m) - t
	t_2 = (t * y) * 4.0
	tmp = 0
	if t_1 <= -4e-13:
		tmp = t_2
	elif t_1 <= 50000000.0:
		tmp = x * x
	elif t_1 <= 1e+169:
		tmp = t_2
	elif t_1 <= 5e+203:
		tmp = x * x
	else:
		tmp = ((y * z_m) * z_m) * -4.0
	return tmp
z_m = abs(z)
function code(x, y, z_m, t)
	t_1 = Float64(Float64(z_m * z_m) - t)
	t_2 = Float64(Float64(t * y) * 4.0)
	tmp = 0.0
	if (t_1 <= -4e-13)
		tmp = t_2;
	elseif (t_1 <= 50000000.0)
		tmp = Float64(x * x);
	elseif (t_1 <= 1e+169)
		tmp = t_2;
	elseif (t_1 <= 5e+203)
		tmp = Float64(x * x);
	else
		tmp = Float64(Float64(Float64(y * z_m) * z_m) * -4.0);
	end
	return tmp
end
z_m = abs(z);
function tmp_2 = code(x, y, z_m, t)
	t_1 = (z_m * z_m) - t;
	t_2 = (t * y) * 4.0;
	tmp = 0.0;
	if (t_1 <= -4e-13)
		tmp = t_2;
	elseif (t_1 <= 50000000.0)
		tmp = x * x;
	elseif (t_1 <= 1e+169)
		tmp = t_2;
	elseif (t_1 <= 5e+203)
		tmp = x * x;
	else
		tmp = ((y * z_m) * z_m) * -4.0;
	end
	tmp_2 = tmp;
end
z_m = N[Abs[z], $MachinePrecision]
code[x_, y_, z$95$m_, t_] := Block[{t$95$1 = N[(N[(z$95$m * z$95$m), $MachinePrecision] - t), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision]}, If[LessEqual[t$95$1, -4e-13], t$95$2, If[LessEqual[t$95$1, 50000000.0], N[(x * x), $MachinePrecision], If[LessEqual[t$95$1, 1e+169], t$95$2, If[LessEqual[t$95$1, 5e+203], N[(x * x), $MachinePrecision], N[(N[(N[(y * z$95$m), $MachinePrecision] * z$95$m), $MachinePrecision] * -4.0), $MachinePrecision]]]]]]]
\begin{array}{l}
z_m = \left|z\right|

\\
\begin{array}{l}
t_1 := z\_m \cdot z\_m - t\\
t_2 := \left(t \cdot y\right) \cdot 4\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{-13}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_1 \leq 50000000:\\
\;\;\;\;x \cdot x\\

\mathbf{elif}\;t\_1 \leq 10^{+169}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+203}:\\
\;\;\;\;x \cdot x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (*.f64 z z) t) < -4.0000000000000001e-13 or 5e7 < (-.f64 (*.f64 z z) t) < 9.99999999999999934e168

    1. Initial program 98.8%

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

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

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

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

        \[\leadsto \left(t \cdot y\right) \cdot 4 \]
    5. Applied rewrites58.7%

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

    if -4.0000000000000001e-13 < (-.f64 (*.f64 z z) t) < 5e7 or 9.99999999999999934e168 < (-.f64 (*.f64 z z) t) < 4.99999999999999994e203

    1. Initial program 98.6%

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

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

        \[\leadsto x \cdot \color{blue}{x} \]
      2. lift-*.f6478.4

        \[\leadsto x \cdot \color{blue}{x} \]
    5. Applied rewrites78.4%

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

    if 4.99999999999999994e203 < (-.f64 (*.f64 z z) t)

    1. Initial program 84.6%

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

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

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

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

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

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

        \[\leadsto \left(\left(z \cdot z\right) \cdot y\right) \cdot -4 \]
      6. lift-*.f6473.8

        \[\leadsto \left(\left(z \cdot z\right) \cdot y\right) \cdot -4 \]
    5. Applied rewrites73.8%

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

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

        \[\leadsto \left(\left(z \cdot z\right) \cdot y\right) \cdot -4 \]
      3. pow2N/A

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

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

        \[\leadsto \left(y \cdot \left(z \cdot z\right)\right) \cdot -4 \]
      6. associate-*r*N/A

        \[\leadsto \left(\left(y \cdot z\right) \cdot z\right) \cdot -4 \]
      7. lower-*.f64N/A

        \[\leadsto \left(\left(y \cdot z\right) \cdot z\right) \cdot -4 \]
      8. lower-*.f6479.1

        \[\leadsto \left(\left(y \cdot z\right) \cdot z\right) \cdot -4 \]
    7. Applied rewrites79.1%

      \[\leadsto \left(\left(y \cdot z\right) \cdot z\right) \cdot -4 \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 3: 87.0% accurate, 0.9× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ \begin{array}{l} \mathbf{if}\;z\_m \leq 4.1 \cdot 10^{+30}:\\ \;\;\;\;\mathsf{fma}\left(4 \cdot y, t, x \cdot x\right)\\ \mathbf{elif}\;z\_m \leq 4.2 \cdot 10^{+156}:\\ \;\;\;\;\left(-4 \cdot y\right) \cdot \mathsf{fma}\left(z\_m, z\_m, -t\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(y \cdot z\_m\right) \cdot z\_m\right) \cdot -4\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
 :precision binary64
 (if (<= z_m 4.1e+30)
   (fma (* 4.0 y) t (* x x))
   (if (<= z_m 4.2e+156)
     (* (* -4.0 y) (fma z_m z_m (- t)))
     (* (* (* y z_m) z_m) -4.0))))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
	double tmp;
	if (z_m <= 4.1e+30) {
		tmp = fma((4.0 * y), t, (x * x));
	} else if (z_m <= 4.2e+156) {
		tmp = (-4.0 * y) * fma(z_m, z_m, -t);
	} else {
		tmp = ((y * z_m) * z_m) * -4.0;
	}
	return tmp;
}
z_m = abs(z)
function code(x, y, z_m, t)
	tmp = 0.0
	if (z_m <= 4.1e+30)
		tmp = fma(Float64(4.0 * y), t, Float64(x * x));
	elseif (z_m <= 4.2e+156)
		tmp = Float64(Float64(-4.0 * y) * fma(z_m, z_m, Float64(-t)));
	else
		tmp = Float64(Float64(Float64(y * z_m) * z_m) * -4.0);
	end
	return tmp
end
z_m = N[Abs[z], $MachinePrecision]
code[x_, y_, z$95$m_, t_] := If[LessEqual[z$95$m, 4.1e+30], N[(N[(4.0 * y), $MachinePrecision] * t + N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z$95$m, 4.2e+156], N[(N[(-4.0 * y), $MachinePrecision] * N[(z$95$m * z$95$m + (-t)), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y * z$95$m), $MachinePrecision] * z$95$m), $MachinePrecision] * -4.0), $MachinePrecision]]]
\begin{array}{l}
z_m = \left|z\right|

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

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

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


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

    1. Initial program 97.9%

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. 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 \color{blue}{x \cdot x} - \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. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 4 \cdot \left(t \cdot y\right) + {x}^{2} \]
      9. mul-1-negN/A

        \[\leadsto 4 \cdot \left(t \cdot y\right) + {x}^{2} \]
      10. fp-cancel-sign-sub-invN/A

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

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

        \[\leadsto 4 \cdot \left(t \cdot y\right) + {x}^{2} \]
      13. *-lft-identityN/A

        \[\leadsto 4 \cdot \left(t \cdot y\right) + {x}^{2} \]
      14. pow2N/A

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

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

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

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

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

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

        \[\leadsto \left(y \cdot t\right) \cdot 4 + x \cdot x \]
      4. associate-*l*N/A

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

        \[\leadsto y \cdot \left(4 \cdot t\right) + x \cdot x \]
      6. associate-*r*N/A

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

        \[\leadsto \left(4 \cdot y\right) \cdot t + x \cdot x \]
      8. pow2N/A

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

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

        \[\leadsto \mathsf{fma}\left(4 \cdot y, t, {x}^{2}\right) \]
      11. pow2N/A

        \[\leadsto \mathsf{fma}\left(4 \cdot y, t, x \cdot x\right) \]
      12. lift-*.f6480.4

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

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

    if 4.10000000000000005e30 < z < 4.19999999999999963e156

    1. Initial program 96.3%

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

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

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

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

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

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

        \[\leadsto \left(-4 \cdot y\right) \cdot \left({z}^{2} - t\right) \]
      6. *-lft-identityN/A

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

        \[\leadsto \left(-4 \cdot y\right) \cdot \left({z}^{2} - \left(\mathsf{neg}\left(-1\right)\right) \cdot t\right) \]
      8. fp-cancel-sign-sub-invN/A

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

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

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

        \[\leadsto \left(-4 \cdot y\right) \cdot \mathsf{fma}\left(z, z, \mathsf{neg}\left(t\right)\right) \]
      12. lower-neg.f6475.3

        \[\leadsto \left(-4 \cdot y\right) \cdot \mathsf{fma}\left(z, z, -t\right) \]
    5. Applied rewrites75.3%

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

    if 4.19999999999999963e156 < z

    1. Initial program 70.1%

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

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

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

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

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

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

        \[\leadsto \left(\left(z \cdot z\right) \cdot y\right) \cdot -4 \]
      6. lift-*.f6475.2

        \[\leadsto \left(\left(z \cdot z\right) \cdot y\right) \cdot -4 \]
    5. Applied rewrites75.2%

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

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

        \[\leadsto \left(\left(z \cdot z\right) \cdot y\right) \cdot -4 \]
      3. pow2N/A

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

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

        \[\leadsto \left(y \cdot \left(z \cdot z\right)\right) \cdot -4 \]
      6. associate-*r*N/A

        \[\leadsto \left(\left(y \cdot z\right) \cdot z\right) \cdot -4 \]
      7. lower-*.f64N/A

        \[\leadsto \left(\left(y \cdot z\right) \cdot z\right) \cdot -4 \]
      8. lower-*.f6483.3

        \[\leadsto \left(\left(y \cdot z\right) \cdot z\right) \cdot -4 \]
    7. Applied rewrites83.3%

      \[\leadsto \left(\left(y \cdot z\right) \cdot z\right) \cdot -4 \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 4: 91.5% accurate, 1.0× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ \begin{array}{l} \mathbf{if}\;z\_m \leq 2.85 \cdot 10^{+45}:\\ \;\;\;\;\mathsf{fma}\left(4 \cdot y, t, x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(y \cdot -4\right) \cdot z\_m, z\_m, x \cdot x\right)\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
 :precision binary64
 (if (<= z_m 2.85e+45)
   (fma (* 4.0 y) t (* x x))
   (fma (* (* y -4.0) z_m) z_m (* x x))))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
	double tmp;
	if (z_m <= 2.85e+45) {
		tmp = fma((4.0 * y), t, (x * x));
	} else {
		tmp = fma(((y * -4.0) * z_m), z_m, (x * x));
	}
	return tmp;
}
z_m = abs(z)
function code(x, y, z_m, t)
	tmp = 0.0
	if (z_m <= 2.85e+45)
		tmp = fma(Float64(4.0 * y), t, Float64(x * x));
	else
		tmp = fma(Float64(Float64(y * -4.0) * z_m), z_m, Float64(x * x));
	end
	return tmp
end
z_m = N[Abs[z], $MachinePrecision]
code[x_, y_, z$95$m_, t_] := If[LessEqual[z$95$m, 2.85e+45], N[(N[(4.0 * y), $MachinePrecision] * t + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y * -4.0), $MachinePrecision] * z$95$m), $MachinePrecision] * z$95$m + N[(x * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|

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

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


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

    1. Initial program 97.9%

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. 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 \color{blue}{x \cdot x} - \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. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 4 \cdot \left(t \cdot y\right) + {x}^{2} \]
      9. mul-1-negN/A

        \[\leadsto 4 \cdot \left(t \cdot y\right) + {x}^{2} \]
      10. fp-cancel-sign-sub-invN/A

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

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

        \[\leadsto 4 \cdot \left(t \cdot y\right) + {x}^{2} \]
      13. *-lft-identityN/A

        \[\leadsto 4 \cdot \left(t \cdot y\right) + {x}^{2} \]
      14. pow2N/A

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

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

        \[\leadsto \mathsf{fma}\left(t \cdot y, \color{blue}{4}, {x}^{2}\right) \]
    7. Applied rewrites79.6%

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

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

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

        \[\leadsto \left(y \cdot t\right) \cdot 4 + x \cdot x \]
      4. associate-*l*N/A

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

        \[\leadsto y \cdot \left(4 \cdot t\right) + x \cdot x \]
      6. associate-*r*N/A

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

        \[\leadsto \left(4 \cdot y\right) \cdot t + x \cdot x \]
      8. pow2N/A

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

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

        \[\leadsto \mathsf{fma}\left(4 \cdot y, t, {x}^{2}\right) \]
      11. pow2N/A

        \[\leadsto \mathsf{fma}\left(4 \cdot y, t, x \cdot x\right) \]
      12. lift-*.f6480.1

        \[\leadsto \mathsf{fma}\left(4 \cdot y, t, x \cdot x\right) \]
    9. Applied rewrites80.1%

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

    if 2.85000000000000013e45 < z

    1. Initial program 80.5%

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

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

        \[\leadsto \color{blue}{x \cdot x} - \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. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 85.4% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 97.6%

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

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

        \[\leadsto \color{blue}{x \cdot x} - \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. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 4 \cdot \left(t \cdot y\right) + {x}^{2} \]
      9. mul-1-negN/A

        \[\leadsto 4 \cdot \left(t \cdot y\right) + {x}^{2} \]
      10. fp-cancel-sign-sub-invN/A

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

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

        \[\leadsto 4 \cdot \left(t \cdot y\right) + {x}^{2} \]
      13. *-lft-identityN/A

        \[\leadsto 4 \cdot \left(t \cdot y\right) + {x}^{2} \]
      14. pow2N/A

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

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

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

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

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

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

        \[\leadsto \left(y \cdot t\right) \cdot 4 + x \cdot x \]
      4. associate-*l*N/A

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

        \[\leadsto y \cdot \left(4 \cdot t\right) + x \cdot x \]
      6. associate-*r*N/A

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

        \[\leadsto \left(4 \cdot y\right) \cdot t + x \cdot x \]
      8. pow2N/A

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

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

        \[\leadsto \mathsf{fma}\left(4 \cdot y, t, {x}^{2}\right) \]
      11. pow2N/A

        \[\leadsto \mathsf{fma}\left(4 \cdot y, t, x \cdot x\right) \]
      12. lift-*.f6478.7

        \[\leadsto \mathsf{fma}\left(4 \cdot y, t, x \cdot x\right) \]
    9. Applied rewrites78.7%

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

    if 6.19999999999999998e101 < z

    1. Initial program 76.6%

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

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

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

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

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

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

        \[\leadsto \left(\left(z \cdot z\right) \cdot y\right) \cdot -4 \]
      6. lift-*.f6473.7

        \[\leadsto \left(\left(z \cdot z\right) \cdot y\right) \cdot -4 \]
    5. Applied rewrites73.7%

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

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

        \[\leadsto \left(\left(z \cdot z\right) \cdot y\right) \cdot -4 \]
      3. pow2N/A

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

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

        \[\leadsto \left(y \cdot \left(z \cdot z\right)\right) \cdot -4 \]
      6. associate-*r*N/A

        \[\leadsto \left(\left(y \cdot z\right) \cdot z\right) \cdot -4 \]
      7. lower-*.f64N/A

        \[\leadsto \left(\left(y \cdot z\right) \cdot z\right) \cdot -4 \]
      8. lower-*.f6480.0

        \[\leadsto \left(\left(y \cdot z\right) \cdot z\right) \cdot -4 \]
    7. Applied rewrites80.0%

      \[\leadsto \left(\left(y \cdot z\right) \cdot z\right) \cdot -4 \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 57.8% accurate, 1.2× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ \begin{array}{l} \mathbf{if}\;x \cdot x \leq 1.2 \cdot 10^{-76}:\\ \;\;\;\;\left(t \cdot y\right) \cdot 4\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
 :precision binary64
 (if (<= (* x x) 1.2e-76) (* (* t y) 4.0) (* x x)))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
	double tmp;
	if ((x * x) <= 1.2e-76) {
		tmp = (t * y) * 4.0;
	} else {
		tmp = x * x;
	}
	return tmp;
}
z_m =     private
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_m, t)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((x * x) <= 1.2d-76) then
        tmp = (t * y) * 4.0d0
    else
        tmp = x * x
    end if
    code = tmp
end function
z_m = Math.abs(z);
public static double code(double x, double y, double z_m, double t) {
	double tmp;
	if ((x * x) <= 1.2e-76) {
		tmp = (t * y) * 4.0;
	} else {
		tmp = x * x;
	}
	return tmp;
}
z_m = math.fabs(z)
def code(x, y, z_m, t):
	tmp = 0
	if (x * x) <= 1.2e-76:
		tmp = (t * y) * 4.0
	else:
		tmp = x * x
	return tmp
z_m = abs(z)
function code(x, y, z_m, t)
	tmp = 0.0
	if (Float64(x * x) <= 1.2e-76)
		tmp = Float64(Float64(t * y) * 4.0);
	else
		tmp = Float64(x * x);
	end
	return tmp
end
z_m = abs(z);
function tmp_2 = code(x, y, z_m, t)
	tmp = 0.0;
	if ((x * x) <= 1.2e-76)
		tmp = (t * y) * 4.0;
	else
		tmp = x * x;
	end
	tmp_2 = tmp;
end
z_m = N[Abs[z], $MachinePrecision]
code[x_, y_, z$95$m_, t_] := If[LessEqual[N[(x * x), $MachinePrecision], 1.2e-76], N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|

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

\mathbf{else}:\\
\;\;\;\;x \cdot x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x x) < 1.20000000000000007e-76

    1. Initial program 95.5%

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

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

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

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

        \[\leadsto \left(t \cdot y\right) \cdot 4 \]
    5. Applied rewrites54.4%

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

    if 1.20000000000000007e-76 < (*.f64 x x)

    1. Initial program 91.9%

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

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

        \[\leadsto x \cdot \color{blue}{x} \]
      2. lift-*.f6468.1

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

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

Alternative 7: 40.5% accurate, 4.5× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ x \cdot x \end{array} \]
z_m = (fabs.f64 z)
(FPCore (x y z_m t) :precision binary64 (* x x))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
	return x * x;
}
z_m =     private
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_m, t)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z_m
    real(8), intent (in) :: t
    code = x * x
end function
z_m = Math.abs(z);
public static double code(double x, double y, double z_m, double t) {
	return x * x;
}
z_m = math.fabs(z)
def code(x, y, z_m, t):
	return x * x
z_m = abs(z)
function code(x, y, z_m, t)
	return Float64(x * x)
end
z_m = abs(z);
function tmp = code(x, y, z_m, t)
	tmp = x * x;
end
z_m = N[Abs[z], $MachinePrecision]
code[x_, y_, z$95$m_, t_] := N[(x * x), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|

\\
x \cdot x
\end{array}
Derivation
  1. Initial program 93.5%

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

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

      \[\leadsto x \cdot \color{blue}{x} \]
    2. lift-*.f6441.3

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

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

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

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

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

Reproduce

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

  :alt
  (! :herbie-platform default (- (* x x) (* 4 (* y (- (* z z) t)))))

  (- (* x x) (* (* y 4.0) (- (* z z) t))))