728x90

 

https://youtu.be/LYyTLMyivUk?si=zy8KpL3jwl85ybfQ

 

 

 

 λ§λΈλΈŒλ‘œ 집합을 μ‹€μ œλ‘œ 그릴 λ•Œμ—λŠ” 점화식에 따라 zn을 κ³„μ‚°ν•˜λ©΄μ„œ μˆ˜μ—΄μ΄ λ°œμ‚°ν•˜λŠ”μ§€ κ·Έλ ‡μ§€ μ•Šμ€μ§€λ₯Ό λŒ€μˆ˜μ μœΌλ‘œ κ²€μ‚¬ν•˜κ²Œ λœλ‹€. zn의 μ ˆλŒ“값이 2보닀 크닀면(즉, xn2+yn2>22이라면) zn은 λ°œμ‚°ν•œλ‹€κ³  말할 수 있으며, 이 λ•Œμ˜ cλŠ” 망델브둜 집합에 속해 μžˆμ§€ μ•ŠλŠ”λ‹€. 이 λ•Œμ˜ 2λΌλŠ” 값은 λ°œμ‚°ν•˜λŠ” μˆ˜μ—΄μ˜ 계산을 미리 막아 μ£ΌλŠ” 역할을 ν•˜λ©°, 경계값이라고 λΆ€λ₯Έλ‹€. 반면 망델브둜 μ§‘ν•© μ•ˆμ— 속해 μžˆλŠ” 점의 경우 zn은 λ°œμ‚°ν•˜μ§€ μ•ŠμœΌλ―€λ‘œ λ¬΄ν•œνžˆ 계산해도 λλ‚˜μ§€ μ•Šμ„ 것이닀. 이런 κ²½μš°μ—λŠ” μ μ ˆν•œ nκ°’ 이후에 계산을 λ©ˆμΆ”μ–΄μ•Όλ§Œ ν•œλ‹€. λ¬΄ν•œνžˆ κ³„μ‚°ν•˜μ§€ μ•ŠλŠ” ν•œ μš°λ¦¬λŠ” 이둠적인 망델브둜 집합이 μ•„λ‹Œ 이에 κ·Όμ‚¬ν•œ μ§‘ν•©λ§Œ 얻을 μˆ˜λ°–μ— μ—†λ‹€.

 

#  카였슀처럼 λ³΄μ΄λŠ” λ‚œμˆ˜μ˜ 집합이 μΌμ •ν•œ μ£ΌκΈ°λ₯Ό κ°–λŠ”λ‹€. μ΄λŸ¬ν•œ 수의 집합을 망델브둜 집합이라 ν•œλ‹€. 

 

Formula : Zn+1 = Zn^2 + C

# C = 1 

Zn+1 = Zn^2 + C 
1 = 0 + 1
2 = 1^2 + 1
5 = 2^2 + 1
26 = 5^2 + 1
.
.
.
.
 
## λ°œμ‚° 

# C = -1 

Zn+1 = Zn^2 + C 
-1 = 0 -1
0 = -1^2 -1
-1 = 0^2 -1
0 = -1^2 -1
.
.
## 0, -1 반볡

 

 

Python κ΅¬ν˜„ 

import numpy as np
import matplotlib.pyplot as plt

def mandelbrot(c, max_iter):
    z = 0
    n = 0
    while abs(z) <= 2 and n < max_iter:
        z = z**2 + c
        n += 1
    if n == max_iter:
        return max_iter
    return n + 1 - np.log(np.log2(abs(z)))

def mandelbrot_set(width, height, x_min, x_max, y_min, y_max, max_iter):
    x, y = np.meshgrid(np.linspace(x_min, x_max, width), np.linspace(y_min, y_max, height))
    c = x + 1j * y
    mandelbrot_image = np.vectorize(mandelbrot)(c, max_iter)
    return mandelbrot_image

def plot_mandelbrot(width, height, x_min, x_max, y_min, y_max, max_iter):
    mandelbrot_image = mandelbrot_set(width, height, x_min, x_max, y_min, y_max, max_iter)
    plt.imshow(mandelbrot_image, extent=(x_min, x_max, y_min, y_max), cmap='hot', interpolation='bilinear')
    plt.colorbar()
    plt.title('Mandelbrot Set')
    
    plt.show()

# λ§€κ°œλ³€μˆ˜ μ„€μ •
width, height = 800, 800
x_min, x_max = -2, 1
y_min, y_max = -1.5, 1.5
max_iter = 100

# λ§¨λ“€λΈŒλ‘œ μ§‘ν•© 그리기
plot_mandelbrot(width, height, x_min, x_max, y_min, y_max, max_iter)

λ°˜μ‘ν˜•
λ‹€ν–ˆλ‹€