Average Error: 14.5 → 0.0
Time: 2.1s
Precision: binary64
\[\left(0 \leq b \land b \leq a\right) \land a \leq 1\]
\[\sqrt{\left|\frac{a \cdot a - b \cdot b}{a \cdot a}\right|} \]
\[\sqrt{\left|\mathsf{log1p}\left(\mathsf{expm1}\left(1 - {\left(\frac{b}{a}\right)}^{2}\right)\right)\right|} \]
\sqrt{\left|\frac{a \cdot a - b \cdot b}{a \cdot a}\right|}
\sqrt{\left|\mathsf{log1p}\left(\mathsf{expm1}\left(1 - {\left(\frac{b}{a}\right)}^{2}\right)\right)\right|}
(FPCore (a b)
 :precision binary64
 (sqrt (fabs (/ (- (* a a) (* b b)) (* a a)))))
(FPCore (a b)
 :precision binary64
 (sqrt (fabs (log1p (expm1 (- 1.0 (pow (/ b a) 2.0)))))))
double code(double a, double b) {
	return sqrt(fabs(((a * a) - (b * b)) / (a * a)));
}
double code(double a, double b) {
	return sqrt(fabs(log1p(expm1(1.0 - pow((b / a), 2.0)))));
}

Error

Bits error versus a

Bits error versus b

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 14.5

    \[\sqrt{\left|\frac{a \cdot a - b \cdot b}{a \cdot a}\right|} \]
  2. Applied expm1-log1p-u_binary6414.5

    \[\leadsto \sqrt{\left|\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{a \cdot a - b \cdot b}{a \cdot a}\right)\right)}\right|} \]
  3. Simplified14.5

    \[\leadsto \sqrt{\left|\mathsf{expm1}\left(\color{blue}{\mathsf{log1p}\left(1 - \frac{b \cdot b}{a \cdot a}\right)}\right)\right|} \]
  4. Applied log1p-expm1-u_binary6414.5

    \[\leadsto \sqrt{\left|\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{expm1}\left(\mathsf{log1p}\left(1 - \frac{b \cdot b}{a \cdot a}\right)\right)\right)\right)}\right|} \]
  5. Simplified0.0

    \[\leadsto \sqrt{\left|\mathsf{log1p}\left(\color{blue}{\mathsf{expm1}\left(1 - {\left(\frac{b}{a}\right)}^{2}\right)}\right)\right|} \]
  6. Final simplification0.0

    \[\leadsto \sqrt{\left|\mathsf{log1p}\left(\mathsf{expm1}\left(1 - {\left(\frac{b}{a}\right)}^{2}\right)\right)\right|} \]

Reproduce

herbie shell --seed 2022097 
(FPCore (a b)
  :name "Eccentricity of an ellipse"
  :precision binary64
  :pre (and (and (<= 0.0 b) (<= b a)) (<= a 1.0))
  (sqrt (fabs (/ (- (* a a) (* b b)) (* a a)))))