User Guide

Learn how to use Calcora effectively for mathematical computations.

Getting Started

Calcora offers three ways to get started:

Differentiation

Compute derivatives with step-by-step explanations.

Basic Example

differentiate("x**2 + 3*x", "x")
Tip: Use verbosity="detailed" for educational explanations showing each rule applied.

Supported Functions

Integration

Compute indefinite and definite integrals with visual representations and step-by-step solutions.

Indefinite Integral (Antiderivative)

# Find ∫x² dx
from calcora import integrate

result = integrate("x**2", "x")
print(result['output'])  # "x**3/3 + C"

Definite Integral (Area Under Curve)

# Calculate ∫₀² x² dx
result = integrate(
    expression="x**2",
    variable="x",
    lower_limit=0,
    upper_limit=2
)
print(result['output'])  # "8/3" (approximately 2.667)

Integration Techniques Supported

💡 Pro Tip: Set generate_graph=true to get visualization data showing the integrand curve, antiderivative, and shaded area (for definite integrals).

Common Integrals

# Trigonometric
integrate("sin(x)", "x")  # -cos(x) + C

# Exponential
integrate("exp(x)", "x")  # exp(x) + C

# Rational
integrate("1/x", "x")  # ln|x| + C

# Product requiring integration by parts
integrate("x*exp(x)", "x")  # x*exp(x) - exp(x) + C

# Area calculation
integrate("sin(x)", "x", 0, 3.14159)  # Area = 2

Matrix Operations

Perform matrix calculations including determinants, inverses, eigenvalues, and RREF with detailed step-by-step explanations.

Determinant

Calculate the determinant of a square matrix:

from calcora import matrix_determinant

matrix = [[3, 8], [4, 6]]
result = matrix_determinant(matrix)
print(result['result'])  # -14

Matrix Inverse

Find the inverse of a matrix (if it exists):

from calcora import matrix_inverse

matrix = [[1, 2], [3, 4]]
result = matrix_inverse(matrix)
print(result['result'])  # [[-2, 1], [1.5, -0.5]]
Note: If the determinant is 0, the matrix is singular and has no inverse.

Eigenvalues and Eigenvectors

Compute eigenvalues and eigenvectors:

from calcora import matrix_eigenvalues

matrix = [[2, 1], [1, 2]]
result = matrix_eigenvalues(matrix)
print(result['eigenvalues'])  # [3, 1]
print(result['eigenvectors'])  # [[0.707, 0.707], [-0.707, 0.707]]

Row Reduction (RREF)

Reduce a matrix to row echelon form:

from calcora import matrix_rref

# Solve system: 2x + y = 5, x - y = 1
augmented = [[2, 1, 5], [1, -1, 1]]
result = matrix_rref(augmented)
print(result['result'])  # [[1, 0, 2], [0, 1, 1]]
# Solution: x = 2, y = 1

LU Decomposition

Factor a matrix into lower and upper triangular forms with partial pivoting: PA = LU

from calcora import matrix_lu

matrix = [[2, 1, 1], [4, -6, 0], [-2, 7, 2]]
result = matrix_lu(matrix)

print(result['P'])  # Permutation matrix
print(result['L'])  # Lower triangular (1s on diagonal)
print(result['U'])  # Upper triangular
💡 Why LU Decomposition? Once computed, you can reuse LU to solve Ax = b for multiple different b vectors efficiently. Also useful for computing determinants and matrix inverses.

Verification

The decomposition satisfies: PA = LU

Use Cases

Common Examples Library

Real-world problems you can solve with Calcora:

Physics & Engineering

# Velocity from position function s(t) = 3t² + 2t
differentiate("3*t**2 + 2*t", "t")  # v(t) = 6t + 2

# Work done by force F = x² over distance 0 to 5
integrate("x**2", "x", 0, 5)  # W = 41.67 J

# Area under normal distribution curve (standard)
integrate("exp(-x**2/2)", "x", -1, 1)  # ≈ 0.683 (68.3%)

Economics & Finance

# Marginal cost from total cost C(x) = 100 + 50x + 0.5x²
differentiate("100 + 50*x + 0.5*x**2", "x")  # MC = 50 + x

# Consumer surplus with demand function p = 100 - 2q
integrate("100 - 2*q", "q", 0, 25)  # Surplus = 1875

# Present value of continuous income stream
integrate("1000*exp(-0.05*t)", "t", 0, 10)  # PV ≈ $7,869

Calculus Practice Problems

# Chain rule: d/dx[sin(x²)]
differentiate("sin(x**2)", "x")  # 2x·cos(x²)

# Product rule: d/dx[x·ln(x)]
differentiate("x*log(x)", "x")  # ln(x) + 1

# Integration by parts: ∫x·eˣ dx
integrate("x*exp(x)", "x")  # x·eˣ - eˣ + C

# Partial fractions: ∫(3x+1)/(x²-1) dx
integrate("(3*x+1)/(x**2-1)", "x")  # 2·ln|x-1| + ln|x+1| + C

Advanced Techniques

# Trig substitution: ∫√(1-x²) dx
integrate("sqrt(1-x**2)", "x")  # (x·√(1-x²) + arcsin(x))/2 + C

# Rational function with u-substitution
integrate("x/(x**2+1)", "x")  # (1/2)·ln(x²+1) + C

# Logarithmic integration
integrate("log(x)", "x")  # x·ln(x) - x + C

Error Messages & Troubleshooting

Understanding common errors and how to fix them:

❌ "Invalid expression syntax"
Problem: Using ^ instead of ** for exponentiation
Fix: x^2x**2
❌ "Integration technique not yet supported"
Problem: Expression requires advanced methods (e.g., trig substitution for complex radicals)
Fix: Try simplifying, or check if SymPy can handle it directly
❌ "Matrix is singular (determinant = 0)"
Problem: Cannot compute inverse because matrix is not invertible
Fix: Verify matrix entries; singular matrices have linearly dependent rows
⚠️ "Result simplified by SymPy (no step-by-step available)"
Meaning: Expression was too complex for step explanations, but result is correct
Context: Happens with highly nested compositions or transcendental combinations

Tips & Tricks

Input Syntax

Verbosity Modes

Performance Tips

Symbolic Variables

Next Steps