A Python library for mathematical and physics calculations.
Project description
PyPoSolver
PyPoSolver is a Python library for performing mathematical and physics calculations, including numerical integration, root-finding, linear algebra operations, and basic mechanics.
Installation
pip install pyposolver
Usage
Mathematics
Integration
Use the trapezoidal_rule
function to perform numerical integration:
from pyposolver.maths.integration import trapezoidal_rule
def f(x):
return x**2
result = trapezoidal_rule(f, 0, 1, 100) # Integrate f(x) from 0 to 1 using 100 intervals
print(result) # Expected: 0.333...
Root-Finding
- Bisection Method
Use bisection_method
to find the root of a function within a specified interval:
from pyposolver.maths.root_finding import bisection_method
def f(x):
return x**2 - 4
root = bisection_method(f, 0, 3) # Find root of f(x) in the interval [0, 3]
print(root) # Expected: 2.0
- Newton-Raphson Method
Use newton_raphson_method
for root-finding with an initial guess and the function's derivative:
from pyposolver.maths.root_finding import newton_raphson_method
def f(x):
return x**3 - 2*x - 5
def df(x):
return 3*x**2 - 2
root = newton_raphson_method(f, df, 2) # Initial guess: 2
print(root) # Expected: 2.094...
Linear Algebra
- Dot Product
Calculate the dot product of two vectors:
from pyposolver.maths.linear_algebra import dot_product
vector1 = [1, 2, 3]
vector2 = [4, 5, 6]
result = dot_product(vector1, vector2)
print(result) # Expected: 32
- Cross Product
Compute the cross product of two 3D vectors:
from pyposolver.maths.linear_algebra import cross_product
vector1 = [1, 2, 3]
vector2 = [4, 5, 6]
result = cross_product(vector1, vector2)
print(result) # Expected: [-3, 6, -3]
- Matrix Multiplication
Multiply two matrices:
from pyposolver.maths.linear_algebra import matrix_multiply
matrix1 = [[1, 2], [3, 4]]
matrix2 = [[5, 6], [7, 8]]
result = matrix_multiply(matrix1, matrix2)
print(result) # Expected: [[19, 22], [43, 50]]
Physics
- Velocity
Calculate velocity given initial velocity, acceleration, and time:
from pyposolver.physics.mechanics import velocity
initial_velocity = 5
acceleration = 2
time = 3
result = velocity(initial_velocity, acceleration, time)
print(result) # Expected: 11
- Force
Calculate force using mass and acceleration:
from pyposolver.physics.mechanics import force
mass = 10
acceleration = 5
result = force(mass, acceleration)
print(result) # Expected: 50
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
Built Distribution
File details
Details for the file pyposolver-0.2.tar.gz
.
File metadata
- Download URL: pyposolver-0.2.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3cdaf02770da753fa6cf7bf6247cfb0e751c5e072b85ff6173e3b054dc0191d |
|
MD5 | ba8d0cb3aa97da0961dce2bbf98f4f45 |
|
BLAKE2b-256 | 4a1a3a72415ba7fa2b67a312579e5392bf9549e2e833e037b727290b58ab10b7 |
File details
Details for the file pyposolver-0.2-py3-none-any.whl
.
File metadata
- Download URL: pyposolver-0.2-py3-none-any.whl
- Upload date:
- Size: 11.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad475ba17a1937f102746c736d6826db1526f73f25aefc9967faa581513374d6 |
|
MD5 | ce7deb3fec24d8a0be458d5970fa0cf8 |
|
BLAKE2b-256 | e3d7b442509899300789c495ce5485c9f5d8d2b75a5a7c5cbbc2c18d63e0bb47 |