sample_python_mpmath.py 400 B

12345678910111213141516
  1. #! /usr/bin/env python3
  2. # Test inspired from example published on the project page:
  3. # https://mpmath.org/
  4. from mpmath import mp
  5. mp.dps = 50
  6. result = mp.quad(lambda x: mp.exp(-x**2), [-mp.inf, mp.inf]) ** 2
  7. # Pi digits can be cross-checked here:
  8. # https://www.angio.net/pi/digits.html
  9. expected_result = "3.1415926535897932384626433832795028841971693993751"
  10. assert str(result) == expected_result