Skip to content

Plotting julia sets for different values of complex constant

Notifications You must be signed in to change notification settings

gsdev42/Julia-Sets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

Julia-Sets

Plotting julia sets for different values of complex constant

Overview

This Python script generates and visualizes Julia sets, which are fascinating fractal patterns in complex dynamics. The Julia set is constructed by iterating a complex function on a grid of complex numbers. The code utilizes NumPy for numerical operations and Matplotlib for plotting.

How it Works

The Julia set is generated by iterating the function (Z = Z^2 + c), where (Z) is a complex number, and (c) is a constant complex number. The algorithm explores how the initial complex numbers evolve over iterations, and the resulting pattern is visualized.

Mathematical Explanation

  • The script defines a grid of complex numbers based on specified width, height, and ranges for (x) and (y).

  • The complex constant (c) is initialized, and you can experiment with different values to observe diverse Julia set patterns.

  • The iterative process begins, updating each complex number in the grid using (Z = Z^2 + c).

  • A mask is created based on the condition that the absolute value of each complex number is less than 1000.

  • The mask is accumulated over iterations, creating an image representing the Julia set.

    image

Code Structure

generate_julia_set Function

def generate_julia_set(width, height, xmin, xmax, ymin, ymax, c, max_iter):
    # ... (explained in code comments)
    return img

This function generates the Julia set image based on the specified parameters.

plot_julia_set Function

def plot_julia_set(julia_set):
    # ... (explained in code comments)

This function plots the generated Julia set using Matplotlib.

Setting Parameters and Visualization

width, height = 800, 800
xmin, xmax = -2, 2
ymin, ymax = -2, 2
c = complex(-0.8, 0.156)  # Experiment with different values of 'c'
#you can try
#c = complex(0, 0.8)
#c = complex(0.35, 0.35)
max_iter = 100

julia_set = generate_julia_set(width, height, xmin, xmax, ymin, ymax, c, max_iter)
plot_julia_set(julia_set)

About

Plotting julia sets for different values of complex constant

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages