Bouland and Aaronson, Equation (24)

Percentage Accurate: 73.4% → 100.0%
Time: 9.2s
Alternatives: 11
Speedup: 9.8×

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(3 + 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) (+ 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) * (3.0 + a))))) - 1.0;
}
real(8) function code(a, b)
    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) * (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) * (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) * (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(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) * (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[(3.0 + a), $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(3 + a\right)\right)\right) - 1
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 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.4% 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(3 + 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) (+ 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) * (3.0 + a))))) - 1.0;
}
real(8) function code(a, b)
    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) * (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) * (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) * (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(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) * (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[(3.0 + a), $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(3 + a\right)\right)\right) - 1
\end{array}

Alternative 1: 100.0% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{\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(a + 3\right)\right) \leq \infty:\\ \;\;\;\;\left({\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + 4 \cdot \left(b \cdot \left(b \cdot \left(a + 3\right)\right) + a \cdot \left(a \cdot \left(1 - a\right)\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(\mathsf{fma}\left(2, b \cdot b, 4\right) + a \cdot \left(a + -4\right)\right)\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<=
      (+
       (pow (+ (* a a) (* b b)) 2.0)
       (* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ a 3.0)))))
      INFINITY)
   (+
    (+
     (pow (hypot a b) 4.0)
     (* 4.0 (+ (* b (* b (+ a 3.0))) (* a (* a (- 1.0 a))))))
    -1.0)
   (+ -1.0 (* (* a a) (+ (fma 2.0 (* b b) 4.0) (* a (+ a -4.0)))))))
double code(double a, double b) {
	double tmp;
	if ((pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))))) <= ((double) INFINITY)) {
		tmp = (pow(hypot(a, b), 4.0) + (4.0 * ((b * (b * (a + 3.0))) + (a * (a * (1.0 - a)))))) + -1.0;
	} else {
		tmp = -1.0 + ((a * a) * (fma(2.0, (b * b), 4.0) + (a * (a + -4.0))));
	}
	return tmp;
}
function code(a, b)
	tmp = 0.0
	if (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(a + 3.0))))) <= Inf)
		tmp = Float64(Float64((hypot(a, b) ^ 4.0) + Float64(4.0 * Float64(Float64(b * Float64(b * Float64(a + 3.0))) + Float64(a * Float64(a * Float64(1.0 - a)))))) + -1.0);
	else
		tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(fma(2.0, Float64(b * b), 4.0) + Float64(a * Float64(a + -4.0)))));
	end
	return tmp
end
code[a_, b_] := If[LessEqual[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[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + N[(4.0 * N[(N[(b * N[(b * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(a * N[(a * N[(1.0 - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(N[(2.0 * N[(b * b), $MachinePrecision] + 4.0), $MachinePrecision] + N[(a * N[(a + -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;{\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(a + 3\right)\right) \leq \infty:\\
\;\;\;\;\left({\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + 4 \cdot \left(b \cdot \left(b \cdot \left(a + 3\right)\right) + a \cdot \left(a \cdot \left(1 - a\right)\right)\right)\right) + -1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (-.f64 1 a)) (*.f64 (*.f64 b b) (+.f64 3 a))))) < +inf.0

    1. Initial program 99.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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg99.8%

        \[\leadsto \color{blue}{\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. fma-def99.8%

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

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

        \[\leadsto \left({\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + 4 \cdot \mathsf{fma}\left(a \cdot a, 1 - a, \left(b \cdot b\right) \cdot \color{blue}{\left(a + 3\right)}\right)\right) + \left(-1\right) \]
      5. metadata-eval99.8%

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

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

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

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

        \[\leadsto \left({\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + 4 \cdot \color{blue}{\left(\left(b \cdot b\right) \cdot \left(3 + a\right) + \left(a \cdot a\right) \cdot \left(1 - a\right)\right)}\right) + -1 \]
      4. associate-*l*99.8%

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

        \[\leadsto \left({\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + 4 \cdot \left(b \cdot \left(b \cdot \color{blue}{\left(a + 3\right)}\right) + \left(a \cdot a\right) \cdot \left(1 - a\right)\right)\right) + -1 \]
      6. associate-*l*99.8%

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

      \[\leadsto \left({\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + 4 \cdot \color{blue}{\left(b \cdot \left(b \cdot \left(a + 3\right)\right) + a \cdot \left(a \cdot \left(1 - a\right)\right)\right)}\right) + -1 \]
    6. Step-by-step derivation
      1. fma-def99.8%

        \[\leadsto \left({\color{blue}{\left(a \cdot a + b \cdot b\right)}}^{2} + 4 \cdot \left(b \cdot \left(b \cdot \left(a + 3\right)\right) + a \cdot \left(a \cdot \left(1 - a\right)\right)\right)\right) + -1 \]
      2. metadata-eval99.8%

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

        \[\leadsto \left(\color{blue}{{\left(\sqrt{a \cdot a + b \cdot b}\right)}^{4}} + 4 \cdot \left(b \cdot \left(b \cdot \left(a + 3\right)\right) + a \cdot \left(a \cdot \left(1 - a\right)\right)\right)\right) + -1 \]
      4. hypot-udef100.0%

        \[\leadsto \left({\color{blue}{\left(\mathsf{hypot}\left(a, b\right)\right)}}^{4} + 4 \cdot \left(b \cdot \left(b \cdot \left(a + 3\right)\right) + a \cdot \left(a \cdot \left(1 - a\right)\right)\right)\right) + -1 \]
      5. expm1-log1p-u98.2%

        \[\leadsto \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}\right)\right)} + 4 \cdot \left(b \cdot \left(b \cdot \left(a + 3\right)\right) + a \cdot \left(a \cdot \left(1 - a\right)\right)\right)\right) + -1 \]
      6. expm1-udef98.2%

        \[\leadsto \left(\color{blue}{\left(e^{\mathsf{log1p}\left({\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}\right)} - 1\right)} + 4 \cdot \left(b \cdot \left(b \cdot \left(a + 3\right)\right) + a \cdot \left(a \cdot \left(1 - a\right)\right)\right)\right) + -1 \]
    7. Applied egg-rr98.2%

      \[\leadsto \left(\color{blue}{\left(e^{\mathsf{log1p}\left({\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}\right)} - 1\right)} + 4 \cdot \left(b \cdot \left(b \cdot \left(a + 3\right)\right) + a \cdot \left(a \cdot \left(1 - a\right)\right)\right)\right) + -1 \]
    8. Step-by-step derivation
      1. expm1-def98.2%

        \[\leadsto \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}\right)\right)} + 4 \cdot \left(b \cdot \left(b \cdot \left(a + 3\right)\right) + a \cdot \left(a \cdot \left(1 - a\right)\right)\right)\right) + -1 \]
      2. expm1-log1p100.0%

        \[\leadsto \left(\color{blue}{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}} + 4 \cdot \left(b \cdot \left(b \cdot \left(a + 3\right)\right) + a \cdot \left(a \cdot \left(1 - a\right)\right)\right)\right) + -1 \]
    9. Simplified100.0%

      \[\leadsto \left(\color{blue}{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}} + 4 \cdot \left(b \cdot \left(b \cdot \left(a + 3\right)\right) + a \cdot \left(a \cdot \left(1 - a\right)\right)\right)\right) + -1 \]

    if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (-.f64 1 a)) (*.f64 (*.f64 b b) (+.f64 3 a)))))

    1. Initial program 0.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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg0.0%

        \[\leadsto \color{blue}{\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. fma-def0.0%

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

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

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

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

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

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

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

        \[\leadsto \left({\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + 4 \cdot \color{blue}{\left(\left(b \cdot b\right) \cdot \left(3 + a\right) + \left(a \cdot a\right) \cdot \left(1 - a\right)\right)}\right) + -1 \]
      4. associate-*l*0.0%

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

        \[\leadsto \left({\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + 4 \cdot \left(b \cdot \left(b \cdot \color{blue}{\left(a + 3\right)}\right) + \left(a \cdot a\right) \cdot \left(1 - a\right)\right)\right) + -1 \]
      6. associate-*l*0.0%

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

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

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

        \[\leadsto \color{blue}{\left(\left(\left(2 \cdot {b}^{2} + 4\right) \cdot {a}^{2} + {a}^{4}\right) + -4 \cdot {a}^{3}\right)} + -1 \]
      2. associate-+l+39.1%

        \[\leadsto \color{blue}{\left(\left(2 \cdot {b}^{2} + 4\right) \cdot {a}^{2} + \left({a}^{4} + -4 \cdot {a}^{3}\right)\right)} + -1 \]
      3. *-commutative39.1%

        \[\leadsto \left(\color{blue}{{a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right)} + \left({a}^{4} + -4 \cdot {a}^{3}\right)\right) + -1 \]
      4. metadata-eval39.1%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left({a}^{\color{blue}{\left(3 + 1\right)}} + -4 \cdot {a}^{3}\right)\right) + -1 \]
      5. pow-plus39.1%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left(\color{blue}{{a}^{3} \cdot a} + -4 \cdot {a}^{3}\right)\right) + -1 \]
      6. *-commutative39.1%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left({a}^{3} \cdot a + \color{blue}{{a}^{3} \cdot -4}\right)\right) + -1 \]
      7. distribute-lft-in100.0%

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

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

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left(\color{blue}{{a}^{2}} \cdot a\right) \cdot \left(a + -4\right)\right) + -1 \]
      10. associate-*l*100.0%

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

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

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

        \[\leadsto \left(a \cdot a\right) \cdot \left(\color{blue}{\mathsf{fma}\left(2, {b}^{2}, 4\right)} + a \cdot \left(a + -4\right)\right) + -1 \]
      14. unpow2100.0%

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

      \[\leadsto \color{blue}{\left(a \cdot a\right) \cdot \left(\mathsf{fma}\left(2, b \cdot b, 4\right) + a \cdot \left(a + -4\right)\right)} + -1 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification100.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\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(a + 3\right)\right) \leq \infty:\\ \;\;\;\;\left({\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + 4 \cdot \left(b \cdot \left(b \cdot \left(a + 3\right)\right) + a \cdot \left(a \cdot \left(1 - a\right)\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(\mathsf{fma}\left(2, b \cdot b, 4\right) + a \cdot \left(a + -4\right)\right)\\ \end{array} \]

Alternative 2: 99.9% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\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(a + 3\right)\right)\\ \mathbf{if}\;t_0 \leq \infty:\\ \;\;\;\;t_0 + -1\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(\mathsf{fma}\left(2, b \cdot b, 4\right) + a \cdot \left(a + -4\right)\right)\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (let* ((t_0
         (+
          (pow (+ (* a a) (* b b)) 2.0)
          (* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ a 3.0)))))))
   (if (<= t_0 INFINITY)
     (+ t_0 -1.0)
     (+ -1.0 (* (* a a) (+ (fma 2.0 (* b b) 4.0) (* a (+ a -4.0))))))))
double code(double a, double b) {
	double t_0 = pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
	double tmp;
	if (t_0 <= ((double) INFINITY)) {
		tmp = t_0 + -1.0;
	} else {
		tmp = -1.0 + ((a * a) * (fma(2.0, (b * b), 4.0) + (a * (a + -4.0))));
	}
	return tmp;
}
function code(a, b)
	t_0 = 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(a + 3.0)))))
	tmp = 0.0
	if (t_0 <= Inf)
		tmp = Float64(t_0 + -1.0);
	else
		tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(fma(2.0, Float64(b * b), 4.0) + Float64(a * Float64(a + -4.0)))));
	end
	return tmp
end
code[a_, b_] := Block[{t$95$0 = 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[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(t$95$0 + -1.0), $MachinePrecision], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(N[(2.0 * N[(b * b), $MachinePrecision] + 4.0), $MachinePrecision] + N[(a * N[(a + -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\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(a + 3\right)\right)\\
\mathbf{if}\;t_0 \leq \infty:\\
\;\;\;\;t_0 + -1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (-.f64 1 a)) (*.f64 (*.f64 b b) (+.f64 3 a))))) < +inf.0

    1. Initial program 99.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(3 + a\right)\right)\right) - 1 \]

    if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (-.f64 1 a)) (*.f64 (*.f64 b b) (+.f64 3 a)))))

    1. Initial program 0.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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg0.0%

        \[\leadsto \color{blue}{\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. fma-def0.0%

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

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

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

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

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

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

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

        \[\leadsto \left({\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + 4 \cdot \color{blue}{\left(\left(b \cdot b\right) \cdot \left(3 + a\right) + \left(a \cdot a\right) \cdot \left(1 - a\right)\right)}\right) + -1 \]
      4. associate-*l*0.0%

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

        \[\leadsto \left({\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + 4 \cdot \left(b \cdot \left(b \cdot \color{blue}{\left(a + 3\right)}\right) + \left(a \cdot a\right) \cdot \left(1 - a\right)\right)\right) + -1 \]
      6. associate-*l*0.0%

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

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

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

        \[\leadsto \color{blue}{\left(\left(\left(2 \cdot {b}^{2} + 4\right) \cdot {a}^{2} + {a}^{4}\right) + -4 \cdot {a}^{3}\right)} + -1 \]
      2. associate-+l+39.1%

        \[\leadsto \color{blue}{\left(\left(2 \cdot {b}^{2} + 4\right) \cdot {a}^{2} + \left({a}^{4} + -4 \cdot {a}^{3}\right)\right)} + -1 \]
      3. *-commutative39.1%

        \[\leadsto \left(\color{blue}{{a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right)} + \left({a}^{4} + -4 \cdot {a}^{3}\right)\right) + -1 \]
      4. metadata-eval39.1%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left({a}^{\color{blue}{\left(3 + 1\right)}} + -4 \cdot {a}^{3}\right)\right) + -1 \]
      5. pow-plus39.1%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left(\color{blue}{{a}^{3} \cdot a} + -4 \cdot {a}^{3}\right)\right) + -1 \]
      6. *-commutative39.1%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left({a}^{3} \cdot a + \color{blue}{{a}^{3} \cdot -4}\right)\right) + -1 \]
      7. distribute-lft-in100.0%

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

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

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left(\color{blue}{{a}^{2}} \cdot a\right) \cdot \left(a + -4\right)\right) + -1 \]
      10. associate-*l*100.0%

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

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

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

        \[\leadsto \left(a \cdot a\right) \cdot \left(\color{blue}{\mathsf{fma}\left(2, {b}^{2}, 4\right)} + a \cdot \left(a + -4\right)\right) + -1 \]
      14. unpow2100.0%

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

      \[\leadsto \color{blue}{\left(a \cdot a\right) \cdot \left(\mathsf{fma}\left(2, b \cdot b, 4\right) + a \cdot \left(a + -4\right)\right)} + -1 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\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(a + 3\right)\right) \leq \infty:\\ \;\;\;\;\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(a + 3\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(\mathsf{fma}\left(2, b \cdot b, 4\right) + a \cdot \left(a + -4\right)\right)\\ \end{array} \]

Alternative 3: 94.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \cdot b \leq 50000:\\ \;\;\;\;-1 + a \cdot \left(a \cdot \mathsf{fma}\left(a, a + -4, 4\right)\right)\\ \mathbf{elif}\;b \cdot b \leq 10^{+112}:\\ \;\;\;\;-1 + \left({b}^{4} + \left(b \cdot b\right) \cdot \left(12 + a \cdot 4\right)\right)\\ \mathbf{elif}\;b \cdot b \leq 2 \cdot 10^{+141}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + {b}^{4}\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= (* b b) 50000.0)
   (+ -1.0 (* a (* a (fma a (+ a -4.0) 4.0))))
   (if (<= (* b b) 1e+112)
     (+ -1.0 (+ (pow b 4.0) (* (* b b) (+ 12.0 (* a 4.0)))))
     (if (<= (* b b) 2e+141)
       (+ -1.0 (* (* a a) (* a a)))
       (+ -1.0 (pow b 4.0))))))
double code(double a, double b) {
	double tmp;
	if ((b * b) <= 50000.0) {
		tmp = -1.0 + (a * (a * fma(a, (a + -4.0), 4.0)));
	} else if ((b * b) <= 1e+112) {
		tmp = -1.0 + (pow(b, 4.0) + ((b * b) * (12.0 + (a * 4.0))));
	} else if ((b * b) <= 2e+141) {
		tmp = -1.0 + ((a * a) * (a * a));
	} else {
		tmp = -1.0 + pow(b, 4.0);
	}
	return tmp;
}
function code(a, b)
	tmp = 0.0
	if (Float64(b * b) <= 50000.0)
		tmp = Float64(-1.0 + Float64(a * Float64(a * fma(a, Float64(a + -4.0), 4.0))));
	elseif (Float64(b * b) <= 1e+112)
		tmp = Float64(-1.0 + Float64((b ^ 4.0) + Float64(Float64(b * b) * Float64(12.0 + Float64(a * 4.0)))));
	elseif (Float64(b * b) <= 2e+141)
		tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(a * a)));
	else
		tmp = Float64(-1.0 + (b ^ 4.0));
	end
	return tmp
end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 50000.0], N[(-1.0 + N[(a * N[(a * N[(a * N[(a + -4.0), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(b * b), $MachinePrecision], 1e+112], N[(-1.0 + N[(N[Power[b, 4.0], $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(12.0 + N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(b * b), $MachinePrecision], 2e+141], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{elif}\;b \cdot b \leq 10^{+112}:\\
\;\;\;\;-1 + \left({b}^{4} + \left(b \cdot b\right) \cdot \left(12 + a \cdot 4\right)\right)\\

\mathbf{elif}\;b \cdot b \leq 2 \cdot 10^{+141}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot a\right)\\

\mathbf{else}:\\
\;\;\;\;-1 + {b}^{4}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 b b) < 5e4

    1. Initial program 84.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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg84.9%

        \[\leadsto \color{blue}{\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. fma-def84.9%

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

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

        \[\leadsto \left({\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + 4 \cdot \mathsf{fma}\left(a \cdot a, 1 - a, \left(b \cdot b\right) \cdot \color{blue}{\left(a + 3\right)}\right)\right) + \left(-1\right) \]
      5. metadata-eval84.9%

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

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

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

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

        \[\leadsto \left({\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + 4 \cdot \color{blue}{\left(\left(b \cdot b\right) \cdot \left(3 + a\right) + \left(a \cdot a\right) \cdot \left(1 - a\right)\right)}\right) + -1 \]
      4. associate-*l*84.9%

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

        \[\leadsto \left({\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + 4 \cdot \left(b \cdot \left(b \cdot \color{blue}{\left(a + 3\right)}\right) + \left(a \cdot a\right) \cdot \left(1 - a\right)\right)\right) + -1 \]
      6. associate-*l*84.9%

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

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

      \[\leadsto \color{blue}{\left(-4 \cdot {a}^{3} + \left(\left(2 \cdot {b}^{2} + 4\right) \cdot {a}^{2} + {a}^{4}\right)\right)} + -1 \]
    7. Step-by-step derivation
      1. +-commutative84.6%

        \[\leadsto \color{blue}{\left(\left(\left(2 \cdot {b}^{2} + 4\right) \cdot {a}^{2} + {a}^{4}\right) + -4 \cdot {a}^{3}\right)} + -1 \]
      2. associate-+l+84.6%

        \[\leadsto \color{blue}{\left(\left(2 \cdot {b}^{2} + 4\right) \cdot {a}^{2} + \left({a}^{4} + -4 \cdot {a}^{3}\right)\right)} + -1 \]
      3. *-commutative84.6%

        \[\leadsto \left(\color{blue}{{a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right)} + \left({a}^{4} + -4 \cdot {a}^{3}\right)\right) + -1 \]
      4. metadata-eval84.6%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left({a}^{\color{blue}{\left(3 + 1\right)}} + -4 \cdot {a}^{3}\right)\right) + -1 \]
      5. pow-plus84.6%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left(\color{blue}{{a}^{3} \cdot a} + -4 \cdot {a}^{3}\right)\right) + -1 \]
      6. *-commutative84.6%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left({a}^{3} \cdot a + \color{blue}{{a}^{3} \cdot -4}\right)\right) + -1 \]
      7. distribute-lft-in99.5%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \color{blue}{{a}^{3} \cdot \left(a + -4\right)}\right) + -1 \]
      8. unpow399.5%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \color{blue}{\left(\left(a \cdot a\right) \cdot a\right)} \cdot \left(a + -4\right)\right) + -1 \]
      9. unpow299.5%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left(\color{blue}{{a}^{2}} \cdot a\right) \cdot \left(a + -4\right)\right) + -1 \]
      10. associate-*l*99.4%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \color{blue}{{a}^{2} \cdot \left(a \cdot \left(a + -4\right)\right)}\right) + -1 \]
      11. distribute-lft-out99.4%

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

        \[\leadsto \color{blue}{\left(a \cdot a\right)} \cdot \left(\left(2 \cdot {b}^{2} + 4\right) + a \cdot \left(a + -4\right)\right) + -1 \]
      13. fma-def99.4%

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

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

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

      \[\leadsto \color{blue}{\left(4 + a \cdot \left(a - 4\right)\right) \cdot {a}^{2}} + -1 \]
    10. Step-by-step derivation
      1. unpow299.4%

        \[\leadsto \left(4 + a \cdot \left(a - 4\right)\right) \cdot \color{blue}{\left(a \cdot a\right)} + -1 \]
      2. *-commutative99.4%

        \[\leadsto \color{blue}{\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a - 4\right)\right)} + -1 \]
      3. associate-*l*99.4%

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

        \[\leadsto a \cdot \left(a \cdot \color{blue}{\left(a \cdot \left(a - 4\right) + 4\right)}\right) + -1 \]
      5. sub-neg99.4%

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

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

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

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

    if 5e4 < (*.f64 b b) < 9.9999999999999993e111

    1. Initial program 71.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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg71.8%

        \[\leadsto \color{blue}{\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. fma-def71.8%

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

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

        \[\leadsto \left({\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + 4 \cdot \mathsf{fma}\left(a \cdot a, 1 - a, \left(b \cdot b\right) \cdot \color{blue}{\left(a + 3\right)}\right)\right) + \left(-1\right) \]
      5. metadata-eval71.8%

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

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

      \[\leadsto \color{blue}{\left(12 \cdot {b}^{2} + \left(4 \cdot \left(a \cdot {b}^{2}\right) + {b}^{4}\right)\right)} + -1 \]
    5. Step-by-step derivation
      1. associate-+r+65.3%

        \[\leadsto \color{blue}{\left(\left(12 \cdot {b}^{2} + 4 \cdot \left(a \cdot {b}^{2}\right)\right) + {b}^{4}\right)} + -1 \]
      2. associate-*r*65.3%

        \[\leadsto \left(\left(12 \cdot {b}^{2} + \color{blue}{\left(4 \cdot a\right) \cdot {b}^{2}}\right) + {b}^{4}\right) + -1 \]
      3. distribute-rgt-out65.3%

        \[\leadsto \left(\color{blue}{{b}^{2} \cdot \left(12 + 4 \cdot a\right)} + {b}^{4}\right) + -1 \]
      4. metadata-eval65.3%

        \[\leadsto \left({b}^{2} \cdot \left(\color{blue}{4 \cdot 3} + 4 \cdot a\right) + {b}^{4}\right) + -1 \]
      5. distribute-lft-in65.3%

        \[\leadsto \left({b}^{2} \cdot \color{blue}{\left(4 \cdot \left(3 + a\right)\right)} + {b}^{4}\right) + -1 \]
      6. unpow265.3%

        \[\leadsto \left(\color{blue}{\left(b \cdot b\right)} \cdot \left(4 \cdot \left(3 + a\right)\right) + {b}^{4}\right) + -1 \]
      7. distribute-rgt-in65.3%

        \[\leadsto \left(\left(b \cdot b\right) \cdot \color{blue}{\left(3 \cdot 4 + a \cdot 4\right)} + {b}^{4}\right) + -1 \]
      8. metadata-eval65.3%

        \[\leadsto \left(\left(b \cdot b\right) \cdot \left(\color{blue}{12} + a \cdot 4\right) + {b}^{4}\right) + -1 \]
    6. Simplified65.3%

      \[\leadsto \color{blue}{\left(\left(b \cdot b\right) \cdot \left(12 + a \cdot 4\right) + {b}^{4}\right)} + -1 \]

    if 9.9999999999999993e111 < (*.f64 b b) < 2.00000000000000003e141

    1. Initial program 33.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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg33.3%

        \[\leadsto \color{blue}{\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. fma-def33.3%

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

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

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

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

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

      \[\leadsto \color{blue}{{a}^{4}} + -1 \]
    5. Step-by-step derivation
      1. sqr-pow100.0%

        \[\leadsto \color{blue}{{a}^{\left(\frac{4}{2}\right)} \cdot {a}^{\left(\frac{4}{2}\right)}} + -1 \]
      2. metadata-eval100.0%

        \[\leadsto {a}^{\color{blue}{2}} \cdot {a}^{\left(\frac{4}{2}\right)} + -1 \]
      3. pow2100.0%

        \[\leadsto \color{blue}{\left(a \cdot a\right)} \cdot {a}^{\left(\frac{4}{2}\right)} + -1 \]
      4. metadata-eval100.0%

        \[\leadsto \left(a \cdot a\right) \cdot {a}^{\color{blue}{2}} + -1 \]
      5. pow2100.0%

        \[\leadsto \left(a \cdot a\right) \cdot \color{blue}{\left(a \cdot a\right)} + -1 \]
    6. Applied egg-rr100.0%

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

    if 2.00000000000000003e141 < (*.f64 b b)

    1. Initial program 64.2%

      \[\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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg64.2%

        \[\leadsto \color{blue}{\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. fma-def64.2%

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

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

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

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

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

      \[\leadsto \color{blue}{{b}^{4}} + -1 \]
  3. Recombined 4 regimes into one program.
  4. Final simplification97.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \cdot b \leq 50000:\\ \;\;\;\;-1 + a \cdot \left(a \cdot \mathsf{fma}\left(a, a + -4, 4\right)\right)\\ \mathbf{elif}\;b \cdot b \leq 10^{+112}:\\ \;\;\;\;-1 + \left({b}^{4} + \left(b \cdot b\right) \cdot \left(12 + a \cdot 4\right)\right)\\ \mathbf{elif}\;b \cdot b \leq 2 \cdot 10^{+141}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + {b}^{4}\\ \end{array} \]

Alternative 4: 97.4% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -8 \cdot 10^{+25} \lor \neg \left(a \leq 8.7 \cdot 10^{-16}\right):\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(\mathsf{fma}\left(2, b \cdot b, 4\right) + a \cdot \left(a + -4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(\left(b \cdot b\right) \cdot 12 + {b}^{4}\right)\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (or (<= a -8e+25) (not (<= a 8.7e-16)))
   (+ -1.0 (* (* a a) (+ (fma 2.0 (* b b) 4.0) (* a (+ a -4.0)))))
   (+ -1.0 (+ (* (* b b) 12.0) (pow b 4.0)))))
double code(double a, double b) {
	double tmp;
	if ((a <= -8e+25) || !(a <= 8.7e-16)) {
		tmp = -1.0 + ((a * a) * (fma(2.0, (b * b), 4.0) + (a * (a + -4.0))));
	} else {
		tmp = -1.0 + (((b * b) * 12.0) + pow(b, 4.0));
	}
	return tmp;
}
function code(a, b)
	tmp = 0.0
	if ((a <= -8e+25) || !(a <= 8.7e-16))
		tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(fma(2.0, Float64(b * b), 4.0) + Float64(a * Float64(a + -4.0)))));
	else
		tmp = Float64(-1.0 + Float64(Float64(Float64(b * b) * 12.0) + (b ^ 4.0)));
	end
	return tmp
end
code[a_, b_] := If[Or[LessEqual[a, -8e+25], N[Not[LessEqual[a, 8.7e-16]], $MachinePrecision]], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(N[(2.0 * N[(b * b), $MachinePrecision] + 4.0), $MachinePrecision] + N[(a * N[(a + -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -8 \cdot 10^{+25} \lor \neg \left(a \leq 8.7 \cdot 10^{-16}\right):\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(\mathsf{fma}\left(2, b \cdot b, 4\right) + a \cdot \left(a + -4\right)\right)\\

\mathbf{else}:\\
\;\;\;\;-1 + \left(\left(b \cdot b\right) \cdot 12 + {b}^{4}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -8.00000000000000072e25 or 8.70000000000000036e-16 < a

    1. Initial program 52.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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg52.8%

        \[\leadsto \color{blue}{\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. fma-def52.8%

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

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

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

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

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

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

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

        \[\leadsto \left({\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + 4 \cdot \color{blue}{\left(\left(b \cdot b\right) \cdot \left(3 + a\right) + \left(a \cdot a\right) \cdot \left(1 - a\right)\right)}\right) + -1 \]
      4. associate-*l*52.8%

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

        \[\leadsto \left({\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + 4 \cdot \left(b \cdot \left(b \cdot \color{blue}{\left(a + 3\right)}\right) + \left(a \cdot a\right) \cdot \left(1 - a\right)\right)\right) + -1 \]
      6. associate-*l*52.8%

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

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

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

        \[\leadsto \color{blue}{\left(\left(\left(2 \cdot {b}^{2} + 4\right) \cdot {a}^{2} + {a}^{4}\right) + -4 \cdot {a}^{3}\right)} + -1 \]
      2. associate-+l+70.2%

        \[\leadsto \color{blue}{\left(\left(2 \cdot {b}^{2} + 4\right) \cdot {a}^{2} + \left({a}^{4} + -4 \cdot {a}^{3}\right)\right)} + -1 \]
      3. *-commutative70.2%

        \[\leadsto \left(\color{blue}{{a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right)} + \left({a}^{4} + -4 \cdot {a}^{3}\right)\right) + -1 \]
      4. metadata-eval70.2%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left({a}^{\color{blue}{\left(3 + 1\right)}} + -4 \cdot {a}^{3}\right)\right) + -1 \]
      5. pow-plus70.1%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left(\color{blue}{{a}^{3} \cdot a} + -4 \cdot {a}^{3}\right)\right) + -1 \]
      6. *-commutative70.1%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left({a}^{3} \cdot a + \color{blue}{{a}^{3} \cdot -4}\right)\right) + -1 \]
      7. distribute-lft-in99.2%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \color{blue}{{a}^{3} \cdot \left(a + -4\right)}\right) + -1 \]
      8. unpow399.2%

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

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left(\color{blue}{{a}^{2}} \cdot a\right) \cdot \left(a + -4\right)\right) + -1 \]
      10. associate-*l*99.2%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \color{blue}{{a}^{2} \cdot \left(a \cdot \left(a + -4\right)\right)}\right) + -1 \]
      11. distribute-lft-out99.2%

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

        \[\leadsto \color{blue}{\left(a \cdot a\right)} \cdot \left(\left(2 \cdot {b}^{2} + 4\right) + a \cdot \left(a + -4\right)\right) + -1 \]
      13. fma-def99.2%

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

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

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

    if -8.00000000000000072e25 < a < 8.70000000000000036e-16

    1. Initial program 99.1%

      \[\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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg99.1%

        \[\leadsto \color{blue}{\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. fma-def99.1%

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

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

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

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

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

      \[\leadsto \color{blue}{\left(12 \cdot {b}^{2} + \left(4 \cdot \left(a \cdot {b}^{2}\right) + {b}^{4}\right)\right)} + -1 \]
    5. Step-by-step derivation
      1. associate-+r+86.3%

        \[\leadsto \color{blue}{\left(\left(12 \cdot {b}^{2} + 4 \cdot \left(a \cdot {b}^{2}\right)\right) + {b}^{4}\right)} + -1 \]
      2. associate-*r*86.3%

        \[\leadsto \left(\left(12 \cdot {b}^{2} + \color{blue}{\left(4 \cdot a\right) \cdot {b}^{2}}\right) + {b}^{4}\right) + -1 \]
      3. distribute-rgt-out96.9%

        \[\leadsto \left(\color{blue}{{b}^{2} \cdot \left(12 + 4 \cdot a\right)} + {b}^{4}\right) + -1 \]
      4. metadata-eval96.9%

        \[\leadsto \left({b}^{2} \cdot \left(\color{blue}{4 \cdot 3} + 4 \cdot a\right) + {b}^{4}\right) + -1 \]
      5. distribute-lft-in96.9%

        \[\leadsto \left({b}^{2} \cdot \color{blue}{\left(4 \cdot \left(3 + a\right)\right)} + {b}^{4}\right) + -1 \]
      6. unpow296.9%

        \[\leadsto \left(\color{blue}{\left(b \cdot b\right)} \cdot \left(4 \cdot \left(3 + a\right)\right) + {b}^{4}\right) + -1 \]
      7. distribute-rgt-in96.9%

        \[\leadsto \left(\left(b \cdot b\right) \cdot \color{blue}{\left(3 \cdot 4 + a \cdot 4\right)} + {b}^{4}\right) + -1 \]
      8. metadata-eval96.9%

        \[\leadsto \left(\left(b \cdot b\right) \cdot \left(\color{blue}{12} + a \cdot 4\right) + {b}^{4}\right) + -1 \]
    6. Simplified96.9%

      \[\leadsto \color{blue}{\left(\left(b \cdot b\right) \cdot \left(12 + a \cdot 4\right) + {b}^{4}\right)} + -1 \]
    7. Taylor expanded in a around 0 97.7%

      \[\leadsto \left(\color{blue}{12 \cdot {b}^{2}} + {b}^{4}\right) + -1 \]
    8. Step-by-step derivation
      1. unpow297.7%

        \[\leadsto \left(12 \cdot \color{blue}{\left(b \cdot b\right)} + {b}^{4}\right) + -1 \]
    9. Simplified97.7%

      \[\leadsto \left(\color{blue}{12 \cdot \left(b \cdot b\right)} + {b}^{4}\right) + -1 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -8 \cdot 10^{+25} \lor \neg \left(a \leq 8.7 \cdot 10^{-16}\right):\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(\mathsf{fma}\left(2, b \cdot b, 4\right) + a \cdot \left(a + -4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(\left(b \cdot b\right) \cdot 12 + {b}^{4}\right)\\ \end{array} \]

Alternative 5: 92.8% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+141}:\\ \;\;\;\;-1 + a \cdot \left(a \cdot \mathsf{fma}\left(a, a + -4, 4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + {b}^{4}\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= (* b b) 2e+141)
   (+ -1.0 (* a (* a (fma a (+ a -4.0) 4.0))))
   (+ -1.0 (pow b 4.0))))
double code(double a, double b) {
	double tmp;
	if ((b * b) <= 2e+141) {
		tmp = -1.0 + (a * (a * fma(a, (a + -4.0), 4.0)));
	} else {
		tmp = -1.0 + pow(b, 4.0);
	}
	return tmp;
}
function code(a, b)
	tmp = 0.0
	if (Float64(b * b) <= 2e+141)
		tmp = Float64(-1.0 + Float64(a * Float64(a * fma(a, Float64(a + -4.0), 4.0))));
	else
		tmp = Float64(-1.0 + (b ^ 4.0));
	end
	return tmp
end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e+141], N[(-1.0 + N[(a * N[(a * N[(a * N[(a + -4.0), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;-1 + {b}^{4}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 b b) < 2.00000000000000003e141

    1. Initial program 81.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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg81.4%

        \[\leadsto \color{blue}{\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. fma-def81.5%

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

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

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

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

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

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

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

        \[\leadsto \left({\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + 4 \cdot \color{blue}{\left(\left(b \cdot b\right) \cdot \left(3 + a\right) + \left(a \cdot a\right) \cdot \left(1 - a\right)\right)}\right) + -1 \]
      4. associate-*l*81.5%

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

        \[\leadsto \left({\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + 4 \cdot \left(b \cdot \left(b \cdot \color{blue}{\left(a + 3\right)}\right) + \left(a \cdot a\right) \cdot \left(1 - a\right)\right)\right) + -1 \]
      6. associate-*l*81.5%

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

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

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

        \[\leadsto \color{blue}{\left(\left(\left(2 \cdot {b}^{2} + 4\right) \cdot {a}^{2} + {a}^{4}\right) + -4 \cdot {a}^{3}\right)} + -1 \]
      2. associate-+l+75.8%

        \[\leadsto \color{blue}{\left(\left(2 \cdot {b}^{2} + 4\right) \cdot {a}^{2} + \left({a}^{4} + -4 \cdot {a}^{3}\right)\right)} + -1 \]
      3. *-commutative75.8%

        \[\leadsto \left(\color{blue}{{a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right)} + \left({a}^{4} + -4 \cdot {a}^{3}\right)\right) + -1 \]
      4. metadata-eval75.8%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left({a}^{\color{blue}{\left(3 + 1\right)}} + -4 \cdot {a}^{3}\right)\right) + -1 \]
      5. pow-plus75.7%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left(\color{blue}{{a}^{3} \cdot a} + -4 \cdot {a}^{3}\right)\right) + -1 \]
      6. *-commutative75.7%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left({a}^{3} \cdot a + \color{blue}{{a}^{3} \cdot -4}\right)\right) + -1 \]
      7. distribute-lft-in92.8%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \color{blue}{{a}^{3} \cdot \left(a + -4\right)}\right) + -1 \]
      8. unpow392.8%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \color{blue}{\left(\left(a \cdot a\right) \cdot a\right)} \cdot \left(a + -4\right)\right) + -1 \]
      9. unpow292.8%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left(\color{blue}{{a}^{2}} \cdot a\right) \cdot \left(a + -4\right)\right) + -1 \]
      10. associate-*l*92.7%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \color{blue}{{a}^{2} \cdot \left(a \cdot \left(a + -4\right)\right)}\right) + -1 \]
      11. distribute-lft-out92.7%

        \[\leadsto \color{blue}{{a}^{2} \cdot \left(\left(2 \cdot {b}^{2} + 4\right) + a \cdot \left(a + -4\right)\right)} + -1 \]
      12. unpow292.7%

        \[\leadsto \color{blue}{\left(a \cdot a\right)} \cdot \left(\left(2 \cdot {b}^{2} + 4\right) + a \cdot \left(a + -4\right)\right) + -1 \]
      13. fma-def92.7%

        \[\leadsto \left(a \cdot a\right) \cdot \left(\color{blue}{\mathsf{fma}\left(2, {b}^{2}, 4\right)} + a \cdot \left(a + -4\right)\right) + -1 \]
      14. unpow292.7%

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

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

      \[\leadsto \color{blue}{\left(4 + a \cdot \left(a - 4\right)\right) \cdot {a}^{2}} + -1 \]
    10. Step-by-step derivation
      1. unpow292.7%

        \[\leadsto \left(4 + a \cdot \left(a - 4\right)\right) \cdot \color{blue}{\left(a \cdot a\right)} + -1 \]
      2. *-commutative92.7%

        \[\leadsto \color{blue}{\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a - 4\right)\right)} + -1 \]
      3. associate-*l*92.7%

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

        \[\leadsto a \cdot \left(a \cdot \color{blue}{\left(a \cdot \left(a - 4\right) + 4\right)}\right) + -1 \]
      5. sub-neg92.7%

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

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

        \[\leadsto a \cdot \left(a \cdot \color{blue}{\mathsf{fma}\left(a, a + -4, 4\right)}\right) + -1 \]
    11. Simplified92.7%

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

    if 2.00000000000000003e141 < (*.f64 b b)

    1. Initial program 64.2%

      \[\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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg64.2%

        \[\leadsto \color{blue}{\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. fma-def64.2%

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

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

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

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

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

      \[\leadsto \color{blue}{{b}^{4}} + -1 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification95.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+141}:\\ \;\;\;\;-1 + a \cdot \left(a \cdot \mathsf{fma}\left(a, a + -4, 4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + {b}^{4}\\ \end{array} \]

Alternative 6: 92.8% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+141}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + -4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + {b}^{4}\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= (* b b) 2e+141)
   (+ -1.0 (* (* a a) (+ 4.0 (* a (+ a -4.0)))))
   (+ -1.0 (pow b 4.0))))
double code(double a, double b) {
	double tmp;
	if ((b * b) <= 2e+141) {
		tmp = -1.0 + ((a * a) * (4.0 + (a * (a + -4.0))));
	} else {
		tmp = -1.0 + pow(b, 4.0);
	}
	return tmp;
}
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: tmp
    if ((b * b) <= 2d+141) then
        tmp = (-1.0d0) + ((a * a) * (4.0d0 + (a * (a + (-4.0d0)))))
    else
        tmp = (-1.0d0) + (b ** 4.0d0)
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double tmp;
	if ((b * b) <= 2e+141) {
		tmp = -1.0 + ((a * a) * (4.0 + (a * (a + -4.0))));
	} else {
		tmp = -1.0 + Math.pow(b, 4.0);
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if (b * b) <= 2e+141:
		tmp = -1.0 + ((a * a) * (4.0 + (a * (a + -4.0))))
	else:
		tmp = -1.0 + math.pow(b, 4.0)
	return tmp
function code(a, b)
	tmp = 0.0
	if (Float64(b * b) <= 2e+141)
		tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(4.0 + Float64(a * Float64(a + -4.0)))));
	else
		tmp = Float64(-1.0 + (b ^ 4.0));
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if ((b * b) <= 2e+141)
		tmp = -1.0 + ((a * a) * (4.0 + (a * (a + -4.0))));
	else
		tmp = -1.0 + (b ^ 4.0);
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e+141], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * N[(a + -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+141}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + -4\right)\right)\\

\mathbf{else}:\\
\;\;\;\;-1 + {b}^{4}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 b b) < 2.00000000000000003e141

    1. Initial program 81.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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg81.4%

        \[\leadsto \color{blue}{\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. fma-def81.5%

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

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

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

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

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

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

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

        \[\leadsto \left({\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + 4 \cdot \color{blue}{\left(\left(b \cdot b\right) \cdot \left(3 + a\right) + \left(a \cdot a\right) \cdot \left(1 - a\right)\right)}\right) + -1 \]
      4. associate-*l*81.5%

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

        \[\leadsto \left({\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + 4 \cdot \left(b \cdot \left(b \cdot \color{blue}{\left(a + 3\right)}\right) + \left(a \cdot a\right) \cdot \left(1 - a\right)\right)\right) + -1 \]
      6. associate-*l*81.5%

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

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

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

        \[\leadsto \color{blue}{\left(\left(\left(2 \cdot {b}^{2} + 4\right) \cdot {a}^{2} + {a}^{4}\right) + -4 \cdot {a}^{3}\right)} + -1 \]
      2. associate-+l+75.8%

        \[\leadsto \color{blue}{\left(\left(2 \cdot {b}^{2} + 4\right) \cdot {a}^{2} + \left({a}^{4} + -4 \cdot {a}^{3}\right)\right)} + -1 \]
      3. *-commutative75.8%

        \[\leadsto \left(\color{blue}{{a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right)} + \left({a}^{4} + -4 \cdot {a}^{3}\right)\right) + -1 \]
      4. metadata-eval75.8%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left({a}^{\color{blue}{\left(3 + 1\right)}} + -4 \cdot {a}^{3}\right)\right) + -1 \]
      5. pow-plus75.7%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left(\color{blue}{{a}^{3} \cdot a} + -4 \cdot {a}^{3}\right)\right) + -1 \]
      6. *-commutative75.7%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left({a}^{3} \cdot a + \color{blue}{{a}^{3} \cdot -4}\right)\right) + -1 \]
      7. distribute-lft-in92.8%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \color{blue}{{a}^{3} \cdot \left(a + -4\right)}\right) + -1 \]
      8. unpow392.8%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \color{blue}{\left(\left(a \cdot a\right) \cdot a\right)} \cdot \left(a + -4\right)\right) + -1 \]
      9. unpow292.8%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left(\color{blue}{{a}^{2}} \cdot a\right) \cdot \left(a + -4\right)\right) + -1 \]
      10. associate-*l*92.7%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \color{blue}{{a}^{2} \cdot \left(a \cdot \left(a + -4\right)\right)}\right) + -1 \]
      11. distribute-lft-out92.7%

        \[\leadsto \color{blue}{{a}^{2} \cdot \left(\left(2 \cdot {b}^{2} + 4\right) + a \cdot \left(a + -4\right)\right)} + -1 \]
      12. unpow292.7%

        \[\leadsto \color{blue}{\left(a \cdot a\right)} \cdot \left(\left(2 \cdot {b}^{2} + 4\right) + a \cdot \left(a + -4\right)\right) + -1 \]
      13. fma-def92.7%

        \[\leadsto \left(a \cdot a\right) \cdot \left(\color{blue}{\mathsf{fma}\left(2, {b}^{2}, 4\right)} + a \cdot \left(a + -4\right)\right) + -1 \]
      14. unpow292.7%

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

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

      \[\leadsto \color{blue}{\left(4 + a \cdot \left(a - 4\right)\right) \cdot {a}^{2}} + -1 \]
    10. Step-by-step derivation
      1. sub-neg92.7%

        \[\leadsto \left(4 + a \cdot \color{blue}{\left(a + \left(-4\right)\right)}\right) \cdot {a}^{2} + -1 \]
      2. metadata-eval92.7%

        \[\leadsto \left(4 + a \cdot \left(a + \color{blue}{-4}\right)\right) \cdot {a}^{2} + -1 \]
      3. unpow292.7%

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

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

    if 2.00000000000000003e141 < (*.f64 b b)

    1. Initial program 64.2%

      \[\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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg64.2%

        \[\leadsto \color{blue}{\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. fma-def64.2%

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

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

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

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

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

      \[\leadsto \color{blue}{{b}^{4}} + -1 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification95.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+141}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + -4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + {b}^{4}\\ \end{array} \]

Alternative 7: 84.6% accurate, 7.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \cdot b \leq 10^{+303}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + -4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + b \cdot \left(b \cdot 12\right)\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= (* b b) 1e+303)
   (+ -1.0 (* (* a a) (+ 4.0 (* a (+ a -4.0)))))
   (+ -1.0 (* b (* b 12.0)))))
double code(double a, double b) {
	double tmp;
	if ((b * b) <= 1e+303) {
		tmp = -1.0 + ((a * a) * (4.0 + (a * (a + -4.0))));
	} else {
		tmp = -1.0 + (b * (b * 12.0));
	}
	return tmp;
}
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: tmp
    if ((b * b) <= 1d+303) then
        tmp = (-1.0d0) + ((a * a) * (4.0d0 + (a * (a + (-4.0d0)))))
    else
        tmp = (-1.0d0) + (b * (b * 12.0d0))
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double tmp;
	if ((b * b) <= 1e+303) {
		tmp = -1.0 + ((a * a) * (4.0 + (a * (a + -4.0))));
	} else {
		tmp = -1.0 + (b * (b * 12.0));
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if (b * b) <= 1e+303:
		tmp = -1.0 + ((a * a) * (4.0 + (a * (a + -4.0))))
	else:
		tmp = -1.0 + (b * (b * 12.0))
	return tmp
function code(a, b)
	tmp = 0.0
	if (Float64(b * b) <= 1e+303)
		tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(4.0 + Float64(a * Float64(a + -4.0)))));
	else
		tmp = Float64(-1.0 + Float64(b * Float64(b * 12.0)));
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if ((b * b) <= 1e+303)
		tmp = -1.0 + ((a * a) * (4.0 + (a * (a + -4.0))));
	else
		tmp = -1.0 + (b * (b * 12.0));
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e+303], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * N[(a + -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(b * N[(b * 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10^{+303}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + -4\right)\right)\\

\mathbf{else}:\\
\;\;\;\;-1 + b \cdot \left(b \cdot 12\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 b b) < 1e303

    1. Initial program 77.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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg77.9%

        \[\leadsto \color{blue}{\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. fma-def77.9%

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

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

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

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

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

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

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

        \[\leadsto \left({\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + 4 \cdot \color{blue}{\left(\left(b \cdot b\right) \cdot \left(3 + a\right) + \left(a \cdot a\right) \cdot \left(1 - a\right)\right)}\right) + -1 \]
      4. associate-*l*77.9%

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

        \[\leadsto \left({\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + 4 \cdot \left(b \cdot \left(b \cdot \color{blue}{\left(a + 3\right)}\right) + \left(a \cdot a\right) \cdot \left(1 - a\right)\right)\right) + -1 \]
      6. associate-*l*77.9%

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

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

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

        \[\leadsto \color{blue}{\left(\left(\left(2 \cdot {b}^{2} + 4\right) \cdot {a}^{2} + {a}^{4}\right) + -4 \cdot {a}^{3}\right)} + -1 \]
      2. associate-+l+65.4%

        \[\leadsto \color{blue}{\left(\left(2 \cdot {b}^{2} + 4\right) \cdot {a}^{2} + \left({a}^{4} + -4 \cdot {a}^{3}\right)\right)} + -1 \]
      3. *-commutative65.4%

        \[\leadsto \left(\color{blue}{{a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right)} + \left({a}^{4} + -4 \cdot {a}^{3}\right)\right) + -1 \]
      4. metadata-eval65.4%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left({a}^{\color{blue}{\left(3 + 1\right)}} + -4 \cdot {a}^{3}\right)\right) + -1 \]
      5. pow-plus65.4%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left(\color{blue}{{a}^{3} \cdot a} + -4 \cdot {a}^{3}\right)\right) + -1 \]
      6. *-commutative65.4%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left({a}^{3} \cdot a + \color{blue}{{a}^{3} \cdot -4}\right)\right) + -1 \]
      7. distribute-lft-in81.3%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \color{blue}{{a}^{3} \cdot \left(a + -4\right)}\right) + -1 \]
      8. unpow381.3%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \color{blue}{\left(\left(a \cdot a\right) \cdot a\right)} \cdot \left(a + -4\right)\right) + -1 \]
      9. unpow281.3%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \left(\color{blue}{{a}^{2}} \cdot a\right) \cdot \left(a + -4\right)\right) + -1 \]
      10. associate-*l*81.2%

        \[\leadsto \left({a}^{2} \cdot \left(2 \cdot {b}^{2} + 4\right) + \color{blue}{{a}^{2} \cdot \left(a \cdot \left(a + -4\right)\right)}\right) + -1 \]
      11. distribute-lft-out81.2%

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

        \[\leadsto \color{blue}{\left(a \cdot a\right)} \cdot \left(\left(2 \cdot {b}^{2} + 4\right) + a \cdot \left(a + -4\right)\right) + -1 \]
      13. fma-def81.2%

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

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

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

      \[\leadsto \color{blue}{\left(4 + a \cdot \left(a - 4\right)\right) \cdot {a}^{2}} + -1 \]
    10. Step-by-step derivation
      1. sub-neg80.4%

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

        \[\leadsto \left(4 + a \cdot \left(a + \color{blue}{-4}\right)\right) \cdot {a}^{2} + -1 \]
      3. unpow280.4%

        \[\leadsto \left(4 + a \cdot \left(a + -4\right)\right) \cdot \color{blue}{\left(a \cdot a\right)} + -1 \]
    11. Simplified80.4%

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

    if 1e303 < (*.f64 b b)

    1. Initial program 63.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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg63.6%

        \[\leadsto \color{blue}{\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. fma-def63.6%

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

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

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

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

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

      \[\leadsto \color{blue}{\left(12 \cdot {b}^{2} + \left(4 \cdot \left(a \cdot {b}^{2}\right) + {b}^{4}\right)\right)} + -1 \]
    5. Step-by-step derivation
      1. associate-+r+52.7%

        \[\leadsto \color{blue}{\left(\left(12 \cdot {b}^{2} + 4 \cdot \left(a \cdot {b}^{2}\right)\right) + {b}^{4}\right)} + -1 \]
      2. associate-*r*52.7%

        \[\leadsto \left(\left(12 \cdot {b}^{2} + \color{blue}{\left(4 \cdot a\right) \cdot {b}^{2}}\right) + {b}^{4}\right) + -1 \]
      3. distribute-rgt-out76.4%

        \[\leadsto \left(\color{blue}{{b}^{2} \cdot \left(12 + 4 \cdot a\right)} + {b}^{4}\right) + -1 \]
      4. metadata-eval76.4%

        \[\leadsto \left({b}^{2} \cdot \left(\color{blue}{4 \cdot 3} + 4 \cdot a\right) + {b}^{4}\right) + -1 \]
      5. distribute-lft-in76.4%

        \[\leadsto \left({b}^{2} \cdot \color{blue}{\left(4 \cdot \left(3 + a\right)\right)} + {b}^{4}\right) + -1 \]
      6. unpow276.4%

        \[\leadsto \left(\color{blue}{\left(b \cdot b\right)} \cdot \left(4 \cdot \left(3 + a\right)\right) + {b}^{4}\right) + -1 \]
      7. distribute-rgt-in76.4%

        \[\leadsto \left(\left(b \cdot b\right) \cdot \color{blue}{\left(3 \cdot 4 + a \cdot 4\right)} + {b}^{4}\right) + -1 \]
      8. metadata-eval76.4%

        \[\leadsto \left(\left(b \cdot b\right) \cdot \left(\color{blue}{12} + a \cdot 4\right) + {b}^{4}\right) + -1 \]
    6. Simplified76.4%

      \[\leadsto \color{blue}{\left(\left(b \cdot b\right) \cdot \left(12 + a \cdot 4\right) + {b}^{4}\right)} + -1 \]
    7. Taylor expanded in b around 0 76.4%

      \[\leadsto \color{blue}{\left(12 + 4 \cdot a\right) \cdot {b}^{2}} + -1 \]
    8. Step-by-step derivation
      1. *-commutative76.4%

        \[\leadsto \left(12 + \color{blue}{a \cdot 4}\right) \cdot {b}^{2} + -1 \]
      2. *-commutative76.4%

        \[\leadsto \color{blue}{{b}^{2} \cdot \left(12 + a \cdot 4\right)} + -1 \]
      3. unpow276.4%

        \[\leadsto \color{blue}{\left(b \cdot b\right)} \cdot \left(12 + a \cdot 4\right) + -1 \]
      4. associate-*l*76.4%

        \[\leadsto \color{blue}{b \cdot \left(b \cdot \left(12 + a \cdot 4\right)\right)} + -1 \]
      5. *-commutative76.4%

        \[\leadsto b \cdot \left(b \cdot \left(12 + \color{blue}{4 \cdot a}\right)\right) + -1 \]
      6. +-commutative76.4%

        \[\leadsto b \cdot \left(b \cdot \color{blue}{\left(4 \cdot a + 12\right)}\right) + -1 \]
      7. fma-def76.4%

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

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

      \[\leadsto \color{blue}{12 \cdot {b}^{2}} + -1 \]
    11. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \color{blue}{{b}^{2} \cdot 12} + -1 \]
      2. unpow2100.0%

        \[\leadsto \color{blue}{\left(b \cdot b\right)} \cdot 12 + -1 \]
      3. associate-*l*100.0%

        \[\leadsto \color{blue}{b \cdot \left(b \cdot 12\right)} + -1 \]
    12. Simplified100.0%

      \[\leadsto \color{blue}{b \cdot \left(b \cdot 12\right)} + -1 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification84.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \cdot b \leq 10^{+303}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + -4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + b \cdot \left(b \cdot 12\right)\\ \end{array} \]

Alternative 8: 83.8% accurate, 9.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \cdot b \leq 10^{+303}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + b \cdot \left(b \cdot 12\right)\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= (* b b) 1e+303)
   (+ -1.0 (* (* a a) (* a a)))
   (+ -1.0 (* b (* b 12.0)))))
double code(double a, double b) {
	double tmp;
	if ((b * b) <= 1e+303) {
		tmp = -1.0 + ((a * a) * (a * a));
	} else {
		tmp = -1.0 + (b * (b * 12.0));
	}
	return tmp;
}
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: tmp
    if ((b * b) <= 1d+303) then
        tmp = (-1.0d0) + ((a * a) * (a * a))
    else
        tmp = (-1.0d0) + (b * (b * 12.0d0))
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double tmp;
	if ((b * b) <= 1e+303) {
		tmp = -1.0 + ((a * a) * (a * a));
	} else {
		tmp = -1.0 + (b * (b * 12.0));
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if (b * b) <= 1e+303:
		tmp = -1.0 + ((a * a) * (a * a))
	else:
		tmp = -1.0 + (b * (b * 12.0))
	return tmp
function code(a, b)
	tmp = 0.0
	if (Float64(b * b) <= 1e+303)
		tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(a * a)));
	else
		tmp = Float64(-1.0 + Float64(b * Float64(b * 12.0)));
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if ((b * b) <= 1e+303)
		tmp = -1.0 + ((a * a) * (a * a));
	else
		tmp = -1.0 + (b * (b * 12.0));
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e+303], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(b * N[(b * 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10^{+303}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot a\right)\\

\mathbf{else}:\\
\;\;\;\;-1 + b \cdot \left(b \cdot 12\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 b b) < 1e303

    1. Initial program 77.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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg77.9%

        \[\leadsto \color{blue}{\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. fma-def77.9%

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

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

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

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

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

      \[\leadsto \color{blue}{{a}^{4}} + -1 \]
    5. Step-by-step derivation
      1. sqr-pow78.1%

        \[\leadsto \color{blue}{{a}^{\left(\frac{4}{2}\right)} \cdot {a}^{\left(\frac{4}{2}\right)}} + -1 \]
      2. metadata-eval78.1%

        \[\leadsto {a}^{\color{blue}{2}} \cdot {a}^{\left(\frac{4}{2}\right)} + -1 \]
      3. pow278.1%

        \[\leadsto \color{blue}{\left(a \cdot a\right)} \cdot {a}^{\left(\frac{4}{2}\right)} + -1 \]
      4. metadata-eval78.1%

        \[\leadsto \left(a \cdot a\right) \cdot {a}^{\color{blue}{2}} + -1 \]
      5. pow278.1%

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

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

    if 1e303 < (*.f64 b b)

    1. Initial program 63.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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg63.6%

        \[\leadsto \color{blue}{\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. fma-def63.6%

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

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

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

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

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

      \[\leadsto \color{blue}{\left(12 \cdot {b}^{2} + \left(4 \cdot \left(a \cdot {b}^{2}\right) + {b}^{4}\right)\right)} + -1 \]
    5. Step-by-step derivation
      1. associate-+r+52.7%

        \[\leadsto \color{blue}{\left(\left(12 \cdot {b}^{2} + 4 \cdot \left(a \cdot {b}^{2}\right)\right) + {b}^{4}\right)} + -1 \]
      2. associate-*r*52.7%

        \[\leadsto \left(\left(12 \cdot {b}^{2} + \color{blue}{\left(4 \cdot a\right) \cdot {b}^{2}}\right) + {b}^{4}\right) + -1 \]
      3. distribute-rgt-out76.4%

        \[\leadsto \left(\color{blue}{{b}^{2} \cdot \left(12 + 4 \cdot a\right)} + {b}^{4}\right) + -1 \]
      4. metadata-eval76.4%

        \[\leadsto \left({b}^{2} \cdot \left(\color{blue}{4 \cdot 3} + 4 \cdot a\right) + {b}^{4}\right) + -1 \]
      5. distribute-lft-in76.4%

        \[\leadsto \left({b}^{2} \cdot \color{blue}{\left(4 \cdot \left(3 + a\right)\right)} + {b}^{4}\right) + -1 \]
      6. unpow276.4%

        \[\leadsto \left(\color{blue}{\left(b \cdot b\right)} \cdot \left(4 \cdot \left(3 + a\right)\right) + {b}^{4}\right) + -1 \]
      7. distribute-rgt-in76.4%

        \[\leadsto \left(\left(b \cdot b\right) \cdot \color{blue}{\left(3 \cdot 4 + a \cdot 4\right)} + {b}^{4}\right) + -1 \]
      8. metadata-eval76.4%

        \[\leadsto \left(\left(b \cdot b\right) \cdot \left(\color{blue}{12} + a \cdot 4\right) + {b}^{4}\right) + -1 \]
    6. Simplified76.4%

      \[\leadsto \color{blue}{\left(\left(b \cdot b\right) \cdot \left(12 + a \cdot 4\right) + {b}^{4}\right)} + -1 \]
    7. Taylor expanded in b around 0 76.4%

      \[\leadsto \color{blue}{\left(12 + 4 \cdot a\right) \cdot {b}^{2}} + -1 \]
    8. Step-by-step derivation
      1. *-commutative76.4%

        \[\leadsto \left(12 + \color{blue}{a \cdot 4}\right) \cdot {b}^{2} + -1 \]
      2. *-commutative76.4%

        \[\leadsto \color{blue}{{b}^{2} \cdot \left(12 + a \cdot 4\right)} + -1 \]
      3. unpow276.4%

        \[\leadsto \color{blue}{\left(b \cdot b\right)} \cdot \left(12 + a \cdot 4\right) + -1 \]
      4. associate-*l*76.4%

        \[\leadsto \color{blue}{b \cdot \left(b \cdot \left(12 + a \cdot 4\right)\right)} + -1 \]
      5. *-commutative76.4%

        \[\leadsto b \cdot \left(b \cdot \left(12 + \color{blue}{4 \cdot a}\right)\right) + -1 \]
      6. +-commutative76.4%

        \[\leadsto b \cdot \left(b \cdot \color{blue}{\left(4 \cdot a + 12\right)}\right) + -1 \]
      7. fma-def76.4%

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

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

      \[\leadsto \color{blue}{12 \cdot {b}^{2}} + -1 \]
    11. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \color{blue}{{b}^{2} \cdot 12} + -1 \]
      2. unpow2100.0%

        \[\leadsto \color{blue}{\left(b \cdot b\right)} \cdot 12 + -1 \]
      3. associate-*l*100.0%

        \[\leadsto \color{blue}{b \cdot \left(b \cdot 12\right)} + -1 \]
    12. Simplified100.0%

      \[\leadsto \color{blue}{b \cdot \left(b \cdot 12\right)} + -1 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification82.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \cdot b \leq 10^{+303}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + b \cdot \left(b \cdot 12\right)\\ \end{array} \]

Alternative 9: 69.1% accurate, 11.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \cdot b \leq 10^{+303}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\ \mathbf{else}:\\ \;\;\;\;-1 + b \cdot \left(b \cdot 12\right)\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= (* b b) 1e+303) (+ -1.0 (* (* a a) 4.0)) (+ -1.0 (* b (* b 12.0)))))
double code(double a, double b) {
	double tmp;
	if ((b * b) <= 1e+303) {
		tmp = -1.0 + ((a * a) * 4.0);
	} else {
		tmp = -1.0 + (b * (b * 12.0));
	}
	return tmp;
}
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: tmp
    if ((b * b) <= 1d+303) then
        tmp = (-1.0d0) + ((a * a) * 4.0d0)
    else
        tmp = (-1.0d0) + (b * (b * 12.0d0))
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double tmp;
	if ((b * b) <= 1e+303) {
		tmp = -1.0 + ((a * a) * 4.0);
	} else {
		tmp = -1.0 + (b * (b * 12.0));
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if (b * b) <= 1e+303:
		tmp = -1.0 + ((a * a) * 4.0)
	else:
		tmp = -1.0 + (b * (b * 12.0))
	return tmp
function code(a, b)
	tmp = 0.0
	if (Float64(b * b) <= 1e+303)
		tmp = Float64(-1.0 + Float64(Float64(a * a) * 4.0));
	else
		tmp = Float64(-1.0 + Float64(b * Float64(b * 12.0)));
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if ((b * b) <= 1e+303)
		tmp = -1.0 + ((a * a) * 4.0);
	else
		tmp = -1.0 + (b * (b * 12.0));
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e+303], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(b * N[(b * 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10^{+303}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\

\mathbf{else}:\\
\;\;\;\;-1 + b \cdot \left(b \cdot 12\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 b b) < 1e303

    1. Initial program 77.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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg77.9%

        \[\leadsto \color{blue}{\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. fma-def77.9%

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

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

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

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

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

      \[\leadsto \color{blue}{\left({a}^{4} + 4 \cdot \left({a}^{2} \cdot \left(1 - a\right)\right)\right)} + -1 \]
    5. Step-by-step derivation
      1. +-commutative64.6%

        \[\leadsto \color{blue}{\left(4 \cdot \left({a}^{2} \cdot \left(1 - a\right)\right) + {a}^{4}\right)} + -1 \]
      2. associate-*r*64.6%

        \[\leadsto \left(\color{blue}{\left(4 \cdot {a}^{2}\right) \cdot \left(1 - a\right)} + {a}^{4}\right) + -1 \]
      3. fma-def68.6%

        \[\leadsto \color{blue}{\mathsf{fma}\left(4 \cdot {a}^{2}, 1 - a, {a}^{4}\right)} + -1 \]
      4. unpow268.6%

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

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

      \[\leadsto \color{blue}{4 \cdot {a}^{2}} + -1 \]
    8. Step-by-step derivation
      1. unpow257.4%

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

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

    if 1e303 < (*.f64 b b)

    1. Initial program 63.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(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg63.6%

        \[\leadsto \color{blue}{\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(3 + a\right)\right)\right) + \left(-1\right)} \]
      2. fma-def63.6%

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

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

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

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

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

      \[\leadsto \color{blue}{\left(12 \cdot {b}^{2} + \left(4 \cdot \left(a \cdot {b}^{2}\right) + {b}^{4}\right)\right)} + -1 \]
    5. Step-by-step derivation
      1. associate-+r+52.7%

        \[\leadsto \color{blue}{\left(\left(12 \cdot {b}^{2} + 4 \cdot \left(a \cdot {b}^{2}\right)\right) + {b}^{4}\right)} + -1 \]
      2. associate-*r*52.7%

        \[\leadsto \left(\left(12 \cdot {b}^{2} + \color{blue}{\left(4 \cdot a\right) \cdot {b}^{2}}\right) + {b}^{4}\right) + -1 \]
      3. distribute-rgt-out76.4%

        \[\leadsto \left(\color{blue}{{b}^{2} \cdot \left(12 + 4 \cdot a\right)} + {b}^{4}\right) + -1 \]
      4. metadata-eval76.4%

        \[\leadsto \left({b}^{2} \cdot \left(\color{blue}{4 \cdot 3} + 4 \cdot a\right) + {b}^{4}\right) + -1 \]
      5. distribute-lft-in76.4%

        \[\leadsto \left({b}^{2} \cdot \color{blue}{\left(4 \cdot \left(3 + a\right)\right)} + {b}^{4}\right) + -1 \]
      6. unpow276.4%

        \[\leadsto \left(\color{blue}{\left(b \cdot b\right)} \cdot \left(4 \cdot \left(3 + a\right)\right) + {b}^{4}\right) + -1 \]
      7. distribute-rgt-in76.4%

        \[\leadsto \left(\left(b \cdot b\right) \cdot \color{blue}{\left(3 \cdot 4 + a \cdot 4\right)} + {b}^{4}\right) + -1 \]
      8. metadata-eval76.4%

        \[\leadsto \left(\left(b \cdot b\right) \cdot \left(\color{blue}{12} + a \cdot 4\right) + {b}^{4}\right) + -1 \]
    6. Simplified76.4%

      \[\leadsto \color{blue}{\left(\left(b \cdot b\right) \cdot \left(12 + a \cdot 4\right) + {b}^{4}\right)} + -1 \]
    7. Taylor expanded in b around 0 76.4%

      \[\leadsto \color{blue}{\left(12 + 4 \cdot a\right) \cdot {b}^{2}} + -1 \]
    8. Step-by-step derivation
      1. *-commutative76.4%

        \[\leadsto \left(12 + \color{blue}{a \cdot 4}\right) \cdot {b}^{2} + -1 \]
      2. *-commutative76.4%

        \[\leadsto \color{blue}{{b}^{2} \cdot \left(12 + a \cdot 4\right)} + -1 \]
      3. unpow276.4%

        \[\leadsto \color{blue}{\left(b \cdot b\right)} \cdot \left(12 + a \cdot 4\right) + -1 \]
      4. associate-*l*76.4%

        \[\leadsto \color{blue}{b \cdot \left(b \cdot \left(12 + a \cdot 4\right)\right)} + -1 \]
      5. *-commutative76.4%

        \[\leadsto b \cdot \left(b \cdot \left(12 + \color{blue}{4 \cdot a}\right)\right) + -1 \]
      6. +-commutative76.4%

        \[\leadsto b \cdot \left(b \cdot \color{blue}{\left(4 \cdot a + 12\right)}\right) + -1 \]
      7. fma-def76.4%

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

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

      \[\leadsto \color{blue}{12 \cdot {b}^{2}} + -1 \]
    11. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \color{blue}{{b}^{2} \cdot 12} + -1 \]
      2. unpow2100.0%

        \[\leadsto \color{blue}{\left(b \cdot b\right)} \cdot 12 + -1 \]
      3. associate-*l*100.0%

        \[\leadsto \color{blue}{b \cdot \left(b \cdot 12\right)} + -1 \]
    12. Simplified100.0%

      \[\leadsto \color{blue}{b \cdot \left(b \cdot 12\right)} + -1 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification66.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \cdot b \leq 10^{+303}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\ \mathbf{else}:\\ \;\;\;\;-1 + b \cdot \left(b \cdot 12\right)\\ \end{array} \]

Alternative 10: 51.1% accurate, 18.3× speedup?

\[\begin{array}{l} \\ -1 + \left(a \cdot a\right) \cdot 4 \end{array} \]
(FPCore (a b) :precision binary64 (+ -1.0 (* (* a a) 4.0)))
double code(double a, double b) {
	return -1.0 + ((a * a) * 4.0);
}
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = (-1.0d0) + ((a * a) * 4.0d0)
end function
public static double code(double a, double b) {
	return -1.0 + ((a * a) * 4.0);
}
def code(a, b):
	return -1.0 + ((a * a) * 4.0)
function code(a, b)
	return Float64(-1.0 + Float64(Float64(a * a) * 4.0))
end
function tmp = code(a, b)
	tmp = -1.0 + ((a * a) * 4.0);
end
code[a_, b_] := N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
-1 + \left(a \cdot a\right) \cdot 4
\end{array}
Derivation
  1. Initial program 74.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(3 + a\right)\right)\right) - 1 \]
  2. Step-by-step derivation
    1. sub-neg74.9%

      \[\leadsto \color{blue}{\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(3 + a\right)\right)\right) + \left(-1\right)} \]
    2. fma-def74.9%

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

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

      \[\leadsto \left({\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + 4 \cdot \mathsf{fma}\left(a \cdot a, 1 - a, \left(b \cdot b\right) \cdot \color{blue}{\left(a + 3\right)}\right)\right) + \left(-1\right) \]
    5. metadata-eval75.6%

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

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

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

      \[\leadsto \color{blue}{\left(4 \cdot \left({a}^{2} \cdot \left(1 - a\right)\right) + {a}^{4}\right)} + -1 \]
    2. associate-*r*55.3%

      \[\leadsto \left(\color{blue}{\left(4 \cdot {a}^{2}\right) \cdot \left(1 - a\right)} + {a}^{4}\right) + -1 \]
    3. fma-def58.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(4 \cdot {a}^{2}, 1 - a, {a}^{4}\right)} + -1 \]
    4. unpow258.8%

      \[\leadsto \mathsf{fma}\left(4 \cdot \color{blue}{\left(a \cdot a\right)}, 1 - a, {a}^{4}\right) + -1 \]
  6. Simplified58.8%

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

    \[\leadsto \color{blue}{4 \cdot {a}^{2}} + -1 \]
  8. Step-by-step derivation
    1. unpow250.1%

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

    \[\leadsto \color{blue}{4 \cdot \left(a \cdot a\right)} + -1 \]
  10. Final simplification50.1%

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

Alternative 11: 24.7% accurate, 128.0× speedup?

\[\begin{array}{l} \\ -1 \end{array} \]
(FPCore (a b) :precision binary64 -1.0)
double code(double a, double b) {
	return -1.0;
}
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = -1.0d0
end function
public static double code(double a, double b) {
	return -1.0;
}
def code(a, b):
	return -1.0
function code(a, b)
	return -1.0
end
function tmp = code(a, b)
	tmp = -1.0;
end
code[a_, b_] := -1.0
\begin{array}{l}

\\
-1
\end{array}
Derivation
  1. Initial program 74.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(3 + a\right)\right)\right) - 1 \]
  2. Step-by-step derivation
    1. sub-neg74.9%

      \[\leadsto \color{blue}{\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(3 + a\right)\right)\right) + \left(-1\right)} \]
    2. fma-def74.9%

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

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

      \[\leadsto \left({\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + 4 \cdot \mathsf{fma}\left(a \cdot a, 1 - a, \left(b \cdot b\right) \cdot \color{blue}{\left(a + 3\right)}\right)\right) + \left(-1\right) \]
    5. metadata-eval75.6%

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

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

    \[\leadsto \color{blue}{{a}^{4}} + -1 \]
  5. Taylor expanded in a around 0 22.4%

    \[\leadsto \color{blue}{-1} \]
  6. Final simplification22.4%

    \[\leadsto -1 \]

Reproduce

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