Bouland and Aaronson, Equation (25)

Percentage Accurate: 73.3% → 98.1%
Time: 6.3s
Alternatives: 7
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 7 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.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: 98.1% 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(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \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), -1\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + {a}^{3} \cdot \left(a + 4\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)
   (+
    (pow (hypot a b) 4.0)
    (fma 4.0 (fma b (* b (fma a -3.0 1.0)) (fma a a (pow a 3.0))) -1.0))
   (+ -1.0 (* (pow a 3.0) (+ 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 = pow(hypot(a, b), 4.0) + fma(4.0, fma(b, (b * fma(a, -3.0, 1.0)), fma(a, a, pow(a, 3.0))), -1.0);
	} else {
		tmp = -1.0 + (pow(a, 3.0) * (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((hypot(a, b) ^ 4.0) + fma(4.0, fma(b, Float64(b * fma(a, -3.0, 1.0)), fma(a, a, (a ^ 3.0))), -1.0));
	else
		tmp = Float64(-1.0 + Float64((a ^ 3.0) * 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[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + N[(4.0 * N[(b * N[(b * N[(a * -3.0 + 1.0), $MachinePrecision]), $MachinePrecision] + N[(a * a + N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[Power[a, 3.0], $MachinePrecision] * N[(a + 4.0), $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(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \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), -1\right)\\

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


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

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \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), -1\right)} \]

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

    1. Initial program 0.0%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(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. fma-def0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.0% 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}:\\ \;\;\;\;-1 + {a}^{3} \cdot \left(a + 4\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 a 3.0) (+ 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(a, 3.0) * (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(a, 3.0) * (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(a, 3.0) * (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((a ^ 3.0) * 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 + ((a ^ 3.0) * (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[a, 3.0], $MachinePrecision] * N[(a + 4.0), $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 + {a}^{3} \cdot \left(a + 4\right)\\


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

    1. Initial program 99.9%

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

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

    1. Initial program 0.0%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(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. fma-def0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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 + {a}^{3} \cdot \left(a + 4\right)\\ \end{array} \]

Alternative 3: 82.1% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 74.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+74.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. fma-def74.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.1999999999999999e36 < b

    1. Initial program 63.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+63.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. fma-def63.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 93.4% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.5 \cdot 10^{+38} \lor \neg \left(a \leq 1.4 \cdot 10^{+25}\right):\\
\;\;\;\;{a}^{4}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -1.5000000000000001e38 or 1.4000000000000001e25 < a

    1. Initial program 38.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. Simplified42.0%

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

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

    if -1.5000000000000001e38 < a < 1.4000000000000001e25

    1. Initial program 97.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+97.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. fma-def97.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -1.5 \cdot 10^{+38} \lor \neg \left(a \leq 1.4 \cdot 10^{+25}\right):\\ \;\;\;\;{a}^{4}\\ \mathbf{else}:\\ \;\;\;\;-1 + {b}^{4}\\ \end{array} \]

Alternative 5: 93.9% accurate, 1.2× speedup?

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

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

\mathbf{elif}\;a \leq 5.2 \cdot 10^{+28}:\\
\;\;\;\;-1 + {b}^{4}\\

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


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

    1. Initial program 26.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+26.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. fma-def26.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 4 \cdot {a}^{3} + \color{blue}{{a}^{3} \cdot a} \]
      3. *-commutative19.2%

        \[\leadsto 4 \cdot {a}^{3} + \color{blue}{a \cdot {a}^{3}} \]
      4. distribute-rgt-out92.8%

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

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

    if -3.25e10 < a < 5.2000000000000004e28

    1. Initial program 97.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+97.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. fma-def97.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.2000000000000004e28 < a

    1. Initial program 52.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. Simplified58.7%

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

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

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

Alternative 6: 57.4% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq 7.2 \cdot 10^{+35}:\\
\;\;\;\;{a}^{4}\\

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


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

    1. Initial program 74.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. Simplified75.9%

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

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

    if 7.2000000000000001e35 < b

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 7.2 \cdot 10^{+35}:\\ \;\;\;\;{a}^{4}\\ \mathbf{else}:\\ \;\;\;\;{b}^{4}\\ \end{array} \]

Alternative 7: 46.3% accurate, 1.3× speedup?

\[\begin{array}{l} \\ {a}^{4} \end{array} \]
(FPCore (a b) :precision binary64 (pow a 4.0))
double code(double a, double b) {
	return pow(a, 4.0);
}
real(8) function code(a, b)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = a ** 4.0d0
end function
public static double code(double a, double b) {
	return Math.pow(a, 4.0);
}
def code(a, b):
	return math.pow(a, 4.0)
function code(a, b)
	return a ^ 4.0
end
function tmp = code(a, b)
	tmp = a ^ 4.0;
end
code[a_, b_] := N[Power[a, 4.0], $MachinePrecision]
\begin{array}{l}

\\
{a}^{4}
\end{array}
Derivation
  1. Initial program 71.8%

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

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

    \[\leadsto \color{blue}{{a}^{4}} \]
  4. Final simplification44.9%

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

Reproduce

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