Bouland and Aaronson, Equation (26)

Percentage Accurate: 99.9% → 100.0%
Time: 5.9s
Alternatives: 7
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \end{array} \]
(FPCore (a b)
 :precision binary64
 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))
double code(double a, double b) {
	return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 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 * (b * b))) - 1.0d0
end function
public static double code(double a, double b) {
	return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0;
}
def code(a, b):
	return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0
function code(a, b)
	return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(b * b))) - 1.0)
end
function tmp = code(a, b)
	tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (b * b))) - 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[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 7 alternatives:

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

Initial Program: 99.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \end{array} \]
(FPCore (a b)
 :precision binary64
 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))
double code(double a, double b) {
	return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 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 * (b * b))) - 1.0d0
end function
public static double code(double a, double b) {
	return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0;
}
def code(a, b):
	return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0
function code(a, b)
	return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(b * b))) - 1.0)
end
function tmp = code(a, b)
	tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (b * b))) - 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[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 100.0% accurate, 0.5× speedup?

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

\\
\left({\left(\mathsf{hypot}\left(b, a\right)\right)}^{4} + 4 \cdot \left(b \cdot b\right)\right) + -1
\end{array}
Derivation
  1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left({\color{blue}{\left(\sqrt{a \cdot a + b \cdot b}\right)}}^{4} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    13. unpow2100.0%

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

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

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

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

      \[\leadsto \left({\left(\sqrt{b \cdot b + \color{blue}{a \cdot a}}\right)}^{4} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    18. hypot-define100.0%

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

    \[\leadsto \left(\color{blue}{{\left(\mathsf{hypot}\left(b, a\right)\right)}^{4}} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
  7. Final simplification100.0%

    \[\leadsto \left({\left(\mathsf{hypot}\left(b, a\right)\right)}^{4} + 4 \cdot \left(b \cdot b\right)\right) + -1 \]
  8. Add Preprocessing

Alternative 2: 81.1% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;b \leq 1.5 \cdot 10^{+45} \lor \neg \left(b \leq 8.8 \cdot 10^{+55}\right):\\
\;\;\;\;{b}^{4}\\

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


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

    1. Initial program 99.9%

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

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

    if 1.5e14 < b < 1.50000000000000005e45 or 8.80000000000000042e55 < b

    1. Initial program 99.8%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. unpow299.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(b \cdot b\right)\right) - 1 \]
      2. distribute-lft-in86.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left({\color{blue}{\left(\sqrt{a \cdot a + b \cdot b}\right)}}^{4} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
      13. unpow299.9%

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

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

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

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

        \[\leadsto \left({\left(\sqrt{b \cdot b + \color{blue}{a \cdot a}}\right)}^{4} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
      18. hypot-define100.0%

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

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

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

    if 1.50000000000000005e45 < b < 8.80000000000000042e55

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left({\color{blue}{\left(\sqrt{a \cdot a + b \cdot b}\right)}}^{4} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
      13. unpow2100.0%

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

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

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

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

        \[\leadsto \left({\left(\sqrt{b \cdot b + \color{blue}{a \cdot a}}\right)}^{4} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
      18. hypot-define100.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 1.5 \cdot 10^{+14}:\\ \;\;\;\;{a}^{4} + -1\\ \mathbf{elif}\;b \leq 1.5 \cdot 10^{+45} \lor \neg \left(b \leq 8.8 \cdot 10^{+55}\right):\\ \;\;\;\;{b}^{4}\\ \mathbf{else}:\\ \;\;\;\;{a}^{4}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 57.4% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;b \leq 3.7 \cdot 10^{-20}:\\
\;\;\;\;-1\\

\mathbf{elif}\;b \leq 1.3 \cdot 10^{+14}:\\
\;\;\;\;{a}^{4}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < 5.0000000000000002e-109 or 3.7000000000000001e-20 < b < 1.3e14

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left({\color{blue}{\left(\sqrt{a \cdot a + b \cdot b}\right)}}^{4} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
      13. unpow2100.0%

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

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

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

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

        \[\leadsto \left({\left(\sqrt{b \cdot b + \color{blue}{a \cdot a}}\right)}^{4} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
      18. hypot-define100.0%

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

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

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

    if 5.0000000000000002e-109 < b < 3.7000000000000001e-20

    1. Initial program 100.0%

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

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

      \[\leadsto \color{blue}{-1} \]

    if 1.3e14 < b

    1. Initial program 99.8%

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. unpow299.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(b \cdot b\right)\right) - 1 \]
      2. distribute-lft-in87.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left({\color{blue}{\left(\sqrt{a \cdot a + b \cdot b}\right)}}^{4} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
      13. unpow299.9%

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

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

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

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

        \[\leadsto \left({\left(\sqrt{b \cdot b + \color{blue}{a \cdot a}}\right)}^{4} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
      18. hypot-define100.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 5 \cdot 10^{-109}:\\ \;\;\;\;{a}^{4}\\ \mathbf{elif}\;b \leq 3.7 \cdot 10^{-20}:\\ \;\;\;\;-1\\ \mathbf{elif}\;b \leq 1.3 \cdot 10^{+14}:\\ \;\;\;\;{a}^{4}\\ \mathbf{else}:\\ \;\;\;\;{b}^{4}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 99.9% accurate, 1.0× speedup?

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

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

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

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

Alternative 5: 82.2% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 99.9%

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

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

    if 4.20000000000000003e43 < a

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left({\color{blue}{\left(\sqrt{a \cdot a + b \cdot b}\right)}}^{4} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
      13. unpow2100.0%

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

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

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

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

        \[\leadsto \left({\left(\sqrt{b \cdot b + \color{blue}{a \cdot a}}\right)}^{4} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
      18. hypot-define100.0%

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

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

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

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

Alternative 6: 47.0% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq 1:\\
\;\;\;\;-1\\

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


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

    1. Initial program 99.9%

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

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

      \[\leadsto \color{blue}{-1} \]

    if 1 < a

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left({\color{blue}{\left(\sqrt{a \cdot a + b \cdot b}\right)}}^{4} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
      13. unpow2100.0%

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

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

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

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

        \[\leadsto \left({\left(\sqrt{b \cdot b + \color{blue}{a \cdot a}}\right)}^{4} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
      18. hypot-define100.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq 1:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;{a}^{4}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 24.5% accurate, 116.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 99.9%

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

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

    \[\leadsto \color{blue}{-1} \]
  5. Final simplification20.9%

    \[\leadsto -1 \]
  6. Add Preprocessing

Reproduce

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