Bouland and Aaronson, Equation (24)

Percentage Accurate: 72.7% → 96.6%
Time: 10.8s
Alternatives: 11
Speedup: 1.2×

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: 72.7% 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: 96.6% accurate, 0.2× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{a}^{4}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < 4.60000000000000034e60

    1. Initial program 89.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. associate--l+89.4%

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

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

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

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

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

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

    if 4.60000000000000034e60 < a

    1. Initial program 4.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. associate--l+4.2%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + \mathsf{fma}\left(4, \mathsf{fma}\left(a, a \cdot \left(1 - a\right), \left(b \cdot b\right) \cdot \left(a + 3\right)\right), -1\right)} \]
    4. Taylor expanded in b around 0 4.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. associate--l+4.3%

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

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

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

      \[\leadsto \color{blue}{{a}^{4}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.2%

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

Alternative 2: 98.4% accurate, 0.2× speedup?

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

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

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


\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.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. associate--l+99.9%

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

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

    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-def10.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. +-commutative10.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-eval10.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. Simplified10.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 93.0%

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

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

Alternative 3: 98.3% accurate, 0.2× speedup?

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

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

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


\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.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. associate--l+99.9%

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

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

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

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

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

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

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

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

    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-def10.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. +-commutative10.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-eval10.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. Simplified10.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 93.0%

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

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

Alternative 4: 98.3% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(b \cdot b + a \cdot a\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:\\ \;\;\;\;-1 + t_0\\ \mathbf{else}:\\ \;\;\;\;{a}^{4} + -1\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (let* ((t_0
         (+
          (pow (+ (* b b) (* a a)) 2.0)
          (* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ a 3.0)))))))
   (if (<= t_0 INFINITY) (+ -1.0 t_0) (+ (pow a 4.0) -1.0))))
double code(double a, double b) {
	double t_0 = pow(((b * b) + (a * a)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
	double tmp;
	if (t_0 <= ((double) INFINITY)) {
		tmp = -1.0 + t_0;
	} else {
		tmp = pow(a, 4.0) + -1.0;
	}
	return tmp;
}
public static double code(double a, double b) {
	double t_0 = Math.pow(((b * b) + (a * a)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
	double tmp;
	if (t_0 <= Double.POSITIVE_INFINITY) {
		tmp = -1.0 + t_0;
	} else {
		tmp = Math.pow(a, 4.0) + -1.0;
	}
	return tmp;
}
def code(a, b):
	t_0 = math.pow(((b * b) + (a * a)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))))
	tmp = 0
	if t_0 <= math.inf:
		tmp = -1.0 + t_0
	else:
		tmp = math.pow(a, 4.0) + -1.0
	return tmp
function code(a, b)
	t_0 = Float64((Float64(Float64(b * b) + Float64(a * a)) ^ 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(-1.0 + t_0);
	else
		tmp = Float64((a ^ 4.0) + -1.0);
	end
	return tmp
end
function tmp_2 = code(a, b)
	t_0 = (((b * b) + (a * a)) ^ 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
	tmp = 0.0;
	if (t_0 <= Inf)
		tmp = -1.0 + t_0;
	else
		tmp = (a ^ 4.0) + -1.0;
	end
	tmp_2 = tmp;
end
code[a_, b_] := Block[{t$95$0 = N[(N[Power[N[(N[(b * b), $MachinePrecision] + N[(a * a), $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[(-1.0 + t$95$0), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(b \cdot b + a \cdot a\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:\\
\;\;\;\;-1 + t_0\\

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


\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.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 \]

    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-def10.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. +-commutative10.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-eval10.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. Simplified10.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 93.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(b \cdot b + a \cdot a\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:\\ \;\;\;\;-1 + \left({\left(b \cdot b + a \cdot a\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)\\ \mathbf{else}:\\ \;\;\;\;{a}^{4} + -1\\ \end{array} \]

Alternative 5: 69.8% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \cdot b \leq 4 \cdot 10^{-251}:\\ \;\;\;\;-1\\ \mathbf{elif}\;b \cdot b \leq 4 \cdot 10^{-156}:\\ \;\;\;\;{a}^{4}\\ \mathbf{elif}\;b \cdot b \leq 0.001:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;{b}^{4}\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= (* b b) 4e-251)
   -1.0
   (if (<= (* b b) 4e-156)
     (pow a 4.0)
     (if (<= (* b b) 0.001) -1.0 (pow b 4.0)))))
double code(double a, double b) {
	double tmp;
	if ((b * b) <= 4e-251) {
		tmp = -1.0;
	} else if ((b * b) <= 4e-156) {
		tmp = pow(a, 4.0);
	} else if ((b * b) <= 0.001) {
		tmp = -1.0;
	} else {
		tmp = 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) <= 4d-251) then
        tmp = -1.0d0
    else if ((b * b) <= 4d-156) then
        tmp = a ** 4.0d0
    else if ((b * b) <= 0.001d0) then
        tmp = -1.0d0
    else
        tmp = b ** 4.0d0
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double tmp;
	if ((b * b) <= 4e-251) {
		tmp = -1.0;
	} else if ((b * b) <= 4e-156) {
		tmp = Math.pow(a, 4.0);
	} else if ((b * b) <= 0.001) {
		tmp = -1.0;
	} else {
		tmp = Math.pow(b, 4.0);
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if (b * b) <= 4e-251:
		tmp = -1.0
	elif (b * b) <= 4e-156:
		tmp = math.pow(a, 4.0)
	elif (b * b) <= 0.001:
		tmp = -1.0
	else:
		tmp = math.pow(b, 4.0)
	return tmp
function code(a, b)
	tmp = 0.0
	if (Float64(b * b) <= 4e-251)
		tmp = -1.0;
	elseif (Float64(b * b) <= 4e-156)
		tmp = a ^ 4.0;
	elseif (Float64(b * b) <= 0.001)
		tmp = -1.0;
	else
		tmp = b ^ 4.0;
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if ((b * b) <= 4e-251)
		tmp = -1.0;
	elseif ((b * b) <= 4e-156)
		tmp = a ^ 4.0;
	elseif ((b * b) <= 0.001)
		tmp = -1.0;
	else
		tmp = b ^ 4.0;
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 4e-251], -1.0, If[LessEqual[N[(b * b), $MachinePrecision], 4e-156], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[N[(b * b), $MachinePrecision], 0.001], -1.0, N[Power[b, 4.0], $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 4 \cdot 10^{-251}:\\
\;\;\;\;-1\\

\mathbf{elif}\;b \cdot b \leq 4 \cdot 10^{-156}:\\
\;\;\;\;{a}^{4}\\

\mathbf{elif}\;b \cdot b \leq 0.001:\\
\;\;\;\;-1\\

\mathbf{else}:\\
\;\;\;\;{b}^{4}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 b b) < 4.00000000000000006e-251 or 4.00000000000000016e-156 < (*.f64 b b) < 1e-3

    1. Initial program 82.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. associate--l+82.3%

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

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

      \[\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+62.6%

        \[\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*62.6%

        \[\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-out62.6%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1} \]

    if 4.00000000000000006e-251 < (*.f64 b b) < 4.00000000000000016e-156

    1. Initial program 87.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. associate--l+87.4%

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

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

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

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

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

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

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

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

      \[\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. associate--l+87.5%

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

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

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

      \[\leadsto \color{blue}{{a}^{4}} \]

    if 1e-3 < (*.f64 b b)

    1. Initial program 65.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. associate--l+65.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \log \left(e^{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}}\right) + \mathsf{fma}\left(4, \color{blue}{\left(a \cdot a\right)} \cdot \left(1 - a\right), -1\right) \]
      2. associate-*r*68.8%

        \[\leadsto \log \left(e^{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}}\right) + \mathsf{fma}\left(4, \color{blue}{a \cdot \left(a \cdot \left(1 - a\right)\right)}, -1\right) \]
      3. *-commutative68.8%

        \[\leadsto \log \left(e^{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}}\right) + \mathsf{fma}\left(4, a \cdot \color{blue}{\left(\left(1 - a\right) \cdot a\right)}, -1\right) \]
      4. sub-neg68.8%

        \[\leadsto \log \left(e^{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}}\right) + \mathsf{fma}\left(4, a \cdot \left(\color{blue}{\left(1 + \left(-a\right)\right)} \cdot a\right), -1\right) \]
      5. +-commutative68.8%

        \[\leadsto \log \left(e^{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}}\right) + \mathsf{fma}\left(4, a \cdot \left(\color{blue}{\left(\left(-a\right) + 1\right)} \cdot a\right), -1\right) \]
      6. distribute-rgt1-in68.8%

        \[\leadsto \log \left(e^{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}}\right) + \mathsf{fma}\left(4, a \cdot \color{blue}{\left(a + \left(-a\right) \cdot a\right)}, -1\right) \]
      7. distribute-lft-neg-out68.8%

        \[\leadsto \log \left(e^{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}}\right) + \mathsf{fma}\left(4, a \cdot \left(a + \color{blue}{\left(-a \cdot a\right)}\right), -1\right) \]
      8. unsub-neg68.8%

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

      \[\leadsto \log \left(e^{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}}\right) + \mathsf{fma}\left(4, \color{blue}{a \cdot \left(a - a \cdot a\right)}, -1\right) \]
    9. Taylor expanded in b around inf 90.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \cdot b \leq 4 \cdot 10^{-251}:\\ \;\;\;\;-1\\ \mathbf{elif}\;b \cdot b \leq 4 \cdot 10^{-156}:\\ \;\;\;\;{a}^{4}\\ \mathbf{elif}\;b \cdot b \leq 0.001:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;{b}^{4}\\ \end{array} \]

Alternative 6: 92.8% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{-32}:\\
\;\;\;\;{a}^{4} + -1\\

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


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

    1. Initial program 82.5%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. sub-neg82.5%

        \[\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-def82.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-def82.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. +-commutative82.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-eval82.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. Simplified82.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 inf 98.3%

      \[\leadsto \color{blue}{{a}^{4}} + -1 \]

    if 5e-32 < (*.f64 b b)

    1. Initial program 65.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. associate--l+65.9%

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

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

      \[\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+62.2%

        \[\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*62.2%

        \[\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-out79.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 92.9% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 82.5%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+82.6%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + \mathsf{fma}\left(4, \mathsf{fma}\left(a, a \cdot \left(1 - a\right), \left(b \cdot b\right) \cdot \left(a + 3\right)\right), -1\right)} \]
    4. Taylor expanded in b around 0 82.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. associate--l+82.6%

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

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

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

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

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

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

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

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

    if 5e-32 < (*.f64 b b)

    1. Initial program 65.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. associate--l+65.9%

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

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

      \[\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+62.2%

        \[\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*62.2%

        \[\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-out79.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 93.4% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \cdot b \leq 500:\\ \;\;\;\;{a}^{4} + -1\\ \mathbf{else}:\\ \;\;\;\;{b}^{4}\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= (* b b) 500.0) (+ (pow a 4.0) -1.0) (pow b 4.0)))
double code(double a, double b) {
	double tmp;
	if ((b * b) <= 500.0) {
		tmp = pow(a, 4.0) + -1.0;
	} else {
		tmp = 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) <= 500.0d0) then
        tmp = (a ** 4.0d0) + (-1.0d0)
    else
        tmp = b ** 4.0d0
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double tmp;
	if ((b * b) <= 500.0) {
		tmp = Math.pow(a, 4.0) + -1.0;
	} else {
		tmp = Math.pow(b, 4.0);
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if (b * b) <= 500.0:
		tmp = math.pow(a, 4.0) + -1.0
	else:
		tmp = math.pow(b, 4.0)
	return tmp
function code(a, b)
	tmp = 0.0
	if (Float64(b * b) <= 500.0)
		tmp = Float64((a ^ 4.0) + -1.0);
	else
		tmp = b ^ 4.0;
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if ((b * b) <= 500.0)
		tmp = (a ^ 4.0) + -1.0;
	else
		tmp = b ^ 4.0;
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 500.0], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 500:\\
\;\;\;\;{a}^{4} + -1\\

\mathbf{else}:\\
\;\;\;\;{b}^{4}\\


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

    1. Initial program 83.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-neg83.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-def83.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-def83.2%

        \[\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. +-commutative83.2%

        \[\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-eval83.2%

        \[\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. Simplified83.2%

      \[\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 96.1%

      \[\leadsto \color{blue}{{a}^{4}} + -1 \]

    if 500 < (*.f64 b b)

    1. Initial program 64.5%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+64.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\mathsf{hypot}\left(a, b\right)\right)}^{\color{blue}{4}} + \mathsf{fma}\left(4, \mathsf{fma}\left(a, a \cdot \left(1 - a\right), \left(b \cdot b\right) \cdot \left(a + 3\right)\right), -1\right) \]
      8. add-log-exp57.6%

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

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

      \[\leadsto \log \left(e^{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}}\right) + \mathsf{fma}\left(4, \color{blue}{{a}^{2} \cdot \left(1 - a\right)}, -1\right) \]
    7. Step-by-step derivation
      1. unpow269.1%

        \[\leadsto \log \left(e^{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}}\right) + \mathsf{fma}\left(4, \color{blue}{\left(a \cdot a\right)} \cdot \left(1 - a\right), -1\right) \]
      2. associate-*r*69.1%

        \[\leadsto \log \left(e^{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}}\right) + \mathsf{fma}\left(4, \color{blue}{a \cdot \left(a \cdot \left(1 - a\right)\right)}, -1\right) \]
      3. *-commutative69.1%

        \[\leadsto \log \left(e^{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}}\right) + \mathsf{fma}\left(4, a \cdot \color{blue}{\left(\left(1 - a\right) \cdot a\right)}, -1\right) \]
      4. sub-neg69.1%

        \[\leadsto \log \left(e^{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}}\right) + \mathsf{fma}\left(4, a \cdot \left(\color{blue}{\left(1 + \left(-a\right)\right)} \cdot a\right), -1\right) \]
      5. +-commutative69.1%

        \[\leadsto \log \left(e^{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}}\right) + \mathsf{fma}\left(4, a \cdot \left(\color{blue}{\left(\left(-a\right) + 1\right)} \cdot a\right), -1\right) \]
      6. distribute-rgt1-in69.1%

        \[\leadsto \log \left(e^{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}}\right) + \mathsf{fma}\left(4, a \cdot \color{blue}{\left(a + \left(-a\right) \cdot a\right)}, -1\right) \]
      7. distribute-lft-neg-out69.1%

        \[\leadsto \log \left(e^{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}}\right) + \mathsf{fma}\left(4, a \cdot \left(a + \color{blue}{\left(-a \cdot a\right)}\right), -1\right) \]
      8. unsub-neg69.1%

        \[\leadsto \log \left(e^{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}}\right) + \mathsf{fma}\left(4, a \cdot \color{blue}{\left(a - a \cdot a\right)}, -1\right) \]
    8. Simplified69.1%

      \[\leadsto \log \left(e^{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}}\right) + \mathsf{fma}\left(4, \color{blue}{a \cdot \left(a - a \cdot a\right)}, -1\right) \]
    9. Taylor expanded in b around inf 92.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \cdot b \leq 500:\\ \;\;\;\;{a}^{4} + -1\\ \mathbf{else}:\\ \;\;\;\;{b}^{4}\\ \end{array} \]

Alternative 9: 68.8% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.42:\\
\;\;\;\;{a}^{4}\\

\mathbf{elif}\;a \leq 2.4:\\
\;\;\;\;-1\\

\mathbf{else}:\\
\;\;\;\;{a}^{4}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -0.419999999999999984 or 2.39999999999999991 < a

    1. Initial program 41.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. associate--l+41.6%

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

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

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

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

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

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

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

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

      \[\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. associate--l+47.7%

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

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

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

      \[\leadsto \color{blue}{{a}^{4}} \]

    if -0.419999999999999984 < a < 2.39999999999999991

    1. Initial program 99.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. associate--l+99.9%

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

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

      \[\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+83.0%

        \[\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*83.0%

        \[\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-out99.3%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification66.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -0.42:\\ \;\;\;\;{a}^{4}\\ \mathbf{elif}\;a \leq 2.4:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;{a}^{4}\\ \end{array} \]

Alternative 10: 41.0% accurate, 11.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \cdot b \leq 0.001:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(\left(b \cdot b\right) \cdot 4\right)\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= (* b b) 0.001) -1.0 (* a (* (* b b) 4.0))))
double code(double a, double b) {
	double tmp;
	if ((b * b) <= 0.001) {
		tmp = -1.0;
	} else {
		tmp = a * ((b * 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) <= 0.001d0) then
        tmp = -1.0d0
    else
        tmp = a * ((b * b) * 4.0d0)
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double tmp;
	if ((b * b) <= 0.001) {
		tmp = -1.0;
	} else {
		tmp = a * ((b * b) * 4.0);
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if (b * b) <= 0.001:
		tmp = -1.0
	else:
		tmp = a * ((b * b) * 4.0)
	return tmp
function code(a, b)
	tmp = 0.0
	if (Float64(b * b) <= 0.001)
		tmp = -1.0;
	else
		tmp = Float64(a * Float64(Float64(b * b) * 4.0));
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if ((b * b) <= 0.001)
		tmp = -1.0;
	else
		tmp = a * ((b * b) * 4.0);
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 0.001], -1.0, N[(a * N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 0.001:\\
\;\;\;\;-1\\

\mathbf{else}:\\
\;\;\;\;a \cdot \left(\left(b \cdot b\right) \cdot 4\right)\\


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

    1. Initial program 83.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. associate--l+83.0%

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

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

      \[\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+59.4%

        \[\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*59.4%

        \[\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-out59.4%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1} \]

    if 1e-3 < (*.f64 b b)

    1. Initial program 65.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. associate--l+65.1%

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

      \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(4, \mathsf{fma}\left(b \cdot b, a + 3, a \cdot a\right) - {a}^{3}, -1\right)} \]
    4. Taylor expanded in a around 0 61.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+61.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*61.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-out78.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot \color{blue}{\left(4 \cdot {b}^{2}\right)} \]
      4. unpow236.3%

        \[\leadsto a \cdot \left(4 \cdot \color{blue}{\left(b \cdot b\right)}\right) \]
    9. Simplified36.3%

      \[\leadsto \color{blue}{a \cdot \left(4 \cdot \left(b \cdot b\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification46.7%

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

Alternative 11: 24.6% 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 73.7%

    \[\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. associate--l+73.8%

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

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

    \[\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+60.4%

      \[\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*60.4%

      \[\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-out69.4%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-1} \]
  8. Final simplification28.3%

    \[\leadsto -1 \]

Reproduce

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