A comprehensive Python toolkit for visualizing complex numbers in 3D space, featuring interactive plots, real-time controls, animations, and educational demonstrations. Perfect for learning complex analysis, signal processing, and mathematical visualization.
Interactive Visualizations:
This project provides multiple ways to visualize complex numbers in three dimensions:
- 3D Complex Plane: Height represents magnitude
- Individual Complex Numbers: Points in 3D space with magnitude as height
- Complex Operations: Addition and multiplication visualization
- Interactive Plots: Rotatable 3D visualizations using Plotly
- Complex Functions: Visualization of f(z) transformations
- Phase Analysis: Argument visualization in 3D
A complex number z = a + bi can be represented in 3D space where:
- X-axis: Real part (a)
- Y-axis: Imaginary part (b)
- Z-axis: Magnitude |z| = β(aΒ² + bΒ²)
This creates a natural 3D representation where:
- Points on the complex plane are elevated based on their distance from the origin
- The surface forms a cone shape, showing magnitude relationships
- Complex operations can be visualized as geometric transformations
- Surface plot showing magnitude as height
- Color-coded magnitude values
- Interactive rotation and zoom
- Point plotting with magnitude as height
- Lines from origin to points
- Annotations and labels
- Addition: Vector addition in 3D space
- Multiplication: Geometric interpretation
- Visual comparison of results
- Plotly-based interactive 3D plots
- Rotatable, zoomable, and pannable
- Hover information and legends
- f(z) = zΒ²: Quadratic transformation
- f(z) = e^z: Exponential function
- f(z) = 1/z: Reciprocal function
- f(z) = sin(z): Trigonometric function
- Argument of complex numbers in 3D
- Color-coded phase values
- Periodic nature visualization
- Live parameter adjustment with sliders
- Real and imaginary part controls
- Range and resolution adjustment
- Color scheme selection
- Animation speed control
- Animated complex operations
- Phase evolution over time
- Time-dependent function animations
- Custom animation parameters
- Export to GIF/MP4 formats
- Real-time interactive visualizations
- Multi-panel dashboards
- Advanced animation controls
- Custom hover information
- Responsive design
- Adaptive resolution based on zoom
- Memory-efficient rendering
- Caching for repeated calculations
- GPU acceleration support (optional)
git clone https://github.com/Sarvesh2304/Complex_Number_Visualisation.git
cd Complex_Number_Visualisation
pip install -r requirements.txtpython simple_demo.pyjupyter notebook Enhanced_Interactive_Demo.ipynbpython complex_3d_visualization.pyThis will generate:
- Static PNG images of various visualizations
- Interactive HTML file for web-based exploration
- Start Jupyter:
jupyter notebook-
Open
Complex_Number_3D_Visualization.ipynborEnhanced_Interactive_Demo.ipynb -
Run cells interactively to explore different visualizations
The enhanced notebook includes interactive widgets for:
- Adjusting real and imaginary parts
- Real-time visualization updates
- Parameter exploration
- Animation controls
- Color scheme selection
- Resolution adjustment
from complex_3d_visualization import ComplexNumber3DVisualizer
visualizer = ComplexNumber3DVisualizer()
# Create interactive plot with real-time controls
interactive_plot = visualizer.create_interactive_plot()
display(interactive_plot) # In Jupyter notebook# Animate complex operations
z1 = 1 + 1j
z2 = 2 - 1j
anim = visualizer.animate_complex_operations(z1, z2, frames=100, duration=5.0)
plt.show()
# Animate phase evolution
anim = visualizer.create_phase_animation(frames=100, duration=5.0)
plt.show()
# Animate custom function
def f_rotating(z, t):
return z * np.exp(1j * t)
anim = visualizer.animate_complex_function(f_rotating, frames=100, duration=5.0)
plt.show()# Real-time interactive Plotly
fig = visualizer.create_real_time_plotly()
fig.show()
# Multi-panel dashboard
fig = create_comprehensive_dashboard()
fig.show()from complex_3d_visualization import ComplexNumber3DVisualizer
visualizer = ComplexNumber3DVisualizer()
# Create basic 3D complex plane
fig, ax = visualizer.create_3d_complex_plane()
plt.show()
# Plot specific complex numbers
z1 = 1 + 1j
z2 = -1 + 2j
visualizer.plot_complex_number_3d(z1, "1 + i", "red")
visualizer.plot_complex_number_3d(z2, "-1 + 2i", "blue")
plt.show()# Visualize addition and multiplication
z1 = 1 + 1j
z2 = 2 - 1j
fig, ax = visualizer.plot_complex_operations(z1, z2)
plt.show()# Visualize complex functions
def f(z): return z**2
fig, ax = visualizer.plot_complex_function_3d(f)
plt.show()- Forms a cone shape centered at the origin
- Height increases with distance from origin
- Shows the relationship between position and magnitude
- Addition: Vector addition in 3D space
- Multiplication: Combines magnitudes and adds phases
- Geometric interpretation: Rotation and scaling
- zΒ²: Doubles the phase, squares the magnitude
- e^z: Creates exponential growth patterns
- 1/z: Inverts magnitude, negates phase
- sin(z): Creates periodic wave patterns
This visualization toolkit is useful for:
- Complex analysis education
- Function theory understanding
- Geometric interpretation of complex operations
- Signal processing analysis
- Electrical circuit analysis (impedance, phasors)
- Control systems design
- Quantum mechanics visualization
- Wave function analysis
- Electromagnetic field visualization
- Fractal generation
- Digital signal processing
- Computer graphics algorithms
complex_number_visualization/
βββ README.md # This file
βββ requirements.txt # Python dependencies
βββ complex_3d_visualization.py # Main visualization script
βββ Complex_Number_3D_Visualization.ipynb # Jupyter notebook
βββ complex_plane_3d.png # Generated static plots
βββ complex_numbers_3d.png
βββ complex_operations_3d.png
βββ interactive_complex_3d.html # Interactive Plotly visualization
βββ complex_function_*.png # Function visualization plots
- NumPy: Numerical computations
- Matplotlib: Static 3D plotting
- Plotly: Interactive 3D visualizations
- IPyWidgets: Interactive widgets for Jupyter
- Jupyter: Notebook environment
def my_function(z):
return z**3 + 2*z + 1
fig, ax = visualizer.plot_complex_function_3d(my_function)
plt.show()# Custom ranges and resolution
fig, ax = visualizer.create_3d_complex_plane(
real_range=(-5, 5),
imag_range=(-5, 5)
)# Use different colormaps
surface = ax.plot_surface(real_grid, imag_grid, magnitudes,
cmap='plasma', alpha=0.8)- Import Errors: Ensure all dependencies are installed
- Display Issues: Use appropriate backend for your environment
- Performance: Reduce grid resolution for faster rendering
- Memory: Close figures when not needed
- Use smaller grid sizes for faster rendering
- Close matplotlib figures to free memory
- Use Plotly for interactive exploration
- Consider using static images for presentations
Feel free to contribute by:
- Adding new visualization methods
- Improving documentation
- Adding more complex functions
- Enhancing interactivity
- Optimizing performance
This project is open source and available under the MIT License.
- Inspired by complex analysis and mathematical visualization
- Built with Python scientific computing ecosystem
- Uses modern interactive plotting libraries
Happy visualizing! π¨π