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

    \[\leadsto \left(\color{blue}{\mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b, b, 2 \cdot \left(a \cdot a\right)\right), {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 (*.f64 b b) (fma.f64 b b (*.f64 2 (*.f64 a a))) (pow.f64 a 4)): 0 points increase in error, 0 points decrease in error
    (fma.f64 (Rewrite<= unpow2 (pow.f64 b 2)) (fma.f64 b b (*.f64 2 (*.f64 a a))) (pow.f64 a 4)): 1 points increase in error, 0 points decrease in error
    (fma.f64 (pow.f64 b 2) (fma.f64 b b (*.f64 2 (Rewrite<= unpow2 (pow.f64 a 2)))) (pow.f64 a 4)): 0 points increase in error, 0 points decrease in error
    (fma.f64 (pow.f64 b 2) (Rewrite<= fma-def (+.f64 (*.f64 b b) (*.f64 2 (pow.f64 a 2)))) (pow.f64 a 4)): 0 points increase in error, 0 points decrease in error
    (fma.f64 (pow.f64 b 2) (+.f64 (Rewrite<= unpow2 (pow.f64 b 2)) (*.f64 2 (pow.f64 a 2))) (pow.f64 a 4)): 0 points increase in error, 0 points decrease in error
    (Rewrite<= fma-def (+.f64 (*.f64 (pow.f64 b 2) (+.f64 (pow.f64 b 2) (*.f64 2 (pow.f64 a 2)))) (pow.f64 a 4))): 0 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite<= distribute-rgt-out (+.f64 (*.f64 (pow.f64 b 2) (pow.f64 b 2)) (*.f64 (*.f64 2 (pow.f64 a 2)) (pow.f64 b 2)))) (pow.f64 a 4)): 0 points increase in error, 0 points decrease in error
    (+.f64 (+.f64 (Rewrite=> pow-sqr (pow.f64 b (*.f64 2 2))) (*.f64 (*.f64 2 (pow.f64 a 2)) (pow.f64 b 2))) (pow.f64 a 4)): 14 points increase in error, 26 points decrease in error
    (+.f64 (+.f64 (pow.f64 b (Rewrite=> metadata-eval 4)) (*.f64 (*.f64 2 (pow.f64 a 2)) (pow.f64 b 2))) (pow.f64 a 4)): 0 points increase in error, 0 points decrease in error
    (+.f64 (+.f64 (pow.f64 b 4) (Rewrite<= associate-*r* (*.f64 2 (*.f64 (pow.f64 a 2) (pow.f64 b 2))))) (pow.f64 a 4)): 0 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite<= +-commutative (+.f64 (*.f64 2 (*.f64 (pow.f64 a 2) (pow.f64 b 2))) (pow.f64 b 4))) (pow.f64 a 4)): 0 points increase in error, 0 points decrease in error
    (Rewrite<= associate-+r+ (+.f64 (*.f64 2 (*.f64 (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
    (+.f64 (*.f64 2 (*.f64 (pow.f64 a 2) (pow.f64 b 2))) (Rewrite=> +-commutative (+.f64 (pow.f64 a 4) (pow.f64 b 4)))): 0 points increase in error, 0 points decrease in error
  4. Applied egg-rr0.1

    \[\leadsto \left(\color{blue}{\left({a}^{4} + b \cdot \left(b \cdot \mathsf{fma}\left(b, b, 2 \cdot \left(a \cdot a\right)\right)\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 \]
  5. Final simplification0.1

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

Alternatives

Alternative 1
Error0.2
Cost14784
\[\begin{array}{l} t_0 := \mathsf{fma}\left(b, b, a \cdot a\right)\\ \left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(a + 3\right)\right) + t_0 \cdot t_0\right) + -1 \end{array} \]
Alternative 2
Error0.2
Cost8192
\[\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(a + 3\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + -1 \]
Alternative 3
Error0.2
Cost8068
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 2 \cdot 10^{-17}:\\ \;\;\;\;\left({a}^{4} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(a + 3\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left({\left(a \cdot a + b \cdot b\right)}^{2} + \left(b \cdot b\right) \cdot 12\right) + -1\\ \end{array} \]
Alternative 4
Error0.2
Cost7684
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 2 \cdot 10^{-17}:\\ \;\;\;\;\left(a \cdot \left(a \cdot 4\right) + -1\right) + \left(a + -4\right) \cdot {a}^{3}\\ \mathbf{else}:\\ \;\;\;\;\left({\left(a \cdot a + b \cdot b\right)}^{2} + \left(b \cdot b\right) \cdot 12\right) + -1\\ \end{array} \]
Alternative 5
Error1.8
Cost7304
\[\begin{array}{l} t_0 := \left(\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + -4\right)\right) + \left(a \cdot \left(a \cdot b\right)\right) \cdot \left(b \cdot 2\right)\right) + -1\\ \mathbf{if}\;a \leq -0.0002251516477075891:\\ \;\;\;\;t_0\\ \mathbf{elif}\;a \leq 8.89459214556273 \cdot 10^{-15}:\\ \;\;\;\;\left(\left(b \cdot b\right) \cdot 12 + {b}^{4}\right) + -1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error1.9
Cost7240
\[\begin{array}{l} t_0 := \left(\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + -4\right)\right) + \left(a \cdot \left(a \cdot b\right)\right) \cdot \left(b \cdot 2\right)\right) + -1\\ \mathbf{if}\;a \leq -0.0002251516477075891:\\ \;\;\;\;t_0\\ \mathbf{elif}\;a \leq 8.89459214556273 \cdot 10^{-15}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \mathsf{fma}\left(b, b, 12\right) + -1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error2.8
Cost6920
\[\begin{array}{l} t_0 := \left(\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + -4\right)\right) + \left(a \cdot \left(a \cdot b\right)\right) \cdot \left(b \cdot 2\right)\right) + -1\\ \mathbf{if}\;a \leq -0.0002251516477075891:\\ \;\;\;\;t_0\\ \mathbf{elif}\;a \leq 8.89459214556273 \cdot 10^{-15}:\\ \;\;\;\;{b}^{4} + -1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error2.4
Cost6792
\[\begin{array}{l} \mathbf{if}\;b \leq -6.479096603681448:\\ \;\;\;\;{b}^{4}\\ \mathbf{elif}\;b \leq 2265.49221940393:\\ \;\;\;\;\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + -4\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;{b}^{4}\\ \end{array} \]
Alternative 9
Error12.1
Cost1472
\[\left(\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + -4\right)\right) + \left(a \cdot \left(a \cdot b\right)\right) \cdot \left(b \cdot 2\right)\right) + -1 \]
Alternative 10
Error13.0
Cost968
\[\begin{array}{l} t_0 := \frac{a}{\frac{\frac{1}{a + -4}}{a \cdot a}}\\ \mathbf{if}\;a \leq -250.33965077917554:\\ \;\;\;\;t_0\\ \mathbf{elif}\;a \leq 0.00431384542529203:\\ \;\;\;\;4 \cdot \left(a \cdot a\right) + -1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 11
Error13.0
Cost968
\[\begin{array}{l} \mathbf{if}\;a \leq -250.33965077917554:\\ \;\;\;\;\frac{a \cdot a}{\frac{1}{a \cdot \left(a + -4\right)}}\\ \mathbf{elif}\;a \leq 0.00431384542529203:\\ \;\;\;\;4 \cdot \left(a \cdot a\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{\frac{\frac{1}{a + -4}}{a \cdot a}}\\ \end{array} \]
Alternative 12
Error12.2
Cost832
\[\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + -4\right)\right) + -1 \]
Alternative 13
Error13.5
Cost704
\[\left(a \cdot a\right) \cdot \left(4 + a \cdot a\right) + -1 \]
Alternative 14
Error23.2
Cost448
\[4 \cdot \left(a \cdot a\right) + -1 \]
Alternative 15
Error24.1
Cost64
\[-1 \]

Error

Reproduce

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