A computer algebra system written in pure Python http://sympy.org/ . To get started to with contributing https://github.com/sympy/sympy/wiki/Introduction-to-contributing
smichr on master
quantile function linked Merge pull request #22938 from … (compare)
x1
or x_1
. Either seems to work in most cases, but only underscored subscripts seem to work in all cases (#19005)
1/3
with say 1000 digits, you can store it as a Rational
number and sympy will not convert it to a float in subsequent operations which means multiplying Rational(1, 3) * 3
gives you an integer 1 instead of a float 1.0
Float
refers to the specific way the numbers are represented, i.e., floating-point. Not all real numbers are represented that way. For instance, Rational(1, 3)
, sqrt(2)
and pi
are real numbers but not floating point, and in fact they can't be exactly represented as floating-point. A floating point number uses a very specific representation of $man\times 2^{exp}$ (see https://mpmath.org/doc/current/technical.html#representation-of-numbers).
Float(x) + Float(y) != Float(x + y)
in general.
x.is_real
will tell you if x is a real number. The Python classes are based on the implementation, which is why they are named after the representation. Calling Float
Real would be inaccurate because it is only one possible representation of real numbers, and one that can't even represent all possible ones at that.
>>> from sympy import *
>>> i = Symbol('i')
>>> a = 3 * i
>>> Sum(a, (i, 1, 5))
Sum(3*i, (i, 1, 5))
>>> Sum(a, (i, 1, 5)).doit()
45
>>> b = Sum(i, (i, 1, 10)) / Sum(i + 1, (i, 1, 10))
>>> b
Sum(i, (i, 1, 10))/Sum(i + 1, (i, 1, 10))
>>> b.doit()
11/13
>>> pprint(Sum(a, (i, 1, 5)))
5
___
╲
╲
╱ 3⋅i
╱
‾‾‾
i = 1
>>> pprint(b)
10
___
╲
╲
╱ i
╱
‾‾‾
i = 1
─────────────
10
___
╲
╲
╱ (i + 1)
╱
‾‾‾
i = 1
solve([x - 5], x)
simply return [5]
?