Bouland and Aaronson, Equation (25)

Percentage Accurate: 73.8% → 99.2%
Time: 11.2s
Alternatives: 12
Speedup: 4.1×

Specification

?
\[\begin{array}{l} \\ \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \end{array} \]
(FPCore (a b)
 :precision binary64
 (-
  (+
   (pow (+ (* a a) (* b b)) 2.0)
   (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 3.0 a))))))
  1.0))
double code(double a, double b) {
	return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0;
}
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(a, b)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = ((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * (((a * a) * (1.0d0 + a)) + ((b * b) * (1.0d0 - (3.0d0 * a)))))) - 1.0d0
end function
public static double code(double a, double b) {
	return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0;
}
def code(a, b):
	return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0
function code(a, b)
	return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 + a)) + Float64(Float64(b * b) * Float64(1.0 - Float64(3.0 * a)))))) - 1.0)
end
function tmp = code(a, b)
	tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0;
end
code[a_, b_] := N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 + a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 - N[(3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}

\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1
\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 12 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: 73.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \end{array} \]
(FPCore (a b)
 :precision binary64
 (-
  (+
   (pow (+ (* a a) (* b b)) 2.0)
   (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 3.0 a))))))
  1.0))
double code(double a, double b) {
	return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0;
}
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(a, b)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = ((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * (((a * a) * (1.0d0 + a)) + ((b * b) * (1.0d0 - (3.0d0 * a)))))) - 1.0d0
end function
public static double code(double a, double b) {
	return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0;
}
def code(a, b):
	return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0
function code(a, b)
	return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 + a)) + Float64(Float64(b * b) * Float64(1.0 - Float64(3.0 * a)))))) - 1.0)
end
function tmp = code(a, b)
	tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0;
end
code[a_, b_] := N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 + a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 - N[(3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}

\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1
\end{array}

Alternative 1: 99.2% accurate, 1.8× speedup?

\[\begin{array}{l} b_m = \left|b\right| \\ \begin{array}{l} \mathbf{if}\;b\_m \leq 9.7 \cdot 10^{-11}:\\ \;\;\;\;\left(\mathsf{fma}\left(a - -4, a, 4\right) \cdot a\right) \cdot a - 1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(a + a, a, b\_m \cdot b\_m\right) \cdot b\_m, b\_m, \left(\left(a \cdot a\right) \cdot a\right) \cdot a\right)\\ \end{array} \end{array} \]
b_m = (fabs.f64 b)
(FPCore (a b_m)
 :precision binary64
 (if (<= b_m 9.7e-11)
   (- (* (* (fma (- a -4.0) a 4.0) a) a) 1.0)
   (fma (* (fma (+ a a) a (* b_m b_m)) b_m) b_m (* (* (* a a) a) a))))
b_m = fabs(b);
double code(double a, double b_m) {
	double tmp;
	if (b_m <= 9.7e-11) {
		tmp = ((fma((a - -4.0), a, 4.0) * a) * a) - 1.0;
	} else {
		tmp = fma((fma((a + a), a, (b_m * b_m)) * b_m), b_m, (((a * a) * a) * a));
	}
	return tmp;
}
b_m = abs(b)
function code(a, b_m)
	tmp = 0.0
	if (b_m <= 9.7e-11)
		tmp = Float64(Float64(Float64(fma(Float64(a - -4.0), a, 4.0) * a) * a) - 1.0);
	else
		tmp = fma(Float64(fma(Float64(a + a), a, Float64(b_m * b_m)) * b_m), b_m, Float64(Float64(Float64(a * a) * a) * a));
	end
	return tmp
end
b_m = N[Abs[b], $MachinePrecision]
code[a_, b$95$m_] := If[LessEqual[b$95$m, 9.7e-11], N[(N[(N[(N[(N[(a - -4.0), $MachinePrecision] * a + 4.0), $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(N[(N[(a + a), $MachinePrecision] * a + N[(b$95$m * b$95$m), $MachinePrecision]), $MachinePrecision] * b$95$m), $MachinePrecision] * b$95$m + N[(N[(N[(a * a), $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
b_m = \left|b\right|

\\
\begin{array}{l}
\mathbf{if}\;b\_m \leq 9.7 \cdot 10^{-11}:\\
\;\;\;\;\left(\mathsf{fma}\left(a - -4, a, 4\right) \cdot a\right) \cdot a - 1\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(a + a, a, b\_m \cdot b\_m\right) \cdot b\_m, b\_m, \left(\left(a \cdot a\right) \cdot a\right) \cdot a\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 9.7000000000000001e-11

    1. Initial program 83.6%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Taylor expanded in b around 0

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

        \[\leadsto \left({a}^{4} + \color{blue}{4 \cdot \left({a}^{2} \cdot \left(1 + a\right)\right)}\right) - 1 \]
      2. metadata-evalN/A

        \[\leadsto \left({a}^{\left(2 + 2\right)} + 4 \cdot \left({a}^{2} \cdot \left(1 + a\right)\right)\right) - 1 \]
      3. pow-prod-upN/A

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

        \[\leadsto \left({a}^{2} \cdot {a}^{2} + \left({a}^{2} \cdot \left(1 + a\right)\right) \cdot \color{blue}{4}\right) - 1 \]
      5. associate-*l*N/A

        \[\leadsto \left({a}^{2} \cdot {a}^{2} + {a}^{2} \cdot \color{blue}{\left(\left(1 + a\right) \cdot 4\right)}\right) - 1 \]
      6. +-commutativeN/A

        \[\leadsto \left({a}^{2} \cdot {a}^{2} + {a}^{2} \cdot \left(\left(a + 1\right) \cdot 4\right)\right) - 1 \]
      7. distribute-rgt1-inN/A

        \[\leadsto \left({a}^{2} \cdot {a}^{2} + {a}^{2} \cdot \left(4 + \color{blue}{a \cdot 4}\right)\right) - 1 \]
      8. *-commutativeN/A

        \[\leadsto \left({a}^{2} \cdot {a}^{2} + {a}^{2} \cdot \left(4 + 4 \cdot \color{blue}{a}\right)\right) - 1 \]
      9. distribute-lft-outN/A

        \[\leadsto {a}^{2} \cdot \color{blue}{\left({a}^{2} + \left(4 + 4 \cdot a\right)\right)} - 1 \]
      10. lower-*.f64N/A

        \[\leadsto {a}^{2} \cdot \color{blue}{\left({a}^{2} + \left(4 + 4 \cdot a\right)\right)} - 1 \]
      11. pow2N/A

        \[\leadsto \left(a \cdot a\right) \cdot \left(\color{blue}{{a}^{2}} + \left(4 + 4 \cdot a\right)\right) - 1 \]
      12. lift-*.f64N/A

        \[\leadsto \left(a \cdot a\right) \cdot \left(\color{blue}{{a}^{2}} + \left(4 + 4 \cdot a\right)\right) - 1 \]
      13. pow2N/A

        \[\leadsto \left(a \cdot a\right) \cdot \left(a \cdot a + \left(\color{blue}{4} + 4 \cdot a\right)\right) - 1 \]
      14. lower-fma.f64N/A

        \[\leadsto \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, \color{blue}{a}, 4 + 4 \cdot a\right) - 1 \]
      15. +-commutativeN/A

        \[\leadsto \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, 4 \cdot a + 4\right) - 1 \]
      16. lower-fma.f6499.9

        \[\leadsto \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1 \]
    4. Applied rewrites99.9%

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

        \[\leadsto \left(a \cdot a\right) \cdot \mathsf{fma}\left(\color{blue}{a}, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1 \]
      2. pow2N/A

        \[\leadsto {a}^{2} \cdot \mathsf{fma}\left(\color{blue}{a}, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1 \]
      3. lift-fma.f64N/A

        \[\leadsto {a}^{2} \cdot \left(a \cdot a + \color{blue}{\mathsf{fma}\left(4, a, 4\right)}\right) - 1 \]
      4. lift-fma.f64N/A

        \[\leadsto {a}^{2} \cdot \left(a \cdot a + \left(4 \cdot a + \color{blue}{4}\right)\right) - 1 \]
      5. lower-*.f64N/A

        \[\leadsto {a}^{2} \cdot \color{blue}{\left(a \cdot a + \left(4 \cdot a + 4\right)\right)} - 1 \]
      6. pow2N/A

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

        \[\leadsto a \cdot \color{blue}{\left(a \cdot \left(a \cdot a + \left(4 \cdot a + 4\right)\right)\right)} - 1 \]
      8. *-commutativeN/A

        \[\leadsto \left(a \cdot \left(a \cdot a + \left(4 \cdot a + 4\right)\right)\right) \cdot \color{blue}{a} - 1 \]
      9. lower-*.f64N/A

        \[\leadsto \left(a \cdot \left(a \cdot a + \left(4 \cdot a + 4\right)\right)\right) \cdot \color{blue}{a} - 1 \]
    6. Applied rewrites99.9%

      \[\leadsto \left(\mathsf{fma}\left(a - -4, a, 4\right) \cdot a\right) \cdot \color{blue}{a} - 1 \]

    if 9.7000000000000001e-11 < b

    1. Initial program 64.8%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Applied rewrites99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(a + a, a, \mathsf{fma}\left(\mathsf{fma}\left(-3, a, 1\right), 4, b \cdot b\right)\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right)} \]
    3. Taylor expanded in b around inf

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

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, {b}^{2}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, {\color{blue}{b}}^{2}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
      3. pow2N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, {b}^{2}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, {b}^{2}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
      5. distribute-lft-inN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, {b}^{2}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
      6. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, {b}^{2}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, {b}^{2}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
      8. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, {b}^{2}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
      9. pow2N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, b \cdot \color{blue}{b}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
      10. lift-*.f6498.6

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, b \cdot \color{blue}{b}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
    5. Applied rewrites98.6%

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, \color{blue}{b \cdot b}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
    6. Taylor expanded in a around inf

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, b \cdot b\right) \cdot b, b, \color{blue}{{a}^{4}}\right) \]
    7. Step-by-step derivation
      1. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, b \cdot b\right) \cdot b, b, {a}^{\left(3 + \color{blue}{1}\right)}\right) \]
      2. pow-plusN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, b \cdot b\right) \cdot b, b, {a}^{3} \cdot \color{blue}{a}\right) \]
      3. pow3N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, b \cdot b\right) \cdot b, b, \left(\left(a \cdot a\right) \cdot a\right) \cdot a\right) \]
      4. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, b \cdot b\right) \cdot b, b, \left(\left(a \cdot a\right) \cdot a\right) \cdot \color{blue}{a}\right) \]
      5. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, b \cdot b\right) \cdot b, b, \left(\left(a \cdot a\right) \cdot a\right) \cdot a\right) \]
      6. lift-*.f6497.5

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, b \cdot b\right) \cdot b, b, \left(\left(a \cdot a\right) \cdot a\right) \cdot a\right) \]
    8. Applied rewrites97.5%

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, b \cdot b\right) \cdot b, b, \color{blue}{\left(\left(a \cdot a\right) \cdot a\right) \cdot a}\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 99.1% accurate, 1.5× speedup?

\[\begin{array}{l} b_m = \left|b\right| \\ \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, b\_m \cdot b\_m\right) \cdot b\_m, b\_m, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \end{array} \]
b_m = (fabs.f64 b)
(FPCore (a b_m)
 :precision binary64
 (fma
  (* (fma (+ a a) a (* b_m b_m)) b_m)
  b_m
  (- (* (* a a) (fma a a (fma 4.0 a 4.0))) 1.0)))
b_m = fabs(b);
double code(double a, double b_m) {
	return fma((fma((a + a), a, (b_m * b_m)) * b_m), b_m, (((a * a) * fma(a, a, fma(4.0, a, 4.0))) - 1.0));
}
b_m = abs(b)
function code(a, b_m)
	return fma(Float64(fma(Float64(a + a), a, Float64(b_m * b_m)) * b_m), b_m, Float64(Float64(Float64(a * a) * fma(a, a, fma(4.0, a, 4.0))) - 1.0))
end
b_m = N[Abs[b], $MachinePrecision]
code[a_, b$95$m_] := N[(N[(N[(N[(a + a), $MachinePrecision] * a + N[(b$95$m * b$95$m), $MachinePrecision]), $MachinePrecision] * b$95$m), $MachinePrecision] * b$95$m + N[(N[(N[(a * a), $MachinePrecision] * N[(a * a + N[(4.0 * a + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
b_m = \left|b\right|

\\
\mathsf{fma}\left(\mathsf{fma}\left(a + a, a, b\_m \cdot b\_m\right) \cdot b\_m, b\_m, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right)
\end{array}
Derivation
  1. Initial program 73.8%

    \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
  2. Applied rewrites99.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(a + a, a, \mathsf{fma}\left(\mathsf{fma}\left(-3, a, 1\right), 4, b \cdot b\right)\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right)} \]
  3. Taylor expanded in b around inf

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

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, {b}^{2}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
    2. +-commutativeN/A

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, {\color{blue}{b}}^{2}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
    3. pow2N/A

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, {b}^{2}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
    4. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, {b}^{2}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
    5. distribute-lft-inN/A

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, {b}^{2}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
    6. associate-*r*N/A

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, {b}^{2}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
    7. metadata-evalN/A

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, {b}^{2}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
    8. metadata-evalN/A

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, {b}^{2}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
    9. pow2N/A

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, b \cdot \color{blue}{b}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
    10. lift-*.f6499.2

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, b \cdot \color{blue}{b}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
  5. Applied rewrites99.2%

    \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, \color{blue}{b \cdot b}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
  6. Add Preprocessing

Alternative 3: 99.0% accurate, 1.9× speedup?

\[\begin{array}{l} b_m = \left|b\right| \\ \mathsf{fma}\left(\left(b\_m \cdot b\_m\right) \cdot b\_m, b\_m, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \end{array} \]
b_m = (fabs.f64 b)
(FPCore (a b_m)
 :precision binary64
 (fma (* (* b_m b_m) b_m) b_m (- (* (* a a) (fma a a (fma 4.0 a 4.0))) 1.0)))
b_m = fabs(b);
double code(double a, double b_m) {
	return fma(((b_m * b_m) * b_m), b_m, (((a * a) * fma(a, a, fma(4.0, a, 4.0))) - 1.0));
}
b_m = abs(b)
function code(a, b_m)
	return fma(Float64(Float64(b_m * b_m) * b_m), b_m, Float64(Float64(Float64(a * a) * fma(a, a, fma(4.0, a, 4.0))) - 1.0))
end
b_m = N[Abs[b], $MachinePrecision]
code[a_, b$95$m_] := N[(N[(N[(b$95$m * b$95$m), $MachinePrecision] * b$95$m), $MachinePrecision] * b$95$m + N[(N[(N[(a * a), $MachinePrecision] * N[(a * a + N[(4.0 * a + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
b_m = \left|b\right|

\\
\mathsf{fma}\left(\left(b\_m \cdot b\_m\right) \cdot b\_m, b\_m, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right)
\end{array}
Derivation
  1. Initial program 73.8%

    \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
  2. Applied rewrites99.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(a + a, a, \mathsf{fma}\left(\mathsf{fma}\left(-3, a, 1\right), 4, b \cdot b\right)\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right)} \]
  3. Taylor expanded in b around inf

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

      \[\leadsto \mathsf{fma}\left(\left(b \cdot \color{blue}{b}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
    2. lift-*.f6499.1

      \[\leadsto \mathsf{fma}\left(\left(b \cdot \color{blue}{b}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
  5. Applied rewrites99.1%

    \[\leadsto \mathsf{fma}\left(\color{blue}{\left(b \cdot b\right)} \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
  6. Add Preprocessing

Alternative 4: 98.7% accurate, 1.9× speedup?

\[\begin{array}{l} b_m = \left|b\right| \\ \begin{array}{l} t_0 := \mathsf{fma}\left(b\_m, b\_m, a \cdot a\right)\\ \mathsf{fma}\left(t\_0, t\_0, \left(b\_m \cdot b\_m\right) \cdot 4 - 1\right) \end{array} \end{array} \]
b_m = (fabs.f64 b)
(FPCore (a b_m)
 :precision binary64
 (let* ((t_0 (fma b_m b_m (* a a))))
   (fma t_0 t_0 (- (* (* b_m b_m) 4.0) 1.0))))
b_m = fabs(b);
double code(double a, double b_m) {
	double t_0 = fma(b_m, b_m, (a * a));
	return fma(t_0, t_0, (((b_m * b_m) * 4.0) - 1.0));
}
b_m = abs(b)
function code(a, b_m)
	t_0 = fma(b_m, b_m, Float64(a * a))
	return fma(t_0, t_0, Float64(Float64(Float64(b_m * b_m) * 4.0) - 1.0))
end
b_m = N[Abs[b], $MachinePrecision]
code[a_, b$95$m_] := Block[{t$95$0 = N[(b$95$m * b$95$m + N[(a * a), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * t$95$0 + N[(N[(N[(b$95$m * b$95$m), $MachinePrecision] * 4.0), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
b_m = \left|b\right|

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(b\_m, b\_m, a \cdot a\right)\\
\mathsf{fma}\left(t\_0, t\_0, \left(b\_m \cdot b\_m\right) \cdot 4 - 1\right)
\end{array}
\end{array}
Derivation
  1. Initial program 73.8%

    \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
  2. Taylor expanded in a around 0

    \[\leadsto \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \color{blue}{{b}^{2}}\right) - 1 \]
  3. Step-by-step derivation
    1. pow2N/A

      \[\leadsto \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot \color{blue}{b}\right)\right) - 1 \]
    2. lift-*.f6499.0

      \[\leadsto \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot \color{blue}{b}\right)\right) - 1 \]
  4. Applied rewrites99.0%

    \[\leadsto \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \color{blue}{\left(b \cdot b\right)}\right) - 1 \]
  5. Step-by-step derivation
    1. lift--.f64N/A

      \[\leadsto \color{blue}{\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1} \]
    2. lift-+.f64N/A

      \[\leadsto \color{blue}{\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right)} - 1 \]
    3. lift-pow.f64N/A

      \[\leadsto \left(\color{blue}{{\left(a \cdot a + b \cdot b\right)}^{2}} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    4. lift-*.f64N/A

      \[\leadsto \left({\left(\color{blue}{a \cdot a} + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    5. lift-*.f64N/A

      \[\leadsto \left({\left(a \cdot a + \color{blue}{b \cdot b}\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    6. lift-+.f64N/A

      \[\leadsto \left({\color{blue}{\left(a \cdot a + b \cdot b\right)}}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    7. associate--l+N/A

      \[\leadsto \color{blue}{{\left(a \cdot a + b \cdot b\right)}^{2} + \left(4 \cdot \left(b \cdot b\right) - 1\right)} \]
    8. unpow2N/A

      \[\leadsto \color{blue}{\left(a \cdot a + b \cdot b\right) \cdot \left(a \cdot a + b \cdot b\right)} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
    9. lower-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(a \cdot a + b \cdot b, a \cdot a + b \cdot b, 4 \cdot \left(b \cdot b\right) - 1\right)} \]
  6. Applied rewrites99.0%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(b, b, a \cdot a\right), \mathsf{fma}\left(b, b, a \cdot a\right), \left(b \cdot b\right) \cdot 4 - 1\right)} \]
  7. Add Preprocessing

Alternative 5: 97.0% accurate, 2.4× speedup?

\[\begin{array}{l} b_m = \left|b\right| \\ \begin{array}{l} \mathbf{if}\;b\_m \leq 3.8 \cdot 10^{+23}:\\ \;\;\;\;\left(\mathsf{fma}\left(a - -4, a, 4\right) \cdot a\right) \cdot a - 1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(a + a, a, b\_m \cdot b\_m\right) \cdot b\_m, b\_m, -1\right)\\ \end{array} \end{array} \]
b_m = (fabs.f64 b)
(FPCore (a b_m)
 :precision binary64
 (if (<= b_m 3.8e+23)
   (- (* (* (fma (- a -4.0) a 4.0) a) a) 1.0)
   (fma (* (fma (+ a a) a (* b_m b_m)) b_m) b_m -1.0)))
b_m = fabs(b);
double code(double a, double b_m) {
	double tmp;
	if (b_m <= 3.8e+23) {
		tmp = ((fma((a - -4.0), a, 4.0) * a) * a) - 1.0;
	} else {
		tmp = fma((fma((a + a), a, (b_m * b_m)) * b_m), b_m, -1.0);
	}
	return tmp;
}
b_m = abs(b)
function code(a, b_m)
	tmp = 0.0
	if (b_m <= 3.8e+23)
		tmp = Float64(Float64(Float64(fma(Float64(a - -4.0), a, 4.0) * a) * a) - 1.0);
	else
		tmp = fma(Float64(fma(Float64(a + a), a, Float64(b_m * b_m)) * b_m), b_m, -1.0);
	end
	return tmp
end
b_m = N[Abs[b], $MachinePrecision]
code[a_, b$95$m_] := If[LessEqual[b$95$m, 3.8e+23], N[(N[(N[(N[(N[(a - -4.0), $MachinePrecision] * a + 4.0), $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(N[(N[(a + a), $MachinePrecision] * a + N[(b$95$m * b$95$m), $MachinePrecision]), $MachinePrecision] * b$95$m), $MachinePrecision] * b$95$m + -1.0), $MachinePrecision]]
\begin{array}{l}
b_m = \left|b\right|

\\
\begin{array}{l}
\mathbf{if}\;b\_m \leq 3.8 \cdot 10^{+23}:\\
\;\;\;\;\left(\mathsf{fma}\left(a - -4, a, 4\right) \cdot a\right) \cdot a - 1\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(a + a, a, b\_m \cdot b\_m\right) \cdot b\_m, b\_m, -1\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 3.79999999999999975e23

    1. Initial program 83.4%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Taylor expanded in b around 0

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

        \[\leadsto \left({a}^{4} + \color{blue}{4 \cdot \left({a}^{2} \cdot \left(1 + a\right)\right)}\right) - 1 \]
      2. metadata-evalN/A

        \[\leadsto \left({a}^{\left(2 + 2\right)} + 4 \cdot \left({a}^{2} \cdot \left(1 + a\right)\right)\right) - 1 \]
      3. pow-prod-upN/A

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

        \[\leadsto \left({a}^{2} \cdot {a}^{2} + \left({a}^{2} \cdot \left(1 + a\right)\right) \cdot \color{blue}{4}\right) - 1 \]
      5. associate-*l*N/A

        \[\leadsto \left({a}^{2} \cdot {a}^{2} + {a}^{2} \cdot \color{blue}{\left(\left(1 + a\right) \cdot 4\right)}\right) - 1 \]
      6. +-commutativeN/A

        \[\leadsto \left({a}^{2} \cdot {a}^{2} + {a}^{2} \cdot \left(\left(a + 1\right) \cdot 4\right)\right) - 1 \]
      7. distribute-rgt1-inN/A

        \[\leadsto \left({a}^{2} \cdot {a}^{2} + {a}^{2} \cdot \left(4 + \color{blue}{a \cdot 4}\right)\right) - 1 \]
      8. *-commutativeN/A

        \[\leadsto \left({a}^{2} \cdot {a}^{2} + {a}^{2} \cdot \left(4 + 4 \cdot \color{blue}{a}\right)\right) - 1 \]
      9. distribute-lft-outN/A

        \[\leadsto {a}^{2} \cdot \color{blue}{\left({a}^{2} + \left(4 + 4 \cdot a\right)\right)} - 1 \]
      10. lower-*.f64N/A

        \[\leadsto {a}^{2} \cdot \color{blue}{\left({a}^{2} + \left(4 + 4 \cdot a\right)\right)} - 1 \]
      11. pow2N/A

        \[\leadsto \left(a \cdot a\right) \cdot \left(\color{blue}{{a}^{2}} + \left(4 + 4 \cdot a\right)\right) - 1 \]
      12. lift-*.f64N/A

        \[\leadsto \left(a \cdot a\right) \cdot \left(\color{blue}{{a}^{2}} + \left(4 + 4 \cdot a\right)\right) - 1 \]
      13. pow2N/A

        \[\leadsto \left(a \cdot a\right) \cdot \left(a \cdot a + \left(\color{blue}{4} + 4 \cdot a\right)\right) - 1 \]
      14. lower-fma.f64N/A

        \[\leadsto \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, \color{blue}{a}, 4 + 4 \cdot a\right) - 1 \]
      15. +-commutativeN/A

        \[\leadsto \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, 4 \cdot a + 4\right) - 1 \]
      16. lower-fma.f6495.8

        \[\leadsto \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1 \]
    4. Applied rewrites95.8%

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

        \[\leadsto \left(a \cdot a\right) \cdot \mathsf{fma}\left(\color{blue}{a}, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1 \]
      2. pow2N/A

        \[\leadsto {a}^{2} \cdot \mathsf{fma}\left(\color{blue}{a}, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1 \]
      3. lift-fma.f64N/A

        \[\leadsto {a}^{2} \cdot \left(a \cdot a + \color{blue}{\mathsf{fma}\left(4, a, 4\right)}\right) - 1 \]
      4. lift-fma.f64N/A

        \[\leadsto {a}^{2} \cdot \left(a \cdot a + \left(4 \cdot a + \color{blue}{4}\right)\right) - 1 \]
      5. lower-*.f64N/A

        \[\leadsto {a}^{2} \cdot \color{blue}{\left(a \cdot a + \left(4 \cdot a + 4\right)\right)} - 1 \]
      6. pow2N/A

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

        \[\leadsto a \cdot \color{blue}{\left(a \cdot \left(a \cdot a + \left(4 \cdot a + 4\right)\right)\right)} - 1 \]
      8. *-commutativeN/A

        \[\leadsto \left(a \cdot \left(a \cdot a + \left(4 \cdot a + 4\right)\right)\right) \cdot \color{blue}{a} - 1 \]
      9. lower-*.f64N/A

        \[\leadsto \left(a \cdot \left(a \cdot a + \left(4 \cdot a + 4\right)\right)\right) \cdot \color{blue}{a} - 1 \]
    6. Applied rewrites95.9%

      \[\leadsto \left(\mathsf{fma}\left(a - -4, a, 4\right) \cdot a\right) \cdot \color{blue}{a} - 1 \]

    if 3.79999999999999975e23 < b

    1. Initial program 63.0%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Applied rewrites99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(a + a, a, \mathsf{fma}\left(\mathsf{fma}\left(-3, a, 1\right), 4, b \cdot b\right)\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right)} \]
    3. Taylor expanded in b around inf

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

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, {b}^{2}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, {\color{blue}{b}}^{2}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
      3. pow2N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, {b}^{2}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, {b}^{2}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
      5. distribute-lft-inN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, {b}^{2}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
      6. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, {b}^{2}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, {b}^{2}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
      8. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, {b}^{2}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
      9. pow2N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, b \cdot \color{blue}{b}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
      10. lift-*.f6499.9

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, b \cdot \color{blue}{b}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
    5. Applied rewrites99.9%

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, \color{blue}{b \cdot b}\right) \cdot b, b, \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1\right) \]
    6. Taylor expanded in a around 0

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, b \cdot b\right) \cdot b, b, \color{blue}{-1}\right) \]
    7. Step-by-step derivation
      1. Applied rewrites98.3%

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a + a, a, b \cdot b\right) \cdot b, b, \color{blue}{-1}\right) \]
    8. Recombined 2 regimes into one program.
    9. Add Preprocessing

    Alternative 6: 94.1% accurate, 2.7× speedup?

    \[\begin{array}{l} b_m = \left|b\right| \\ \begin{array}{l} \mathbf{if}\;b\_m \leq 2.5 \cdot 10^{+30}:\\ \;\;\;\;\left(\mathsf{fma}\left(a - -4, a, 4\right) \cdot a\right) \cdot a - 1\\ \mathbf{else}:\\ \;\;\;\;\left(\left(b\_m \cdot b\_m\right) \cdot b\_m\right) \cdot b\_m\\ \end{array} \end{array} \]
    b_m = (fabs.f64 b)
    (FPCore (a b_m)
     :precision binary64
     (if (<= b_m 2.5e+30)
       (- (* (* (fma (- a -4.0) a 4.0) a) a) 1.0)
       (* (* (* b_m b_m) b_m) b_m)))
    b_m = fabs(b);
    double code(double a, double b_m) {
    	double tmp;
    	if (b_m <= 2.5e+30) {
    		tmp = ((fma((a - -4.0), a, 4.0) * a) * a) - 1.0;
    	} else {
    		tmp = ((b_m * b_m) * b_m) * b_m;
    	}
    	return tmp;
    }
    
    b_m = abs(b)
    function code(a, b_m)
    	tmp = 0.0
    	if (b_m <= 2.5e+30)
    		tmp = Float64(Float64(Float64(fma(Float64(a - -4.0), a, 4.0) * a) * a) - 1.0);
    	else
    		tmp = Float64(Float64(Float64(b_m * b_m) * b_m) * b_m);
    	end
    	return tmp
    end
    
    b_m = N[Abs[b], $MachinePrecision]
    code[a_, b$95$m_] := If[LessEqual[b$95$m, 2.5e+30], N[(N[(N[(N[(N[(a - -4.0), $MachinePrecision] * a + 4.0), $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(N[(b$95$m * b$95$m), $MachinePrecision] * b$95$m), $MachinePrecision] * b$95$m), $MachinePrecision]]
    
    \begin{array}{l}
    b_m = \left|b\right|
    
    \\
    \begin{array}{l}
    \mathbf{if}\;b\_m \leq 2.5 \cdot 10^{+30}:\\
    \;\;\;\;\left(\mathsf{fma}\left(a - -4, a, 4\right) \cdot a\right) \cdot a - 1\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(\left(b\_m \cdot b\_m\right) \cdot b\_m\right) \cdot b\_m\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if b < 2.4999999999999999e30

      1. Initial program 83.3%

        \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
      2. Taylor expanded in b around 0

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

          \[\leadsto \left({a}^{4} + \color{blue}{4 \cdot \left({a}^{2} \cdot \left(1 + a\right)\right)}\right) - 1 \]
        2. metadata-evalN/A

          \[\leadsto \left({a}^{\left(2 + 2\right)} + 4 \cdot \left({a}^{2} \cdot \left(1 + a\right)\right)\right) - 1 \]
        3. pow-prod-upN/A

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

          \[\leadsto \left({a}^{2} \cdot {a}^{2} + \left({a}^{2} \cdot \left(1 + a\right)\right) \cdot \color{blue}{4}\right) - 1 \]
        5. associate-*l*N/A

          \[\leadsto \left({a}^{2} \cdot {a}^{2} + {a}^{2} \cdot \color{blue}{\left(\left(1 + a\right) \cdot 4\right)}\right) - 1 \]
        6. +-commutativeN/A

          \[\leadsto \left({a}^{2} \cdot {a}^{2} + {a}^{2} \cdot \left(\left(a + 1\right) \cdot 4\right)\right) - 1 \]
        7. distribute-rgt1-inN/A

          \[\leadsto \left({a}^{2} \cdot {a}^{2} + {a}^{2} \cdot \left(4 + \color{blue}{a \cdot 4}\right)\right) - 1 \]
        8. *-commutativeN/A

          \[\leadsto \left({a}^{2} \cdot {a}^{2} + {a}^{2} \cdot \left(4 + 4 \cdot \color{blue}{a}\right)\right) - 1 \]
        9. distribute-lft-outN/A

          \[\leadsto {a}^{2} \cdot \color{blue}{\left({a}^{2} + \left(4 + 4 \cdot a\right)\right)} - 1 \]
        10. lower-*.f64N/A

          \[\leadsto {a}^{2} \cdot \color{blue}{\left({a}^{2} + \left(4 + 4 \cdot a\right)\right)} - 1 \]
        11. pow2N/A

          \[\leadsto \left(a \cdot a\right) \cdot \left(\color{blue}{{a}^{2}} + \left(4 + 4 \cdot a\right)\right) - 1 \]
        12. lift-*.f64N/A

          \[\leadsto \left(a \cdot a\right) \cdot \left(\color{blue}{{a}^{2}} + \left(4 + 4 \cdot a\right)\right) - 1 \]
        13. pow2N/A

          \[\leadsto \left(a \cdot a\right) \cdot \left(a \cdot a + \left(\color{blue}{4} + 4 \cdot a\right)\right) - 1 \]
        14. lower-fma.f64N/A

          \[\leadsto \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, \color{blue}{a}, 4 + 4 \cdot a\right) - 1 \]
        15. +-commutativeN/A

          \[\leadsto \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, 4 \cdot a + 4\right) - 1 \]
        16. lower-fma.f6494.7

          \[\leadsto \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1 \]
      4. Applied rewrites94.7%

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

          \[\leadsto \left(a \cdot a\right) \cdot \mathsf{fma}\left(\color{blue}{a}, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1 \]
        2. pow2N/A

          \[\leadsto {a}^{2} \cdot \mathsf{fma}\left(\color{blue}{a}, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1 \]
        3. lift-fma.f64N/A

          \[\leadsto {a}^{2} \cdot \left(a \cdot a + \color{blue}{\mathsf{fma}\left(4, a, 4\right)}\right) - 1 \]
        4. lift-fma.f64N/A

          \[\leadsto {a}^{2} \cdot \left(a \cdot a + \left(4 \cdot a + \color{blue}{4}\right)\right) - 1 \]
        5. lower-*.f64N/A

          \[\leadsto {a}^{2} \cdot \color{blue}{\left(a \cdot a + \left(4 \cdot a + 4\right)\right)} - 1 \]
        6. pow2N/A

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

          \[\leadsto a \cdot \color{blue}{\left(a \cdot \left(a \cdot a + \left(4 \cdot a + 4\right)\right)\right)} - 1 \]
        8. *-commutativeN/A

          \[\leadsto \left(a \cdot \left(a \cdot a + \left(4 \cdot a + 4\right)\right)\right) \cdot \color{blue}{a} - 1 \]
        9. lower-*.f64N/A

          \[\leadsto \left(a \cdot \left(a \cdot a + \left(4 \cdot a + 4\right)\right)\right) \cdot \color{blue}{a} - 1 \]
      6. Applied rewrites94.7%

        \[\leadsto \left(\mathsf{fma}\left(a - -4, a, 4\right) \cdot a\right) \cdot \color{blue}{a} - 1 \]

      if 2.4999999999999999e30 < b

      1. Initial program 62.5%

        \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
      2. Taylor expanded in b around inf

        \[\leadsto \color{blue}{{b}^{4}} \]
      3. Step-by-step derivation
        1. metadata-evalN/A

          \[\leadsto {b}^{\left(2 + \color{blue}{2}\right)} \]
        2. pow-prod-upN/A

          \[\leadsto {b}^{2} \cdot \color{blue}{{b}^{2}} \]
        3. pow2N/A

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

          \[\leadsto \left({b}^{2} \cdot b\right) \cdot \color{blue}{b} \]
        5. pow-plusN/A

          \[\leadsto {b}^{\left(2 + 1\right)} \cdot b \]
        6. metadata-evalN/A

          \[\leadsto {b}^{3} \cdot b \]
        7. cube-unmultN/A

          \[\leadsto \left(b \cdot \left(b \cdot b\right)\right) \cdot b \]
        8. pow2N/A

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

          \[\leadsto \left(b \cdot {b}^{2}\right) \cdot \color{blue}{b} \]
        10. pow2N/A

          \[\leadsto \left(b \cdot \left(b \cdot b\right)\right) \cdot b \]
        11. cube-unmultN/A

          \[\leadsto {b}^{3} \cdot b \]
        12. metadata-evalN/A

          \[\leadsto {b}^{\left(2 + 1\right)} \cdot b \]
        13. pow-plusN/A

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

          \[\leadsto \left({b}^{2} \cdot b\right) \cdot b \]
        15. pow2N/A

          \[\leadsto \left(\left(b \cdot b\right) \cdot b\right) \cdot b \]
        16. lift-*.f6493.3

          \[\leadsto \left(\left(b \cdot b\right) \cdot b\right) \cdot b \]
      4. Applied rewrites93.3%

        \[\leadsto \color{blue}{\left(\left(b \cdot b\right) \cdot b\right) \cdot b} \]
    3. Recombined 2 regimes into one program.
    4. Add Preprocessing

    Alternative 7: 93.9% accurate, 2.3× speedup?

    \[\begin{array}{l} b_m = \left|b\right| \\ \begin{array}{l} \mathbf{if}\;a \leq -900000:\\ \;\;\;\;\left(a - -4\right) \cdot \left(\left(a \cdot a\right) \cdot a\right)\\ \mathbf{elif}\;a \leq 1.3 \cdot 10^{+39}:\\ \;\;\;\;\left(\left(b\_m \cdot b\_m\right) \cdot b\_m\right) \cdot b\_m - 1\\ \mathbf{else}:\\ \;\;\;\;{a}^{4}\\ \end{array} \end{array} \]
    b_m = (fabs.f64 b)
    (FPCore (a b_m)
     :precision binary64
     (if (<= a -900000.0)
       (* (- a -4.0) (* (* a a) a))
       (if (<= a 1.3e+39) (- (* (* (* b_m b_m) b_m) b_m) 1.0) (pow a 4.0))))
    b_m = fabs(b);
    double code(double a, double b_m) {
    	double tmp;
    	if (a <= -900000.0) {
    		tmp = (a - -4.0) * ((a * a) * a);
    	} else if (a <= 1.3e+39) {
    		tmp = (((b_m * b_m) * b_m) * b_m) - 1.0;
    	} else {
    		tmp = pow(a, 4.0);
    	}
    	return tmp;
    }
    
    b_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(a, b_m)
    use fmin_fmax_functions
        real(8), intent (in) :: a
        real(8), intent (in) :: b_m
        real(8) :: tmp
        if (a <= (-900000.0d0)) then
            tmp = (a - (-4.0d0)) * ((a * a) * a)
        else if (a <= 1.3d+39) then
            tmp = (((b_m * b_m) * b_m) * b_m) - 1.0d0
        else
            tmp = a ** 4.0d0
        end if
        code = tmp
    end function
    
    b_m = Math.abs(b);
    public static double code(double a, double b_m) {
    	double tmp;
    	if (a <= -900000.0) {
    		tmp = (a - -4.0) * ((a * a) * a);
    	} else if (a <= 1.3e+39) {
    		tmp = (((b_m * b_m) * b_m) * b_m) - 1.0;
    	} else {
    		tmp = Math.pow(a, 4.0);
    	}
    	return tmp;
    }
    
    b_m = math.fabs(b)
    def code(a, b_m):
    	tmp = 0
    	if a <= -900000.0:
    		tmp = (a - -4.0) * ((a * a) * a)
    	elif a <= 1.3e+39:
    		tmp = (((b_m * b_m) * b_m) * b_m) - 1.0
    	else:
    		tmp = math.pow(a, 4.0)
    	return tmp
    
    b_m = abs(b)
    function code(a, b_m)
    	tmp = 0.0
    	if (a <= -900000.0)
    		tmp = Float64(Float64(a - -4.0) * Float64(Float64(a * a) * a));
    	elseif (a <= 1.3e+39)
    		tmp = Float64(Float64(Float64(Float64(b_m * b_m) * b_m) * b_m) - 1.0);
    	else
    		tmp = a ^ 4.0;
    	end
    	return tmp
    end
    
    b_m = abs(b);
    function tmp_2 = code(a, b_m)
    	tmp = 0.0;
    	if (a <= -900000.0)
    		tmp = (a - -4.0) * ((a * a) * a);
    	elseif (a <= 1.3e+39)
    		tmp = (((b_m * b_m) * b_m) * b_m) - 1.0;
    	else
    		tmp = a ^ 4.0;
    	end
    	tmp_2 = tmp;
    end
    
    b_m = N[Abs[b], $MachinePrecision]
    code[a_, b$95$m_] := If[LessEqual[a, -900000.0], N[(N[(a - -4.0), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.3e+39], N[(N[(N[(N[(b$95$m * b$95$m), $MachinePrecision] * b$95$m), $MachinePrecision] * b$95$m), $MachinePrecision] - 1.0), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]
    
    \begin{array}{l}
    b_m = \left|b\right|
    
    \\
    \begin{array}{l}
    \mathbf{if}\;a \leq -900000:\\
    \;\;\;\;\left(a - -4\right) \cdot \left(\left(a \cdot a\right) \cdot a\right)\\
    
    \mathbf{elif}\;a \leq 1.3 \cdot 10^{+39}:\\
    \;\;\;\;\left(\left(b\_m \cdot b\_m\right) \cdot b\_m\right) \cdot b\_m - 1\\
    
    \mathbf{else}:\\
    \;\;\;\;{a}^{4}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if a < -9e5

      1. Initial program 32.5%

        \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
      2. Taylor expanded in a around inf

        \[\leadsto \color{blue}{{a}^{4} \cdot \left(1 + 4 \cdot \frac{1}{a}\right)} \]
      3. Step-by-step derivation
        1. distribute-rgt-inN/A

          \[\leadsto 1 \cdot {a}^{4} + \color{blue}{\left(4 \cdot \frac{1}{a}\right) \cdot {a}^{4}} \]
        2. *-lft-identityN/A

          \[\leadsto {a}^{4} + \color{blue}{\left(4 \cdot \frac{1}{a}\right)} \cdot {a}^{4} \]
        3. metadata-evalN/A

          \[\leadsto {a}^{\left(2 + 2\right)} + \left(4 \cdot \color{blue}{\frac{1}{a}}\right) \cdot {a}^{4} \]
        4. pow-prod-upN/A

          \[\leadsto {a}^{2} \cdot {a}^{2} + \color{blue}{\left(4 \cdot \frac{1}{a}\right)} \cdot {a}^{4} \]
        5. associate-*l*N/A

          \[\leadsto {a}^{2} \cdot {a}^{2} + 4 \cdot \color{blue}{\left(\frac{1}{a} \cdot {a}^{4}\right)} \]
        6. inv-powN/A

          \[\leadsto {a}^{2} \cdot {a}^{2} + 4 \cdot \left({a}^{-1} \cdot {\color{blue}{a}}^{4}\right) \]
        7. pow-prod-upN/A

          \[\leadsto {a}^{2} \cdot {a}^{2} + 4 \cdot {a}^{\color{blue}{\left(-1 + 4\right)}} \]
        8. metadata-evalN/A

          \[\leadsto {a}^{2} \cdot {a}^{2} + 4 \cdot {a}^{3} \]
        9. cube-multN/A

          \[\leadsto {a}^{2} \cdot {a}^{2} + 4 \cdot \left(a \cdot \color{blue}{\left(a \cdot a\right)}\right) \]
        10. pow2N/A

          \[\leadsto {a}^{2} \cdot {a}^{2} + 4 \cdot \left(a \cdot {a}^{\color{blue}{2}}\right) \]
        11. associate-*r*N/A

          \[\leadsto {a}^{2} \cdot {a}^{2} + \left(4 \cdot a\right) \cdot \color{blue}{{a}^{2}} \]
        12. distribute-rgt-outN/A

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

          \[\leadsto {a}^{2} \cdot \left({a}^{2} + a \cdot \color{blue}{4}\right) \]
        14. fp-cancel-sign-subN/A

          \[\leadsto {a}^{2} \cdot \left({a}^{2} - \color{blue}{\left(\mathsf{neg}\left(a\right)\right) \cdot 4}\right) \]
        15. pow2N/A

          \[\leadsto {a}^{2} \cdot \left(a \cdot a - \color{blue}{\left(\mathsf{neg}\left(a\right)\right)} \cdot 4\right) \]
        16. sqr-neg-revN/A

          \[\leadsto {a}^{2} \cdot \left(\left(\mathsf{neg}\left(a\right)\right) \cdot \left(\mathsf{neg}\left(a\right)\right) - \color{blue}{\left(\mathsf{neg}\left(a\right)\right)} \cdot 4\right) \]
        17. lower-*.f64N/A

          \[\leadsto {a}^{2} \cdot \color{blue}{\left(\left(\mathsf{neg}\left(a\right)\right) \cdot \left(\mathsf{neg}\left(a\right)\right) - \left(\mathsf{neg}\left(a\right)\right) \cdot 4\right)} \]
      4. Applied rewrites90.9%

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

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

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

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

          \[\leadsto {a}^{2} \cdot \left(a \cdot \left(a - \color{blue}{-4}\right)\right) \]
        5. metadata-evalN/A

          \[\leadsto {a}^{2} \cdot \left(a \cdot \left(a - -1 \cdot \color{blue}{4}\right)\right) \]
        6. metadata-evalN/A

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

          \[\leadsto {a}^{2} \cdot \left(a \cdot \left(a + \color{blue}{1 \cdot 4}\right)\right) \]
        8. metadata-evalN/A

          \[\leadsto {a}^{2} \cdot \left(a \cdot \left(a + 4\right)\right) \]
        9. +-commutativeN/A

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

          \[\leadsto {a}^{2} \cdot \color{blue}{\left(a \cdot \left(4 + a\right)\right)} \]
        11. associate-*l*N/A

          \[\leadsto \left({a}^{2} \cdot a\right) \cdot \color{blue}{\left(4 + a\right)} \]
        12. pow2N/A

          \[\leadsto \left(\left(a \cdot a\right) \cdot a\right) \cdot \left(4 + a\right) \]
        13. unpow3N/A

          \[\leadsto {a}^{3} \cdot \left(\color{blue}{4} + a\right) \]
        14. pow3N/A

          \[\leadsto \left(\left(a \cdot a\right) \cdot a\right) \cdot \left(\color{blue}{4} + a\right) \]
        15. *-commutativeN/A

          \[\leadsto \left(4 + a\right) \cdot \color{blue}{\left(\left(a \cdot a\right) \cdot a\right)} \]
        16. lower-*.f64N/A

          \[\leadsto \left(4 + a\right) \cdot \color{blue}{\left(\left(a \cdot a\right) \cdot a\right)} \]
        17. +-commutativeN/A

          \[\leadsto \left(a + 4\right) \cdot \left(\color{blue}{\left(a \cdot a\right)} \cdot a\right) \]
        18. metadata-evalN/A

          \[\leadsto \left(a + 1 \cdot 4\right) \cdot \left(\left(a \cdot \color{blue}{a}\right) \cdot a\right) \]
        19. fp-cancel-sign-sub-invN/A

          \[\leadsto \left(a - \left(\mathsf{neg}\left(1\right)\right) \cdot 4\right) \cdot \left(\color{blue}{\left(a \cdot a\right)} \cdot a\right) \]
        20. metadata-evalN/A

          \[\leadsto \left(a - -1 \cdot 4\right) \cdot \left(\left(a \cdot a\right) \cdot a\right) \]
        21. metadata-evalN/A

          \[\leadsto \left(a - -4\right) \cdot \left(\left(a \cdot \color{blue}{a}\right) \cdot a\right) \]
        22. lift--.f64N/A

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

          \[\leadsto \left(a - -4\right) \cdot \left(\left(a \cdot a\right) \cdot \color{blue}{a}\right) \]
        24. lift-*.f6490.9

          \[\leadsto \left(a - -4\right) \cdot \left(\left(a \cdot a\right) \cdot a\right) \]
      6. Applied rewrites90.9%

        \[\leadsto \left(a - -4\right) \cdot \color{blue}{\left(\left(a \cdot a\right) \cdot a\right)} \]

      if -9e5 < a < 1.3e39

      1. Initial program 97.9%

        \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
      2. Taylor expanded in b around inf

        \[\leadsto \color{blue}{{b}^{4}} - 1 \]
      3. Step-by-step derivation
        1. metadata-evalN/A

          \[\leadsto {b}^{\left(2 + \color{blue}{2}\right)} - 1 \]
        2. pow-prod-upN/A

          \[\leadsto {b}^{2} \cdot \color{blue}{{b}^{2}} - 1 \]
        3. pow2N/A

          \[\leadsto {b}^{2} \cdot \left(b \cdot \color{blue}{b}\right) - 1 \]
        4. associate-*r*N/A

          \[\leadsto \left({b}^{2} \cdot b\right) \cdot \color{blue}{b} - 1 \]
        5. pow-plusN/A

          \[\leadsto {b}^{\left(2 + 1\right)} \cdot b - 1 \]
        6. metadata-evalN/A

          \[\leadsto {b}^{3} \cdot b - 1 \]
        7. cube-unmultN/A

          \[\leadsto \left(b \cdot \left(b \cdot b\right)\right) \cdot b - 1 \]
        8. pow2N/A

          \[\leadsto \left(b \cdot {b}^{2}\right) \cdot b - 1 \]
        9. lower-*.f64N/A

          \[\leadsto \left(b \cdot {b}^{2}\right) \cdot \color{blue}{b} - 1 \]
        10. pow2N/A

          \[\leadsto \left(b \cdot \left(b \cdot b\right)\right) \cdot b - 1 \]
        11. cube-unmultN/A

          \[\leadsto {b}^{3} \cdot b - 1 \]
        12. metadata-evalN/A

          \[\leadsto {b}^{\left(2 + 1\right)} \cdot b - 1 \]
        13. pow-plusN/A

          \[\leadsto \left({b}^{2} \cdot b\right) \cdot b - 1 \]
        14. lower-*.f64N/A

          \[\leadsto \left({b}^{2} \cdot b\right) \cdot b - 1 \]
        15. pow2N/A

          \[\leadsto \left(\left(b \cdot b\right) \cdot b\right) \cdot b - 1 \]
        16. lift-*.f6494.9

          \[\leadsto \left(\left(b \cdot b\right) \cdot b\right) \cdot b - 1 \]
      4. Applied rewrites94.9%

        \[\leadsto \color{blue}{\left(\left(b \cdot b\right) \cdot b\right) \cdot b} - 1 \]

      if 1.3e39 < a

      1. Initial program 58.9%

        \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
      2. Taylor expanded in a around inf

        \[\leadsto \color{blue}{{a}^{4}} \]
      3. Step-by-step derivation
        1. metadata-evalN/A

          \[\leadsto {a}^{\left(3 + \color{blue}{1}\right)} \]
        2. pow-plusN/A

          \[\leadsto {a}^{3} \cdot \color{blue}{a} \]
        3. lower-*.f64N/A

          \[\leadsto {a}^{3} \cdot \color{blue}{a} \]
        4. unpow3N/A

          \[\leadsto \left(\left(a \cdot a\right) \cdot a\right) \cdot a \]
        5. pow2N/A

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

          \[\leadsto \left({a}^{2} \cdot a\right) \cdot a \]
        7. pow2N/A

          \[\leadsto \left(\left(a \cdot a\right) \cdot a\right) \cdot a \]
        8. lift-*.f6494.5

          \[\leadsto \left(\left(a \cdot a\right) \cdot a\right) \cdot a \]
      4. Applied rewrites94.5%

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

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

          \[\leadsto \left(\left(a \cdot a\right) \cdot a\right) \cdot a \]
        3. lift-*.f64N/A

          \[\leadsto \left(\left(a \cdot a\right) \cdot a\right) \cdot a \]
        4. pow3N/A

          \[\leadsto {a}^{3} \cdot a \]
        5. pow-plusN/A

          \[\leadsto {a}^{\color{blue}{\left(3 + 1\right)}} \]
        6. metadata-evalN/A

          \[\leadsto {a}^{4} \]
        7. lower-pow.f6494.5

          \[\leadsto {a}^{\color{blue}{4}} \]
      6. Applied rewrites94.5%

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

    Alternative 8: 93.9% accurate, 2.8× speedup?

    \[\begin{array}{l} b_m = \left|b\right| \\ \begin{array}{l} t_0 := \left(a \cdot a\right) \cdot a\\ \mathbf{if}\;a \leq -900000:\\ \;\;\;\;\left(a - -4\right) \cdot t\_0\\ \mathbf{elif}\;a \leq 1.3 \cdot 10^{+39}:\\ \;\;\;\;\left(\left(b\_m \cdot b\_m\right) \cdot b\_m\right) \cdot b\_m - 1\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot a\\ \end{array} \end{array} \]
    b_m = (fabs.f64 b)
    (FPCore (a b_m)
     :precision binary64
     (let* ((t_0 (* (* a a) a)))
       (if (<= a -900000.0)
         (* (- a -4.0) t_0)
         (if (<= a 1.3e+39) (- (* (* (* b_m b_m) b_m) b_m) 1.0) (* t_0 a)))))
    b_m = fabs(b);
    double code(double a, double b_m) {
    	double t_0 = (a * a) * a;
    	double tmp;
    	if (a <= -900000.0) {
    		tmp = (a - -4.0) * t_0;
    	} else if (a <= 1.3e+39) {
    		tmp = (((b_m * b_m) * b_m) * b_m) - 1.0;
    	} else {
    		tmp = t_0 * a;
    	}
    	return tmp;
    }
    
    b_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(a, b_m)
    use fmin_fmax_functions
        real(8), intent (in) :: a
        real(8), intent (in) :: b_m
        real(8) :: t_0
        real(8) :: tmp
        t_0 = (a * a) * a
        if (a <= (-900000.0d0)) then
            tmp = (a - (-4.0d0)) * t_0
        else if (a <= 1.3d+39) then
            tmp = (((b_m * b_m) * b_m) * b_m) - 1.0d0
        else
            tmp = t_0 * a
        end if
        code = tmp
    end function
    
    b_m = Math.abs(b);
    public static double code(double a, double b_m) {
    	double t_0 = (a * a) * a;
    	double tmp;
    	if (a <= -900000.0) {
    		tmp = (a - -4.0) * t_0;
    	} else if (a <= 1.3e+39) {
    		tmp = (((b_m * b_m) * b_m) * b_m) - 1.0;
    	} else {
    		tmp = t_0 * a;
    	}
    	return tmp;
    }
    
    b_m = math.fabs(b)
    def code(a, b_m):
    	t_0 = (a * a) * a
    	tmp = 0
    	if a <= -900000.0:
    		tmp = (a - -4.0) * t_0
    	elif a <= 1.3e+39:
    		tmp = (((b_m * b_m) * b_m) * b_m) - 1.0
    	else:
    		tmp = t_0 * a
    	return tmp
    
    b_m = abs(b)
    function code(a, b_m)
    	t_0 = Float64(Float64(a * a) * a)
    	tmp = 0.0
    	if (a <= -900000.0)
    		tmp = Float64(Float64(a - -4.0) * t_0);
    	elseif (a <= 1.3e+39)
    		tmp = Float64(Float64(Float64(Float64(b_m * b_m) * b_m) * b_m) - 1.0);
    	else
    		tmp = Float64(t_0 * a);
    	end
    	return tmp
    end
    
    b_m = abs(b);
    function tmp_2 = code(a, b_m)
    	t_0 = (a * a) * a;
    	tmp = 0.0;
    	if (a <= -900000.0)
    		tmp = (a - -4.0) * t_0;
    	elseif (a <= 1.3e+39)
    		tmp = (((b_m * b_m) * b_m) * b_m) - 1.0;
    	else
    		tmp = t_0 * a;
    	end
    	tmp_2 = tmp;
    end
    
    b_m = N[Abs[b], $MachinePrecision]
    code[a_, b$95$m_] := Block[{t$95$0 = N[(N[(a * a), $MachinePrecision] * a), $MachinePrecision]}, If[LessEqual[a, -900000.0], N[(N[(a - -4.0), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[a, 1.3e+39], N[(N[(N[(N[(b$95$m * b$95$m), $MachinePrecision] * b$95$m), $MachinePrecision] * b$95$m), $MachinePrecision] - 1.0), $MachinePrecision], N[(t$95$0 * a), $MachinePrecision]]]]
    
    \begin{array}{l}
    b_m = \left|b\right|
    
    \\
    \begin{array}{l}
    t_0 := \left(a \cdot a\right) \cdot a\\
    \mathbf{if}\;a \leq -900000:\\
    \;\;\;\;\left(a - -4\right) \cdot t\_0\\
    
    \mathbf{elif}\;a \leq 1.3 \cdot 10^{+39}:\\
    \;\;\;\;\left(\left(b\_m \cdot b\_m\right) \cdot b\_m\right) \cdot b\_m - 1\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0 \cdot a\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if a < -9e5

      1. Initial program 32.5%

        \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
      2. Taylor expanded in a around inf

        \[\leadsto \color{blue}{{a}^{4} \cdot \left(1 + 4 \cdot \frac{1}{a}\right)} \]
      3. Step-by-step derivation
        1. distribute-rgt-inN/A

          \[\leadsto 1 \cdot {a}^{4} + \color{blue}{\left(4 \cdot \frac{1}{a}\right) \cdot {a}^{4}} \]
        2. *-lft-identityN/A

          \[\leadsto {a}^{4} + \color{blue}{\left(4 \cdot \frac{1}{a}\right)} \cdot {a}^{4} \]
        3. metadata-evalN/A

          \[\leadsto {a}^{\left(2 + 2\right)} + \left(4 \cdot \color{blue}{\frac{1}{a}}\right) \cdot {a}^{4} \]
        4. pow-prod-upN/A

          \[\leadsto {a}^{2} \cdot {a}^{2} + \color{blue}{\left(4 \cdot \frac{1}{a}\right)} \cdot {a}^{4} \]
        5. associate-*l*N/A

          \[\leadsto {a}^{2} \cdot {a}^{2} + 4 \cdot \color{blue}{\left(\frac{1}{a} \cdot {a}^{4}\right)} \]
        6. inv-powN/A

          \[\leadsto {a}^{2} \cdot {a}^{2} + 4 \cdot \left({a}^{-1} \cdot {\color{blue}{a}}^{4}\right) \]
        7. pow-prod-upN/A

          \[\leadsto {a}^{2} \cdot {a}^{2} + 4 \cdot {a}^{\color{blue}{\left(-1 + 4\right)}} \]
        8. metadata-evalN/A

          \[\leadsto {a}^{2} \cdot {a}^{2} + 4 \cdot {a}^{3} \]
        9. cube-multN/A

          \[\leadsto {a}^{2} \cdot {a}^{2} + 4 \cdot \left(a \cdot \color{blue}{\left(a \cdot a\right)}\right) \]
        10. pow2N/A

          \[\leadsto {a}^{2} \cdot {a}^{2} + 4 \cdot \left(a \cdot {a}^{\color{blue}{2}}\right) \]
        11. associate-*r*N/A

          \[\leadsto {a}^{2} \cdot {a}^{2} + \left(4 \cdot a\right) \cdot \color{blue}{{a}^{2}} \]
        12. distribute-rgt-outN/A

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

          \[\leadsto {a}^{2} \cdot \left({a}^{2} + a \cdot \color{blue}{4}\right) \]
        14. fp-cancel-sign-subN/A

          \[\leadsto {a}^{2} \cdot \left({a}^{2} - \color{blue}{\left(\mathsf{neg}\left(a\right)\right) \cdot 4}\right) \]
        15. pow2N/A

          \[\leadsto {a}^{2} \cdot \left(a \cdot a - \color{blue}{\left(\mathsf{neg}\left(a\right)\right)} \cdot 4\right) \]
        16. sqr-neg-revN/A

          \[\leadsto {a}^{2} \cdot \left(\left(\mathsf{neg}\left(a\right)\right) \cdot \left(\mathsf{neg}\left(a\right)\right) - \color{blue}{\left(\mathsf{neg}\left(a\right)\right)} \cdot 4\right) \]
        17. lower-*.f64N/A

          \[\leadsto {a}^{2} \cdot \color{blue}{\left(\left(\mathsf{neg}\left(a\right)\right) \cdot \left(\mathsf{neg}\left(a\right)\right) - \left(\mathsf{neg}\left(a\right)\right) \cdot 4\right)} \]
      4. Applied rewrites90.9%

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

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

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

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

          \[\leadsto {a}^{2} \cdot \left(a \cdot \left(a - \color{blue}{-4}\right)\right) \]
        5. metadata-evalN/A

          \[\leadsto {a}^{2} \cdot \left(a \cdot \left(a - -1 \cdot \color{blue}{4}\right)\right) \]
        6. metadata-evalN/A

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

          \[\leadsto {a}^{2} \cdot \left(a \cdot \left(a + \color{blue}{1 \cdot 4}\right)\right) \]
        8. metadata-evalN/A

          \[\leadsto {a}^{2} \cdot \left(a \cdot \left(a + 4\right)\right) \]
        9. +-commutativeN/A

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

          \[\leadsto {a}^{2} \cdot \color{blue}{\left(a \cdot \left(4 + a\right)\right)} \]
        11. associate-*l*N/A

          \[\leadsto \left({a}^{2} \cdot a\right) \cdot \color{blue}{\left(4 + a\right)} \]
        12. pow2N/A

          \[\leadsto \left(\left(a \cdot a\right) \cdot a\right) \cdot \left(4 + a\right) \]
        13. unpow3N/A

          \[\leadsto {a}^{3} \cdot \left(\color{blue}{4} + a\right) \]
        14. pow3N/A

          \[\leadsto \left(\left(a \cdot a\right) \cdot a\right) \cdot \left(\color{blue}{4} + a\right) \]
        15. *-commutativeN/A

          \[\leadsto \left(4 + a\right) \cdot \color{blue}{\left(\left(a \cdot a\right) \cdot a\right)} \]
        16. lower-*.f64N/A

          \[\leadsto \left(4 + a\right) \cdot \color{blue}{\left(\left(a \cdot a\right) \cdot a\right)} \]
        17. +-commutativeN/A

          \[\leadsto \left(a + 4\right) \cdot \left(\color{blue}{\left(a \cdot a\right)} \cdot a\right) \]
        18. metadata-evalN/A

          \[\leadsto \left(a + 1 \cdot 4\right) \cdot \left(\left(a \cdot \color{blue}{a}\right) \cdot a\right) \]
        19. fp-cancel-sign-sub-invN/A

          \[\leadsto \left(a - \left(\mathsf{neg}\left(1\right)\right) \cdot 4\right) \cdot \left(\color{blue}{\left(a \cdot a\right)} \cdot a\right) \]
        20. metadata-evalN/A

          \[\leadsto \left(a - -1 \cdot 4\right) \cdot \left(\left(a \cdot a\right) \cdot a\right) \]
        21. metadata-evalN/A

          \[\leadsto \left(a - -4\right) \cdot \left(\left(a \cdot \color{blue}{a}\right) \cdot a\right) \]
        22. lift--.f64N/A

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

          \[\leadsto \left(a - -4\right) \cdot \left(\left(a \cdot a\right) \cdot \color{blue}{a}\right) \]
        24. lift-*.f6490.9

          \[\leadsto \left(a - -4\right) \cdot \left(\left(a \cdot a\right) \cdot a\right) \]
      6. Applied rewrites90.9%

        \[\leadsto \left(a - -4\right) \cdot \color{blue}{\left(\left(a \cdot a\right) \cdot a\right)} \]

      if -9e5 < a < 1.3e39

      1. Initial program 97.9%

        \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
      2. Taylor expanded in b around inf

        \[\leadsto \color{blue}{{b}^{4}} - 1 \]
      3. Step-by-step derivation
        1. metadata-evalN/A

          \[\leadsto {b}^{\left(2 + \color{blue}{2}\right)} - 1 \]
        2. pow-prod-upN/A

          \[\leadsto {b}^{2} \cdot \color{blue}{{b}^{2}} - 1 \]
        3. pow2N/A

          \[\leadsto {b}^{2} \cdot \left(b \cdot \color{blue}{b}\right) - 1 \]
        4. associate-*r*N/A

          \[\leadsto \left({b}^{2} \cdot b\right) \cdot \color{blue}{b} - 1 \]
        5. pow-plusN/A

          \[\leadsto {b}^{\left(2 + 1\right)} \cdot b - 1 \]
        6. metadata-evalN/A

          \[\leadsto {b}^{3} \cdot b - 1 \]
        7. cube-unmultN/A

          \[\leadsto \left(b \cdot \left(b \cdot b\right)\right) \cdot b - 1 \]
        8. pow2N/A

          \[\leadsto \left(b \cdot {b}^{2}\right) \cdot b - 1 \]
        9. lower-*.f64N/A

          \[\leadsto \left(b \cdot {b}^{2}\right) \cdot \color{blue}{b} - 1 \]
        10. pow2N/A

          \[\leadsto \left(b \cdot \left(b \cdot b\right)\right) \cdot b - 1 \]
        11. cube-unmultN/A

          \[\leadsto {b}^{3} \cdot b - 1 \]
        12. metadata-evalN/A

          \[\leadsto {b}^{\left(2 + 1\right)} \cdot b - 1 \]
        13. pow-plusN/A

          \[\leadsto \left({b}^{2} \cdot b\right) \cdot b - 1 \]
        14. lower-*.f64N/A

          \[\leadsto \left({b}^{2} \cdot b\right) \cdot b - 1 \]
        15. pow2N/A

          \[\leadsto \left(\left(b \cdot b\right) \cdot b\right) \cdot b - 1 \]
        16. lift-*.f6494.9

          \[\leadsto \left(\left(b \cdot b\right) \cdot b\right) \cdot b - 1 \]
      4. Applied rewrites94.9%

        \[\leadsto \color{blue}{\left(\left(b \cdot b\right) \cdot b\right) \cdot b} - 1 \]

      if 1.3e39 < a

      1. Initial program 58.9%

        \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
      2. Taylor expanded in a around inf

        \[\leadsto \color{blue}{{a}^{4}} \]
      3. Step-by-step derivation
        1. metadata-evalN/A

          \[\leadsto {a}^{\left(3 + \color{blue}{1}\right)} \]
        2. pow-plusN/A

          \[\leadsto {a}^{3} \cdot \color{blue}{a} \]
        3. lower-*.f64N/A

          \[\leadsto {a}^{3} \cdot \color{blue}{a} \]
        4. unpow3N/A

          \[\leadsto \left(\left(a \cdot a\right) \cdot a\right) \cdot a \]
        5. pow2N/A

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

          \[\leadsto \left({a}^{2} \cdot a\right) \cdot a \]
        7. pow2N/A

          \[\leadsto \left(\left(a \cdot a\right) \cdot a\right) \cdot a \]
        8. lift-*.f6494.5

          \[\leadsto \left(\left(a \cdot a\right) \cdot a\right) \cdot a \]
      4. Applied rewrites94.5%

        \[\leadsto \color{blue}{\left(\left(a \cdot a\right) \cdot a\right) \cdot a} \]
    3. Recombined 3 regimes into one program.
    4. Add Preprocessing

    Alternative 9: 81.7% accurate, 4.1× speedup?

    \[\begin{array}{l} b_m = \left|b\right| \\ \begin{array}{l} \mathbf{if}\;b\_m \leq 1.15 \cdot 10^{+25}:\\ \;\;\;\;\left(a \cdot a\right) \cdot 4 - 1\\ \mathbf{else}:\\ \;\;\;\;\left(\left(b\_m \cdot b\_m\right) \cdot b\_m\right) \cdot b\_m\\ \end{array} \end{array} \]
    b_m = (fabs.f64 b)
    (FPCore (a b_m)
     :precision binary64
     (if (<= b_m 1.15e+25) (- (* (* a a) 4.0) 1.0) (* (* (* b_m b_m) b_m) b_m)))
    b_m = fabs(b);
    double code(double a, double b_m) {
    	double tmp;
    	if (b_m <= 1.15e+25) {
    		tmp = ((a * a) * 4.0) - 1.0;
    	} else {
    		tmp = ((b_m * b_m) * b_m) * b_m;
    	}
    	return tmp;
    }
    
    b_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(a, b_m)
    use fmin_fmax_functions
        real(8), intent (in) :: a
        real(8), intent (in) :: b_m
        real(8) :: tmp
        if (b_m <= 1.15d+25) then
            tmp = ((a * a) * 4.0d0) - 1.0d0
        else
            tmp = ((b_m * b_m) * b_m) * b_m
        end if
        code = tmp
    end function
    
    b_m = Math.abs(b);
    public static double code(double a, double b_m) {
    	double tmp;
    	if (b_m <= 1.15e+25) {
    		tmp = ((a * a) * 4.0) - 1.0;
    	} else {
    		tmp = ((b_m * b_m) * b_m) * b_m;
    	}
    	return tmp;
    }
    
    b_m = math.fabs(b)
    def code(a, b_m):
    	tmp = 0
    	if b_m <= 1.15e+25:
    		tmp = ((a * a) * 4.0) - 1.0
    	else:
    		tmp = ((b_m * b_m) * b_m) * b_m
    	return tmp
    
    b_m = abs(b)
    function code(a, b_m)
    	tmp = 0.0
    	if (b_m <= 1.15e+25)
    		tmp = Float64(Float64(Float64(a * a) * 4.0) - 1.0);
    	else
    		tmp = Float64(Float64(Float64(b_m * b_m) * b_m) * b_m);
    	end
    	return tmp
    end
    
    b_m = abs(b);
    function tmp_2 = code(a, b_m)
    	tmp = 0.0;
    	if (b_m <= 1.15e+25)
    		tmp = ((a * a) * 4.0) - 1.0;
    	else
    		tmp = ((b_m * b_m) * b_m) * b_m;
    	end
    	tmp_2 = tmp;
    end
    
    b_m = N[Abs[b], $MachinePrecision]
    code[a_, b$95$m_] := If[LessEqual[b$95$m, 1.15e+25], N[(N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(N[(b$95$m * b$95$m), $MachinePrecision] * b$95$m), $MachinePrecision] * b$95$m), $MachinePrecision]]
    
    \begin{array}{l}
    b_m = \left|b\right|
    
    \\
    \begin{array}{l}
    \mathbf{if}\;b\_m \leq 1.15 \cdot 10^{+25}:\\
    \;\;\;\;\left(a \cdot a\right) \cdot 4 - 1\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(\left(b\_m \cdot b\_m\right) \cdot b\_m\right) \cdot b\_m\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if b < 1.1499999999999999e25

      1. Initial program 83.3%

        \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
      2. Taylor expanded in b around 0

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

          \[\leadsto \left({a}^{4} + \color{blue}{4 \cdot \left({a}^{2} \cdot \left(1 + a\right)\right)}\right) - 1 \]
        2. metadata-evalN/A

          \[\leadsto \left({a}^{\left(2 + 2\right)} + 4 \cdot \left({a}^{2} \cdot \left(1 + a\right)\right)\right) - 1 \]
        3. pow-prod-upN/A

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

          \[\leadsto \left({a}^{2} \cdot {a}^{2} + \left({a}^{2} \cdot \left(1 + a\right)\right) \cdot \color{blue}{4}\right) - 1 \]
        5. associate-*l*N/A

          \[\leadsto \left({a}^{2} \cdot {a}^{2} + {a}^{2} \cdot \color{blue}{\left(\left(1 + a\right) \cdot 4\right)}\right) - 1 \]
        6. +-commutativeN/A

          \[\leadsto \left({a}^{2} \cdot {a}^{2} + {a}^{2} \cdot \left(\left(a + 1\right) \cdot 4\right)\right) - 1 \]
        7. distribute-rgt1-inN/A

          \[\leadsto \left({a}^{2} \cdot {a}^{2} + {a}^{2} \cdot \left(4 + \color{blue}{a \cdot 4}\right)\right) - 1 \]
        8. *-commutativeN/A

          \[\leadsto \left({a}^{2} \cdot {a}^{2} + {a}^{2} \cdot \left(4 + 4 \cdot \color{blue}{a}\right)\right) - 1 \]
        9. distribute-lft-outN/A

          \[\leadsto {a}^{2} \cdot \color{blue}{\left({a}^{2} + \left(4 + 4 \cdot a\right)\right)} - 1 \]
        10. lower-*.f64N/A

          \[\leadsto {a}^{2} \cdot \color{blue}{\left({a}^{2} + \left(4 + 4 \cdot a\right)\right)} - 1 \]
        11. pow2N/A

          \[\leadsto \left(a \cdot a\right) \cdot \left(\color{blue}{{a}^{2}} + \left(4 + 4 \cdot a\right)\right) - 1 \]
        12. lift-*.f64N/A

          \[\leadsto \left(a \cdot a\right) \cdot \left(\color{blue}{{a}^{2}} + \left(4 + 4 \cdot a\right)\right) - 1 \]
        13. pow2N/A

          \[\leadsto \left(a \cdot a\right) \cdot \left(a \cdot a + \left(\color{blue}{4} + 4 \cdot a\right)\right) - 1 \]
        14. lower-fma.f64N/A

          \[\leadsto \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, \color{blue}{a}, 4 + 4 \cdot a\right) - 1 \]
        15. +-commutativeN/A

          \[\leadsto \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, 4 \cdot a + 4\right) - 1 \]
        16. lower-fma.f6495.6

          \[\leadsto \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1 \]
      4. Applied rewrites95.6%

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

        \[\leadsto \left(a \cdot a\right) \cdot 4 - 1 \]
      6. Step-by-step derivation
        1. Applied rewrites72.2%

          \[\leadsto \left(a \cdot a\right) \cdot 4 - 1 \]

        if 1.1499999999999999e25 < b

        1. Initial program 62.9%

          \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
        2. Taylor expanded in b around inf

          \[\leadsto \color{blue}{{b}^{4}} \]
        3. Step-by-step derivation
          1. metadata-evalN/A

            \[\leadsto {b}^{\left(2 + \color{blue}{2}\right)} \]
          2. pow-prod-upN/A

            \[\leadsto {b}^{2} \cdot \color{blue}{{b}^{2}} \]
          3. pow2N/A

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

            \[\leadsto \left({b}^{2} \cdot b\right) \cdot \color{blue}{b} \]
          5. pow-plusN/A

            \[\leadsto {b}^{\left(2 + 1\right)} \cdot b \]
          6. metadata-evalN/A

            \[\leadsto {b}^{3} \cdot b \]
          7. cube-unmultN/A

            \[\leadsto \left(b \cdot \left(b \cdot b\right)\right) \cdot b \]
          8. pow2N/A

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

            \[\leadsto \left(b \cdot {b}^{2}\right) \cdot \color{blue}{b} \]
          10. pow2N/A

            \[\leadsto \left(b \cdot \left(b \cdot b\right)\right) \cdot b \]
          11. cube-unmultN/A

            \[\leadsto {b}^{3} \cdot b \]
          12. metadata-evalN/A

            \[\leadsto {b}^{\left(2 + 1\right)} \cdot b \]
          13. pow-plusN/A

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

            \[\leadsto \left({b}^{2} \cdot b\right) \cdot b \]
          15. pow2N/A

            \[\leadsto \left(\left(b \cdot b\right) \cdot b\right) \cdot b \]
          16. lift-*.f6492.6

            \[\leadsto \left(\left(b \cdot b\right) \cdot b\right) \cdot b \]
        4. Applied rewrites92.6%

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

      Alternative 10: 68.6% accurate, 0.8× speedup?

      \[\begin{array}{l} b_m = \left|b\right| \\ \begin{array}{l} \mathbf{if}\;\left({\left(a \cdot a + b\_m \cdot b\_m\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b\_m \cdot b\_m\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \leq -0.5:\\ \;\;\;\;\left(a \cdot a\right) \cdot 4 - 1\\ \mathbf{else}:\\ \;\;\;\;\left(\left(a \cdot a\right) \cdot a\right) \cdot a\\ \end{array} \end{array} \]
      b_m = (fabs.f64 b)
      (FPCore (a b_m)
       :precision binary64
       (if (<=
            (-
             (+
              (pow (+ (* a a) (* b_m b_m)) 2.0)
              (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b_m b_m) (- 1.0 (* 3.0 a))))))
             1.0)
            -0.5)
         (- (* (* a a) 4.0) 1.0)
         (* (* (* a a) a) a)))
      b_m = fabs(b);
      double code(double a, double b_m) {
      	double tmp;
      	if (((pow(((a * a) + (b_m * b_m)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b_m * b_m) * (1.0 - (3.0 * a)))))) - 1.0) <= -0.5) {
      		tmp = ((a * a) * 4.0) - 1.0;
      	} else {
      		tmp = ((a * a) * a) * a;
      	}
      	return tmp;
      }
      
      b_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(a, b_m)
      use fmin_fmax_functions
          real(8), intent (in) :: a
          real(8), intent (in) :: b_m
          real(8) :: tmp
          if ((((((a * a) + (b_m * b_m)) ** 2.0d0) + (4.0d0 * (((a * a) * (1.0d0 + a)) + ((b_m * b_m) * (1.0d0 - (3.0d0 * a)))))) - 1.0d0) <= (-0.5d0)) then
              tmp = ((a * a) * 4.0d0) - 1.0d0
          else
              tmp = ((a * a) * a) * a
          end if
          code = tmp
      end function
      
      b_m = Math.abs(b);
      public static double code(double a, double b_m) {
      	double tmp;
      	if (((Math.pow(((a * a) + (b_m * b_m)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b_m * b_m) * (1.0 - (3.0 * a)))))) - 1.0) <= -0.5) {
      		tmp = ((a * a) * 4.0) - 1.0;
      	} else {
      		tmp = ((a * a) * a) * a;
      	}
      	return tmp;
      }
      
      b_m = math.fabs(b)
      def code(a, b_m):
      	tmp = 0
      	if ((math.pow(((a * a) + (b_m * b_m)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b_m * b_m) * (1.0 - (3.0 * a)))))) - 1.0) <= -0.5:
      		tmp = ((a * a) * 4.0) - 1.0
      	else:
      		tmp = ((a * a) * a) * a
      	return tmp
      
      b_m = abs(b)
      function code(a, b_m)
      	tmp = 0.0
      	if (Float64(Float64((Float64(Float64(a * a) + Float64(b_m * b_m)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 + a)) + Float64(Float64(b_m * b_m) * Float64(1.0 - Float64(3.0 * a)))))) - 1.0) <= -0.5)
      		tmp = Float64(Float64(Float64(a * a) * 4.0) - 1.0);
      	else
      		tmp = Float64(Float64(Float64(a * a) * a) * a);
      	end
      	return tmp
      end
      
      b_m = abs(b);
      function tmp_2 = code(a, b_m)
      	tmp = 0.0;
      	if ((((((a * a) + (b_m * b_m)) ^ 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b_m * b_m) * (1.0 - (3.0 * a)))))) - 1.0) <= -0.5)
      		tmp = ((a * a) * 4.0) - 1.0;
      	else
      		tmp = ((a * a) * a) * a;
      	end
      	tmp_2 = tmp;
      end
      
      b_m = N[Abs[b], $MachinePrecision]
      code[a_, b$95$m_] := If[LessEqual[N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b$95$m * b$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 + a), $MachinePrecision]), $MachinePrecision] + N[(N[(b$95$m * b$95$m), $MachinePrecision] * N[(1.0 - N[(3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], -0.5], N[(N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(N[(a * a), $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision]]
      
      \begin{array}{l}
      b_m = \left|b\right|
      
      \\
      \begin{array}{l}
      \mathbf{if}\;\left({\left(a \cdot a + b\_m \cdot b\_m\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b\_m \cdot b\_m\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \leq -0.5:\\
      \;\;\;\;\left(a \cdot a\right) \cdot 4 - 1\\
      
      \mathbf{else}:\\
      \;\;\;\;\left(\left(a \cdot a\right) \cdot a\right) \cdot a\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (-.f64 (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (+.f64 (*.f64 (*.f64 a a) (+.f64 #s(literal 1 binary64) a)) (*.f64 (*.f64 b b) (-.f64 #s(literal 1 binary64) (*.f64 #s(literal 3 binary64) a)))))) #s(literal 1 binary64)) < -0.5

        1. Initial program 100.0%

          \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
        2. Taylor expanded in b around 0

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

            \[\leadsto \left({a}^{4} + \color{blue}{4 \cdot \left({a}^{2} \cdot \left(1 + a\right)\right)}\right) - 1 \]
          2. metadata-evalN/A

            \[\leadsto \left({a}^{\left(2 + 2\right)} + 4 \cdot \left({a}^{2} \cdot \left(1 + a\right)\right)\right) - 1 \]
          3. pow-prod-upN/A

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

            \[\leadsto \left({a}^{2} \cdot {a}^{2} + \left({a}^{2} \cdot \left(1 + a\right)\right) \cdot \color{blue}{4}\right) - 1 \]
          5. associate-*l*N/A

            \[\leadsto \left({a}^{2} \cdot {a}^{2} + {a}^{2} \cdot \color{blue}{\left(\left(1 + a\right) \cdot 4\right)}\right) - 1 \]
          6. +-commutativeN/A

            \[\leadsto \left({a}^{2} \cdot {a}^{2} + {a}^{2} \cdot \left(\left(a + 1\right) \cdot 4\right)\right) - 1 \]
          7. distribute-rgt1-inN/A

            \[\leadsto \left({a}^{2} \cdot {a}^{2} + {a}^{2} \cdot \left(4 + \color{blue}{a \cdot 4}\right)\right) - 1 \]
          8. *-commutativeN/A

            \[\leadsto \left({a}^{2} \cdot {a}^{2} + {a}^{2} \cdot \left(4 + 4 \cdot \color{blue}{a}\right)\right) - 1 \]
          9. distribute-lft-outN/A

            \[\leadsto {a}^{2} \cdot \color{blue}{\left({a}^{2} + \left(4 + 4 \cdot a\right)\right)} - 1 \]
          10. lower-*.f64N/A

            \[\leadsto {a}^{2} \cdot \color{blue}{\left({a}^{2} + \left(4 + 4 \cdot a\right)\right)} - 1 \]
          11. pow2N/A

            \[\leadsto \left(a \cdot a\right) \cdot \left(\color{blue}{{a}^{2}} + \left(4 + 4 \cdot a\right)\right) - 1 \]
          12. lift-*.f64N/A

            \[\leadsto \left(a \cdot a\right) \cdot \left(\color{blue}{{a}^{2}} + \left(4 + 4 \cdot a\right)\right) - 1 \]
          13. pow2N/A

            \[\leadsto \left(a \cdot a\right) \cdot \left(a \cdot a + \left(\color{blue}{4} + 4 \cdot a\right)\right) - 1 \]
          14. lower-fma.f64N/A

            \[\leadsto \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, \color{blue}{a}, 4 + 4 \cdot a\right) - 1 \]
          15. +-commutativeN/A

            \[\leadsto \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, 4 \cdot a + 4\right) - 1 \]
          16. lower-fma.f6499.0

            \[\leadsto \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1 \]
        4. Applied rewrites99.0%

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

          \[\leadsto \left(a \cdot a\right) \cdot 4 - 1 \]
        6. Step-by-step derivation
          1. Applied rewrites98.4%

            \[\leadsto \left(a \cdot a\right) \cdot 4 - 1 \]

          if -0.5 < (-.f64 (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (+.f64 (*.f64 (*.f64 a a) (+.f64 #s(literal 1 binary64) a)) (*.f64 (*.f64 b b) (-.f64 #s(literal 1 binary64) (*.f64 #s(literal 3 binary64) a)))))) #s(literal 1 binary64))

          1. Initial program 65.0%

            \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
          2. Taylor expanded in a around inf

            \[\leadsto \color{blue}{{a}^{4}} \]
          3. Step-by-step derivation
            1. metadata-evalN/A

              \[\leadsto {a}^{\left(3 + \color{blue}{1}\right)} \]
            2. pow-plusN/A

              \[\leadsto {a}^{3} \cdot \color{blue}{a} \]
            3. lower-*.f64N/A

              \[\leadsto {a}^{3} \cdot \color{blue}{a} \]
            4. unpow3N/A

              \[\leadsto \left(\left(a \cdot a\right) \cdot a\right) \cdot a \]
            5. pow2N/A

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

              \[\leadsto \left({a}^{2} \cdot a\right) \cdot a \]
            7. pow2N/A

              \[\leadsto \left(\left(a \cdot a\right) \cdot a\right) \cdot a \]
            8. lift-*.f6458.6

              \[\leadsto \left(\left(a \cdot a\right) \cdot a\right) \cdot a \]
          4. Applied rewrites58.6%

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

        Alternative 11: 68.6% accurate, 0.8× speedup?

        \[\begin{array}{l} b_m = \left|b\right| \\ \begin{array}{l} \mathbf{if}\;\left({\left(a \cdot a + b\_m \cdot b\_m\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b\_m \cdot b\_m\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \leq -0.5:\\ \;\;\;\;\left(a \cdot a\right) \cdot 4 - 1\\ \mathbf{else}:\\ \;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a\right)\\ \end{array} \end{array} \]
        b_m = (fabs.f64 b)
        (FPCore (a b_m)
         :precision binary64
         (if (<=
              (-
               (+
                (pow (+ (* a a) (* b_m b_m)) 2.0)
                (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b_m b_m) (- 1.0 (* 3.0 a))))))
               1.0)
              -0.5)
           (- (* (* a a) 4.0) 1.0)
           (* (* a a) (* a a))))
        b_m = fabs(b);
        double code(double a, double b_m) {
        	double tmp;
        	if (((pow(((a * a) + (b_m * b_m)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b_m * b_m) * (1.0 - (3.0 * a)))))) - 1.0) <= -0.5) {
        		tmp = ((a * a) * 4.0) - 1.0;
        	} else {
        		tmp = (a * a) * (a * a);
        	}
        	return tmp;
        }
        
        b_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(a, b_m)
        use fmin_fmax_functions
            real(8), intent (in) :: a
            real(8), intent (in) :: b_m
            real(8) :: tmp
            if ((((((a * a) + (b_m * b_m)) ** 2.0d0) + (4.0d0 * (((a * a) * (1.0d0 + a)) + ((b_m * b_m) * (1.0d0 - (3.0d0 * a)))))) - 1.0d0) <= (-0.5d0)) then
                tmp = ((a * a) * 4.0d0) - 1.0d0
            else
                tmp = (a * a) * (a * a)
            end if
            code = tmp
        end function
        
        b_m = Math.abs(b);
        public static double code(double a, double b_m) {
        	double tmp;
        	if (((Math.pow(((a * a) + (b_m * b_m)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b_m * b_m) * (1.0 - (3.0 * a)))))) - 1.0) <= -0.5) {
        		tmp = ((a * a) * 4.0) - 1.0;
        	} else {
        		tmp = (a * a) * (a * a);
        	}
        	return tmp;
        }
        
        b_m = math.fabs(b)
        def code(a, b_m):
        	tmp = 0
        	if ((math.pow(((a * a) + (b_m * b_m)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b_m * b_m) * (1.0 - (3.0 * a)))))) - 1.0) <= -0.5:
        		tmp = ((a * a) * 4.0) - 1.0
        	else:
        		tmp = (a * a) * (a * a)
        	return tmp
        
        b_m = abs(b)
        function code(a, b_m)
        	tmp = 0.0
        	if (Float64(Float64((Float64(Float64(a * a) + Float64(b_m * b_m)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 + a)) + Float64(Float64(b_m * b_m) * Float64(1.0 - Float64(3.0 * a)))))) - 1.0) <= -0.5)
        		tmp = Float64(Float64(Float64(a * a) * 4.0) - 1.0);
        	else
        		tmp = Float64(Float64(a * a) * Float64(a * a));
        	end
        	return tmp
        end
        
        b_m = abs(b);
        function tmp_2 = code(a, b_m)
        	tmp = 0.0;
        	if ((((((a * a) + (b_m * b_m)) ^ 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b_m * b_m) * (1.0 - (3.0 * a)))))) - 1.0) <= -0.5)
        		tmp = ((a * a) * 4.0) - 1.0;
        	else
        		tmp = (a * a) * (a * a);
        	end
        	tmp_2 = tmp;
        end
        
        b_m = N[Abs[b], $MachinePrecision]
        code[a_, b$95$m_] := If[LessEqual[N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b$95$m * b$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 + a), $MachinePrecision]), $MachinePrecision] + N[(N[(b$95$m * b$95$m), $MachinePrecision] * N[(1.0 - N[(3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], -0.5], N[(N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(a * a), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision]]
        
        \begin{array}{l}
        b_m = \left|b\right|
        
        \\
        \begin{array}{l}
        \mathbf{if}\;\left({\left(a \cdot a + b\_m \cdot b\_m\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b\_m \cdot b\_m\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \leq -0.5:\\
        \;\;\;\;\left(a \cdot a\right) \cdot 4 - 1\\
        
        \mathbf{else}:\\
        \;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a\right)\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if (-.f64 (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (+.f64 (*.f64 (*.f64 a a) (+.f64 #s(literal 1 binary64) a)) (*.f64 (*.f64 b b) (-.f64 #s(literal 1 binary64) (*.f64 #s(literal 3 binary64) a)))))) #s(literal 1 binary64)) < -0.5

          1. Initial program 100.0%

            \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
          2. Taylor expanded in b around 0

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

              \[\leadsto \left({a}^{4} + \color{blue}{4 \cdot \left({a}^{2} \cdot \left(1 + a\right)\right)}\right) - 1 \]
            2. metadata-evalN/A

              \[\leadsto \left({a}^{\left(2 + 2\right)} + 4 \cdot \left({a}^{2} \cdot \left(1 + a\right)\right)\right) - 1 \]
            3. pow-prod-upN/A

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

              \[\leadsto \left({a}^{2} \cdot {a}^{2} + \left({a}^{2} \cdot \left(1 + a\right)\right) \cdot \color{blue}{4}\right) - 1 \]
            5. associate-*l*N/A

              \[\leadsto \left({a}^{2} \cdot {a}^{2} + {a}^{2} \cdot \color{blue}{\left(\left(1 + a\right) \cdot 4\right)}\right) - 1 \]
            6. +-commutativeN/A

              \[\leadsto \left({a}^{2} \cdot {a}^{2} + {a}^{2} \cdot \left(\left(a + 1\right) \cdot 4\right)\right) - 1 \]
            7. distribute-rgt1-inN/A

              \[\leadsto \left({a}^{2} \cdot {a}^{2} + {a}^{2} \cdot \left(4 + \color{blue}{a \cdot 4}\right)\right) - 1 \]
            8. *-commutativeN/A

              \[\leadsto \left({a}^{2} \cdot {a}^{2} + {a}^{2} \cdot \left(4 + 4 \cdot \color{blue}{a}\right)\right) - 1 \]
            9. distribute-lft-outN/A

              \[\leadsto {a}^{2} \cdot \color{blue}{\left({a}^{2} + \left(4 + 4 \cdot a\right)\right)} - 1 \]
            10. lower-*.f64N/A

              \[\leadsto {a}^{2} \cdot \color{blue}{\left({a}^{2} + \left(4 + 4 \cdot a\right)\right)} - 1 \]
            11. pow2N/A

              \[\leadsto \left(a \cdot a\right) \cdot \left(\color{blue}{{a}^{2}} + \left(4 + 4 \cdot a\right)\right) - 1 \]
            12. lift-*.f64N/A

              \[\leadsto \left(a \cdot a\right) \cdot \left(\color{blue}{{a}^{2}} + \left(4 + 4 \cdot a\right)\right) - 1 \]
            13. pow2N/A

              \[\leadsto \left(a \cdot a\right) \cdot \left(a \cdot a + \left(\color{blue}{4} + 4 \cdot a\right)\right) - 1 \]
            14. lower-fma.f64N/A

              \[\leadsto \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, \color{blue}{a}, 4 + 4 \cdot a\right) - 1 \]
            15. +-commutativeN/A

              \[\leadsto \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, 4 \cdot a + 4\right) - 1 \]
            16. lower-fma.f6499.0

              \[\leadsto \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1 \]
          4. Applied rewrites99.0%

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

            \[\leadsto \left(a \cdot a\right) \cdot 4 - 1 \]
          6. Step-by-step derivation
            1. Applied rewrites98.4%

              \[\leadsto \left(a \cdot a\right) \cdot 4 - 1 \]

            if -0.5 < (-.f64 (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (+.f64 (*.f64 (*.f64 a a) (+.f64 #s(literal 1 binary64) a)) (*.f64 (*.f64 b b) (-.f64 #s(literal 1 binary64) (*.f64 #s(literal 3 binary64) a)))))) #s(literal 1 binary64))

            1. Initial program 65.0%

              \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
            2. Taylor expanded in a around inf

              \[\leadsto \color{blue}{{a}^{4} \cdot \left(1 + 4 \cdot \frac{1}{a}\right)} \]
            3. Step-by-step derivation
              1. distribute-rgt-inN/A

                \[\leadsto 1 \cdot {a}^{4} + \color{blue}{\left(4 \cdot \frac{1}{a}\right) \cdot {a}^{4}} \]
              2. *-lft-identityN/A

                \[\leadsto {a}^{4} + \color{blue}{\left(4 \cdot \frac{1}{a}\right)} \cdot {a}^{4} \]
              3. metadata-evalN/A

                \[\leadsto {a}^{\left(2 + 2\right)} + \left(4 \cdot \color{blue}{\frac{1}{a}}\right) \cdot {a}^{4} \]
              4. pow-prod-upN/A

                \[\leadsto {a}^{2} \cdot {a}^{2} + \color{blue}{\left(4 \cdot \frac{1}{a}\right)} \cdot {a}^{4} \]
              5. associate-*l*N/A

                \[\leadsto {a}^{2} \cdot {a}^{2} + 4 \cdot \color{blue}{\left(\frac{1}{a} \cdot {a}^{4}\right)} \]
              6. inv-powN/A

                \[\leadsto {a}^{2} \cdot {a}^{2} + 4 \cdot \left({a}^{-1} \cdot {\color{blue}{a}}^{4}\right) \]
              7. pow-prod-upN/A

                \[\leadsto {a}^{2} \cdot {a}^{2} + 4 \cdot {a}^{\color{blue}{\left(-1 + 4\right)}} \]
              8. metadata-evalN/A

                \[\leadsto {a}^{2} \cdot {a}^{2} + 4 \cdot {a}^{3} \]
              9. cube-multN/A

                \[\leadsto {a}^{2} \cdot {a}^{2} + 4 \cdot \left(a \cdot \color{blue}{\left(a \cdot a\right)}\right) \]
              10. pow2N/A

                \[\leadsto {a}^{2} \cdot {a}^{2} + 4 \cdot \left(a \cdot {a}^{\color{blue}{2}}\right) \]
              11. associate-*r*N/A

                \[\leadsto {a}^{2} \cdot {a}^{2} + \left(4 \cdot a\right) \cdot \color{blue}{{a}^{2}} \]
              12. distribute-rgt-outN/A

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

                \[\leadsto {a}^{2} \cdot \left({a}^{2} + a \cdot \color{blue}{4}\right) \]
              14. fp-cancel-sign-subN/A

                \[\leadsto {a}^{2} \cdot \left({a}^{2} - \color{blue}{\left(\mathsf{neg}\left(a\right)\right) \cdot 4}\right) \]
              15. pow2N/A

                \[\leadsto {a}^{2} \cdot \left(a \cdot a - \color{blue}{\left(\mathsf{neg}\left(a\right)\right)} \cdot 4\right) \]
              16. sqr-neg-revN/A

                \[\leadsto {a}^{2} \cdot \left(\left(\mathsf{neg}\left(a\right)\right) \cdot \left(\mathsf{neg}\left(a\right)\right) - \color{blue}{\left(\mathsf{neg}\left(a\right)\right)} \cdot 4\right) \]
              17. lower-*.f64N/A

                \[\leadsto {a}^{2} \cdot \color{blue}{\left(\left(\mathsf{neg}\left(a\right)\right) \cdot \left(\mathsf{neg}\left(a\right)\right) - \left(\mathsf{neg}\left(a\right)\right) \cdot 4\right)} \]
            4. Applied rewrites59.0%

              \[\leadsto \color{blue}{\left(a \cdot a\right) \cdot \left(a \cdot \left(a - -4\right)\right)} \]
            5. Taylor expanded in a around inf

              \[\leadsto \left(a \cdot a\right) \cdot \left(a \cdot a\right) \]
            6. Step-by-step derivation
              1. Applied rewrites58.6%

                \[\leadsto \left(a \cdot a\right) \cdot \left(a \cdot a\right) \]
            7. Recombined 2 regimes into one program.
            8. Add Preprocessing

            Alternative 12: 50.7% accurate, 5.9× speedup?

            \[\begin{array}{l} b_m = \left|b\right| \\ \left(a \cdot a\right) \cdot 4 - 1 \end{array} \]
            b_m = (fabs.f64 b)
            (FPCore (a b_m) :precision binary64 (- (* (* a a) 4.0) 1.0))
            b_m = fabs(b);
            double code(double a, double b_m) {
            	return ((a * a) * 4.0) - 1.0;
            }
            
            b_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(a, b_m)
            use fmin_fmax_functions
                real(8), intent (in) :: a
                real(8), intent (in) :: b_m
                code = ((a * a) * 4.0d0) - 1.0d0
            end function
            
            b_m = Math.abs(b);
            public static double code(double a, double b_m) {
            	return ((a * a) * 4.0) - 1.0;
            }
            
            b_m = math.fabs(b)
            def code(a, b_m):
            	return ((a * a) * 4.0) - 1.0
            
            b_m = abs(b)
            function code(a, b_m)
            	return Float64(Float64(Float64(a * a) * 4.0) - 1.0)
            end
            
            b_m = abs(b);
            function tmp = code(a, b_m)
            	tmp = ((a * a) * 4.0) - 1.0;
            end
            
            b_m = N[Abs[b], $MachinePrecision]
            code[a_, b$95$m_] := N[(N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision] - 1.0), $MachinePrecision]
            
            \begin{array}{l}
            b_m = \left|b\right|
            
            \\
            \left(a \cdot a\right) \cdot 4 - 1
            \end{array}
            
            Derivation
            1. Initial program 73.8%

              \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
            2. Taylor expanded in b around 0

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

                \[\leadsto \left({a}^{4} + \color{blue}{4 \cdot \left({a}^{2} \cdot \left(1 + a\right)\right)}\right) - 1 \]
              2. metadata-evalN/A

                \[\leadsto \left({a}^{\left(2 + 2\right)} + 4 \cdot \left({a}^{2} \cdot \left(1 + a\right)\right)\right) - 1 \]
              3. pow-prod-upN/A

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

                \[\leadsto \left({a}^{2} \cdot {a}^{2} + \left({a}^{2} \cdot \left(1 + a\right)\right) \cdot \color{blue}{4}\right) - 1 \]
              5. associate-*l*N/A

                \[\leadsto \left({a}^{2} \cdot {a}^{2} + {a}^{2} \cdot \color{blue}{\left(\left(1 + a\right) \cdot 4\right)}\right) - 1 \]
              6. +-commutativeN/A

                \[\leadsto \left({a}^{2} \cdot {a}^{2} + {a}^{2} \cdot \left(\left(a + 1\right) \cdot 4\right)\right) - 1 \]
              7. distribute-rgt1-inN/A

                \[\leadsto \left({a}^{2} \cdot {a}^{2} + {a}^{2} \cdot \left(4 + \color{blue}{a \cdot 4}\right)\right) - 1 \]
              8. *-commutativeN/A

                \[\leadsto \left({a}^{2} \cdot {a}^{2} + {a}^{2} \cdot \left(4 + 4 \cdot \color{blue}{a}\right)\right) - 1 \]
              9. distribute-lft-outN/A

                \[\leadsto {a}^{2} \cdot \color{blue}{\left({a}^{2} + \left(4 + 4 \cdot a\right)\right)} - 1 \]
              10. lower-*.f64N/A

                \[\leadsto {a}^{2} \cdot \color{blue}{\left({a}^{2} + \left(4 + 4 \cdot a\right)\right)} - 1 \]
              11. pow2N/A

                \[\leadsto \left(a \cdot a\right) \cdot \left(\color{blue}{{a}^{2}} + \left(4 + 4 \cdot a\right)\right) - 1 \]
              12. lift-*.f64N/A

                \[\leadsto \left(a \cdot a\right) \cdot \left(\color{blue}{{a}^{2}} + \left(4 + 4 \cdot a\right)\right) - 1 \]
              13. pow2N/A

                \[\leadsto \left(a \cdot a\right) \cdot \left(a \cdot a + \left(\color{blue}{4} + 4 \cdot a\right)\right) - 1 \]
              14. lower-fma.f64N/A

                \[\leadsto \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, \color{blue}{a}, 4 + 4 \cdot a\right) - 1 \]
              15. +-commutativeN/A

                \[\leadsto \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, 4 \cdot a + 4\right) - 1 \]
              16. lower-fma.f6469.1

                \[\leadsto \left(a \cdot a\right) \cdot \mathsf{fma}\left(a, a, \mathsf{fma}\left(4, a, 4\right)\right) - 1 \]
            4. Applied rewrites69.1%

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

              \[\leadsto \left(a \cdot a\right) \cdot 4 - 1 \]
            6. Step-by-step derivation
              1. Applied rewrites50.7%

                \[\leadsto \left(a \cdot a\right) \cdot 4 - 1 \]
              2. Add Preprocessing

              Reproduce

              ?
              herbie shell --seed 2025130 
              (FPCore (a b)
                :name "Bouland and Aaronson, Equation (25)"
                :precision binary64
                (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 3.0 a)))))) 1.0))