Skip to main content

Math Engine

Deterministic verification of mathematical expressions using SymPy.

Overview

The Math Engine uses SymPy for symbolic computation to provide 100% accurate verification of:

  • Arithmetic expressions
  • Algebraic identities
  • Calculus (derivatives, integrals)
  • Trigonometric functions
  • Complex numbers

Usage

result = client.verify_math("x**2 + 2*x + 1 = (x+1)**2")
print(result.verified) # True (identity verified)

Supported Operations

CategoryExamples
Arithmetic2+2=4, 15*3=45
Algebrax^2 - 1 = (x-1)(x+1)
Calculusderivative of x^2 = 2x
Trigonometrysin(pi/2) = 1
Logarithmslog(e) = 1

Identity Verification

# Verify algebraic identities
result = client.verify_math("(a+b)^2 = a^2 + 2*a*b + b^2")
# Verified: True

# Catch incorrect identities
result = client.verify_math("(a+b)^2 = a^2 + b^2")
# Verified: False, Message: "Missing 2ab term"

Expression Evaluation

result = client.verify_math("sqrt(16) + 3^2")
# Result: 13.0

Error Correction

result = client.verify("15% of 200 is 40")
# Status: CORRECTED
# Message: "15% of 200 is 30, not 40"