Skip to main content

A toy math implementation with Vector, Matrix, and Polynomial

Project description

k3math

Build Status Documentation Status Package

no desc

k3math is a component of pykit3 project: a python3 toolkit set.

Install

pip install k3math

Synopsis

xs = [1, 2, 3, 4]
ys = [6, 5, 7, 10]

# Fit polynomial curve with 4 points, at degree 0, 1, 2, 3:
for deg in (0, 1, 2, 3):
    poly = Polynomial.fit(xs, ys, degree=deg)
    print 'y =', poly

    # Evaluate y(5) with polynomial
    y5 = Polynomial.evaluate(poly, 5)
    print 'y(5) =', y5

    # Plot the curve and points
    lines = Polynomial.plot([(poly, '.')], (-1, 6),
                            width=30, height=10,
                            points=zip(xs + [5],
                                       ys + [y5],
                                       ['X', 'X', 'X', 'X', '*']))
    for l in lines:
        print l

# y = 7
# y(5) = 7.0
#                     X
#
#
#
# ...............X.........*....
#      X
#           X
# y = 3.5 + 1.4x
# y(5) = 10.5
#                              .
#                          *...
#                     X....
#                .....
#           .....X
#      X....X
# .....
# y = 8.5 - 3.6x + x²
# y(5) = 15.5
#                              .
#                             .
#                           ..
#                         .*
#                      ...
# ..               ...X
#   ...X....X....X.
# y = 12 - 9.166667x + 3.5x² - 0.333333x³
# y(5) = 12.0
#
# .                     ...*....
#  .                  X.
#   .               ..
#    .            ..
#     .         .X
#      X....X...

Author

Zhang Yanpo (张炎泼) drdr.xp@gmail.com

Copyright and License

The MIT License (MIT)

Copyright (c) 2015 Zhang Yanpo (张炎泼) drdr.xp@gmail.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

k3math-0.1.4.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

k3math-0.1.4-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file k3math-0.1.4.tar.gz.

File metadata

  • Download URL: k3math-0.1.4.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for k3math-0.1.4.tar.gz
Algorithm Hash digest
SHA256 ba3426d3bdf6e2eddf18e48f891aa32341174a43ccb28a1e71e4ea2d21f89d0e
MD5 ed13fe73176bc564c1e20ca35684264c
BLAKE2b-256 dba53db5d9ac10351c311783c3893d94c23c0936aae2895064c2e8bc30f30dc1

See more details on using hashes here.

File details

Details for the file k3math-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: k3math-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for k3math-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 85cfeb96bb0a11943674054e3a2c4a881d09420d4e36d24fa6fb1347dc89da7b
MD5 f5193d6e481e4e8b3a3b28fae52f7436
BLAKE2b-256 077e0088cc9a578388a258241e535acf258e5efd6acb1309f831ffe3c74b9eb5

See more details on using hashes here.

Supported by

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