cosine_cdf.py 354 B

1234567891011121314151617
  1. import mpmath
  2. def f(x):
  3. return (mpmath.pi + x + mpmath.sin(x)) / (2*mpmath.pi)
  4. # Note: 40 digits might be overkill; a few more digits than the default
  5. # might be sufficient.
  6. mpmath.mp.dps = 40
  7. ts = mpmath.taylor(f, -mpmath.pi, 20)
  8. p, q = mpmath.pade(ts, 9, 10)
  9. p = [float(c) for c in p]
  10. q = [float(c) for c in q]
  11. print('p =', p)
  12. print('q =', q)