https://github.com/callumjhays/mathpad
Type-hinted, simplified interface to `sympy` for solving engineering, science and maths problems.
https://github.com/callumjhays/mathpad
compute-algebraic-systems dynamical-systems ipython-notebook latex maths python sympy units-of-measurement
Last synced: 8 months ago
JSON representation
Type-hinted, simplified interface to `sympy` for solving engineering, science and maths problems.
- Host: GitHub
- URL: https://github.com/callumjhays/mathpad
- Owner: CallumJHays
- License: mit
- Created: 2021-08-19T21:26:22.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-12-18T21:36:07.000Z (almost 2 years ago)
- Last Synced: 2024-10-11T15:24:53.305Z (about 1 year ago)
- Topics: compute-algebraic-systems, dynamical-systems, ipython-notebook, latex, maths, python, sympy, units-of-measurement
- Language: Python
- Homepage: https://colab.research.google.com/github/CallumJHays/mathpad/blob/main/examples/Walkthrough.ipynb
- Size: 98.7 MB
- Stars: 14
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# mathpad
`mathpad` is a robust Computer Algebra System (CAS) library built on top of `SymPy`, providing a simple and intuitive way to solve engineering, science, and math problems using Python.
## Quickstart
1. Install using package manager of choice. For example, `pip`:```bash
pip install mathpad
```2. Import and use the library in `python`:
Code Display
```python
from mathpad import *v = 5 * m / s
mph = "mph" * miles / hour
eqn = mph == v.eval()
```

## Documentation
Currently the only in-depth documentation is `Walkthrough.ipynb`. You can access it on the [JupyterLite Sandbox Site here](https://callumjhays.github.io/mathpad/lab?path=Walkthrough.ipynb).
## Showcase
Feature Example Display
Units
```python
mm / s ** 2
feet.in_units(cm)
(V * A).in_units(watt)
```
Values
```python
v = 2.5 * m / sc = m(5)
```
Symbols
```python
t = "t" * secondsy = "\\hat{y}_1" * volts
```
Symbolic Functions
```python
a = "a(t)" * m / s ** 2
```
Equations
```python
eqn = (v == a * t)
```
Solving
```python
sln, = solve([eqn], solve_for=[a])sln[a]
```
Algebra
```python
simplify(e ** (1j * pi))
expand((t + 1)(t + 2))
factor(t**2 + 3 * t * s + 2)
subs((t + 1)(t + 2), { t: 5 })
```
Calculus
```python
diff(a, wrt=t, order=1)integral(a, wrt=t, between=(0, 10))
```
Vectors
```python
O = R3("O") # 3D frame of reference
v1 = O[1, 2, 3]x, y, z = ("x", "y", "z") * m
v2 = O[x, y, z]v3 = "v_3" @ O
v2.cross(v3)
```
Matrices
```python
O2 = R2("O2")
A = Mat[O, O2](
[1, 2],
[3, 4],
[5, 6]
)v2_wrt_O2 = v2 @ A
B = Mat[O2, O]("B")
I = Mat[O2, O2].I
```
Numpy Compatibility
```python
y = sin(t)
y_fn = as_numpy_func(y)y_fn({ t: [1, 2, 3] })
import numpy as np
y_fn({
t: np.arange(
start=0, stop=2 * np.pi, step=np.pi / 12
)
})
```
array([0.84147098, 0.90929743, 0.14112001])
array([0. , 0.25881905, 0.5 , 0.70710678, 0.8660254 ,
0.96592583, 1. , 0.96592583, 0.8660254 , 0.70710678,
0.5 , 0.25881905])Code Generation
```python
generate_c_code(theta, [t])
```## Credits
This package was created with
[Cookiecutter](https://github.com/audreyr/cookiecutter) and the
[browniebroke/cookiecutter-pypackage](https://github.com/browniebroke/cookiecutter-pypackage)
project template.