Bouland and Aaronson, Equation (24)

Percentage Accurate: 73.5% → 99.4%
Time: 8.9s
Alternatives: 12
Speedup: 1.1×

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 12 alternatives:

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

Initial Program: 73.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(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: 99.4% accurate, 0.2× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -2.45e-5

    1. Initial program 65.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. Add Preprocessing
    3. Step-by-step derivation
      1. unpow265.4%

        \[\leadsto \left(\color{blue}{\left(a \cdot a + b \cdot b\right) \cdot \left(a \cdot a + b \cdot b\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) - 1 \]
      2. +-commutative65.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.45e-5 < a

    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. Add Preprocessing
    3. Taylor expanded in a around 0 99.2%

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

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

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

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

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


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

    1. Initial program 99.8%

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

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

    1. Initial program 0.0%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
    2. Add Preprocessing
    3. Taylor expanded in a around 0 69.7%

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

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

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

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

Alternative 3: 98.1% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 81.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. Add Preprocessing
    3. Taylor expanded in a around 0 96.7%

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

    if 1.99999999999999993e79 < (*.f64 b b)

    1. Initial program 64.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. Add Preprocessing
    3. Taylor expanded in a around 0 84.2%

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

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

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

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

Alternative 4: 94.1% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -9.8 \cdot 10^{+48} \lor \neg \left(a \leq 1.75 \cdot 10^{+27}\right):\\
\;\;\;\;{a}^{4}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -9.80000000000000059e48 or 1.7500000000000001e27 < a

    1. Initial program 41.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. Add Preprocessing
    3. Step-by-step derivation
      1. unpow241.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.80000000000000059e48 < a < 1.7500000000000001e27

    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. Add Preprocessing
    3. Taylor expanded in a around 0 95.5%

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

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

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

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

Alternative 5: 60.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {a}^{4} \cdot \left(1 - \frac{4}{a}\right)\\ \mathbf{if}\;b \leq 1.85 \cdot 10^{-212}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;b \leq 6.8 \cdot 10^{-5}:\\ \;\;\;\;4 \cdot \left(\left(1 - a\right) \cdot \left(a \cdot a\right)\right) + -1\\ \mathbf{elif}\;b \leq 1.35 \cdot 10^{+35}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;{b}^{4}\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (let* ((t_0 (* (pow a 4.0) (- 1.0 (/ 4.0 a)))))
   (if (<= b 1.85e-212)
     t_0
     (if (<= b 6.8e-5)
       (+ (* 4.0 (* (- 1.0 a) (* a a))) -1.0)
       (if (<= b 1.35e+35) t_0 (pow b 4.0))))))
double code(double a, double b) {
	double t_0 = pow(a, 4.0) * (1.0 - (4.0 / a));
	double tmp;
	if (b <= 1.85e-212) {
		tmp = t_0;
	} else if (b <= 6.8e-5) {
		tmp = (4.0 * ((1.0 - a) * (a * a))) + -1.0;
	} else if (b <= 1.35e+35) {
		tmp = t_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) :: t_0
    real(8) :: tmp
    t_0 = (a ** 4.0d0) * (1.0d0 - (4.0d0 / a))
    if (b <= 1.85d-212) then
        tmp = t_0
    else if (b <= 6.8d-5) then
        tmp = (4.0d0 * ((1.0d0 - a) * (a * a))) + (-1.0d0)
    else if (b <= 1.35d+35) then
        tmp = t_0
    else
        tmp = b ** 4.0d0
    end if
    code = tmp
end function
public static double code(double a, double b) {
	double t_0 = Math.pow(a, 4.0) * (1.0 - (4.0 / a));
	double tmp;
	if (b <= 1.85e-212) {
		tmp = t_0;
	} else if (b <= 6.8e-5) {
		tmp = (4.0 * ((1.0 - a) * (a * a))) + -1.0;
	} else if (b <= 1.35e+35) {
		tmp = t_0;
	} else {
		tmp = Math.pow(b, 4.0);
	}
	return tmp;
}
def code(a, b):
	t_0 = math.pow(a, 4.0) * (1.0 - (4.0 / a))
	tmp = 0
	if b <= 1.85e-212:
		tmp = t_0
	elif b <= 6.8e-5:
		tmp = (4.0 * ((1.0 - a) * (a * a))) + -1.0
	elif b <= 1.35e+35:
		tmp = t_0
	else:
		tmp = math.pow(b, 4.0)
	return tmp
function code(a, b)
	t_0 = Float64((a ^ 4.0) * Float64(1.0 - Float64(4.0 / a)))
	tmp = 0.0
	if (b <= 1.85e-212)
		tmp = t_0;
	elseif (b <= 6.8e-5)
		tmp = Float64(Float64(4.0 * Float64(Float64(1.0 - a) * Float64(a * a))) + -1.0);
	elseif (b <= 1.35e+35)
		tmp = t_0;
	else
		tmp = b ^ 4.0;
	end
	return tmp
end
function tmp_2 = code(a, b)
	t_0 = (a ^ 4.0) * (1.0 - (4.0 / a));
	tmp = 0.0;
	if (b <= 1.85e-212)
		tmp = t_0;
	elseif (b <= 6.8e-5)
		tmp = (4.0 * ((1.0 - a) * (a * a))) + -1.0;
	elseif (b <= 1.35e+35)
		tmp = t_0;
	else
		tmp = b ^ 4.0;
	end
	tmp_2 = tmp;
end
code[a_, b_] := Block[{t$95$0 = N[(N[Power[a, 4.0], $MachinePrecision] * N[(1.0 - N[(4.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 1.85e-212], t$95$0, If[LessEqual[b, 6.8e-5], N[(N[(4.0 * N[(N[(1.0 - a), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[b, 1.35e+35], t$95$0, N[Power[b, 4.0], $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {a}^{4} \cdot \left(1 - \frac{4}{a}\right)\\
\mathbf{if}\;b \leq 1.85 \cdot 10^{-212}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;b \leq 1.35 \cdot 10^{+35}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < 1.84999999999999995e-212 or 6.7999999999999999e-5 < b < 1.35000000000000001e35

    1. Initial program 71.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. associate--l+71.6%

        \[\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)} \]
      2. fma-define71.6%

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

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

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

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

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

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

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

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

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

    if 1.84999999999999995e-212 < b < 6.7999999999999999e-5

    1. Initial program 92.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+92.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)} \]
      2. fma-define92.7%

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

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

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

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

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

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

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

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

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

    if 1.35000000000000001e35 < b

    1. Initial program 66.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. Add Preprocessing
    3. Step-by-step derivation
      1. unpow266.6%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(a, a, b \cdot b\right)}, a \cdot a + b \cdot b, 4 \cdot \mathsf{fma}\left(a \cdot a, 1 - a, b \cdot \left(b \cdot \left(a + 3\right)\right)\right)\right) - 1 \]
      7. add-sqr-sqrt68.6%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 1.85 \cdot 10^{-212}:\\ \;\;\;\;{a}^{4} \cdot \left(1 - \frac{4}{a}\right)\\ \mathbf{elif}\;b \leq 6.8 \cdot 10^{-5}:\\ \;\;\;\;4 \cdot \left(\left(1 - a\right) \cdot \left(a \cdot a\right)\right) + -1\\ \mathbf{elif}\;b \leq 1.35 \cdot 10^{+35}:\\ \;\;\;\;{a}^{4} \cdot \left(1 - \frac{4}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;{b}^{4}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 93.8% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -9.2 \cdot 10^{+46} \lor \neg \left(a \leq 9.6 \cdot 10^{+27}\right):\\
\;\;\;\;{a}^{4}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -9.2000000000000002e46 or 9.59999999999999991e27 < a

    1. Initial program 41.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. Add Preprocessing
    3. Step-by-step derivation
      1. unpow241.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.2000000000000002e46 < a < 9.59999999999999991e27

    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. associate--l+97.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)} \]
      2. fma-define97.1%

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

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

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

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

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

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

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

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

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

Alternative 7: 60.4% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.7 \cdot 10^{-212}:\\
\;\;\;\;{a}^{3} \cdot \left(a - 4\right)\\

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

\mathbf{elif}\;b \leq 6 \cdot 10^{+35}:\\
\;\;\;\;{a}^{4}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if b < 3.6999999999999999e-212

    1. Initial program 71.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+71.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)} \]
      2. fma-define71.7%

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

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

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

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

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

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

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

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

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

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

    if 3.6999999999999999e-212 < b < 2.0000000000000001e-4

    1. Initial program 92.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+92.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)} \]
      2. fma-define92.7%

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

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

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

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

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

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

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

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

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

    if 2.0000000000000001e-4 < b < 5.99999999999999981e35

    1. Initial program 70.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 \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. unpow270.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.99999999999999981e35 < b

    1. Initial program 66.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. Add Preprocessing
    3. Step-by-step derivation
      1. unpow266.6%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(a, a, b \cdot b\right)}, a \cdot a + b \cdot b, 4 \cdot \mathsf{fma}\left(a \cdot a, 1 - a, b \cdot \left(b \cdot \left(a + 3\right)\right)\right)\right) - 1 \]
      7. add-sqr-sqrt68.6%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 3.7 \cdot 10^{-212}:\\ \;\;\;\;{a}^{3} \cdot \left(a - 4\right)\\ \mathbf{elif}\;b \leq 0.0002:\\ \;\;\;\;4 \cdot \left(\left(1 - a\right) \cdot \left(a \cdot a\right)\right) + -1\\ \mathbf{elif}\;b \leq 6 \cdot 10^{+35}:\\ \;\;\;\;{a}^{4}\\ \mathbf{else}:\\ \;\;\;\;{b}^{4}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 60.2% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.35 \cdot 10^{-212}:\\
\;\;\;\;{a}^{4}\\

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

\mathbf{elif}\;b \leq 3.2 \cdot 10^{+36}:\\
\;\;\;\;{a}^{4}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < 1.34999999999999991e-212 or 1.29999999999999992e-5 < b < 3.1999999999999999e36

    1. Initial program 71.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. Add Preprocessing
    3. Step-by-step derivation
      1. unpow271.6%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(a, a, b \cdot b\right)}, a \cdot a + b \cdot b, 4 \cdot \mathsf{fma}\left(a \cdot a, 1 - a, b \cdot \left(b \cdot \left(a + 3\right)\right)\right)\right) - 1 \]
      7. add-sqr-sqrt73.5%

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.34999999999999991e-212 < b < 1.29999999999999992e-5

    1. Initial program 92.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+92.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)} \]
      2. fma-define92.7%

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

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

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

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

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

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

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

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

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

    if 3.1999999999999999e36 < b

    1. Initial program 66.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. Add Preprocessing
    3. Step-by-step derivation
      1. unpow266.6%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(a, a, b \cdot b\right)}, a \cdot a + b \cdot b, 4 \cdot \mathsf{fma}\left(a \cdot a, 1 - a, b \cdot \left(b \cdot \left(a + 3\right)\right)\right)\right) - 1 \]
      7. add-sqr-sqrt68.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 81.5% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -5.5 \cdot 10^{+26} \lor \neg \left(a \leq 1.65 \cdot 10^{+29}\right):\\
\;\;\;\;{a}^{4}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -5.4999999999999997e26 or 1.64999999999999992e29 < a

    1. Initial program 42.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. Add Preprocessing
    3. Step-by-step derivation
      1. unpow242.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.4999999999999997e26 < a < 1.64999999999999992e29

    1. Initial program 98.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+98.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)} \]
      2. fma-define98.4%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 62.9% accurate, 8.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -1.20000000000000004e68

    1. Initial program 65.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+65.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)} \]
      2. fma-define65.9%

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

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

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

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

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

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

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

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

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

    if -1.20000000000000004e68 < a

    1. Initial program 75.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 \]
    2. Step-by-step derivation
      1. associate--l+75.8%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(12 \cdot \color{blue}{\left(b \cdot b\right)} + {b}^{4}\right) - 1 \]
    10. Applied egg-rr54.2%

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

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

Alternative 11: 51.7% accurate, 18.3× speedup?

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

\\
\left(b \cdot b\right) \cdot 12 + -1
\end{array}
Derivation
  1. Initial program 74.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+74.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)} \]
    2. fma-define74.1%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{b}^{2} \cdot 12} - 1 \]
  8. Simplified48.4%

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

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

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

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

Alternative 12: 25.1% 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.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+74.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)} \]
    2. fma-define74.1%

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

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

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

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

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

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

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

Reproduce

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