Average Error: 0.2 → 0.0
Time: 5.9s
Precision: binary64
Cost: 19776
\[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
\[{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(b, b \cdot 4, -1\right) \]
(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) (fma b (* b 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(hypot(a, b), 4.0) + fma(b, (b * 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((hypot(a, b) ^ 4.0) + fma(b, Float64(b * 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[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + N[(b * N[(b * 4.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1
{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(b, b \cdot 4, -1\right)

Error

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.0

    \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(b, b \cdot 4, -1\right)} \]
    Proof
    (+.f64 (pow.f64 (hypot.f64 a b) 4) (fma.f64 b (*.f64 b 4) -1)): 0 points increase in error, 0 points decrease in error
    (+.f64 (pow.f64 (Rewrite<= hypot-def_binary64 (sqrt.f64 (+.f64 (*.f64 a a) (*.f64 b b)))) 4) (fma.f64 b (*.f64 b 4) -1)): 0 points increase in error, 0 points decrease in error
    (+.f64 (pow.f64 (Rewrite<= unpow1/2_binary64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 1/2)) 4) (fma.f64 b (*.f64 b 4) -1)): 0 points increase in error, 0 points decrease in error
    (+.f64 (pow.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (Rewrite<= metadata-eval (/.f64 1 2))) 4) (fma.f64 b (*.f64 b 4) -1)): 0 points increase in error, 0 points decrease in error
    (+.f64 (pow.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (/.f64 1 2)) (Rewrite<= metadata-eval (+.f64 3 1))) (fma.f64 b (*.f64 b 4) -1)): 0 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite<= pow-plus_binary64 (*.f64 (pow.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (/.f64 1 2)) 3) (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (/.f64 1 2)))) (fma.f64 b (*.f64 b 4) -1)): 19 points increase in error, 1 points decrease in error
    (+.f64 (*.f64 (Rewrite=> unpow3_binary64 (*.f64 (*.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (/.f64 1 2)) (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (/.f64 1 2))) (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (/.f64 1 2)))) (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (/.f64 1 2))) (fma.f64 b (*.f64 b 4) -1)): 11 points increase in error, 6 points decrease in error
    (+.f64 (*.f64 (*.f64 (Rewrite<= sqr-pow_binary64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 1)) (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (/.f64 1 2))) (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (/.f64 1 2))) (fma.f64 b (*.f64 b 4) -1)): 0 points increase in error, 0 points decrease in error
    (+.f64 (*.f64 (*.f64 (Rewrite=> unpow1_binary64 (+.f64 (*.f64 a a) (*.f64 b b))) (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (/.f64 1 2))) (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (/.f64 1 2))) (fma.f64 b (*.f64 b 4) -1)): 0 points increase in error, 0 points decrease in error
    (+.f64 (*.f64 (*.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (/.f64 1 2))) (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (/.f64 1 2))) (fma.f64 b (Rewrite<= *-commutative_binary64 (*.f64 4 b)) -1)): 0 points increase in error, 0 points decrease in error
    (+.f64 (*.f64 (*.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (/.f64 1 2))) (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (/.f64 1 2))) (fma.f64 b (*.f64 4 b) (Rewrite<= metadata-eval (neg.f64 1)))): 0 points increase in error, 0 points decrease in error
    (+.f64 (*.f64 (*.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (/.f64 1 2))) (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (/.f64 1 2))) (Rewrite<= fma-neg_binary64 (-.f64 (*.f64 b (*.f64 4 b)) 1))): 1 points increase in error, 0 points decrease in error
    (+.f64 (*.f64 (*.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (/.f64 1 2))) (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (/.f64 1 2))) (-.f64 (Rewrite<= *-commutative_binary64 (*.f64 (*.f64 4 b) b)) 1)): 0 points increase in error, 0 points decrease in error
    (+.f64 (*.f64 (*.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (/.f64 1 2))) (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (/.f64 1 2))) (-.f64 (Rewrite<= associate-*r*_binary64 (*.f64 4 (*.f64 b b))) 1)): 0 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite<= associate-*r*_binary64 (*.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (*.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (/.f64 1 2)) (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (/.f64 1 2))))) (-.f64 (*.f64 4 (*.f64 b b)) 1)): 15 points increase in error, 5 points decrease in error
    (+.f64 (*.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (Rewrite<= sqr-pow_binary64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 1))) (-.f64 (*.f64 4 (*.f64 b b)) 1)): 0 points increase in error, 0 points decrease in error
    (+.f64 (*.f64 (+.f64 (*.f64 a a) (*.f64 b b)) (Rewrite=> unpow1_binary64 (+.f64 (*.f64 a a) (*.f64 b b)))) (-.f64 (*.f64 4 (*.f64 b b)) 1)): 0 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite<= unpow2_binary64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2)) (-.f64 (*.f64 4 (*.f64 b b)) 1)): 0 points increase in error, 0 points decrease in error
    (Rewrite<= associate--l+_binary64 (-.f64 (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (*.f64 b b))) 1)): 1 points increase in error, 0 points decrease in error
  3. Final simplification0.0

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

Alternatives

Alternative 1
Error0.2
Cost7424
\[-1 + \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) \]
Alternative 2
Error1.7
Cost7304
\[\begin{array}{l} t_0 := -1 + {a}^{4}\\ \mathbf{if}\;a \leq -0.0509790986569743:\\ \;\;\;\;t_0\\ \mathbf{elif}\;a \leq 1.4753338535189284 \cdot 10^{-24}:\\ \;\;\;\;-1 + \left(4 \cdot \left(b \cdot b\right) + {b}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error1.7
Cost7240
\[\begin{array}{l} t_0 := -1 + {a}^{4}\\ \mathbf{if}\;a \leq -0.0509790986569743:\\ \;\;\;\;t_0\\ \mathbf{elif}\;a \leq 1.4753338535189284 \cdot 10^{-24}:\\ \;\;\;\;-1 + b \cdot \left(b \cdot \mathsf{fma}\left(b, b, 4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error1.7
Cost6920
\[\begin{array}{l} t_0 := -1 + {a}^{4}\\ \mathbf{if}\;a \leq -0.0509790986569743:\\ \;\;\;\;t_0\\ \mathbf{elif}\;a \leq 1.4753338535189284 \cdot 10^{-24}:\\ \;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(4 + b \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error11.8
Cost704
\[-1 + \left(b \cdot b\right) \cdot \left(4 + b \cdot b\right) \]
Alternative 6
Error22.7
Cost448
\[-1 + b \cdot \left(b \cdot 4\right) \]
Alternative 7
Error23.7
Cost64
\[-1 \]

Error

Reproduce

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