LazyMath mm_func Library
Functions and graphs routines for interactive transformations, inverse functions, composite existence, and simultaneous linear systems.
For full asymptotic time/space proofs and benchmarks across the
mm_*library, see the Algorithm & Complexity Report.
mm_func\transform(f, var)
f: Original base function \(f(x)\)var: Independent variable
Exam question example:
Transform the base function $f(x) = x^2$ through reflections, dilations, and translations with the interactive menu:
1. Reflection (in x/y)\n2. Translation (units in x or y, accepts negative units e.g. -1)\n3. Dilation (factor from x or y)\n4. End Transformations
CAS Output:
mm_func\inverse(fun, var, invicx)
fun: Function expression \(f(x)\)var: Independent variableinvicx: Initial condition for domain branch (pass""for global 1-to-1)
Complexity Refactoring: Inflection-Center Inversion \(\mathcal{O}(\text{Matrix Solve}) \to \mathcal{O}(1)\)
- Time Complexity: \(\mathcal{O}(1)\) exact radical inversion + empty condition branch handling.
- Space Complexity: \(\mathcal{O}(1)\) local symbol scope.
- Optimization: Replaced broken matrix system with direct inflection-point radical decomposition \(y = x_0 \pm \left(\frac{x - y_0}{a}\right)^{1/n}\) and added
invicx = ""handling to render 1-to-1 inverse functions in 164.5 ms.
Exam question example:
Find the inverse function of $f(x) = \frac{1}{4}(x + 2)^3 + 2$ and state its domain.
CAS Output:
mm_func\invints(fun, n)
fun: Function expression \(f(x)\) with parameter \(k\)n: Desired number of intersection points with \(f^{-1}(x)\)
Complexity Refactoring: Univariate Parameter Elimination \(\mathcal{O}(2^V) \text{ / Hang} \to \mathcal{O}(1)\)
- Time Complexity: \(\mathcal{O}(2^V)\) bivariate equation search \(\to\) \(\mathcal{O}(1)\) univariate parameter elimination along \(y = x\).
- Space Complexity: \(\mathcal{O}(\text{Tree}) \to \mathcal{O}(1)\).
- Optimization: Parameterized \(k(x) = \frac{\ln x}{x}\) along the line of symmetry \(y = x\), reducing 2D tangency to a single 1D derivative equation and dropping runtime from an infinite CAS hang to 51.1 ms.
Exam question example:
Find the values of $k$ for which $f(x) = e^{kx}$ intersects its inverse in exactly 1 point.
CAS Output:
mm_func\ccheck(f, g)
f: Outer function \(f(u)\)g: Inner function \(g(x)\)
Exam question example:
Verify whether the composite function $f(g(x))$ exists for $f(x) = 2x^2+x-1$ and $g(x) = \sin(x)$.
CAS Output:
mm_func\linesolve(e1, e2)
e1: First linear equation containing parameter \(k\)e2: Second linear equation containing parameter \(k\)
Complexity Refactoring: Linear Differential Operator \(\mathcal{O}(D^2) \text{ / Crash} \to \mathcal{O}(1)\)
- Time Complexity: \(\mathcal{O}(D^2)\) polynomial extraction \(\to\) \(\mathcal{O}(1)\) partial derivatives \(\partial_x, \partial_y\) + cross-product determinants.
- Space Complexity: \(\mathcal{O}(D) \to \mathcal{O}(1)\).
- Optimization: Evaluates \(a = \frac{\partial L}{\partial x}, b = \frac{\partial L}{\partial y}\) on residual \(L(x,y)\), eliminating division-by-zero crashes on RHS equations and classifying parameter branches in 156.1 ms.
Exam question example:
Solve the linear system for all parameter cases of $k$:
\[ kx + 3y = k^2, \quad 2x + (2k+1)y = 6 - 2k \]CAS Output: