k3math is a toy math impl
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
Release history Release notifications | RSS feed
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.2.tar.gz
(7.4 kB
view details)
Built Distribution
File details
Details for the file k3math-0.1.2.tar.gz
.
File metadata
- Download URL: k3math-0.1.2.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d0c2527e7f04fea9e340b9c4afe5b3016a78f25e318978ce7125923cf117b9c |
|
MD5 | e96add739133fdb3c1ab109b00e3e061 |
|
BLAKE2b-256 | 95ff60f776f3811deea97c3e531898625b4cccce77909b0ad169c2744ffd5f05 |
File details
Details for the file k3math-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: k3math-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9ff36621dc8c00874f91485e679ab273490e194372af94df7c40740bed849a0 |
|
MD5 | 938b6497e997ff451495e2d0cd011c34 |
|
BLAKE2b-256 | a0de72a108ef64ae7376c0b64598df709c677e7453714d2b8a667d462c4fa22f |