A Windows desktop application for symbolic calculus with step-by-step solutions and interactive features.
🎓 Comprehensive calculus toolkit supporting single and multivariate calculus operations with symbolic computation and real-time visualization.
- Differentiation (d/dx) - Find derivatives with step-by-step solutions
- Indefinite Integration (∫ f(x) dx) - Find antiderivatives + C
- Definite Integration (∫[a,b] f(x) dx) - Calculate area under curve
- Limits (lim f(x)) - Calculate limits with step-by-step evaluation
- Matrix Multiplication - Multiply matrices with custom dimensions
- Partial Derivatives (∂f/∂x, ∂f/∂y) - Compute partial derivatives for multivariate functions
- Double Integration (∫∫ f(x,y) dy dx) - Calculate double integrals over rectangular regions
- Custom Equation Input: Type your own equations interactively
- Step-by-Step Solutions: View detailed calculations with mathematical notation
- UTF-8 Support: Full Unicode support for Greek letters (∂, π, α) and math symbols (⋅, √, ∫)
- Interactive Menu: Choose operation at startup
- Multiple Examples: Pre-loaded expressions for each mode
- OpenGL Plotting: Real-time graphs for all modes:
- Differentiation: f(x) and f'(x) curves
- Indefinite: f(x) and F(x) antiderivative curves
- Definite: f(x) with shaded area between bounds
- Bounds Input: Set custom integration bounds for definite integrals
- C++17
- SDL2 + SDL2_ttf for windowing and UTF-8 text rendering
- OpenGL for plotting and graphics
- GLEW for OpenGL extension loading
- CMake for cross-platform building
Download and install MSYS2 from https://www.msys2.org/
Open MSYS2 MinGW64 terminal and run:
# Update package database
pacman -Syu
# Install compiler and build tools
pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake mingw-w64-x86_64-make
# Install SDL2 and graphics libraries
pacman -S mingw-w64-x86_64-SDL2 mingw-w64-x86_64-SDL2_ttf
pacman -S mingw-w64-x86_64-glew mingw-w64-x86_64-glmcd Mathh
mkdir build
cd build
g++ -std=c++17 -I/mingw64/include -I../src ../src/main.cpp ../src/engine/parser.cpp ../src/engine/differentiator.cpp ../src/engine/integrator.cpp ../src/engine/simplifier.cpp ../src/engine/limit_calculator.cpp ../src/engine/matrix_operations.cpp ../src/engine/latex_exporter.cpp ../src/engine/partial_derivative.cpp ../src/engine/multivariate_integrator.cpp ../src/ui/renderer.cpp ../src/ui/text_renderer.cpp ../src/ui/plotter.cpp -L/mingw64/lib -o MathEngineUTF8.exe -lmingw32 -lSDL2main -lSDL2 -lSDL2_ttf -lfreetype -lharfbuzz -lgraphite2 -ldwrite -lole32 -lbz2 -lz -lglew32 -lopengl32 -mconsole -O2 -Wallcd Mathh
mkdir build
cd build
# Generate build files
cmake -G "MinGW Makefiles" ..
# Compile
cmake --build ../math_engine.exeMathEngineUTF8 now supports native Linux builds 🎉
Follow the steps below to compile and run it easily.
Make sure you have all required development tools and libraries:
sudo apt update
sudo apt install build-essential pkg-config libsdl2-dev libsdl2-ttf-dev libglew-dev libgl1-mesa-devgit clone https://github.com/shubhu121/Mathh.git
cd Mathh
Run the included Linux build script:
./build/build_linux.sh
This script will:
-
Compile all source files using g++ -std=c++17
-
Use pkg-config to link against SDL2, SDL2_ttf, GLEW, and OpenGL
-
Output the executable MathEngineUTF8 inside the build/ directory
./build/MathEngineUTF8
you should see output like :
+===================================+
| Mathematics Engine - Calculus |
+===================================+
- The Linux build script is located at:
build/build_linux.sh - You can edit it if you use a different compiler or custom flags.
- The script won’t affect Windows or other build systems.
| Key | Action |
|---|---|
| 1-7 | Select operation (1=Diff, 2=Indefinite, 3=Definite, 4=Limits, 5=Matrix, 6=Partial, 7=Double) |
| UP/DOWN | Navigate menu |
| ENTER | Confirm selection |
| ESC | Quit |
| Key | Action |
|---|---|
| ENTER | Type custom equation |
| SPACE | Next example |
| UP/DOWN | Scroll steps |
| ESC | Return to menu |
| Key | Action |
|---|---|
| B | Change bounds |
| TAB | Switch between bounds |
| Key | Action |
|---|---|
| L or P | Open limit configuration |
| T | Quick toggle limit type (finite/+∞/-∞) |
| TAB | Switch fields in config |
| Key | Action |
|---|---|
| TAB | Switch between dimension fields |
| ENTER | Confirm and enter matrix values |
| Key | Action |
|---|---|
| ENTER | Type custom equation f(x,y) |
| SPACE | Next example |
| X | Export to LaTeX |
| Key | Action |
|---|---|
| B | Set integration bounds (x and y) |
| TAB | Switch between bound fields |
| SPACE | Next example |
- Launch: See main menu with 7 operations
- Select Mode: Press 1-7 or use UP/DOWN arrows + ENTER
- Custom Input: Press ENTER and type equation
- View Results: See step-by-step solution
- Advanced Features: Press B for bounds, L/P for limit config, X for LaTeX export
- Return: Press ESC to go back to menu
- Addition:
x + 2 - Subtraction:
x - 3 - Multiplication:
x * 5or5x - Division:
x / 2 - Exponentiation:
x^3
sin(x),cos(x),tan(x)
exp(x)- Exponentialln(x)- Natural logarithmsqrt(x)- Square root
Differentiation:
sin(x^2) → Chain rule
x^3 + 2*x → Power rule
(x^3 + 2*x)*cos(x) → Product rule
Integration:
x^2 → Power rule (first/second degree)
sin(x) → Trigonometric
exp(x) → Exponential
Definite Integration:
x^2 from [0, 3] → Area = 9.0
sin(x) from [0, π] → Area = 2.0
Partial Derivatives:
x^2 + y^2 → ∂f/∂x = 2*x, ∂f/∂y = 2*y
x*y → ∂f/∂x = y, ∂f/∂y = x
sin(x)*cos(y) → ∂f/∂x = cos(x)*cos(y), ∂f/∂y = -sin(x)*sin(y)
Double Integration:
x*y over [0,1]×[0,1] → Result = 0.25
x^2 + y^2 over [0,2]×[0,2] → Numerical result
MathEngine/
├── CMakeLists.txt # Build configuration
├── README.md # This file
├── src/
│ ├── main.cpp # Application entry point
│ ├── engine/
│ │ ├── ast.h/.cpp # Abstract Syntax Tree definitions
│ │ ├── parser.h/.cpp # Expression parser
│ │ ├── differentiator.h/.cpp # Symbolic differentiation
│ │ ├── integrator.h/.cpp # Symbolic integration
│ │ ├── simplifier.h/.cpp # Expression simplification
│ │ ├── limit_calculator.h/.cpp # Limit evaluation
│ │ ├── matrix_operations.h/.cpp # Matrix operations
│ │ ├── latex_exporter.h/.cpp # LaTeX export
│ │ ├── partial_derivative.h/.cpp # Partial derivatives
│ │ └── multivariate_integrator.h/.cpp # Double integration
│ └── ui/
│ ├── renderer.h/.cpp # SDL2/OpenGL renderer
│ ├── text_renderer.h/.cpp # UTF-8 text rendering
│ └── plotter.h/.cpp # Function plotting
└── assets/
└── fonts/
└── NotoSans-Regular.ttf # UTF-8 compatible font
- Input expression is tokenized and converted to Abstract Syntax Tree (AST)
- Supports operator precedence and parentheses
- Handles implicit multiplication (e.g.,
2x→2 * x)
- Applies calculus rules:
- Power Rule: d/dx(xⁿ) = n·xⁿ⁻¹
- Chain Rule: d/dx(f(g(x))) = f'(g(x))·g'(x)
- Product Rule: d/dx(f·g) = f'·g + f·g'
- Quotient Rule: d/dx(f/g) = (f'·g - f·g')/g²
- Records each step with description and expression
- Applies integration rules:
- Power Rule: ∫ xⁿ dx = xⁿ⁺¹/(n+1) + C
- Constant Multiple: ∫ c·f(x) dx = c·∫ f(x) dx
- Sum Rule: ∫ (f + g) dx = ∫ f dx + ∫ g dx
- Trigonometric: ∫ sin(x) dx = -cos(x) + C
- For definite: applies Fundamental Theorem (F(b) - F(a))
- Records each step with description
- Eliminates redundant operations:
x + 0→xx * 1→xx * 0→0x^1→x
- Constant folding: evaluates numeric expressions
- Text: SDL2_ttf renders UTF-8 strings to OpenGL textures
- Plotting: OpenGL draws function graphs by sampling x values
- UI: Orthographic projection for 2D interface
- Menu System: Interactive mode selection
Edit src/main.cpp:
textRenderer.init("assets/fonts/NotoSans-Regular.ttf", 24); // Change 24 to desired size- Add function to
UnaryFuncenum insrc/engine/ast.h - Implement derivative in
src/engine/differentiator.cpp - Add parser support in
src/engine/parser.cpp
Edit src/main.cpp:
plotter.setViewport(-5, 5, -5, 5); // xMin, xMax, yMin, yMaxEnsure NotoSans-Regular.ttf is in build/assets/fonts/
Copy these from MinGW64 bin to build directory:
- SDL2.dll
- SDL2_ttf.dll
- libfreetype-6.dll
- glew32.dll
- libgcc_s_seh-1.dll
- libstdc++-6.dll
- libwinpthread-1.dll
Update graphics drivers to support OpenGL 2.1+
- Multiple variable support (partial derivatives, double integration)
- Limits with L'Hôpital's rule
- Matrix operations
- LaTeX export
- Triple integration
- Gradient and divergence
- Taylor series expansion
- Visual AST tree representation
- ImGui-based UI for expression input
- Syntax highlighting in input field
- Symbol palette (∫, π, ∑, etc.)
- Equation solver
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Make your changes and test thoroughly
- Commit with clear messages:
git commit -m "feat: add new feature" - Push and create a pull request
- 🐛 Bug fixes and testing
- 📚 Documentation improvements
- ✨ New mathematical operations
- 🎨 UI/UX enhancements
- ⚡ Performance optimizations
This project is licensed under the MIT License - see the LICENSE file for details.
TL;DR: Feel free to use, modify, and distribute this software. Attribution is appreciated but not required.
Created by: Shubh (@positronx_)
Contributors: See contributors list
Built with ❤️ using SDL2, OpenGL, and C++17 for Windows 10/11 (MSYS2 MinGW64)
If you find this project helpful, consider supporting its development!
Your support helps me:
- 🚀 Build more open-source tools
- 📚 Create educational content
- 🔧 Maintain and improve existing projects
- ☕ Stay caffeinated while coding!
⭐ Star this repository if you find it helpful!
🐛 Report issues to help us improve
🔧 Contribute to make it even better!