Bouland and Aaronson, Equation (25)

Percentage Accurate: 73.5% → 98.3%
Time: 8.8s
Alternatives: 6
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 6 alternatives:

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

Initial Program: 73.5% 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: 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}:\\ \;\;\;\;\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + 4\right)\right) + -1\\ \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)
     (+ (* (* a a) (+ 4.0 (* a (+ a 4.0)))) -1.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 = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.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 = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.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 = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.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(Float64(Float64(a * a) * Float64(4.0 + Float64(a * Float64(a + 4.0)))) + -1.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 = ((a * a) * (4.0 + (a * (a + 4.0)))) + -1.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[(N[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * N[(a + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $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}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + 4\right)\right) + -1\\


\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.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. 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.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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}:\\ \;\;\;\;\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + 4\right)\right) + -1\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 81.7% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 79.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\sqrt[3]{{a}^{8}}, \sqrt[3]{{a}^{4}}, 4 \cdot \mathsf{fma}\left(a, a, a \cdot \color{blue}{\left(a \cdot a\right)}\right)\right) + -1 \]
      12. cube-unmult54.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.7e-8 < b

    1. Initial program 64.2%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(4, \mathsf{fma}\left(b \cdot b, \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} + -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in a around 0 95.9%

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

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

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

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

Alternative 3: 81.9% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 79.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\sqrt[3]{{a}^{8}}, \sqrt[3]{{a}^{4}}, 4 \cdot \mathsf{fma}\left(a, a, a \cdot \color{blue}{\left(a \cdot a\right)}\right)\right) + -1 \]
      12. cube-unmult54.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 142 < b

    1. Initial program 63.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-neg63.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. Simplified66.6%

      \[\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 inf 95.7%

      \[\leadsto \color{blue}{{b}^{4}} + -1 \]
    6. Step-by-step derivation
      1. metadata-eval95.7%

        \[\leadsto {b}^{\color{blue}{\left(2 + 2\right)}} + -1 \]
      2. pow-prod-up95.6%

        \[\leadsto \color{blue}{{b}^{2} \cdot {b}^{2}} + -1 \]
      3. unpow295.6%

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

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

        \[\leadsto \left(\color{blue}{\left(b \cdot b\right)} \cdot b\right) \cdot b + -1 \]
      6. pow395.7%

        \[\leadsto \color{blue}{{b}^{3}} \cdot b + -1 \]
    7. Applied egg-rr95.7%

      \[\leadsto \color{blue}{{b}^{3} \cdot b} + -1 \]
    8. Taylor expanded in b around inf 95.7%

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

Alternative 4: 69.5% accurate, 10.0× speedup?

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

\\
\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + 4\right)\right) + -1
\end{array}
Derivation
  1. Initial program 75.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. sub-neg75.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 51.1% accurate, 18.6× speedup?

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

\\
-1 + \left(a \cdot a\right) \cdot 4
\end{array}
Derivation
  1. Initial program 75.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. sub-neg75.3%

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

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

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

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

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

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

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

Alternative 6: 24.8% 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 75.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. sub-neg75.3%

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

    \[\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 inf 63.6%

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

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

Reproduce

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