Average Error: 0.2 → 0.0
Time: 7.3s
Precision: binary64
Cost: 20544
\[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
\[\left(\left(\mathsf{fma}\left(2, \left(a \cdot a\right) \cdot \left(b \cdot b\right), {b}^{4}\right) + {a}^{4}\right) + \left(b \cdot b\right) \cdot 4\right) + -1 \]
(FPCore (a b)
 :precision binary64
 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))
(FPCore (a b)
 :precision binary64
 (+
  (+ (+ (fma 2.0 (* (* a a) (* b b)) (pow b 4.0)) (pow a 4.0)) (* (* b b) 4.0))
  -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 ((fma(2.0, ((a * a) * (b * b)), pow(b, 4.0)) + pow(a, 4.0)) + ((b * b) * 4.0)) + -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(Float64(Float64(fma(2.0, Float64(Float64(a * a) * Float64(b * b)), (b ^ 4.0)) + (a ^ 4.0)) + Float64(Float64(b * b) * 4.0)) + -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[(N[(N[(2.0 * N[(N[(a * a), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1
\left(\left(\mathsf{fma}\left(2, \left(a \cdot a\right) \cdot \left(b \cdot b\right), {b}^{4}\right) + {a}^{4}\right) + \left(b \cdot b\right) \cdot 4\right) + -1

Error

Derivation

  1. Initial program 0.2

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

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

    \[\leadsto \left(\color{blue}{\left(\mathsf{fma}\left(2, \left(a \cdot a\right) \cdot \left(b \cdot b\right), {b}^{4}\right) + {a}^{4}\right)} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
    Proof
    (-.f64 (+.f64 (+.f64 (fma.f64 2 (*.f64 (*.f64 a a) (*.f64 b b)) (pow.f64 b 4)) (pow.f64 a 4)) (*.f64 4 (*.f64 b b))) 1): 0 points increase in error, 0 points decrease in error
    (-.f64 (+.f64 (+.f64 (fma.f64 2 (*.f64 (Rewrite<= unpow2_binary64 (pow.f64 a 2)) (*.f64 b b)) (pow.f64 b 4)) (pow.f64 a 4)) (*.f64 4 (*.f64 b b))) 1): 0 points increase in error, 0 points decrease in error
    (-.f64 (+.f64 (+.f64 (fma.f64 2 (*.f64 (pow.f64 a 2) (Rewrite<= unpow2_binary64 (pow.f64 b 2))) (pow.f64 b 4)) (pow.f64 a 4)) (*.f64 4 (*.f64 b b))) 1): 0 points increase in error, 0 points decrease in error
    (-.f64 (+.f64 (+.f64 (Rewrite<= fma-def_binary64 (+.f64 (*.f64 2 (*.f64 (pow.f64 a 2) (pow.f64 b 2))) (pow.f64 b 4))) (pow.f64 a 4)) (*.f64 4 (*.f64 b b))) 1): 0 points increase in error, 0 points decrease in error
    (-.f64 (+.f64 (Rewrite<= associate-+r+_binary64 (+.f64 (*.f64 2 (*.f64 (pow.f64 a 2) (pow.f64 b 2))) (+.f64 (pow.f64 b 4) (pow.f64 a 4)))) (*.f64 4 (*.f64 b b))) 1): 0 points increase in error, 0 points decrease in error
    (-.f64 (+.f64 (+.f64 (*.f64 2 (*.f64 (pow.f64 a 2) (pow.f64 b 2))) (Rewrite<= +-commutative_binary64 (+.f64 (pow.f64 a 4) (pow.f64 b 4)))) (*.f64 4 (*.f64 b b))) 1): 0 points increase in error, 0 points decrease in error
  4. Final simplification0.0

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

Alternatives

Alternative 1
Error0.0
Cost19776
\[{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(b \cdot b, 4, -1\right) \]
Alternative 2
Error0.2
Cost13696
\[{\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + \left(\left(b \cdot b\right) \cdot 4 + -1\right) \]
Alternative 3
Error0.2
Cost7424
\[-1 + \left(\left(b \cdot b\right) \cdot 4 + {\left(a \cdot a + b \cdot b\right)}^{2}\right) \]
Alternative 4
Error1.9
Cost7300
\[\begin{array}{l} \mathbf{if}\;a \cdot a \leq 5 \cdot 10^{-37}:\\ \;\;\;\;{b}^{4} + \left(\left(b \cdot b\right) \cdot 4 + -1\right)\\ \mathbf{else}:\\ \;\;\;\;{a}^{4} + -1\\ \end{array} \]
Alternative 5
Error2.0
Cost6916
\[\begin{array}{l} \mathbf{if}\;a \cdot a \leq 5 \cdot 10^{-37}:\\ \;\;\;\;\left(\left(b \cdot b\right) \cdot 4 + -1\right) + \left(b \cdot b\right) \cdot \left(b \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;{a}^{4} + -1\\ \end{array} \]
Alternative 6
Error2.0
Cost1220
\[\begin{array}{l} \mathbf{if}\;a \cdot a \leq 1.7 \cdot 10^{-33}:\\ \;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 4\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(b \cdot b\right) \cdot 4 + -1\right) + \left(a \cdot a\right) \cdot \left(a \cdot a\right)\\ \end{array} \]
Alternative 7
Error2.0
Cost1220
\[\begin{array}{l} t_0 := \left(b \cdot b\right) \cdot 4 + -1\\ \mathbf{if}\;a \cdot a \leq 1.7 \cdot 10^{-33}:\\ \;\;\;\;t_0 + \left(b \cdot b\right) \cdot \left(b \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 + \left(a \cdot a\right) \cdot \left(a \cdot a\right)\\ \end{array} \]
Alternative 8
Error13.0
Cost708
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 0.24:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b\right)\\ \end{array} \]
Alternative 9
Error12.8
Cost708
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 3.7:\\ \;\;\;\;\left(b \cdot b\right) \cdot 4 + -1\\ \mathbf{else}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b\right)\\ \end{array} \]
Alternative 10
Error12.1
Cost704
\[-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 4\right) \]
Alternative 11
Error23.8
Cost64
\[-1 \]

Error

Reproduce

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