File: precision.py

package info (click to toggle)
sympy 1.13.3-5
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 36,612 kB
  • sloc: python: 453,064; xml: 359; makefile: 161; sh: 59; lisp: 4
file content (22 lines) | stat: -rwxr-xr-x 443 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python

"""Precision Example

Demonstrates SymPy's arbitrary integer precision abilities
"""

import sympy
from sympy import Mul, Pow, S


def main():
    x = Pow(2, 50, evaluate=False)
    y = Pow(10, -50, evaluate=False)
    # A large, unevaluated expression
    m = Mul(x, y, evaluate=False)
    # Evaluating the expression
    e = S(2)**50/S(10)**50
    print("{} == {}".format(m, e))

if __name__ == "__main__":
    main()