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.5.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.5.tar.gz.
File metadata
- Download URL: k3math-0.1.5.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 |
7f3508c846871c7caadcae6c97b537f060eb5f17aee685937343eb779c93e4c7
|
|
| MD5 |
cb82d21a423e2eea8213378873f5a8a7
|
|
| BLAKE2b-256 |
5f22e93caff2d34cac6ccb7dae6c484c90d7e9fa5f73d13db2c4687f55552e03
|
File details
Details for the file k3math-0.1.5-py3-none-any.whl.
File metadata
- Download URL: k3math-0.1.5-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 |
d65248877c1141e9d65a8efb37979b1f20e1a4de86bcd5a14cec447d837edd38
|
|
| MD5 |
3cd6ae2646dbf3707585cbdf4aa2bae8
|
|
| BLAKE2b-256 |
0a05ff6fb282bb7731a5b3b48144f66db7bfb908880d19f0f5022a86e293509d
|