Symbolic algebra and integration system built from scratch. Here are some integrals it can solve!
Current version can do algebraic & trigonometric simplifications, perform differentiation, and can perform all AP calculus BC integrals including polynomials, rational functions, trig functions, logs, exponentials, and combinations of them. Also supports simplification of mathematical expressions, including a custom regex-like library for parsing mathematical expressions.
Clone the repo and pip install .. You can run pytest . in the root directory to run my tests. Look at test_integrals.py and test_khan_academy_integrals.py to see some sample integrals we can do :)
For example, these integrals:
Can be done like so:
import simpy as sp
from fractions import Fraction as F
x = sp.symbols("x")
ans1 = sp.integrate(sp.atan(x))
ans2 = sp.integrate((x - 5)/(-2*x + 2))
ans3 = sp.integrate(sp.sec(2*x)*sp.tan(2*x), (0, sp.pi/6))
ans4 = sp.integrate((F(1, 15) - F(1, 360) * (x-6))*(1 - (40-x)**2/875), (x, 15, 30))
print(ans1, ans2, ans3, ans4, sep="\n")Run pip install -e .[dev] to get the dev dependencies as well as making the install editable.
This project is actively undergoing development; please let me know about any bugs you encounter by making a github issue! If there's an integral that we currently can't solve, create an issue and tag "new integral."
This project uses black and isort with line width of 120.
Run make style to format accordingly. And make check-style to check your edits meet the formatting guidelines.
If you use vscode, you can add this to settings.json to automatically format when you save.
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "always",
"source.fixAll": "always"
},
"editor.rulers": [120],
},
"black-formatter.args": ["--line-length", "120"],
"isort.args": ["--profile", "black", "--line-length", "120"],