Advanced Techniques with the General Purpose Math Visualizer Package

Quick Start Guide to the General Purpose Math Visualizer Package

What it is

A lightweight library for creating interactive, high-quality visualizations of mathematical objects and functions (plots, vector fields, matrices, geometry, symbolic expressions) with a simple API that works in notebooks and web apps.

Installation

  • Python (recommended):

    Code

    pip install gp-math-visualizer
  • JavaScript (optional web front-end):

    Code

    npm install gp-math-visualizer

Basic usage (Python)

python

from gp_math_visualizer import Visualizer viz = Visualizer() # Plot a function viz.plot_function(lambda x: x3 - 2*x + 1, x_range=(-3, 3), title=“Cubic”) # Plot vector field viz.plot_vector_field(lambda x,y: (y, -x), x_range=(-2,2), y_range=(-2,2)) # Show multiple subplots viz.subplot([ lambda ax: ax.plot_function(lambda x: x**2, x_range=(-2,2)), lambda ax: ax.plot_function(lambda x: np.sin(x), xrange=(-6,6)) ], cols=2) viz.show()

Basic usage (JavaScript)

javascript

import { Visualizer } from “gp-math-visualizer”; const viz = new Visualizer(”#canvas”); // function plot viz.plotFunction(x => Math.sin(x), { xRange: [-6,6], title: “Sine” }); // vector field viz.plotVectorField((x,y) => [y, -x], { xRange: [-2,2], yRange: [-2,2] });

Key features

  • Function plotting (1D, parametric)
  • 2D and 3D plots, surface and contour maps
  • Vector fields and phase portraits
  • Matrix visualizations (heatmaps, singular values)
  • Symbolic expression rendering (LaTeX output)
  • Interactive controls: zoom, pan, sliders, animation controls
  • Notebook and web embedding; export to PNG/SVG

Typical workflow

  1. Install package.
  2. Create Visualizer instance for your environment (notebook or DOM element).
  3. Call specific plot methods for function, vector field, surface, or matrix.
  4. Add interactive widgets (sliders, play buttons) to control parameters.
  5. Export or embed the visualization.

Tips

  • Use vectorized NumPy functions for performance in Python.
  • Precompute dense grids for smooth 3D surfaces.
  • Combine symbolic simplification with numeric evaluation for clearer labels.
  • Use export to SVG for publication-quality figures.

Troubleshooting

  • Slow renders: reduce grid resolution or use WebGL backend.
  • Missing LaTeX: install a LaTeX renderer or enable MathJax in web front-end.
  • Large datasets: stream data or use downsampling.

If you want, I can generate example notebooks for specific plots (phase portrait, surface with slider, or matrix SVD visualization).

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *