MCPcopy Index your code
hub / github.com/HarleyCoops/Math-To-Manim

github.com/HarleyCoops/Math-To-Manim @v1.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.0.0 ↗ · + Follow
1,037 symbols 3,006 edges 139 files 485 documented · 47%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Math-To-Manim

Python Version License FFmpeg Required Manim Version GitHub Stars

Claude Sonnet 4.5 Gemini 3 Kimi K2 DeepSeek R1 Grok 3

Star History Chart

See It In Action

Brownian Motion: From Pollen to Portfolio

Brownian Motion

A journey from Robert Brown's microscope to Einstein's heat equation, arriving at the Black-Scholes model for financial options pricing.


Recursive Rhombicosidodecahedron

Recursive Rhombicosidodecahedron

A fractal Archimedean solid where every vertex spawns another complete rhombicosidodecahedron.


The Hopf Fibration

Teaching Hopf

Stereographic projection of S3 fibers creating nested tori - pure topology rendered in 3D.


The Whiskering Exchange

Whiskering Exchange

Visualizing the commutative property of 2-cell composition in higher category theory.

Three AI Pipelines, One Goal

Math-To-Manim offers three distinct AI pipelines. Choose based on your API access and preferences:

Pipeline Comparison

Feature Gemini 3 (Google ADK) Claude Sonnet 4.5 Kimi K2
Framework Google Agent Development Kit Anthropic Agent SDK OpenAI-compatible API
Architecture Six-Agent Swarm Six-Agent Pipeline Three-Stage Enrichment
Strengths Complex topology, physics reasoning Reliable code generation, recursion Chain-of-thought, structured tools
Best For Advanced 3D math, Kerr metrics General purpose, production use LaTeX-heavy explanations
Setup Complexity Moderate Simple Simple

Pipeline 1: Google Gemini 3 (ADK)

Location: Gemini3/

The Gemini pipeline uses the Google Agent Development Kit with a six-agent swarm architecture. Each agent is a specialist with a specific role in the animation generation process.

How It Works

Gemini Pipeline Architecture

Quick Start

# Set API key
echo "GOOGLE_API_KEY=your_key_here" >> .env

# Run the pipeline
python Gemini3/run_pipeline.py "Explain the Hopf Fibration"

Key Files

  • Gemini3/run_pipeline.py - Entry point
  • Gemini3/src/agents.py - Agent definitions with system prompts
  • Gemini3/src/pipeline.py - Orchestration logic
  • Gemini3/docs/GOOGLE_ADK_AGENTS.md - Full documentation

Pipeline 2: Claude Sonnet 4.5 (Anthropic SDK)

Location: src/

The Claude pipeline uses the Anthropic Agent SDK with automatic context management and built-in tools.

How It Works

Claude Pipeline Architecture

Key Files

  • src/app_claude.py - Gradio UI entry point
  • src/agents/prerequisite_explorer_claude.py - Claude SDK agent
  • docs/ARCHITECTURE.md - System design details

Pipeline 3: Kimi K2 Thinking Model

Location: KimiK2Thinking/

The Kimi pipeline uses Moonshot AI's K2 thinking model with an OpenAI-compatible API and tool-calling interface.

How It Works

Kimi Pipeline Architecture

Quick Start

# Set API key
echo "MOONSHOT_API_KEY=your_key_here" >> .env

# Run prerequisite exploration
python KimiK2Thinking/examples/test_kimi_integration.py

# Run full enrichment pipeline
python KimiK2Thinking/examples/run_enrichment_pipeline.py path/to/tree.json

Key Files

  • KimiK2Thinking/kimi_client.py - API client
  • KimiK2Thinking/agents/enrichment_chain.py - Three-stage pipeline
  • KimiK2Thinking/README.md - Complete documentation

Installation

# Clone repository
git clone https://github.com/HarleyCoops/Math-To-Manim
cd Math-To-Manim

# Install dependencies
pip install -r requirements.txt

# Set up your preferred API key
echo "ANTHROPIC_API_KEY=your_key" >> .env    # For Claude
echo "GOOGLE_API_KEY=your_key" >> .env       # For Gemini
echo "MOONSHOT_API_KEY=your_key" >> .env     # For Kimi

# Install FFmpeg (required for video rendering)
# Windows: choco install ffmpeg
# Linux: sudo apt-get install ffmpeg
# macOS: brew install ffmpeg

Run Example Animations

We have 55+ working examples organized by topic:

# Physics - Black Hole Symphony
manim -pql examples/physics/black_hole_symphony.py BlackHoleSymphony

# Mathematics - Hopf Fibration
manim -pql examples/misc/epic_hopf.py HopfFibrationEpic

# Finance - Option Pricing
manim -pql examples/finance/optionskew.py OptionSkewScene

# Computer Science - Neural Networks
manim -pql examples/computer_science/machine_learning/AlexNet.py AlexNetScene

Flags: -p preview, -q quality (l low, m medium, h high, k 4K)

Browse all examples: docs/EXAMPLES.md


Repository Structure

Math-To-Manim/
|
+-- src/                    # Claude Sonnet 4.5 pipeline
|   +-- agents/             # Agent implementations
|   +-- app_claude.py       # Gradio UI
|
+-- Gemini3/                # Google Gemini 3 pipeline
|   +-- src/                # Agent definitions
|   +-- docs/               # Gemini-specific docs
|   +-- run_pipeline.py     # Entry point
|
+-- KimiK2Thinking/         # Kimi K2 pipeline
|   +-- agents/             # Enrichment chain
|   +-- examples/           # Usage examples
|
+-- examples/               # 55+ working animations
|   +-- physics/            # Quantum, gravity, particles
|   +-- mathematics/        # Geometry, topology, analysis
|   +-- computer_science/   # ML, algorithms
|   +-- cosmology/          # Cosmic evolution
|   +-- finance/            # Option pricing
|
+-- docs/                   # Documentation
+-- tests/                  # Test suite
+-- tools/                  # Utility scripts

Why LaTeX-Rich Prompting Works

The Problem with Vague Prompts

"Create an animation showing quantum field theory"

Result: Generic, incorrect, or broken code.

The Solution: Verbose LaTeX Prompts

"Begin with Minkowski spacetime showing the metric:

$$ds^2 = -c^2 dt^2 + dx^2 + dy^2 + dz^2$$

Each component highlighted in different hues. Introduce the QED Lagrangian:

$$\mathcal{L}_{\text{QED}} = \bar{\psi}(i \gamma^\mu D_\mu - m)\psi - \tfrac{1}{4}F_{\mu\nu}F^{\mu\nu}$$

with Dirac spinor $\psi$ in orange, covariant derivative $D_\mu$ in green..."

Result: Perfect animations with correct LaTeX, camera movements, and timing.

Our agents generate these verbose prompts automatically by walking the knowledge tree.


Common Pitfalls (And How We Solve Them)

Problem Traditional Approach Our Solution
LaTeX Errors Hope for the best Verbose prompts show exact formulas
Vague Cinematography "Show quantum field" Specify colors, angles, timing
Missing Prerequisites Jump to advanced topics Recursive dependency discovery
Inconsistent Notation Mixed symbols Mathematical enricher maintains consistency

Technical Requirements

  • Python: 3.10+
  • **

Core symbols most depended-on inside this repo

run
called by 25
Gemini3/src/pipeline.py
analyze
called by 20
src/agents/prerequisite_explorer.py
explore
called by 16
src/agents/prerequisite_explorer.py
get_text_content
called by 12
KimiK2Thinking/kimi_client.py
chat_completion
called by 11
KimiK2Thinking/kimi_client.py
log
called by 11
Gemini3/reproduce_issue.py
run_query_via_sdk
called by 8
src/agents/claude_agent_runtime.py
to_dict
called by 8
src/agents/visual_designer.py

Shape

Method 632
Class 218
Function 162
Route 25

Languages

Python100%

Modules by API surface

tests/test_prerequisite_explorer.py55 symbols
examples/cosmology/Claude37Cosmic.py39 symbols
tests/live_test_runner.py31 symbols
tests/test_kimi_k2_prerequisite_explorer.py30 symbols
KimiK2Thinking/agents/enrichment_chain.py29 symbols
examples/physics/black_hole_symphony.py27 symbols
src/agents/prerequisite_explorer_claude.py21 symbols
examples/computer_science/machine_learning/NativeSparseAttention2.py21 symbols
examples/physics/quantum/Hunyuan-T1QED.py20 symbols
examples/computer_science/machine_learning/NativeSparseAttention.py20 symbols
examples/physics/nuclear/radium_atom.py18 symbols
examples/misc/visual_styles_showcase.py18 symbols

For agents

$ claude mcp add Math-To-Manim \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page