Bouland and Aaronson, Equation (24)

Percentage Accurate: 73.9% → 100.0%
Time: 12.1s
Alternatives: 11
Speedup: 1.2×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 73.9% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 0.2× speedup?

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

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

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


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

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 57.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(4, \color{blue}{a \cdot \left(a \cdot \left(1 - a\right)\right)}, {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + -1\right) \]
    10. Step-by-step derivation
      1. add-sqr-sqrt73.5%

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

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

      \[\leadsto \mathsf{fma}\left(4, a \cdot \left(a \cdot \left(1 - a\right)\right), \color{blue}{{\left(\sqrt{\mathsf{hypot}\left(a, b\right)}\right)}^{4} \cdot {\left(\sqrt{\mathsf{hypot}\left(a, b\right)}\right)}^{4}} + -1\right) \]
    12. Step-by-step derivation
      1. pow-sqr73.5%

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

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

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

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

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

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

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

Alternative 2: 99.9% accurate, 0.2× speedup?

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

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


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

    1. Initial program 99.6%

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

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

    1. Initial program 57.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(4, \color{blue}{a \cdot \left(a \cdot \left(1 - a\right)\right)}, {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + -1\right) \]
    10. Step-by-step derivation
      1. add-sqr-sqrt73.8%

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.3% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 87.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.99999999999999986e73 < a

    1. Initial program 17.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 98.2% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 99.8%

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

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

    1. Initial program 0.0%

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

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

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

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

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

        \[\leadsto \left({\left(a \cdot a + \left(-b\right) \cdot \left(-b\right)\right)}^{2} + \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(3 + a\right)\right) \cdot 4\right)}\right) + \left(-1\right) \]
      6. sqr-neg0.0%

        \[\leadsto \left({\left(a \cdot a + \left(-b\right) \cdot \left(-b\right)\right)}^{2} + \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(3 + a\right)\right) \cdot 4\right)\right) + \left(-1\right) \]
      7. distribute-rgt-in0.0%

        \[\leadsto \left({\left(a \cdot a + \left(-b\right) \cdot \left(-b\right)\right)}^{2} + \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(3 + a\right)\right)}\right) + \left(-1\right) \]
    3. Simplified7.2%

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

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

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

Alternative 5: 92.6% accurate, 1.1× speedup?

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

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

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


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

    1. Initial program 82.5%

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

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

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

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

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

        \[\leadsto \left({\left(a \cdot a + \left(-b\right) \cdot \left(-b\right)\right)}^{2} + \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(3 + a\right)\right) \cdot 4\right)}\right) + \left(-1\right) \]
      6. sqr-neg82.5%

        \[\leadsto \left({\left(a \cdot a + \left(-b\right) \cdot \left(-b\right)\right)}^{2} + \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(3 + a\right)\right) \cdot 4\right)\right) + \left(-1\right) \]
      7. distribute-rgt-in82.5%

        \[\leadsto \left({\left(a \cdot a + \left(-b\right) \cdot \left(-b\right)\right)}^{2} + \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(3 + a\right)\right)}\right) + \left(-1\right) \]
    3. Simplified82.5%

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

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

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

    1. Initial program 63.4%

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

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

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

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

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

        \[\leadsto \left({\left(a \cdot a + \left(-b\right) \cdot \left(-b\right)\right)}^{2} + \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(3 + a\right)\right) \cdot 4\right)}\right) + \left(-1\right) \]
      6. sqr-neg63.4%

        \[\leadsto \left({\left(a \cdot a + \left(-b\right) \cdot \left(-b\right)\right)}^{2} + \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(3 + a\right)\right) \cdot 4\right)\right) + \left(-1\right) \]
      7. distribute-rgt-in63.4%

        \[\leadsto \left({\left(a \cdot a + \left(-b\right) \cdot \left(-b\right)\right)}^{2} + \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(3 + a\right)\right)}\right) + \left(-1\right) \]
    3. Simplified67.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 93.5% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 83.1%

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

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

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

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

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

        \[\leadsto \left({\left(a \cdot a + \left(-b\right) \cdot \left(-b\right)\right)}^{2} + \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(3 + a\right)\right) \cdot 4\right)}\right) + \left(-1\right) \]
      6. sqr-neg83.1%

        \[\leadsto \left({\left(a \cdot a + \left(-b\right) \cdot \left(-b\right)\right)}^{2} + \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(3 + a\right)\right) \cdot 4\right)\right) + \left(-1\right) \]
      7. distribute-rgt-in83.1%

        \[\leadsto \left({\left(a \cdot a + \left(-b\right) \cdot \left(-b\right)\right)}^{2} + \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(3 + a\right)\right)}\right) + \left(-1\right) \]
    3. Simplified83.1%

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

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

    if 5e3 < (*.f64 b b)

    1. Initial program 62.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 81.9% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.5 \cdot 10^{+20}:\\
\;\;\;\;{a}^{4}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -2.5e20 or 1.50000000000000011e37 < a

    1. Initial program 43.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.5e20 < a < 1.50000000000000011e37

    1. Initial program 99.0%

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

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

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

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

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

        \[\leadsto \left({\left(a \cdot a + \left(-b\right) \cdot \left(-b\right)\right)}^{2} + \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(3 + a\right)\right) \cdot 4\right)}\right) + \left(-1\right) \]
      6. sqr-neg99.0%

        \[\leadsto \left({\left(a \cdot a + \left(-b\right) \cdot \left(-b\right)\right)}^{2} + \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(3 + a\right)\right) \cdot 4\right)\right) + \left(-1\right) \]
      7. distribute-rgt-in99.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{12 \cdot {b}^{2}} + -1 \]
    14. Step-by-step derivation
      1. unpow275.2%

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

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

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

Alternative 8: 66.3% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 76.6%

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

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

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

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

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

        \[\leadsto \left({\left(a \cdot a + \left(-b\right) \cdot \left(-b\right)\right)}^{2} + \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(3 + a\right)\right) \cdot 4\right)}\right) + \left(-1\right) \]
      6. sqr-neg76.6%

        \[\leadsto \left({\left(a \cdot a + \left(-b\right) \cdot \left(-b\right)\right)}^{2} + \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(3 + a\right)\right) \cdot 4\right)\right) + \left(-1\right) \]
      7. distribute-rgt-in76.6%

        \[\leadsto \left({\left(a \cdot a + \left(-b\right) \cdot \left(-b\right)\right)}^{2} + \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(3 + a\right)\right)}\right) + \left(-1\right) \]
    3. Simplified77.6%

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

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

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

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

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

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

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

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

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

    if 102 < b

    1. Initial program 62.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 60.2% accurate, 14.1× speedup?

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

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

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


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

    1. Initial program 77.2%

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

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

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

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

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

        \[\leadsto \left({\left(a \cdot a + \left(-b\right) \cdot \left(-b\right)\right)}^{2} + \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(3 + a\right)\right) \cdot 4\right)}\right) + \left(-1\right) \]
      6. sqr-neg77.2%

        \[\leadsto \left({\left(a \cdot a + \left(-b\right) \cdot \left(-b\right)\right)}^{2} + \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(3 + a\right)\right) \cdot 4\right)\right) + \left(-1\right) \]
      7. distribute-rgt-in77.2%

        \[\leadsto \left({\left(a \cdot a + \left(-b\right) \cdot \left(-b\right)\right)}^{2} + \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(3 + a\right)\right)}\right) + \left(-1\right) \]
    3. Simplified78.1%

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

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

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

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

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

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

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

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

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

    if 6.99999999999999963e152 < b

    1. Initial program 45.7%

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

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

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

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

        \[\leadsto \left({\left(a \cdot a + \left(-b\right) \cdot \left(-b\right)\right)}^{2} + \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(3 + a\right)\right) \cdot 4\right)}\right) + \left(-1\right) \]
      6. sqr-neg45.7%

        \[\leadsto \left({\left(a \cdot a + \left(-b\right) \cdot \left(-b\right)\right)}^{2} + \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(3 + a\right)\right) \cdot 4\right)\right) + \left(-1\right) \]
      7. distribute-rgt-in45.7%

        \[\leadsto \left({\left(a \cdot a + \left(-b\right) \cdot \left(-b\right)\right)}^{2} + \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(3 + a\right)\right)}\right) + \left(-1\right) \]
    3. Simplified54.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 50.5% accurate, 18.3× speedup?

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

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

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

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

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

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

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

      \[\leadsto \left({\left(a \cdot a + \left(-b\right) \cdot \left(-b\right)\right)}^{2} + \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(3 + a\right)\right) \cdot 4\right)}\right) + \left(-1\right) \]
    6. sqr-neg72.9%

      \[\leadsto \left({\left(a \cdot a + \left(-b\right) \cdot \left(-b\right)\right)}^{2} + \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(3 + a\right)\right) \cdot 4\right)\right) + \left(-1\right) \]
    7. distribute-rgt-in72.9%

      \[\leadsto \left({\left(a \cdot a + \left(-b\right) \cdot \left(-b\right)\right)}^{2} + \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(3 + a\right)\right)}\right) + \left(-1\right) \]
  3. Simplified74.8%

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

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

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

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

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

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

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

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

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

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

Alternative 11: 24.4% accurate, 128.0× speedup?

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

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

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

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

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

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

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

      \[\leadsto \left({\left(a \cdot a + \left(-b\right) \cdot \left(-b\right)\right)}^{2} + \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(3 + a\right)\right) \cdot 4\right)}\right) + \left(-1\right) \]
    6. sqr-neg72.9%

      \[\leadsto \left({\left(a \cdot a + \left(-b\right) \cdot \left(-b\right)\right)}^{2} + \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(3 + a\right)\right) \cdot 4\right)\right) + \left(-1\right) \]
    7. distribute-rgt-in72.9%

      \[\leadsto \left({\left(a \cdot a + \left(-b\right) \cdot \left(-b\right)\right)}^{2} + \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(3 + a\right)\right)}\right) + \left(-1\right) \]
  3. Simplified74.8%

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

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

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

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

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

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

    \[\leadsto \color{blue}{-1} \]
  8. Final simplification26.6%

    \[\leadsto -1 \]

Reproduce

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