Average Error: 0.0 → 0.3
Time: 1.5s
Precision: binary64
\[\sqrt{1 - x \cdot x} \]
\[\mathsf{fma}\left(x \cdot x, -0.5, 1\right) \]
(FPCore (x) :precision binary64 (sqrt (- 1.0 (* x x))))
(FPCore (x) :precision binary64 (fma (* x x) -0.5 1.0))
double code(double x) {
	return sqrt((1.0 - (x * x)));
}
double code(double x) {
	return fma((x * x), -0.5, 1.0);
}
function code(x)
	return sqrt(Float64(1.0 - Float64(x * x)))
end
function code(x)
	return fma(Float64(x * x), -0.5, 1.0)
end
code[x_] := N[Sqrt[N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
code[x_] := N[(N[(x * x), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]
\sqrt{1 - x \cdot x}
\mathsf{fma}\left(x \cdot x, -0.5, 1\right)

Error

Bits error versus x

Derivation

  1. Initial program 0.0

    \[\sqrt{1 - x \cdot x} \]
  2. Taylor expanded in x around 0 0.3

    \[\leadsto \color{blue}{1 - 0.5 \cdot {x}^{2}} \]
  3. Simplified0.3

    \[\leadsto \color{blue}{\mathsf{fma}\left(x \cdot x, -0.5, 1\right)} \]
  4. Final simplification0.3

    \[\leadsto \mathsf{fma}\left(x \cdot x, -0.5, 1\right) \]

Reproduce

herbie shell --seed 2022131 
(FPCore (x)
  :name "Diagrams.TwoD.Ellipse:ellipse from diagrams-lib-1.3.0.3"
  :precision binary64
  (sqrt (- 1.0 (* x x))))