Average Error: 0.2 → 0.0
Time: 10.2s
Precision: binary64
Cost: 21312
\[\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 \]
\[\left(\mathsf{fma}\left(2, \left(b \cdot b\right) \cdot \left(a \cdot a\right), {b}^{4} + {a}^{4}\right) + 4 \cdot \left(\left(b \cdot b\right) \cdot \left(a + 3\right) + \left(a \cdot a\right) \cdot \left(1 - a\right)\right)\right) + -1 \]
(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))
(FPCore (a b)
 :precision binary64
 (+
  (+
   (fma 2.0 (* (* b b) (* a a)) (+ (pow b 4.0) (pow a 4.0)))
   (* 4.0 (+ (* (* b b) (+ a 3.0)) (* (* a a) (- 1.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;
}
double code(double a, double b) {
	return (fma(2.0, ((b * b) * (a * a)), (pow(b, 4.0) + pow(a, 4.0))) + (4.0 * (((b * b) * (a + 3.0)) + ((a * a) * (1.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 code(a, b)
	return Float64(Float64(fma(2.0, Float64(Float64(b * b) * Float64(a * a)), Float64((b ^ 4.0) + (a ^ 4.0))) + Float64(4.0 * Float64(Float64(Float64(b * b) * Float64(a + 3.0)) + Float64(Float64(a * a) * Float64(1.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]
code[a_, b_] := N[(N[(N[(2.0 * N[(N[(b * b), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision] + N[(N[Power[b, 4.0], $MachinePrecision] + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(4.0 * N[(N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]
\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
\left(\mathsf{fma}\left(2, \left(b \cdot b\right) \cdot \left(a \cdot a\right), {b}^{4} + {a}^{4}\right) + 4 \cdot \left(\left(b \cdot b\right) \cdot \left(a + 3\right) + \left(a \cdot a\right) \cdot \left(1 - a\right)\right)\right) + -1

Error

Derivation

  1. Initial program 0.2

    \[\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. 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(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
  3. Simplified0.0

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

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

Alternatives

Alternative 1
Error0.2
Cost8192
\[\left(4 \cdot \left(\left(b \cdot b\right) \cdot \left(a + 3\right) + \left(a \cdot a\right) \cdot \left(1 - a\right)\right) + {\left(b \cdot b + a \cdot a\right)}^{2}\right) + -1 \]
Alternative 2
Error0.2
Cost7684
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 4 \cdot 10^{-33}:\\ \;\;\;\;\left({a}^{4} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left({\left(b \cdot b + a \cdot a\right)}^{2} + \left(b \cdot b\right) \cdot 12\right) + -1\\ \end{array} \]
Alternative 3
Error2.0
Cost7556
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 4 \cdot 10^{-33}:\\ \;\;\;\;a \cdot \left(a \cdot \mathsf{fma}\left(a, a, 4 \cdot \left(1 - a\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;b \cdot \left({b}^{3} + b \cdot \left(12 + a \cdot 4\right)\right) + -1\\ \end{array} \]
Alternative 4
Error2.0
Cost7556
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 4 \cdot 10^{-33}:\\ \;\;\;\;\left({a}^{4} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;b \cdot \left({b}^{3} + b \cdot \left(12 + a \cdot 4\right)\right) + -1\\ \end{array} \]
Alternative 5
Error1.9
Cost7556
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 4 \cdot 10^{-33}:\\ \;\;\;\;\left({a}^{4} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left({b}^{4} + \left(b \cdot b\right) \cdot \left(12 + a \cdot 4\right)\right) + -1\\ \end{array} \]
Alternative 6
Error2.0
Cost7492
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 4 \cdot 10^{-33}:\\ \;\;\;\;a \cdot \left(a \cdot \mathsf{fma}\left(a, a, 4 \cdot \left(1 - a\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \mathsf{fma}\left(b, b, 12\right) + -1\\ \end{array} \]
Alternative 7
Error2.0
Cost7236
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 4 \cdot 10^{-33}:\\ \;\;\;\;a \cdot \left(a \cdot \left(4 + a \cdot \left(a + -4\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \mathsf{fma}\left(b, b, 12\right) + -1\\ \end{array} \]
Alternative 8
Error2.4
Cost6792
\[\begin{array}{l} \mathbf{if}\;b \leq -3.9:\\ \;\;\;\;{b}^{4}\\ \mathbf{elif}\;b \leq 2.3:\\ \;\;\;\;a \cdot \left(a \cdot \left(4 + a \cdot \left(a + -4\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;{b}^{4}\\ \end{array} \]
Alternative 9
Error2.4
Cost6792
\[\begin{array}{l} \mathbf{if}\;b \leq -6.2 \cdot 10^{-5}:\\ \;\;\;\;{b}^{4} + -1\\ \mathbf{elif}\;b \leq 2.2:\\ \;\;\;\;a \cdot \left(a \cdot \left(4 + a \cdot \left(a + -4\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;{b}^{4}\\ \end{array} \]
Alternative 10
Error12.2
Cost832
\[a \cdot \left(a \cdot \left(4 + a \cdot \left(a + -4\right)\right)\right) + -1 \]
Alternative 11
Error13.1
Cost704
\[a \cdot \left(a \cdot \left(a \cdot \left(a + -4\right)\right)\right) + -1 \]
Alternative 12
Error13.1
Cost704
\[a \cdot \left(\left(a \cdot a\right) \cdot \left(a + -4\right)\right) + -1 \]
Alternative 13
Error13.5
Cost576
\[a \cdot \left(a \cdot \left(a \cdot a\right)\right) + -1 \]
Alternative 14
Error22.8
Cost448
\[\left(b \cdot b\right) \cdot 12 + -1 \]
Alternative 15
Error23.0
Cost448
\[a \cdot \left(a \cdot 4\right) + -1 \]
Alternative 16
Error23.8
Cost64
\[-1 \]

Error

Reproduce

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