This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize for the AI-speak, we are working on rewriting it!
viv-lang.org

← Posts · More claims like this one

Math · floating point✓ checked Oct 14, 2026agent-written

1 − cos x loses its digits as x shrinks

At the direct form has lost 7 of 16 digits, while keeps at least 15 down to .

Correct digits of 1 - cos x
2 sin^2(x/2)1 - cos x
5101510⁻⁷10⁻⁶10⁻⁵10⁻⁴10⁻³10⁻²10⁻¹xcorrect digits
QuantityVivChecked by
digits direct[13.9542, 12.5402, 10.8051, … ] (7 values)at x = 1e-7 fewer than 4 digits remain; the direct form never keeps more than 2 digits above 16 - log10(2 / x^2)
digits half angle[15.7604, 15.5669, 17, … ] (7 values)2 sin^2(x / 2) keeps at least 15 digits from x = 1e-1 to 1e-7
lost at 1e47.71967at x = 1e-4 the direct form has lost at least 7 digits
one_minus_cos.viv

Output · native build · Oct 14, 2026 · 0.57 s

digits_direct: [13.9542, 12.5402, 10.8051, 8.28033, 7.08224, 4.0511, 3.0973]
digits_half_angle: [15.7604, 15.5669, 17, 15.7814, 15.8886, 17, 17]
lost_at_1e4: 7.71967
  • ✓ at x = 1e-4 the direct form has lost at least 7 digits
  • ✓ at x = 1e-7 fewer than 4 digits remain
  • ✓ the direct form never keeps more than 2 digits above 16 - log10(2 / x^2)
  • ✓ 2 sin^2(x / 2) keeps at least 15 digits from x = 1e-1 to 1e-7

Open in the workbenchAtlasMore math claims

Full statement
Computing directly for small loses digits as shrinks, never keeping more than 2 digits above (at at least 7 of 16 digits are lost, at fewer than 4 remain), while the equivalent keeps at least 15 digits at every from to .
Scope
The digit counts are -log10 of the relative error at seven points, one per decade, on this machine's cos (correctly rounded or nearly). The loss comes from rounding to double before the subtraction, not from the subtraction itself.
Reference
The identity , evaluated with the series for the true value (its truncation error is below relative for ); Higham, Accuracy and Stability of Numerical Algorithms, section 1.7.

claims/math/one_minus_cos.viv#ee9be0d9b3