A toy math implementation with Vector, Matrix, and Polynomial
Project description
k3math
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.6.tar.gz
(7.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file k3math-0.1.6.tar.gz.
File metadata
- Download URL: k3math-0.1.6.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8c6ce6a1655a870110335e11ade40ba104e1057c437d22885b14a05756552a7
|
|
| MD5 |
69f2c0ea49198aed648fa93c1d57ec63
|
|
| BLAKE2b-256 |
a6a8f890e250f8eeb9f6c592926dc58aa5422d6cea83a8e92bb2f703b744d91d
|
File details
Details for the file k3math-0.1.6-py3-none-any.whl.
File metadata
- Download URL: k3math-0.1.6-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25ea60417cdde1962cc73b5ba0bafd6a9b1ec84b5dc315b4b1e3b92a8c591a94
|
|
| MD5 |
659e3847e299c8c256ef124f952fbcd3
|
|
| BLAKE2b-256 |
ce89084cddaad2a47200f71ee1d77f48a9d74f149c6f8fef86a9e1b261797434
|