Bouland and Aaronson, Equation (24)

Percentage Accurate: 73.3% → 100.0%
Time: 7.3s
Alternatives: 10
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 10 alternatives:

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

Initial Program: 73.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(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.4× 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^{+67}:\\ \;\;\;\;-1 + t_0\\ \mathbf{else}:\\ \;\;\;\;{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + -1\\ \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+67) (+ -1.0 t_0) (+ (pow (hypot a b) 4.0) -1.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+67) {
		tmp = -1.0 + t_0;
	} else {
		tmp = pow(hypot(a, b), 4.0) + -1.0;
	}
	return tmp;
}
public static double code(double a, double b) {
	double t_0 = Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
	double tmp;
	if (t_0 <= 5e+67) {
		tmp = -1.0 + t_0;
	} else {
		tmp = Math.pow(Math.hypot(a, b), 4.0) + -1.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 <= 5e+67:
		tmp = -1.0 + t_0
	else:
		tmp = math.pow(math.hypot(a, b), 4.0) + -1.0
	return tmp
function code(a, b)
	t_0 = Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + Float64(Float64(b * b) * Float64(a + 3.0)))))
	tmp = 0.0
	if (t_0 <= 5e+67)
		tmp = Float64(-1.0 + t_0);
	else
		tmp = Float64((hypot(a, b) ^ 4.0) + -1.0);
	end
	return tmp
end
function tmp_2 = code(a, b)
	t_0 = (((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
	tmp = 0.0;
	if (t_0 <= 5e+67)
		tmp = -1.0 + t_0;
	else
		tmp = (hypot(a, b) ^ 4.0) + -1.0;
	end
	tmp_2 = tmp;
end
code[a_, b_] := Block[{t$95$0 = N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(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+67], N[(-1.0 + t$95$0), $MachinePrecision], N[(N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}

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

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


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

    1. Initial program 99.9%

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

    if 4.99999999999999976e67 < (+.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 63.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + {\color{blue}{\left({\left(12 \cdot {b}^{2} - 1\right)}^{0.3333333333333333}\right)}}^{3} \]
    7. Step-by-step derivation
      1. unpow1/3100.0%

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

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

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

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

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

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

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

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

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

Alternative 2: 99.1% accurate, 0.3× speedup?

\[\begin{array}{l} \\ {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + {\left(\sqrt[3]{\mathsf{fma}\left(b, b \cdot 12, -1\right)}\right)}^{3} \end{array} \]
(FPCore (a b)
 :precision binary64
 (+ (pow (hypot a b) 4.0) (pow (cbrt (fma b (* b 12.0) -1.0)) 3.0)))
double code(double a, double b) {
	return pow(hypot(a, b), 4.0) + pow(cbrt(fma(b, (b * 12.0), -1.0)), 3.0);
}
function code(a, b)
	return Float64((hypot(a, b) ^ 4.0) + (cbrt(fma(b, Float64(b * 12.0), -1.0)) ^ 3.0))
end
code[a_, b_] := N[(N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + N[Power[N[Power[N[(b * N[(b * 12.0), $MachinePrecision] + -1.0), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + {\left(\sqrt[3]{\mathsf{fma}\left(b, b \cdot 12, -1\right)}\right)}^{3}
\end{array}
Derivation
  1. Initial program 74.9%

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

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

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

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

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

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

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

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

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

    \[\leadsto {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + {\color{blue}{\left({\left(12 \cdot {b}^{2} - 1\right)}^{0.3333333333333333}\right)}}^{3} \]
  7. Step-by-step derivation
    1. unpow1/399.2%

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

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

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

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

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

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

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

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

Alternative 3: 98.3% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(a + 3\right)\right)\\ \mathbf{if}\;t_0 \leq \infty:\\ \;\;\;\;-1 + t_0\\ \mathbf{else}:\\ \;\;\;\;{a}^{4}\\ \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) (+ -1.0 t_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 = -1.0 + t_0;
	} else {
		tmp = 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 = -1.0 + t_0;
	} else {
		tmp = 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 = -1.0 + t_0
	else:
		tmp = 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(-1.0 + t_0);
	else
		tmp = 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 = -1.0 + t_0;
	else
		tmp = 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[(-1.0 + t$95$0), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]
\begin{array}{l}

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

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


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

    1. Initial program 99.9%

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

    \[\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:\\ \;\;\;\;-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(a + 3\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;{a}^{4}\\ \end{array} \]

Alternative 4: 93.9% accurate, 1.1× speedup?

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

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

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

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


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

    1. Initial program 51.9%

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

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

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

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

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

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

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

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

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

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

    if -3.30000000000000013e44 < a < 38000

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

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

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

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

        \[\leadsto \left({\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + 4 \cdot \mathsf{fma}\left(a \cdot a, 1 - a, \left(b \cdot b\right) \cdot \left(a + 3\right)\right)\right) + \color{blue}{-1} \]
    3. Simplified97.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 0 83.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 38000 < a

    1. Initial program 45.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-neg45.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. fma-def45.1%

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

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

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

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

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

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

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

Alternative 5: 81.1% accurate, 1.2× speedup?

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

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

\mathbf{elif}\;b \cdot b \leq 5 \cdot 10^{+149}:\\
\;\;\;\;{a}^{4}\\

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


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

    1. Initial program 88.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-neg88.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. fma-def88.7%

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

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

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

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

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

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

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

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

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

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

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

    if 9.9999999999999998e-20 < (*.f64 b b) < 4.9999999999999999e149

    1. Initial program 63.7%

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

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

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

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

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

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

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

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

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

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

    if 4.9999999999999999e149 < (*.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. associate--l+63.4%

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

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

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

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

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

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

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

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

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

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

Alternative 6: 91.9% accurate, 1.2× speedup?

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

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


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

    1. Initial program 82.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-neg82.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. fma-def82.4%

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

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

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

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

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

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

    if 4.9999999999999999e149 < (*.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. associate--l+63.4%

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

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

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

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

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

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

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

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

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

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

Alternative 7: 81.4% accurate, 1.2× speedup?

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

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

\mathbf{elif}\;a \leq 35000:\\
\;\;\;\;-1 + b \cdot \left(b \cdot 12\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -3.30000000000000013e44 or 35000 < a

    1. Initial program 48.1%

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

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

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

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

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

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

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

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

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

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

    if -3.30000000000000013e44 < a < 35000

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

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

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

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

        \[\leadsto \left({\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + 4 \cdot \mathsf{fma}\left(a \cdot a, 1 - a, \left(b \cdot b\right) \cdot \left(a + 3\right)\right)\right) + \color{blue}{-1} \]
    3. Simplified97.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 0 83.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 69.7% accurate, 11.6× speedup?

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

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

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


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

    1. Initial program 78.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-neg78.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. fma-def78.4%

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

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

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

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

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

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

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

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

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

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

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

    if 9.99999999999999981e295 < (*.f64 b b)

    1. Initial program 64.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-neg64.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. fma-def64.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 51.5% accurate, 18.3× speedup?

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

\\
-1 + 4 \cdot \left(a \cdot a\right)
\end{array}
Derivation
  1. Initial program 74.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-neg74.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. fma-def74.9%

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

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

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

      \[\leadsto \left({\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + 4 \cdot \mathsf{fma}\left(a \cdot a, 1 - a, \left(b \cdot b\right) \cdot \left(a + 3\right)\right)\right) + \color{blue}{-1} \]
  3. Simplified76.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 55.1%

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

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

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

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

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

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

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

Alternative 10: 24.6% accurate, 128.0× speedup?

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

\\
-1
\end{array}
Derivation
  1. Initial program 74.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-neg74.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. fma-def74.9%

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

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

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

      \[\leadsto \left({\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + 4 \cdot \mathsf{fma}\left(a \cdot a, 1 - a, \left(b \cdot b\right) \cdot \left(a + 3\right)\right)\right) + \color{blue}{-1} \]
  3. Simplified76.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 0 56.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto -1 \]

Reproduce

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