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

Percentage Accurate: 91.1% → 95.8%
Time: 9.1s
Alternatives: 7
Speedup: 0.8×

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 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: 91.1% accurate, 1.0× speedup?

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

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

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

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

Alternative 1: 95.8% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 97.7%

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]

    if 5.00000000000000008e140 < z

    1. Initial program 73.1%

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

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

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

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

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

        \[\leadsto x \cdot x - \left(\left(-4 \cdot \frac{t \cdot y}{{z}^{2}} + 4 \cdot y\right) \cdot z\right) \cdot \color{blue}{z} \]
    4. Applied rewrites90.8%

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

Alternative 2: 95.1% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 97.1%

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]

    if 6.1999999999999996e159 < z

    1. Initial program 71.8%

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

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

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

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

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

        \[\leadsto \left(\left(\frac{{x}^{2}}{{z}^{2}} - \left(-4 \cdot \frac{t \cdot y}{{z}^{2}} + 4 \cdot y\right)\right) \cdot z\right) \cdot \color{blue}{z} \]
    4. Applied rewrites62.0%

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

      \[\leadsto \left(\left(-4 \cdot y\right) \cdot z\right) \cdot z \]
    6. Step-by-step derivation
      1. lower-*.f6488.9

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

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

Alternative 3: 89.0% accurate, 0.8× speedup?

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

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

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

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


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

    1. Initial program 98.2%

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

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

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

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

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

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

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

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

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

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

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

    if 6.7999999999999996e36 < z < 6.1999999999999996e159

    1. Initial program 94.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\left(z \cdot z\right) \cdot y, -4, x \cdot x\right) \]
      11. lift-*.f6483.8

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

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

    if 6.1999999999999996e159 < z

    1. Initial program 71.8%

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

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

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

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

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

        \[\leadsto \left(\left(\frac{{x}^{2}}{{z}^{2}} - \left(-4 \cdot \frac{t \cdot y}{{z}^{2}} + 4 \cdot y\right)\right) \cdot z\right) \cdot \color{blue}{z} \]
    4. Applied rewrites62.0%

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

      \[\leadsto \left(\left(-4 \cdot y\right) \cdot z\right) \cdot z \]
    6. Step-by-step derivation
      1. lower-*.f6488.9

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

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

Alternative 4: 84.6% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 98.1%

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

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

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

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

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

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

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

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

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

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

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

    if 2.35000000000000009e44 < z

    1. Initial program 81.5%

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

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

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

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

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

        \[\leadsto \left(\left(\frac{{x}^{2}}{{z}^{2}} - \left(-4 \cdot \frac{t \cdot y}{{z}^{2}} + 4 \cdot y\right)\right) \cdot z\right) \cdot \color{blue}{z} \]
    4. Applied rewrites75.5%

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

      \[\leadsto \left(\left(-4 \cdot y\right) \cdot z\right) \cdot z \]
    6. Step-by-step derivation
      1. lower-*.f6476.8

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

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

Alternative 5: 60.9% accurate, 0.4× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ \begin{array}{l} t_1 := x \cdot x - \left(y \cdot 4\right) \cdot \left(z\_m \cdot z\_m - t\right)\\ \mathbf{if}\;t\_1 \leq -5 \cdot 10^{+298}:\\ \;\;\;\;\left(\left(-4 \cdot y\right) \cdot z\_m\right) \cdot z\_m\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-152}:\\ \;\;\;\;\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
 (let* ((t_1 (- (* x x) (* (* y 4.0) (- (* z_m z_m) t)))))
   (if (<= t_1 -5e+298)
     (* (* (* -4.0 y) z_m) z_m)
     (if (<= t_1 5e-152) (* (* t y) 4.0) (* x x)))))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
	double t_1 = (x * x) - ((y * 4.0) * ((z_m * z_m) - t));
	double tmp;
	if (t_1 <= -5e+298) {
		tmp = ((-4.0 * y) * z_m) * z_m;
	} else if (t_1 <= 5e-152) {
		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) :: t_1
    real(8) :: tmp
    t_1 = (x * x) - ((y * 4.0d0) * ((z_m * z_m) - t))
    if (t_1 <= (-5d+298)) then
        tmp = (((-4.0d0) * y) * z_m) * z_m
    else if (t_1 <= 5d-152) 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 t_1 = (x * x) - ((y * 4.0) * ((z_m * z_m) - t));
	double tmp;
	if (t_1 <= -5e+298) {
		tmp = ((-4.0 * y) * z_m) * z_m;
	} else if (t_1 <= 5e-152) {
		tmp = (t * y) * 4.0;
	} else {
		tmp = x * x;
	}
	return tmp;
}
z_m = math.fabs(z)
def code(x, y, z_m, t):
	t_1 = (x * x) - ((y * 4.0) * ((z_m * z_m) - t))
	tmp = 0
	if t_1 <= -5e+298:
		tmp = ((-4.0 * y) * z_m) * z_m
	elif t_1 <= 5e-152:
		tmp = (t * y) * 4.0
	else:
		tmp = x * x
	return tmp
z_m = abs(z)
function code(x, y, z_m, t)
	t_1 = Float64(Float64(x * x) - Float64(Float64(y * 4.0) * Float64(Float64(z_m * z_m) - t)))
	tmp = 0.0
	if (t_1 <= -5e+298)
		tmp = Float64(Float64(Float64(-4.0 * y) * z_m) * z_m);
	elseif (t_1 <= 5e-152)
		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)
	t_1 = (x * x) - ((y * 4.0) * ((z_m * z_m) - t));
	tmp = 0.0;
	if (t_1 <= -5e+298)
		tmp = ((-4.0 * y) * z_m) * z_m;
	elseif (t_1 <= 5e-152)
		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_] := Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] - N[(N[(y * 4.0), $MachinePrecision] * N[(N[(z$95$m * z$95$m), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+298], N[(N[(N[(-4.0 * y), $MachinePrecision] * z$95$m), $MachinePrecision] * z$95$m), $MachinePrecision], If[LessEqual[t$95$1, 5e-152], N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision], N[(x * x), $MachinePrecision]]]]
\begin{array}{l}
z_m = \left|z\right|

\\
\begin{array}{l}
t_1 := x \cdot x - \left(y \cdot 4\right) \cdot \left(z\_m \cdot z\_m - t\right)\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+298}:\\
\;\;\;\;\left(\left(-4 \cdot y\right) \cdot z\_m\right) \cdot z\_m\\

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-152}:\\
\;\;\;\;\left(t \cdot y\right) \cdot 4\\

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


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

    1. Initial program 86.7%

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

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

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

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

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

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

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

      \[\leadsto \left(\left(-4 \cdot y\right) \cdot z\right) \cdot z \]
    6. Step-by-step derivation
      1. lower-*.f6475.8

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

      \[\leadsto \left(\left(-4 \cdot y\right) \cdot z\right) \cdot z \]

    if -5.0000000000000003e298 < (-.f64 (*.f64 x x) (*.f64 (*.f64 y #s(literal 4 binary64)) (-.f64 (*.f64 z z) t))) < 4.9999999999999997e-152

    1. Initial program 99.9%

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

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

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

    if 4.9999999999999997e-152 < (-.f64 (*.f64 x x) (*.f64 (*.f64 y #s(literal 4 binary64)) (-.f64 (*.f64 z z) t)))

    1. Initial program 89.7%

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

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

        \[\leadsto x \cdot \color{blue}{x} \]
      2. lift-*.f6455.9

        \[\leadsto x \cdot \color{blue}{x} \]
    4. Applied rewrites55.9%

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

Alternative 6: 45.6% accurate, 1.7× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ \begin{array}{l} \mathbf{if}\;x \leq 2.8 \cdot 10^{-45}:\\ \;\;\;\;\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 2.8e-45) (* (* 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 <= 2.8e-45) {
		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 <= 2.8d-45) 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 <= 2.8e-45) {
		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 <= 2.8e-45:
		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 (x <= 2.8e-45)
		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 <= 2.8e-45)
		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[x, 2.8e-45], 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 \leq 2.8 \cdot 10^{-45}:\\
\;\;\;\;\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 x < 2.8000000000000001e-45

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

        \[\leadsto \left(t \cdot y\right) \cdot 4 \]
    4. Applied rewrites38.3%

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

    if 2.8000000000000001e-45 < x

    1. Initial program 87.3%

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

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

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

        \[\leadsto x \cdot \color{blue}{x} \]
    4. Applied rewrites64.2%

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

Alternative 7: 40.8% accurate, 4.6× 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 91.1%

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

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

      \[\leadsto x \cdot \color{blue}{x} \]
    2. lift-*.f6440.8

      \[\leadsto x \cdot \color{blue}{x} \]
  4. Applied rewrites40.8%

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

Reproduce

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