Average Error: 0.2 → 0.0
Time: 8.8s
Precision: binary64
Cost: 14272
\[\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(\mathsf{hypot}\left(b, a\right)\right)}^{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 \]
(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 (hypot b a) 4.0)
   (* 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(hypot(b, a), 4.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))))) + -1.0;
}
public static double code(double a, double b) {
	return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0;
}
public static double code(double a, double b) {
	return (Math.pow(Math.hypot(b, a), 4.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))))) + -1.0;
}
def code(a, b):
	return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0
def code(a, b):
	return (math.pow(math.hypot(b, a), 4.0) + (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((hypot(b, a) ^ 4.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + Float64(Float64(b * b) * Float64(a + 3.0))))) + -1.0)
end
function tmp = code(a, b)
	tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0;
end
function tmp = code(a, b)
	tmp = ((hypot(b, a) ^ 4.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (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[Power[N[Sqrt[b ^ 2 + a ^ 2], $MachinePrecision], 4.0], $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(\mathsf{hypot}\left(b, a\right)\right)}^{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

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(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1 \]
  2. Applied egg-rr2.1

    \[\leadsto \left(\color{blue}{\left(e^{\mathsf{log1p}\left({\left({\left(\mathsf{hypot}\left(b, a\right)\right)}^{2}\right)}^{2}\right)} - 1\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}{{\left(\mathsf{hypot}\left(b, a\right)\right)}^{4}} + 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
    (pow.f64 (hypot.f64 b a) 4): 0 points increase in error, 0 points decrease in error
    (pow.f64 (hypot.f64 b a) (Rewrite<= metadata-eval (*.f64 2 2))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= pow-sqr_binary64 (*.f64 (pow.f64 (hypot.f64 b a) 2) (pow.f64 (hypot.f64 b a) 2))): 59 points increase in error, 22 points decrease in error
    (Rewrite<= unpow2_binary64 (pow.f64 (pow.f64 (hypot.f64 b a) 2) 2)): 0 points increase in error, 0 points decrease in error
    (Rewrite<= expm1-log1p_binary64 (expm1.f64 (log1p.f64 (pow.f64 (pow.f64 (hypot.f64 b a) 2) 2)))): 81 points increase in error, 3 points decrease in error
    (Rewrite<= expm1-def_binary64 (-.f64 (exp.f64 (log1p.f64 (pow.f64 (pow.f64 (hypot.f64 b a) 2) 2))) 1)): 5 points increase in error, 83 points decrease in error
  4. Final simplification0.0

    \[\leadsto \left({\left(\mathsf{hypot}\left(b, a\right)\right)}^{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 \]

Alternatives

Alternative 1
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 2
Error0.2
Cost7684
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 10^{-23}:\\ \;\;\;\;\left(\left(1 - a\right) \cdot \left(a \cdot \left(a \cdot 4\right)\right) + {a}^{4}\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left({\left(a \cdot a + b \cdot b\right)}^{2} + b \cdot \left(b \cdot 12\right)\right) + -1\\ \end{array} \]
Alternative 3
Error1.2
Cost7680
\[\left({\left(a \cdot a + b \cdot b\right)}^{2} + \left(1 - a\right) \cdot \left(a \cdot \left(a \cdot 4\right)\right)\right) + -1 \]
Alternative 4
Error1.6
Cost7560
\[\begin{array}{l} t_0 := {b}^{4} + -1\\ \mathbf{if}\;b \leq -2.3 \cdot 10^{-8}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(a \cdot 4 + 12\right) + t_0\\ \mathbf{elif}\;b \leq 5.9 \cdot 10^{-5}:\\ \;\;\;\;\left(\left(1 - a\right) \cdot \left(a \cdot \left(a \cdot 4\right)\right) + {a}^{4}\right) + -1\\ \mathbf{else}:\\ \;\;\;\;t_0 + b \cdot \left(b \cdot 12\right)\\ \end{array} \]
Alternative 5
Error2.7
Cost7428
\[\begin{array}{l} t_0 := {b}^{4} + -1\\ \mathbf{if}\;b \leq -3.8 \cdot 10^{-15}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(a \cdot 4 + 12\right) + t_0\\ \mathbf{elif}\;b \leq 0.00015:\\ \;\;\;\;-1 + {a}^{3} \cdot \left(a + -4\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 + b \cdot \left(b \cdot 12\right)\\ \end{array} \]
Alternative 6
Error2.6
Cost7304
\[\begin{array}{l} t_0 := \left({b}^{4} + -1\right) + b \cdot \left(b \cdot 12\right)\\ \mathbf{if}\;b \leq -9.8 \cdot 10^{-8}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b \leq 5.9 \cdot 10^{-5}:\\ \;\;\;\;-1 + {a}^{3} \cdot \left(a + -4\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error2.6
Cost7240
\[\begin{array}{l} \mathbf{if}\;b \leq -1.06 \cdot 10^{-7}:\\ \;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 4 \cdot \left(a + 3\right)\right)\\ \mathbf{elif}\;b \leq 5.9 \cdot 10^{-5}:\\ \;\;\;\;-1 + {a}^{3} \cdot \left(a + -4\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + b \cdot \left(b \cdot \mathsf{fma}\left(b, b, 12\right)\right)\\ \end{array} \]
Alternative 8
Error2.7
Cost7176
\[\begin{array}{l} \mathbf{if}\;b \leq -8.2 \cdot 10^{-8}:\\ \;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 4 \cdot \left(a + 3\right)\right)\\ \mathbf{elif}\;b \leq 5.9 \cdot 10^{-5}:\\ \;\;\;\;-1 + {a}^{3} \cdot \left(a + -4\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 12\right)\\ \end{array} \]
Alternative 9
Error2.6
Cost7048
\[\begin{array}{l} t_0 := {a}^{3} \cdot \left(a + -4\right)\\ \mathbf{if}\;a \leq -26000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;a \leq 6.5:\\ \;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 4 \cdot \left(a + 3\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 10
Error3.1
Cost6920
\[\begin{array}{l} \mathbf{if}\;b \leq -1.25 \cdot 10^{-8}:\\ \;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 4 \cdot \left(a + 3\right)\right)\\ \mathbf{elif}\;b \leq 5.9 \cdot 10^{-5}:\\ \;\;\;\;{a}^{4} + -1\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 12\right)\\ \end{array} \]
Alternative 11
Error2.9
Cost6792
\[\begin{array}{l} \mathbf{if}\;a \leq -3500:\\ \;\;\;\;{a}^{4}\\ \mathbf{elif}\;a \leq 240:\\ \;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 4 \cdot \left(a + 3\right)\right)\\ \mathbf{else}:\\ \;\;\;\;{a}^{4}\\ \end{array} \]
Alternative 12
Error12.2
Cost960
\[-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 4 \cdot \left(a + 3\right)\right) \]
Alternative 13
Error12.2
Cost704
\[-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 12\right) \]
Alternative 14
Error23.2
Cost448
\[-1 + \left(b \cdot b\right) \cdot 12 \]
Alternative 15
Error24.2
Cost64
\[-1 \]

Error

Reproduce

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