Average Error: 0.2 → 0.0
Time: 10.0s
Precision: binary64
Cost: 14016
\[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
\[\left({b}^{4} + \left(\left(4 + 2 \cdot \left(a \cdot a\right)\right) \cdot \left(b \cdot b\right) + {a}^{4}\right)\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
 (- (+ (pow b 4.0) (+ (* (+ 4.0 (* 2.0 (* a a))) (* b b)) (pow a 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 (pow(b, 4.0) + (((4.0 + (2.0 * (a * a))) * (b * b)) + pow(a, 4.0))) - 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 = ((b ** 4.0d0) + (((4.0d0 + (2.0d0 * (a * a))) * (b * b)) + (a ** 4.0d0))) - 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(b, 4.0) + (((4.0 + (2.0 * (a * a))) * (b * b)) + Math.pow(a, 4.0))) - 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(b, 4.0) + (((4.0 + (2.0 * (a * a))) * (b * b)) + math.pow(a, 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((b ^ 4.0) + Float64(Float64(Float64(4.0 + Float64(2.0 * Float64(a * a))) * Float64(b * b)) + (a ^ 4.0))) - 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 = ((b ^ 4.0) + (((4.0 + (2.0 * (a * a))) * (b * b)) + (a ^ 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[Power[b, 4.0], $MachinePrecision] + N[(N[(N[(4.0 + N[(2.0 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision] + N[Power[a, 4.0], $MachinePrecision]), $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({b}^{4} + \left(\left(4 + 2 \cdot \left(a \cdot a\right)\right) \cdot \left(b \cdot b\right) + {a}^{4}\right)\right) - 1

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

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. Simplified0.2

    \[\leadsto \color{blue}{{\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + \mathsf{fma}\left(4 \cdot b, b, -1\right)} \]
    Proof
  3. Taylor expanded in b around 0 0.0

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

    \[\leadsto \left({b}^{4} + \left({a}^{4} + \color{blue}{\left(-\left(-4 + -2 \cdot \left(a \cdot a\right)\right) \cdot \left(b \cdot b\right)\right)}\right)\right) - 1 \]
  5. Applied egg-rr0.0

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

Alternatives

Alternative 1
Error0.1
Cost13952
\[\left({a}^{4} + \left(b \cdot b\right) \cdot \left(b \cdot b + \mathsf{fma}\left(a \cdot a, 2, 4\right)\right)\right) + -1 \]
Alternative 2
Error0.2
Cost13696
\[\left(4 \cdot b\right) \cdot b + \left(-1 + {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2}\right) \]
Alternative 3
Error0.2
Cost7424
\[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
Alternative 4
Error1.6
Cost7300
\[\begin{array}{l} \mathbf{if}\;a \cdot a \leq 4 \cdot 10^{-13}:\\ \;\;\;\;\left({b}^{4} + 4 \cdot \left(b \cdot b\right)\right) - 1\\ \mathbf{else}:\\ \;\;\;\;{a}^{4} - 1\\ \end{array} \]
Alternative 5
Error3.4
Cost6920
\[\begin{array}{l} t_0 := \left(b \cdot b\right) \cdot \left(\left(2 \cdot \left(a \cdot a\right) + 4\right) + b \cdot b\right) - 1\\ \mathbf{if}\;b \leq -43748.51101949656:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b \leq 5.250945805445222 \cdot 10^{-90}:\\ \;\;\;\;{a}^{4} - 1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error2.1
Cost6792
\[\begin{array}{l} \mathbf{if}\;a \leq -3.6978752065879785:\\ \;\;\;\;{a}^{4}\\ \mathbf{elif}\;a \leq 0.00029232286294341705:\\ \;\;\;\;\left(\left(b \cdot b\right) \cdot \left(b \cdot b\right) + 4 \cdot \left(b \cdot b\right)\right) - 1\\ \mathbf{else}:\\ \;\;\;\;{a}^{4}\\ \end{array} \]
Alternative 7
Error11.6
Cost1088
\[\left(b \cdot b\right) \cdot \left(\left(2 \cdot \left(a \cdot a\right) + 4\right) + b \cdot b\right) - 1 \]
Alternative 8
Error11.7
Cost960
\[\left(\left(b \cdot b\right) \cdot \left(b \cdot b\right) + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
Alternative 9
Error12.7
Cost576
\[\left(b \cdot b\right) \cdot \left(b \cdot b\right) - 1 \]
Alternative 10
Error22.4
Cost448
\[4 \cdot \left(b \cdot b\right) - 1 \]
Alternative 11
Error23.3
Cost64
\[-1 \]

Error

Reproduce

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