Skip to content

🎨 Interactive 3D Complex Number Visualization with real-time controls, animations, and educational features. Perfect for learning complex analysis, signal processing, and mathematical visualization.

License

Notifications You must be signed in to change notification settings

Sarvesh2304/Complex_Number_Visualisation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎨 3D Complex Number Visualization

Python Plotly License Jupyter

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.

🌟 Live Demo

Open in Colab

Interactive Visualizations:

Overview

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

Mathematical Background

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

Features

1. Basic 3D Complex Plane

  • Surface plot showing magnitude as height
  • Color-coded magnitude values
  • Interactive rotation and zoom

2. Individual Complex Numbers

  • Point plotting with magnitude as height
  • Lines from origin to points
  • Annotations and labels

3. Complex Operations

  • Addition: Vector addition in 3D space
  • Multiplication: Geometric interpretation
  • Visual comparison of results

4. Interactive Visualizations

  • Plotly-based interactive 3D plots
  • Rotatable, zoomable, and pannable
  • Hover information and legends

5. Complex Function Analysis

  • f(z) = zΒ²: Quadratic transformation
  • f(z) = e^z: Exponential function
  • f(z) = 1/z: Reciprocal function
  • f(z) = sin(z): Trigonometric function

6. Phase Visualization

  • Argument of complex numbers in 3D
  • Color-coded phase values
  • Periodic nature visualization

7. πŸ†• Real-time Interactive Controls

  • Live parameter adjustment with sliders
  • Real and imaginary part controls
  • Range and resolution adjustment
  • Color scheme selection
  • Animation speed control

8. πŸ†• Animation Capabilities

  • Animated complex operations
  • Phase evolution over time
  • Time-dependent function animations
  • Custom animation parameters
  • Export to GIF/MP4 formats

9. πŸ†• Enhanced Plotly Integration

  • Real-time interactive visualizations
  • Multi-panel dashboards
  • Advanced animation controls
  • Custom hover information
  • Responsive design

10. πŸ†• Performance Optimization

  • Adaptive resolution based on zoom
  • Memory-efficient rendering
  • Caching for repeated calculations
  • GPU acceleration support (optional)

πŸš€ Quick Start

Installation

git clone https://github.com/Sarvesh2304/Complex_Number_Visualisation.git
cd Complex_Number_Visualisation
pip install -r requirements.txt

Run Demo

python simple_demo.py

Interactive Notebook

jupyter notebook Enhanced_Interactive_Demo.ipynb

Usage

Running the Main Script

python complex_3d_visualization.py

This will generate:

  • Static PNG images of various visualizations
  • Interactive HTML file for web-based exploration

Using the Jupyter Notebook

  1. Start Jupyter:
jupyter notebook
  1. Open Complex_Number_3D_Visualization.ipynb or Enhanced_Interactive_Demo.ipynb

  2. Run cells interactively to explore different visualizations

Interactive Exploration

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

πŸ†• New Interactive Features

Real-time Controls

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

Animation Examples

# 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()

Enhanced Plotly Visualizations

# Real-time interactive Plotly
fig = visualizer.create_real_time_plotly()
fig.show()

# Multi-panel dashboard
fig = create_comprehensive_dashboard()
fig.show()

Examples

Example 1: Basic Complex Numbers

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()

Example 2: Complex Operations

# Visualize addition and multiplication
z1 = 1 + 1j
z2 = 2 - 1j
fig, ax = visualizer.plot_complex_operations(z1, z2)
plt.show()

Example 3: Complex Functions

# Visualize complex functions
def f(z): return z**2
fig, ax = visualizer.plot_complex_function_3d(f)
plt.show()

Key Insights

Magnitude Surface

  • Forms a cone shape centered at the origin
  • Height increases with distance from origin
  • Shows the relationship between position and magnitude

Complex Operations

  • Addition: Vector addition in 3D space
  • Multiplication: Combines magnitudes and adds phases
  • Geometric interpretation: Rotation and scaling

Function Transformations

  • 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

Applications

This visualization toolkit is useful for:

Mathematics

  • Complex analysis education
  • Function theory understanding
  • Geometric interpretation of complex operations

Engineering

  • Signal processing analysis
  • Electrical circuit analysis (impedance, phasors)
  • Control systems design

Physics

  • Quantum mechanics visualization
  • Wave function analysis
  • Electromagnetic field visualization

Computer Science

  • Fractal generation
  • Digital signal processing
  • Computer graphics algorithms

File Structure

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

Dependencies

  • NumPy: Numerical computations
  • Matplotlib: Static 3D plotting
  • Plotly: Interactive 3D visualizations
  • IPyWidgets: Interactive widgets for Jupyter
  • Jupyter: Notebook environment

Customization

Adding New Complex Functions

def my_function(z):
    return z**3 + 2*z + 1

fig, ax = visualizer.plot_complex_function_3d(my_function)
plt.show()

Modifying Visualization Parameters

# Custom ranges and resolution
fig, ax = visualizer.create_3d_complex_plane(
    real_range=(-5, 5),
    imag_range=(-5, 5)
)

Creating Custom Color Schemes

# Use different colormaps
surface = ax.plot_surface(real_grid, imag_grid, magnitudes, 
                         cmap='plasma', alpha=0.8)

Troubleshooting

Common Issues

  1. Import Errors: Ensure all dependencies are installed
  2. Display Issues: Use appropriate backend for your environment
  3. Performance: Reduce grid resolution for faster rendering
  4. Memory: Close figures when not needed

Performance Tips

  • Use smaller grid sizes for faster rendering
  • Close matplotlib figures to free memory
  • Use Plotly for interactive exploration
  • Consider using static images for presentations

Contributing

Feel free to contribute by:

  • Adding new visualization methods
  • Improving documentation
  • Adding more complex functions
  • Enhancing interactivity
  • Optimizing performance

License

This project is open source and available under the MIT License.

Acknowledgments

  • Inspired by complex analysis and mathematical visualization
  • Built with Python scientific computing ecosystem
  • Uses modern interactive plotting libraries

Happy visualizing! πŸŽ¨πŸ“Š

About

🎨 Interactive 3D Complex Number Visualization with real-time controls, animations, and educational features. Perfect for learning complex analysis, signal processing, and mathematical visualization.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages