mathlogic-automate
A Python library that automates common mathematics and logic calculations — arithmetic, algebra, geometry, trigonometry, statistics, calculus, and propositional/boolean logic — all through simple, well-documented functions.
Installation
pip install mathlogic-automate
Quick start
import mathlogic_automate as mla
# Basic arithmetic
mla.add(2, 3) # 5
mla.factorial(5) # 120
mla.is_prime(17) # True
# Algebra
mla.solve_equation("x**2 - 4 = 0") # [-2, 2]
mla.expand_expression("(x + 1)**2") # 'x**2 + 2*x + 1'
mla.factor_expression("x**2 - 9") # '(x - 3)*(x + 3)'
mla.quadratic_roots(1, -3, 2) # (1, 2)
# Geometry
mla.circle_area(5) # 78.53981633974483
mla.triangle_area_heron(3, 4, 5) # 6.0
mla.pythagoras(a=3, b=4) # 5.0
# Trigonometry
mla.sin_deg(30) # 0.49999999999999994
# Statistics
mla.summary_stats([1, 2, 2, 3, 4])
# {'count': 5, 'mean': 2.4, 'median': 2, 'mode': [2], 'min': 1,
# 'max': 4, 'range': 3, 'variance': 1.3, 'std_dev': 1.140...}
# Calculus
mla.differentiate("x**3 + 2*x") # '3*x**2 + 2'
mla.integrate_expr("2*x") # 'x**2'
mla.definite_integral("x**2", "x", 0, 3) # 9.0
mla.limit_of("sin(x)/x", "x", 0) # '1'
# Logic
mla.evaluate_logical_expression("A AND (B OR NOT C)", {"A": True, "B": False, "C": False})
# True
mla.truth_table("A AND B")
# [{'A': False, 'B': False, 'result': False},
# {'A': False, 'B': True, 'result': False},
# {'A': True, 'B': False, 'result': False},
# {'A': True, 'B': True, 'result': True}]
mla.simplify_boolean("A AND (A OR B)") # 'A'
mla.is_tautology("A OR NOT A") # True
mla.is_satisfiable("A AND NOT A") # False
Modules
| Module | Covers |
|---|---|
basic |
add, subtract, multiply, divide, power, square root, factorial, primes, gcd/lcm, percentage, average |
algebra |
solving equations & systems, expanding, factoring, simplifying, evaluating expressions |
geometry |
area, perimeter, surface area, and volume for common 2D/3D shapes |
trigonometry |
sin/cos/tan in degrees and radians |
statistics_ops |
mean, median, mode, variance, standard deviation, summary stats |
calculus |
differentiation, indefinite/definite integrals, limits |
logic |
truth tables, boolean simplification, CNF/DNF, tautology/contradiction/satisfiability checks, AND/OR/NOT/XOR/implies/equivalent |
Logic expression syntax
Expressions accept either word operators or symbols:
| Meaning | Word form | Symbol form |
|---|---|---|
| AND | A AND B |
A & B |
| OR | A OR B |
A | B |
| NOT | NOT A |
~A |
| XOR | A XOR B |
A ^ B |
| Implies | A -> B |
A -> B |
| Equivalent | A <-> B |
A <-> B |
Running tests
pip install -e ".[dev]"
pytest
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mathlogic_automate-0.1.0.tar.gz
(11.6 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 mathlogic_automate-0.1.0.tar.gz.
File metadata
- Download URL: mathlogic_automate-0.1.0.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f1e650d10d63a765177b1d3d9739f985749ba3c45a67221a6793ec1727432a4
|
|
| MD5 |
fca5f14c43b9b813516ec6bba4eadfcf
|
|
| BLAKE2b-256 |
a12812e0e71a5d4b7cec2b26b97c5a912fdb66f8e41b8dd52b75a05456d5cd44
|
File details
Details for the file mathlogic_automate-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mathlogic_automate-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ad260b6375a8d288d212928b1924aed62ffd2b17dab7381f314a8431825b257
|
|
| MD5 |
24c0a50da9a2ff37a842d032c7d4d446
|
|
| BLAKE2b-256 |
1fd022a9775cda542e239d4b291b013f7225e08866cbf1919fa23174c8702d40
|