?

Average Error: 0.28% → 0.02%
Time: 8.4s
Precision: binary64
Cost: 13504

?

\[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
\[\left({\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + 4 \cdot \left(b \cdot b\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 (hypot a b) 4.0) (* 4.0 (* b b))) -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(hypot(a, b), 4.0) + (4.0 * (b * b))) + -1.0;
}
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(Math.hypot(a, b), 4.0) + (4.0 * (b * b))) + -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(math.hypot(a, b), 4.0) + (4.0 * (b * b))) + -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((hypot(a, b) ^ 4.0) + Float64(4.0 * Float64(b * b))) + -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 = ((hypot(a, b) ^ 4.0) + (4.0 * (b * b))) + -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[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + N[(4.0 * N[(b * b), $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({\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + 4 \cdot \left(b \cdot b\right)\right) + -1

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 0.28

    \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
  2. Applied egg-rr3.25

    \[\leadsto \left(\color{blue}{\left(e^{\mathsf{log1p}\left({\left({\left(\mathsf{hypot}\left(a, b\right)\right)}^{2}\right)}^{2}\right)} - 1\right)} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
  3. Simplified0.02

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

    [Start]3.25

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

    expm1-def [=>]3.23

    \[ \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left({\left(\mathsf{hypot}\left(a, b\right)\right)}^{2}\right)}^{2}\right)\right)} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]

    expm1-log1p [=>]0.29

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

    unpow2 [=>]0.29

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

    pow-sqr [=>]0.02

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

    metadata-eval [=>]0.02

    \[ \left({\left(\mathsf{hypot}\left(a, b\right)\right)}^{\color{blue}{4}} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
  4. Final simplification0.02

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

Alternatives

Alternative 1
Error0.28%
Cost7744
\[\left(4 \cdot \left(b \cdot b\right) + \mathsf{fma}\left(b, b, a \cdot a\right) \cdot \left(b \cdot b + a \cdot a\right)\right) + -1 \]
Alternative 2
Error4.55%
Cost1480
\[\begin{array}{l} t_0 := 4 \cdot \left(b \cdot b\right)\\ \mathbf{if}\;b \leq -0.00098:\\ \;\;\;\;\left(t_0 + \left(b \cdot b\right) \cdot \left(b \cdot b\right)\right) + -1\\ \mathbf{elif}\;b \leq 3.15 \cdot 10^{+25}:\\ \;\;\;\;\left(t_0 + \left(a \cdot a\right) \cdot \left(b \cdot b + a \cdot a\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b + \left(a \cdot a\right) \cdot 2\right)\\ \end{array} \]
Alternative 3
Error4.53%
Cost1480
\[\begin{array}{l} t_0 := 4 \cdot \left(b \cdot b\right)\\ t_1 := b \cdot b + a \cdot a\\ \mathbf{if}\;b \leq -0.00108:\\ \;\;\;\;\left(t_0 + \left(b \cdot b\right) \cdot t_1\right) + -1\\ \mathbf{elif}\;b \leq 3.15 \cdot 10^{+25}:\\ \;\;\;\;\left(t_0 + \left(a \cdot a\right) \cdot t_1\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b + \left(a \cdot a\right) \cdot 2\right)\\ \end{array} \]
Alternative 4
Error0.28%
Cost1472
\[\begin{array}{l} t_0 := b \cdot b + a \cdot a\\ \left(4 \cdot \left(b \cdot b\right) + t_0 \cdot t_0\right) + -1 \end{array} \]
Alternative 5
Error5.63%
Cost1097
\[\begin{array}{l} \mathbf{if}\;b \leq -420 \lor \neg \left(b \leq 3.15 \cdot 10^{+25}\right):\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b + \left(a \cdot a\right) \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 + a \cdot a\right) \cdot \left(a \cdot a + -1\right)\\ \end{array} \]
Alternative 6
Error5.12%
Cost1096
\[\begin{array}{l} \mathbf{if}\;b \leq -4.6 \cdot 10^{-7}:\\ \;\;\;\;\left(4 \cdot \left(b \cdot b\right) + \left(b \cdot b\right) \cdot \left(b \cdot b\right)\right) + -1\\ \mathbf{elif}\;b \leq 3.15 \cdot 10^{+25}:\\ \;\;\;\;\left(1 + a \cdot a\right) \cdot \left(a \cdot a + -1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b + \left(a \cdot a\right) \cdot 2\right)\\ \end{array} \]
Alternative 7
Error18.43%
Cost704
\[\left(1 + a \cdot a\right) \cdot \left(a \cdot a + -1\right) \]
Alternative 8
Error36.38%
Cost64
\[-1 \]

Error

Reproduce?

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