Skip to content

Instantly share code, notes, and snippets.

@to-osaki
Last active June 19, 2022 03:09
Show Gist options
  • Save to-osaki/464c1d90e88af59308c938afa8582753 to your computer and use it in GitHub Desktop.
Save to-osaki/464c1d90e88af59308c938afa8582753 to your computer and use it in GitHub Desktop.

クリフォード/デヨン アトラクタ https://gihyo.jp/book/2021/978-4-297-12383-3

def Clifford(x, y, a = -1.1, b = -1, c = -3.0, d = -0.1): # -3 ~ 3
    x_ = np.sin(a*y) + c*np.cos(a*x)
    y_ = np.sin(b*x) + d*np.cos(b*y)
    return x_, y_

def DeJong(x, y, a = -2, b = -2.3, c = -1.4, d = 2.1): # -3 ~ 3
    x_ = np.sin(a*y) - np.cos(b*x)
    y_ = np.sin(c*x) - np.cos(d*y)
    return x_, y_

def Hopalong(x, y, p): # 0 ~ 10
    a, b, c = p
    x_ = y - 1 - ((x-1)*np.sqrt(abs(b*x-1-c)))/abs(x-1)
    y_ = a - x - 1
    return x_, y_

def Goldfish(x, y, p):
    a, b = p
    x_ = np.cos(a*x - y) + y*np.sin(b*x*y)
    y_ = x + b*np.sin(y)
    return x_, y_

def Rebirth(x, y, p):
    a, b = p
    x_ = a*x + b*y
    y_ = x**2 + b
    return x_, y_

def Cylinder(x, y, p):
    a = p[0]
    x_ = x + a*np.sin(2*np.pi*y)
    y_ = x*np.cos(2*np.pi*y) + a*y
    return x_, y_

cnt = 2**15
xs = np.zeros(cnt)
ys = np.zeros(cnt) 
xs[0], ys[0] = 0.1, 0.1
f = Clifford

for i in range(1, cnt):
    xs[i], ys[i] = f(xs[i-1], ys[i-1])

CliffordAttractor CliffordAttractor2 DeJongAttractor DeJongAttractor2

グモウスキー・ミラの写像 https://ja.wikipedia.org/wiki/%E3%82%B0%E3%83%A2%E3%82%A6%E3%82%B9%E3%82%AD%E3%83%BC%E3%83%BB%E3%83%9F%E3%83%A9%E3%81%AE%E5%86%99%E5%83%8F

def f1(x, y):
    xx = y + g(x)
    yy = -x + g(xx)
    return (xx, yy)
def f2(x, y):
    xx = y + alpha*y*(1-sigma*(y**2)) + g(x)
    yy = -x + g(xx)
    return (xx, yy)

def g1(x):
    x_2 = x**2
    return mu*x + (2*(1-mu)*x_2)/(1+x_2)
def g2(x):
    x_2 = x**2
    return mu*x + (1-mu)*x_2 * np.exp((1-x_2) / 4)

alpha = 0.008
sigma = 0.05
mu = -0.496
f = f2
g = g1

samples=25000
xs=np.zeros(samples)
ys=np.zeros(samples)
x, y = [1, 1]

for i in range(samples):
    x, y = f(x, y)
    xs[i] = x
    ys[i] = y

gm1 gm2

http://chaoscloud950.blog60.fc2.com/blog-entry-37.html?sp

a = 0.02
b = 0.98
R = 5.0
def f(x, y, n):
    x2 = x**2
    y2 = y**2
    n_ = 1 if n % 2 == 0 else -1
    xx = y + a*x + (5*x2 / (1+x2)) + 1 - 0.2*np.exp(-y2)
    yy = -b*x + R*n_
    return xx, yy

2t

ウエダアトラクタ / Japanese attractor 参考 : https://sites.google.com/site/cinderellajapan/cinderellade-kaosu/japanizu

k = 0.1
B = 12.0

step_per_sample=800
samples=5000
dt = 2*np.pi / step_per_sample

xs=np.zeros(samples)
ys=np.zeros(samples)
x, y = [0.2, 0.1]

for i in range(samples):
    for j in range(step_per_sample):
        t = j*dt
        xx = x + y*dt # x´ = y
        y_dot = -k*y - x**3 + B*np.cos(t)
        yy = y + y_dot*dt # y´ = -k*y - x^3 + B*cos(t)
        x = xx
        y = yy
    xs[i] = x
    ys[i] = y

初期値 x, y = 0.2, 0.1から最初のサンプルに達するまでのx,y

trail

5000サンプル(5000*800step)

4000000_per_800

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment