Skip to main content

A Python math and physics module

Project description

matphys v1.1.27

A Python math and physics modules

  • Pascal’s Triangle

  • Bell Triangle

  • Euler’s Triangle

  • Euler’s Constant

  • Power Series

  • Floyd’s Triangle

  • Fibonacci Sequence

pascal module

Pascal’s Triangle

>>> from matphys import pascal
>>> p = pascal.PascalTriangle(10) #arg is the number of rows wanted
>>> p.read()
[1]
[1, 1]
[1, 2, 1]
[1, 3, 3, 1]
[1, 4, 6, 4, 1]
[1, 5, 10, 10, 5, 1]
[1, 6, 15, 20, 15, 6, 1]
[1, 7, 21, 35, 35, 21, 7, 1]
[1, 8, 28, 56, 70, 56, 28, 8, 1]
[1, 9, 36, 84, 126, 126, 84, 36, 9, 1]
>>> p.row(5) #arg is row number
16

bell module

Bell Triangle

>>> from matphys import bell
>>> b = bell.BellTriangle(10) #arg is the number of rows wanted
>>> b.read()
[1]
[1, 2]
[2, 3, 5]
[5, 7, 10, 15]
[15, 20, 27, 37, 52]
[52, 67, 87, 114, 151, 203]
[203, 255, 322, 409, 523, 674, 877]
[877, 1080, 1335, 1657, 2066, 2589, 3263, 4140]
[4140, 5017, 6097, 7432, 9089, 11155, 13744, 17007, 21147]
[21147, 25287, 30304, 36401, 43833, 52922, 64077, 77821, 94828, 115975]
>>> b.row(5) #arg is row number
151

floyd module

Floyd’s Triangle

>>> from matphys import floyd
>>> f = floyd.FloydTriangle(10) #arg is the number of rows wanted
>>> f.read()
[1]
[2, 3]
[4, 5, 6]
[7, 8, 9, 10]
[11, 12, 13, 14, 15]
[16, 17, 18, 19, 20, 21]
[22, 23, 24, 25, 26, 27, 28]
[29, 30, 31, 32, 33, 34, 35, 36]
[37, 38, 39, 40, 41, 42, 43, 44, 45]
[46, 47, 48, 49, 50, 51, 52, 53, 54, 55]
>>> f.row(5) #arg is row number
65

euler module

Euler’s Triangle

>>> from matphys import euler
>>> e = euler.EulerTriangle(10) #arg is the number of rows wanted
>>> e.read()
[1]
[1, 1]
[1, 4, 1]
[1, 11, 11, 1]
[1, 26, 66, 26, 1]
[1, 57, 302, 302, 57, 1]
[1, 120, 1191, 2416, 1191, 120, 1]
[1, 247, 4293, 15619, 15619, 4293, 247, 1]
[1, 502, 14608, 88234, 156190, 88234, 14608, 502, 1]
[1, 1013, 47840, 455192, 1310354, 1310354, 455192, 47840, 1013, 1]
>>> e.row(5)
120

Euler’s Number

Euler’s number is represented by (e) in mathematics

>>> from matphys import euler
>>> e = euler.EulerNumber(128500000) #arg is the precision
>>> e.read()
2.7182818243

Euler’s Constant

Euler’s Constant is represented by gamma (γ) in mathematics

>>> from matphys import euler
>>> e = euler.EulerConstant(10000000) #arg is the precision of the constant
>>> e.read()
0.577265664068

Power Series

>>> from matphys import euler
>>> p = euler.PowerSeries(10, 10) #args are (n, x)
>>> p.read()
12842.305114638448

fibonacci module

Fibonacci Sequence

>>> from matphys import fibonacci
>>> f = fibonacci.FibonacciSequence(10) #arg is the sequence out to the nth term
>>> f.read()
[1, 1, 2, 3, 5, 8, 13, 21, 34, 55]

Project details


Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page