MathRuler

0.1.0 · active · verified Fri Apr 17

MathRuler is a powerful and versatile Python library, currently at version 0.1.0, designed to simplify and enhance mathematical calculations. It aims to provide tools for handling equations, units, and general computations, leveraging symbolic and numerical backends. As an early-stage library, its API is subject to iterative improvements with a rapid release cadence.

Common errors

Warnings

Install

Imports

Quickstart

Initializes a MathRuler instance and demonstrates solving a simple equation, evaluating an expression, and using variables. The `.equation()` method returns an equation object that can be further manipulated, for example, to solve for a specific variable. The `.evaluate()` method directly computes an expression.

from mathruler import MathRuler

# Initialize the MathRuler
ruler = MathRuler()

# Solve a simple algebraic equation
result_equation = ruler.equation("2x + 5 = 10")
print(f"Equation result: {result_equation.solve_for('x')}")

# Perform a calculation with units (if supported in future versions, currently basic)
# Note: Unit support is an evolving feature and may require specific syntax.
# For 0.1.0, focus on basic equations.
# Example: Evaluate an expression
result_eval = ruler.evaluate("5 * (3 + 2)")
print(f"Evaluation result: {result_eval}")

# Define and use a variable
ruler.set_variable('y', 15)
result_var = ruler.evaluate("y / 3")
print(f"Variable calculation result: {result_var}")

view raw JSON →