A web-based tool for visualizing phase portraits of two-dimensional autonomous systems of differential equations. This application allows users to input custom differential equations and explore their phase portraits through interactive 2D and 3D visualizations.

- Interactive Visualizations: Supports 2D phase portraits, 3D trajectories, and 3D surface plots
- Custom Equations: Input any differentiable functions for dx/dt and dy/dt
- Built-in Examples: Pre-loaded systems including harmonic oscillator, predator-prey, and spiral dynamics
- Vector Field Display: Shows direction field with customizable arrow density and scaling
- Trajectory Integration: Computes and displays solution trajectories with adjustable time steps
- Equilibrium Analysis: Automatically finds and highlights equilibrium points
- Viewing Controls: Zoom, pan, and adjust window bounds interactively
- Export Functionality: Save visualizations as PNG images
- Dark Mode: Toggle between light and dark themes
- Responsive Design: Works on desktop and mobile devices
The application uses:
- p5.js for canvas rendering and interactive graphics
- math.js for symbolic differentiation and numerical evaluation
- Runge-Kutta 4th order integration for trajectory computation
- HTML5 Canvas for high-performance 2D/3D rendering
- A modern web browser with JavaScript enabled
- Internet connection for loading external libraries (math.js and p5.js)
- Clone or download this repository
- Navigate to the project directory
- Open
index.htmlin your web browser
No additional installation or build steps are required.
- Enter differential equations in the input fields:
dx/dt = f(x,y): Rate of change of x with respect to timedy/dt = g(x,y): Rate of change of y with respect to time
- Adjust the viewing window bounds if needed
- Select visualization type (2D, 3D Trajectories, or 3D Surface)
- The plot will update automatically
- Harmonic Oscillator: dx/dt = y, dy/dt = -x
- Predator-Prey: dx/dt = x(1-y), dy/dt = y(x-1)
- Spiral: dx/dt = x-y, dy/dt = x+y
Use the "Common Examples" dropdown to load these presets.
- Custom Trajectories: Click on the canvas to add trajectory starting points
- Find Equilibria: Use the "Find Equilibria" button to locate and mark fixed points
- Vector Field Settings: Adjust arrow density, length, and scaling
- Zoom Controls: Use zoom in/out buttons or adjust bounds manually
Click the "Save Image" button to export the current visualization as a PNG file.
The application is designed for interactive testing:
- Load the page in your browser
- Try the built-in examples to verify basic functionality
- Enter custom equations and observe the resulting phase portraits
- Test different visualization modes (2D, 3D)
- Verify export functionality by saving images
- Check responsiveness on different screen sizes
- Chrome/Chromium 80+
- Firefox 75+
- Safari 13+
- Edge 80+
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
Copyright (c) 2013 Mark Otto.
Copyright (c) 2017 Andrew Fong.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.