?

Average Accuracy: 99.7% → 100.0%
Time: 10.3s
Precision: binary64
Cost: 14016

?

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

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 99.7%

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

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

    [Start]99.7

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

    associate--l+ [=>]99.7

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

    fma-def [=>]99.7

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

    *-commutative [=>]99.7

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

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

    [Start]99.7

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

    unpow2 [=>]99.7

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

    fma-udef [=>]99.7

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

    distribute-lft-in [=>]99.7

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

    add-sqr-sqrt [=>]99.7

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

    pow2 [=>]99.7

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

    pow2 [=>]99.7

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

    pow-prod-down [=>]99.7

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

    fma-udef [=>]99.7

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

    hypot-def [=>]99.7

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

    add-sqr-sqrt [=>]99.7

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

    pow2 [=>]99.7

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

    pow2 [=>]99.7

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

    pow-prod-down [=>]99.7

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

    fma-udef [=>]99.7

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

    hypot-def [=>]99.7

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

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

    [Start]99.7

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

    unpow2 [=>]99.7

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

    swap-sqr [=>]99.7

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

    unpow2 [<=]99.7

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

    unpow2 [=>]99.7

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

    swap-sqr [=>]99.7

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

    unpow2 [<=]99.7

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

    distribute-lft-out [=>]99.7

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

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

    [Start]99.7

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

    unpow2 [=>]99.7

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

    hypot-udef [=>]99.7

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

    hypot-udef [=>]99.7

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

    add-sqr-sqrt [<=]99.7

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

    +-commutative [=>]99.7

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

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

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

    [Start]100.0

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

    associate-+r+ [=>]100.0

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

    +-commutative [<=]100.0

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

    associate-+r+ [<=]100.0

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

    associate--l+ [=>]100.0

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

    unpow2 [=>]100.0

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

    unpow2 [=>]100.0

    \[ {a}^{4} + \left(\left({b}^{4} + \left(4 + 2 \cdot \left(a \cdot a\right)\right) \cdot \color{blue}{\left(b \cdot b\right)}\right) - 1\right) \]
  8. Final simplification100.0%

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

Alternatives

Alternative 1
Accuracy99.7%
Cost14016
\[{\left(\mathsf{hypot}\left(a, b\right)\right)}^{2} \cdot \left(a \cdot a + b \cdot b\right) + \left(4 \cdot \left(b \cdot b\right) + -1\right) \]
Alternative 2
Accuracy99.7%
Cost7744
\[\left(4 \cdot \left(b \cdot b\right) + -1\right) + \left(a \cdot a + b \cdot b\right) \cdot \mathsf{fma}\left(a, a, b \cdot b\right) \]
Alternative 3
Accuracy99.7%
Cost7424
\[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) + -1 \]
Alternative 4
Accuracy97.2%
Cost1481
\[\begin{array}{l} t_0 := 4 \cdot \left(b \cdot b\right)\\ \mathbf{if}\;a \leq -0.00065 \lor \neg \left(a \leq 5100\right):\\ \;\;\;\;\left(t_0 + -1\right) + \left(a \cdot a\right) \cdot \left(a \cdot a + b \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\left(t_0 + \left(b \cdot b\right) \cdot \left(b \cdot b\right)\right) + -1\\ \end{array} \]
Alternative 5
Accuracy99.7%
Cost1472
\[\begin{array}{l} t_0 := a \cdot a + b \cdot b\\ \left(4 \cdot \left(b \cdot b\right) + -1\right) + t_0 \cdot t_0 \end{array} \]
Alternative 6
Accuracy97.1%
Cost1225
\[\begin{array}{l} \mathbf{if}\;a \leq -0.00142 \lor \neg \left(a \leq 5100\right):\\ \;\;\;\;\left(4 \cdot \left(b \cdot b\right) + -1\right) + \left(a \cdot a\right) \cdot \left(a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(4 + b \cdot b\right) + -1\\ \end{array} \]
Alternative 7
Accuracy97.1%
Cost1225
\[\begin{array}{l} t_0 := 4 \cdot \left(b \cdot b\right)\\ \mathbf{if}\;a \leq -0.0015 \lor \neg \left(a \leq 5100\right):\\ \;\;\;\;\left(t_0 + -1\right) + \left(a \cdot a\right) \cdot \left(a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;\left(t_0 + \left(b \cdot b\right) \cdot \left(b \cdot b\right)\right) + -1\\ \end{array} \]
Alternative 8
Accuracy81.6%
Cost704
\[\left(b \cdot b\right) \cdot \left(4 + b \cdot b\right) + -1 \]
Alternative 9
Accuracy80.3%
Cost576
\[\left(b \cdot b\right) \cdot \left(b \cdot b\right) + -1 \]
Alternative 10
Accuracy64.9%
Cost448
\[b \cdot \left(4 \cdot b\right) + -1 \]

Error

Reproduce?

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