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.3.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.3-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: k3math-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 487f48a838802a369b62c8665f2f06347d872a17dfec9469c0254311eb2e467f
MD5 7a333f760abaf00cfea2fdb23b6f2911
BLAKE2b-256 d783897fff69319cd430ee9629cc94e50ae400055d75a902357d46329ebbd85c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: k3math-0.1.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c911f8568cb25e48fb74bf1c953ee121b19c6edaa5089bf06970a52593068661
MD5 f216b56a3f08b8fb4c908a3059650e12
BLAKE2b-256 7b1bd1a3e5e90e02e5e671e90fc2023295d673f1b5a8eabc6d60238bed46b055

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