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

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

Specification

?
\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
(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]
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 90.6% accurate, 1.0× speedup?

\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
(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]
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)

Alternative 1: 99.3% accurate, 0.5× speedup?

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

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 5.00000000000000019e120

    1. Initial program 90.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(\left(-y\right) \cdot z\right) \cdot z - \left(-t\right) \cdot y\right) \cdot 4 + \color{blue}{x \cdot x} \]
      10. lower-fma.f6493.7

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

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

    if 5.00000000000000019e120 < x

    1. Initial program 90.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 97.7% accurate, 0.6× speedup?

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

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 5.00000000000000019e120

    1. Initial program 90.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(\left(-y\right) \cdot z\right) \cdot z - \left(-t\right) \cdot y\right) \cdot 4 + \color{blue}{x \cdot x} \]
      10. lower-fma.f6493.7

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

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

    if 5.00000000000000019e120 < x

    1. Initial program 90.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 97.3% accurate, 0.7× speedup?

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

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


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

    1. Initial program 90.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(\left(-y\right) \cdot z\right) \cdot z - \left(-t\right) \cdot y\right) \cdot 4 + \color{blue}{x \cdot x} \]
      10. lower-fma.f6493.7

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

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

    if 5.0000000000000004e43 < y

    1. Initial program 90.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 94.2% accurate, 0.7× speedup?

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

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -5.60000000000000023e-255

    1. Initial program 90.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(\left(-y\right) \cdot z\right) \cdot z - \left(-t\right) \cdot y\right) \cdot 4 + \color{blue}{x \cdot x} \]
      10. lower-fma.f6493.7

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.60000000000000023e-255 < t

    1. Initial program 90.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 93.9% accurate, 0.7× speedup?

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

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -5.00000000000000035e-230

    1. Initial program 90.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(\left(-y\right) \cdot z\right) \cdot z - \left(-t\right) \cdot y\right) \cdot 4 + \color{blue}{x \cdot x} \]
      10. lower-fma.f6493.7

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.00000000000000035e-230 < t

    1. Initial program 90.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 93.0% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 67.5% accurate, 1.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 8: 58.8% accurate, 1.3× speedup?

    \[\begin{array}{l} \mathbf{if}\;\left|x\right| \leq 32000000000:\\ \;\;\;\;4 \cdot \left(t \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \left(\left|x\right| \cdot \left|x\right|\right)\\ \end{array} \]
    (FPCore (x y z t)
     :precision binary64
     (if (<= (fabs x) 32000000000.0)
       (* 4.0 (* t y))
       (* 1.0 (* (fabs x) (fabs x)))))
    double code(double x, double y, double z, double t) {
    	double tmp;
    	if (fabs(x) <= 32000000000.0) {
    		tmp = 4.0 * (t * y);
    	} else {
    		tmp = 1.0 * (fabs(x) * fabs(x));
    	}
    	return tmp;
    }
    
    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
        real(8) :: tmp
        if (abs(x) <= 32000000000.0d0) then
            tmp = 4.0d0 * (t * y)
        else
            tmp = 1.0d0 * (abs(x) * abs(x))
        end if
        code = tmp
    end function
    
    public static double code(double x, double y, double z, double t) {
    	double tmp;
    	if (Math.abs(x) <= 32000000000.0) {
    		tmp = 4.0 * (t * y);
    	} else {
    		tmp = 1.0 * (Math.abs(x) * Math.abs(x));
    	}
    	return tmp;
    }
    
    def code(x, y, z, t):
    	tmp = 0
    	if math.fabs(x) <= 32000000000.0:
    		tmp = 4.0 * (t * y)
    	else:
    		tmp = 1.0 * (math.fabs(x) * math.fabs(x))
    	return tmp
    
    function code(x, y, z, t)
    	tmp = 0.0
    	if (abs(x) <= 32000000000.0)
    		tmp = Float64(4.0 * Float64(t * y));
    	else
    		tmp = Float64(1.0 * Float64(abs(x) * abs(x)));
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, y, z, t)
    	tmp = 0.0;
    	if (abs(x) <= 32000000000.0)
    		tmp = 4.0 * (t * y);
    	else
    		tmp = 1.0 * (abs(x) * abs(x));
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, y_, z_, t_] := If[LessEqual[N[Abs[x], $MachinePrecision], 32000000000.0], N[(4.0 * N[(t * y), $MachinePrecision]), $MachinePrecision], N[(1.0 * N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    \mathbf{if}\;\left|x\right| \leq 32000000000:\\
    \;\;\;\;4 \cdot \left(t \cdot y\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;1 \cdot \left(\left|x\right| \cdot \left|x\right|\right)\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x < 3.2e10

      1. Initial program 90.6%

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

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

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

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

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

      if 3.2e10 < x

      1. Initial program 90.6%

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

          \[\leadsto \color{blue}{x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)} \]
        2. sub-to-multN/A

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

          \[\leadsto \color{blue}{\left(1 - \frac{\left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)}{x \cdot x}\right) \cdot \left(x \cdot x\right)} \]
      3. Applied rewrites60.3%

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

        \[\leadsto \color{blue}{1} \cdot \left(x \cdot x\right) \]
      5. Step-by-step derivation
        1. Applied rewrites41.5%

          \[\leadsto \color{blue}{1} \cdot \left(x \cdot x\right) \]
      6. Recombined 2 regimes into one program.
      7. Add Preprocessing

      Alternative 9: 31.6% accurate, 2.6× speedup?

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

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

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

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

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

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

      Reproduce

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