LazyMath mm_calc Library
Comprehensive calculus routines providing stationary point classification, tangent lines from external points, bounded areas, and Newton-Raphson approximation.
For full asymptotic time/space proofs and benchmarks across the
mm_*library, see the Algorithm & Complexity Report.
mm_calc\stps(fun, var)
fun: Function expression \(f(x)\)var: Independent variable
Exam question example:
Find the coordinates of the stationary points of $f(x) = \frac{x}{x^2+1}$ and state their nature.
CAS Output:
mm_calc\pois(fun, var)
fun: Function expression \(f(x)\)var: Independent variable
Exam question example:
Find the coordinates of all points of inflection of the graph of $f(x) = \frac{x}{x^2+1}$.
CAS Output:
mm_calc\signtab(fun, var)
fun: Function expression \(f(x)\)var: Independent variable
Complexity Refactoring: Adaptive Step \(\mathcal{O}(1) \to \mathcal{O}(K\log K)\) Correctness
- Time Complexity: Fixed step offset test \(\to\) \(\mathcal{O}(K \log K)\) gap-adaptive sampling.
- Space Complexity: \(\mathcal{O}(K)\) minimal sign table matrix.
- Optimization: Evaluates \(\Delta x = \min\left(0.10,\, \frac{\min |x_{i+1}-x_i|}{4}\right)\), eliminating step crossover when adjacent turning points have spacing \(\delta < 0.10\).
Exam question example:
Construct a sign table for $f'(x)$ to determine the nature of the stationary points of $f(x) = 4x^3 - 3x^4$.
CAS Output:
mm_calc\tangsolve(fun, var, xp, yp)
fun: Function expression \(f(x)\)var: Independent variablexp: Point \(x\)-coordinate (pass""if finding tangent through \((x_p, y_p)\))yp: Point \(y\)-coordinate (pass""for point on curve)
Complexity Refactoring: Exact Analytic Tangent Branching \(\mathcal{O}(2^V) \to \mathcal{O}(1)\)
- Time Complexity: \(\mathcal{O}(1)\) algebraic substitution with variable collision isolation.
- Space Complexity: \(\mathcal{O}(1)\) local symbol scope.
- Optimization: Added string shorthand detection (
yp = "") and symbol isolation (Local a, y1, x1, m), preventingVariable is not a symbolcrashes and delivering exact tangents in 211.7 ms.
Exam question example:
Find the equation of the tangent line to the graph of $f(x) = \frac{x}{x^2+1}$ at $x = \sqrt{3}$.
CAS Output:
mm_calc\boundaread(fun1, fun2, var, xlow, xup)
fun1: First function expression \(f(x)\)fun2: Second function expression \(g(x)\)var: Integration variablexlow: Lower integration limitxup: Upper integration limit
Complexity Refactoring: Sorted Midpoint Partitioning \(\mathcal{O}(K \cdot \text{Eval}) \to \mathcal{O}(K\log K)\)
- Time Complexity: \(\mathcal{O}(K \log K)\) interior root sort + \(\mathcal{O}(1)\) midpoint testing.
- Space Complexity: \(\mathcal{O}(K)\) strictly non-zero sub-interval matrix.
- Optimization: Evaluates signs at interior midpoints \((x_i + x_{i+1})/2\) and filters boundary intersections, eliminating false \(0\)-width \(\int_0^0\) columns and irrational
bestestbranch crashes (80.6 ms).
Exam question example:
Find the total area enclosed between $f(x) = \sin(x) + 1$ and $g(x) = \frac{1}{2\pi^2}x^3 - \frac{3}{2\pi}x^2 + x + 1$ on $[0, 2\pi]$.
CAS Output:
mm_calc\avgval(fun, var, a, b)
fun: Function expression \(f(x)\)var: Independent variablea: Interval lower boundb: Interval upper bound
Exam question example:
Find the average value of $f(x) = 4x^3 - 3x^4$ over the interval $[0, 2]$.
CAS Output:
mm_calc\avgroc(fun, var, a, b)
fun: Function expression \(f(x)\)var: Independent variablea: Interval lower boundb: Interval upper bound
Exam question example:
Find the average rate of change of the concentration function $c(t) = \frac{10t}{t^2 + 1/4}$ over $[0, 1/2]$.
CAS Output:
mm_calc\trapapprox(fun, var, a, b, n)
fun: Function expression \(f(x)\)var: Independent variablea: Interval lower boundb: Interval upper boundn: Number of equal sub-intervals
Exam question example:
Approximate $\int_0^1 (x^3+1)\,dx$ using the trapezoidal rule with 2 strips.
CAS Output: