Bouland and Aaronson, Equation (25)

Percentage Accurate: 74.3% → 100.0%
Time: 10.7s
Alternatives: 16
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(1 - 3 \cdot a\right)\right)\right) - 1 \end{array} \]
(FPCore (a b)
 :precision binary64
 (-
  (+
   (pow (+ (* a a) (* b b)) 2.0)
   (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 3.0 a))))))
  1.0))
double code(double a, double b) {
	return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0;
}
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) * (1.0d0 - (3.0d0 * a)))))) - 1.0d0
end function
public static double code(double a, double b) {
	return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0;
}
def code(a, b):
	return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0
function code(a, b)
	return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 + a)) + Float64(Float64(b * b) * Float64(1.0 - Float64(3.0 * a)))))) - 1.0)
end
function tmp = code(a, b)
	tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0;
end
code[a_, b_] := N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 + a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 - N[(3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}

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

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

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

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

Alternative 1: 100.0% accurate, 0.2× speedup?

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

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

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


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

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

        \[\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(1 - 3 \cdot a\right)\right)\right) + \left(-1\right)} \]
    3. Simplified99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    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(1 - 3 \cdot 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(1 - 3 \cdot a\right)\right)\right) + \left(-1\right)} \]
    3. Simplified7.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.9% accurate, 0.3× speedup?

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

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

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


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

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

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

    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(1 - 3 \cdot 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(1 - 3 \cdot a\right)\right)\right) + \left(-1\right)} \]
    3. Simplified7.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right)\right) \leq \infty:\\ \;\;\;\;\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;-1 + \left({b}^{4} + {a}^{2} \cdot \left(4 + \left(2 \cdot {b}^{2} + a \cdot \left(a + 4\right)\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 98.3% accurate, 0.5× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{a}^{4} \cdot \left(1 + \frac{4}{a}\right)\\


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

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

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

    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(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+0.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(1 - 3 \cdot a\right)\right) - 1\right)} \]
      2. +-commutative0.0%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{a}^{4} \cdot \left(1 + 4 \cdot \frac{1}{a}\right)} \]
    6. Step-by-step derivation
      1. associate-*r/94.2%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right)\right) \leq \infty:\\ \;\;\;\;\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;{a}^{4} \cdot \left(1 + \frac{4}{a}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 94.5% accurate, 1.1× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;{a}^{4} \cdot \left(-1 + \left(2 + \frac{4}{a}\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if a < -1.7e11

    1. Initial program 29.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(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+29.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(1 - 3 \cdot a\right)\right) - 1\right)} \]
      2. +-commutative29.2%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{a}^{4} \cdot \left(1 + 4 \cdot \frac{1}{a}\right)} \]
    6. Step-by-step derivation
      1. associate-*r/98.1%

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

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

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

    if -1.7e11 < a < 2.65e9

    1. Initial program 99.8%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+99.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(1 - 3 \cdot a\right)\right) - 1\right)} \]
      2. +-commutative99.8%

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

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

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

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

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

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

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

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

        \[\leadsto \left(4 \cdot \color{blue}{\left(b \cdot b\right)} + {b}^{4}\right) - 1 \]
    7. Applied egg-rr99.0%

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

    if 2.65e9 < a

    1. Initial program 56.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(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+56.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(1 - 3 \cdot a\right)\right) - 1\right)} \]
      2. +-commutative56.1%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{a}^{4} \cdot \left(1 + 4 \cdot \frac{1}{a}\right)} \]
    6. Step-by-step derivation
      1. associate-*r/91.2%

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

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

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

        \[\leadsto {a}^{4} \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(1 + \frac{4}{a}\right)\right)} \]
      2. expm1-undefine91.2%

        \[\leadsto {a}^{4} \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(1 + \frac{4}{a}\right)} - 1\right)} \]
    9. Applied egg-rr91.2%

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

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

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

        \[\leadsto {a}^{4} \cdot \color{blue}{\left(-1 + e^{\mathsf{log1p}\left(1 + \frac{4}{a}\right)}\right)} \]
      4. log1p-undefine91.2%

        \[\leadsto {a}^{4} \cdot \left(-1 + e^{\color{blue}{\log \left(1 + \left(1 + \frac{4}{a}\right)\right)}}\right) \]
      5. rem-exp-log91.2%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -170000000000:\\ \;\;\;\;{a}^{4} \cdot \left(1 + \frac{4}{a}\right)\\ \mathbf{elif}\;a \leq 2650000000:\\ \;\;\;\;-1 + \left({b}^{4} + \left(b \cdot b\right) \cdot 4\right)\\ \mathbf{else}:\\ \;\;\;\;{a}^{4} \cdot \left(-1 + \left(2 + \frac{4}{a}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 94.0% accurate, 1.1× speedup?

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

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

\mathbf{elif}\;a \leq 42000000:\\
\;\;\;\;{b}^{4} + -1\\

\mathbf{else}:\\
\;\;\;\;{a}^{4} \cdot \left(-1 + \left(2 + \frac{4}{a}\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if a < -1.05e11

    1. Initial program 29.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(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+29.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(1 - 3 \cdot a\right)\right) - 1\right)} \]
      2. +-commutative29.2%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{a}^{4} \cdot \left(1 + 4 \cdot \frac{1}{a}\right)} \]
    6. Step-by-step derivation
      1. associate-*r/98.1%

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

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

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

    if -1.05e11 < a < 4.2e7

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.2e7 < a

    1. Initial program 56.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(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+56.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(1 - 3 \cdot a\right)\right) - 1\right)} \]
      2. +-commutative56.1%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{a}^{4} \cdot \left(1 + 4 \cdot \frac{1}{a}\right)} \]
    6. Step-by-step derivation
      1. associate-*r/91.2%

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

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

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

        \[\leadsto {a}^{4} \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(1 + \frac{4}{a}\right)\right)} \]
      2. expm1-undefine91.2%

        \[\leadsto {a}^{4} \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(1 + \frac{4}{a}\right)} - 1\right)} \]
    9. Applied egg-rr91.2%

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

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

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

        \[\leadsto {a}^{4} \cdot \color{blue}{\left(-1 + e^{\mathsf{log1p}\left(1 + \frac{4}{a}\right)}\right)} \]
      4. log1p-undefine91.2%

        \[\leadsto {a}^{4} \cdot \left(-1 + e^{\color{blue}{\log \left(1 + \left(1 + \frac{4}{a}\right)\right)}}\right) \]
      5. rem-exp-log91.2%

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

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

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

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

Alternative 6: 94.0% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -80000000000 \lor \neg \left(a \leq 180000000000\right):\\ \;\;\;\;{a}^{4} \cdot \left(1 + \frac{4}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;{b}^{4} + -1\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (or (<= a -80000000000.0) (not (<= a 180000000000.0)))
   (* (pow a 4.0) (+ 1.0 (/ 4.0 a)))
   (+ (pow b 4.0) -1.0)))
double code(double a, double b) {
	double tmp;
	if ((a <= -80000000000.0) || !(a <= 180000000000.0)) {
		tmp = pow(a, 4.0) * (1.0 + (4.0 / a));
	} else {
		tmp = 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 ((a <= (-80000000000.0d0)) .or. (.not. (a <= 180000000000.0d0))) then
        tmp = (a ** 4.0d0) * (1.0d0 + (4.0d0 / a))
    else
        tmp = (b ** 4.0d0) + (-1.0d0)
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double tmp;
	if ((a <= -80000000000.0) || !(a <= 180000000000.0)) {
		tmp = Math.pow(a, 4.0) * (1.0 + (4.0 / a));
	} else {
		tmp = Math.pow(b, 4.0) + -1.0;
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if (a <= -80000000000.0) or not (a <= 180000000000.0):
		tmp = math.pow(a, 4.0) * (1.0 + (4.0 / a))
	else:
		tmp = math.pow(b, 4.0) + -1.0
	return tmp
function code(a, b)
	tmp = 0.0
	if ((a <= -80000000000.0) || !(a <= 180000000000.0))
		tmp = Float64((a ^ 4.0) * Float64(1.0 + Float64(4.0 / a)));
	else
		tmp = Float64((b ^ 4.0) + -1.0);
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if ((a <= -80000000000.0) || ~((a <= 180000000000.0)))
		tmp = (a ^ 4.0) * (1.0 + (4.0 / a));
	else
		tmp = (b ^ 4.0) + -1.0;
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[Or[LessEqual[a, -80000000000.0], N[Not[LessEqual[a, 180000000000.0]], $MachinePrecision]], N[(N[Power[a, 4.0], $MachinePrecision] * N[(1.0 + N[(4.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -80000000000 \lor \neg \left(a \leq 180000000000\right):\\
\;\;\;\;{a}^{4} \cdot \left(1 + \frac{4}{a}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -8e10 or 1.8e11 < a

    1. Initial program 44.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(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+44.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(1 - 3 \cdot a\right)\right) - 1\right)} \]
      2. +-commutative44.2%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{a}^{4} \cdot \left(1 + 4 \cdot \frac{1}{a}\right)} \]
    6. Step-by-step derivation
      1. associate-*r/94.3%

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

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

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

    if -8e10 < a < 1.8e11

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -80000000000 \lor \neg \left(a \leq 180000000000\right):\\ \;\;\;\;{a}^{4} \cdot \left(1 + \frac{4}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;{b}^{4} + -1\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 93.9% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -140000000000 \lor \neg \left(a \leq 205000000000\right):\\ \;\;\;\;\left(a + 4\right) \cdot {a}^{3}\\ \mathbf{else}:\\ \;\;\;\;{b}^{4} + -1\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (or (<= a -140000000000.0) (not (<= a 205000000000.0)))
   (* (+ a 4.0) (pow a 3.0))
   (+ (pow b 4.0) -1.0)))
double code(double a, double b) {
	double tmp;
	if ((a <= -140000000000.0) || !(a <= 205000000000.0)) {
		tmp = (a + 4.0) * pow(a, 3.0);
	} else {
		tmp = 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 ((a <= (-140000000000.0d0)) .or. (.not. (a <= 205000000000.0d0))) then
        tmp = (a + 4.0d0) * (a ** 3.0d0)
    else
        tmp = (b ** 4.0d0) + (-1.0d0)
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double tmp;
	if ((a <= -140000000000.0) || !(a <= 205000000000.0)) {
		tmp = (a + 4.0) * Math.pow(a, 3.0);
	} else {
		tmp = Math.pow(b, 4.0) + -1.0;
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if (a <= -140000000000.0) or not (a <= 205000000000.0):
		tmp = (a + 4.0) * math.pow(a, 3.0)
	else:
		tmp = math.pow(b, 4.0) + -1.0
	return tmp
function code(a, b)
	tmp = 0.0
	if ((a <= -140000000000.0) || !(a <= 205000000000.0))
		tmp = Float64(Float64(a + 4.0) * (a ^ 3.0));
	else
		tmp = Float64((b ^ 4.0) + -1.0);
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if ((a <= -140000000000.0) || ~((a <= 205000000000.0)))
		tmp = (a + 4.0) * (a ^ 3.0);
	else
		tmp = (b ^ 4.0) + -1.0;
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[Or[LessEqual[a, -140000000000.0], N[Not[LessEqual[a, 205000000000.0]], $MachinePrecision]], N[(N[(a + 4.0), $MachinePrecision] * N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision], N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -140000000000 \lor \neg \left(a \leq 205000000000\right):\\
\;\;\;\;\left(a + 4\right) \cdot {a}^{3}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -1.4e11 or 2.05e11 < a

    1. Initial program 44.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(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+44.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(1 - 3 \cdot a\right)\right) - 1\right)} \]
      2. +-commutative44.2%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{a}^{4} \cdot \left(1 + 4 \cdot \frac{1}{a}\right)} \]
    6. Step-by-step derivation
      1. associate-*r/94.3%

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

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

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

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

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

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

    if -1.4e11 < a < 2.05e11

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -140000000000 \lor \neg \left(a \leq 205000000000\right):\\ \;\;\;\;\left(a + 4\right) \cdot {a}^{3}\\ \mathbf{else}:\\ \;\;\;\;{b}^{4} + -1\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 93.8% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -220000000000 \lor \neg \left(a \leq 1000000000\right):\\ \;\;\;\;{a}^{4}\\ \mathbf{else}:\\ \;\;\;\;{b}^{4} + -1\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (or (<= a -220000000000.0) (not (<= a 1000000000.0)))
   (pow a 4.0)
   (+ (pow b 4.0) -1.0)))
double code(double a, double b) {
	double tmp;
	if ((a <= -220000000000.0) || !(a <= 1000000000.0)) {
		tmp = pow(a, 4.0);
	} else {
		tmp = 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 ((a <= (-220000000000.0d0)) .or. (.not. (a <= 1000000000.0d0))) then
        tmp = a ** 4.0d0
    else
        tmp = (b ** 4.0d0) + (-1.0d0)
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double tmp;
	if ((a <= -220000000000.0) || !(a <= 1000000000.0)) {
		tmp = Math.pow(a, 4.0);
	} else {
		tmp = Math.pow(b, 4.0) + -1.0;
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if (a <= -220000000000.0) or not (a <= 1000000000.0):
		tmp = math.pow(a, 4.0)
	else:
		tmp = math.pow(b, 4.0) + -1.0
	return tmp
function code(a, b)
	tmp = 0.0
	if ((a <= -220000000000.0) || !(a <= 1000000000.0))
		tmp = a ^ 4.0;
	else
		tmp = Float64((b ^ 4.0) + -1.0);
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if ((a <= -220000000000.0) || ~((a <= 1000000000.0)))
		tmp = a ^ 4.0;
	else
		tmp = (b ^ 4.0) + -1.0;
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[Or[LessEqual[a, -220000000000.0], N[Not[LessEqual[a, 1000000000.0]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -220000000000 \lor \neg \left(a \leq 1000000000\right):\\
\;\;\;\;{a}^{4}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -2.2e11 or 1e9 < a

    1. Initial program 44.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(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+44.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(1 - 3 \cdot a\right)\right) - 1\right)} \]
      2. +-commutative44.2%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{a}^{4} \cdot \left(1 + 4 \cdot \frac{1}{a}\right)} \]
    6. Step-by-step derivation
      1. associate-*r/94.3%

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

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

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

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

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

      \[\leadsto \color{blue}{{a}^{3} \cdot \left(a + 4\right)} \]
    11. Taylor expanded in a around inf 93.5%

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

    if -2.2e11 < a < 1e9

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -220000000000 \lor \neg \left(a \leq 1000000000\right):\\ \;\;\;\;{a}^{4}\\ \mathbf{else}:\\ \;\;\;\;{b}^{4} + -1\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 82.3% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -90000000000 \lor \neg \left(a \leq 15000000\right):\\
\;\;\;\;{a}^{4}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -9e10 or 1.5e7 < a

    1. Initial program 44.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(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+44.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(1 - 3 \cdot a\right)\right) - 1\right)} \]
      2. +-commutative44.2%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{a}^{4} \cdot \left(1 + 4 \cdot \frac{1}{a}\right)} \]
    6. Step-by-step derivation
      1. associate-*r/94.3%

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

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

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

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

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

      \[\leadsto \color{blue}{{a}^{3} \cdot \left(a + 4\right)} \]
    11. Taylor expanded in a around inf 93.5%

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

    if -9e10 < a < 1.5e7

    1. Initial program 99.8%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+99.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(1 - 3 \cdot a\right)\right) - 1\right)} \]
      2. +-commutative99.8%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{4 \cdot {b}^{2} - 1} \]
    7. Step-by-step derivation
      1. unpow299.0%

        \[\leadsto \left(4 \cdot \color{blue}{\left(b \cdot b\right)} + {b}^{4}\right) - 1 \]
    8. Applied egg-rr69.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -90000000000 \lor \neg \left(a \leq 15000000\right):\\ \;\;\;\;{a}^{4}\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(b \cdot b\right) \cdot 4\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 93.5% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \cdot b \leq 0.5:\\ \;\;\;\;{a}^{4} + -1\\ \mathbf{else}:\\ \;\;\;\;{b}^{4}\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= (* b b) 0.5) (+ (pow a 4.0) -1.0) (pow b 4.0)))
double code(double a, double b) {
	double tmp;
	if ((b * b) <= 0.5) {
		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) <= 0.5d0) 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) <= 0.5) {
		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) <= 0.5:
		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) <= 0.5)
		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) <= 0.5)
		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], 0.5], 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 0.5:\\
\;\;\;\;{a}^{4} + -1\\

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


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

    1. Initial program 83.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.5 < (*.f64 b b)

    1. Initial program 65.3%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+65.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(1 - 3 \cdot a\right)\right) - 1\right)} \]
      2. +-commutative65.3%

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

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

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

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

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

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

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

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

        \[\leadsto \left(4 \cdot \color{blue}{\left(b \cdot b\right)} + {b}^{4}\right) - 1 \]
    7. Applied egg-rr90.4%

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

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

Alternative 11: 82.5% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 83.8%

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

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

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

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

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

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

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

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

    if 0.5 < (*.f64 b b)

    1. Initial program 65.3%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+65.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(1 - 3 \cdot a\right)\right) - 1\right)} \]
      2. +-commutative65.3%

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

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

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

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

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

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

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

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

        \[\leadsto \left(4 \cdot \color{blue}{\left(b \cdot b\right)} + {b}^{4}\right) - 1 \]
    7. Applied egg-rr90.4%

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

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

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

Alternative 12: 72.7% accurate, 5.2× speedup?

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

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

\mathbf{elif}\;b \cdot b \leq 5 \cdot 10^{+297}:\\
\;\;\;\;2 \cdot \left(\left(a \cdot b\right) \cdot \left(a \cdot b\right)\right)\\

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


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

    1. Initial program 83.8%

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

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

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

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

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

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

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

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

    if 0.5 < (*.f64 b b) < 4.9999999999999998e297

    1. Initial program 77.9%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+77.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(1 - 3 \cdot a\right)\right) - 1\right)} \]
      2. +-commutative77.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \color{blue}{\left({b}^{2} \cdot {a}^{2}\right)} \]
      2. unpow229.1%

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

        \[\leadsto 2 \cdot \left(\left(b \cdot b\right) \cdot \color{blue}{\left(a \cdot a\right)}\right) \]
      4. swap-sqr29.1%

        \[\leadsto 2 \cdot \color{blue}{\left(\left(b \cdot a\right) \cdot \left(b \cdot a\right)\right)} \]
      5. unpow229.1%

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

        \[\leadsto 2 \cdot {\color{blue}{\left(a \cdot b\right)}}^{2} \]
    8. Simplified29.1%

      \[\leadsto \color{blue}{2 \cdot {\left(a \cdot b\right)}^{2}} \]
    9. Step-by-step derivation
      1. unpow280.0%

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

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

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

      \[\leadsto 2 \cdot \color{blue}{\left(\left(b \cdot a\right) \cdot \left(b \cdot a\right)\right)} \]

    if 4.9999999999999998e297 < (*.f64 b b)

    1. Initial program 51.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(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+51.7%

        \[\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(1 - 3 \cdot a\right)\right) - 1\right)} \]
      2. +-commutative51.7%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{4 \cdot {b}^{2} - 1} \]
    7. Step-by-step derivation
      1. add-sqr-sqrt98.6%

        \[\leadsto \color{blue}{\sqrt{4 \cdot {b}^{2}} \cdot \sqrt{4 \cdot {b}^{2}}} - 1 \]
      2. difference-of-sqr-198.6%

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

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

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

        \[\leadsto \left(\color{blue}{{b}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{4} + 1\right) \cdot \left(\sqrt{4 \cdot {b}^{2}} - 1\right) \]
      6. metadata-eval46.9%

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

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

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

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

        \[\leadsto \left(b \cdot 2 + 1\right) \cdot \left(\color{blue}{\sqrt{{b}^{2}} \cdot \sqrt{4}} - 1\right) \]
      11. sqrt-pow198.6%

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

        \[\leadsto \left(b \cdot 2 + 1\right) \cdot \left({b}^{\color{blue}{1}} \cdot \sqrt{4} - 1\right) \]
      13. pow198.6%

        \[\leadsto \left(b \cdot 2 + 1\right) \cdot \left(\color{blue}{b} \cdot \sqrt{4} - 1\right) \]
      14. metadata-eval98.6%

        \[\leadsto \left(b \cdot 2 + 1\right) \cdot \left(b \cdot \color{blue}{2} - 1\right) \]
    8. Applied egg-rr98.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \cdot b \leq 0.5:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\ \mathbf{elif}\;b \cdot b \leq 5 \cdot 10^{+297}:\\ \;\;\;\;2 \cdot \left(\left(a \cdot b\right) \cdot \left(a \cdot b\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 + b \cdot 2\right) \cdot \left(-1 + b \cdot 2\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 72.7% accurate, 5.6× speedup?

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

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

\mathbf{elif}\;b \cdot b \leq 5 \cdot 10^{+297}:\\
\;\;\;\;2 \cdot \left(\left(a \cdot b\right) \cdot \left(a \cdot b\right)\right)\\

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


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

    1. Initial program 83.8%

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

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

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

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

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

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

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

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

    if 0.5 < (*.f64 b b) < 4.9999999999999998e297

    1. Initial program 77.9%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+77.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(1 - 3 \cdot a\right)\right) - 1\right)} \]
      2. +-commutative77.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \color{blue}{\left({b}^{2} \cdot {a}^{2}\right)} \]
      2. unpow229.1%

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

        \[\leadsto 2 \cdot \left(\left(b \cdot b\right) \cdot \color{blue}{\left(a \cdot a\right)}\right) \]
      4. swap-sqr29.1%

        \[\leadsto 2 \cdot \color{blue}{\left(\left(b \cdot a\right) \cdot \left(b \cdot a\right)\right)} \]
      5. unpow229.1%

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

        \[\leadsto 2 \cdot {\color{blue}{\left(a \cdot b\right)}}^{2} \]
    8. Simplified29.1%

      \[\leadsto \color{blue}{2 \cdot {\left(a \cdot b\right)}^{2}} \]
    9. Step-by-step derivation
      1. unpow280.0%

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

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

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

      \[\leadsto 2 \cdot \color{blue}{\left(\left(b \cdot a\right) \cdot \left(b \cdot a\right)\right)} \]

    if 4.9999999999999998e297 < (*.f64 b b)

    1. Initial program 51.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(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+51.7%

        \[\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(1 - 3 \cdot a\right)\right) - 1\right)} \]
      2. +-commutative51.7%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{4 \cdot {b}^{2} - 1} \]
    7. Step-by-step derivation
      1. unpow2100.0%

        \[\leadsto \left(4 \cdot \color{blue}{\left(b \cdot b\right)} + {b}^{4}\right) - 1 \]
    8. Applied egg-rr98.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \cdot b \leq 0.5:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\ \mathbf{elif}\;b \cdot b \leq 5 \cdot 10^{+297}:\\ \;\;\;\;2 \cdot \left(\left(a \cdot b\right) \cdot \left(a \cdot b\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(b \cdot b\right) \cdot 4\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 70.0% accurate, 9.3× speedup?

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

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

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


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

    1. Initial program 81.9%

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

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

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

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

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

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

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

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

    if 8.59999999999999982e303 < (*.f64 b b)

    1. Initial program 51.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(1 - 3 \cdot a\right)\right)\right) - 1 \]
    2. Step-by-step derivation
      1. associate--l+51.7%

        \[\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(1 - 3 \cdot a\right)\right) - 1\right)} \]
      2. +-commutative51.7%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{4 \cdot {b}^{2} - 1} \]
    7. Step-by-step derivation
      1. unpow2100.0%

        \[\leadsto \left(4 \cdot \color{blue}{\left(b \cdot b\right)} + {b}^{4}\right) - 1 \]
    8. Applied egg-rr98.6%

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

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

Alternative 15: 51.6% accurate, 18.6× speedup?

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

\\
-1 + \left(b \cdot b\right) \cdot 4
\end{array}
Derivation
  1. Initial program 74.8%

    \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
  2. Step-by-step derivation
    1. associate--l+74.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(1 - 3 \cdot a\right)\right) - 1\right)} \]
    2. +-commutative74.8%

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{4 \cdot {b}^{2} - 1} \]
  7. Step-by-step derivation
    1. unpow270.4%

      \[\leadsto \left(4 \cdot \color{blue}{\left(b \cdot b\right)} + {b}^{4}\right) - 1 \]
  8. Applied egg-rr50.8%

    \[\leadsto 4 \cdot \color{blue}{\left(b \cdot b\right)} - 1 \]
  9. Final simplification50.8%

    \[\leadsto -1 + \left(b \cdot b\right) \cdot 4 \]
  10. Add Preprocessing

Alternative 16: 25.1% accurate, 130.0× speedup?

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

\\
-1
\end{array}
Derivation
  1. Initial program 74.8%

    \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1 \]
  2. Step-by-step derivation
    1. associate--l+74.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(1 - 3 \cdot a\right)\right) - 1\right)} \]
    2. +-commutative74.8%

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-1} \]
  7. Add Preprocessing

Reproduce

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