カオスな写像で遊んでみた

テント写像,ロジスティック写像などの分布を画像化

**テント写像**

```math
x_{n+1} =\left\{
\begin{array}{ll}
ax_{n} & (0 \leq x \leq \frac{1}{2}) \\
a(1-x_{n}) & (\frac{1}{2} \lt x_{n} \leq 1)
\end{array}
\right.
```

**ロジスティック写像**

```math

x_{n+1} = \begin{array}{ll} ax_{n}(1-x_{n}) & (0 \leq x \leq 1) \end{array}

```

この2つをまとめると

```math

x_{n+1} = \begin{array}{ll} k \{1-(| 1-2x_{n} |)^p\} & (0 \leq x \leq 1) \end{array}

```

となる
**k=a/2 , p=1**とおくとテント写像
**k=a/4 , p=2**とおくとロジスティック写像

pを固定しkを0から1まで変化させていった場合の分布の変化をMagickWandで画像化した
適当なxの初期値からスタートしてn=100までは捨てて
それ以降の10000個のデータの分布を使った

余興で複数組み合わせて使った場合のものも作った
その1

```math

\begin{align}
a_{n+1} &=　k \bigl\{ b_{n} \{1-(| 1-2a_{n} |)\} + (1-b_{n}) \{1-(| 1-2a_{n} |)^2\} \bigr\} \\
b_{n+1} &= (1-b_{n}) \{1-(| 1-2a_{n} |)\} + b_{n} \{1-(| 1-2a_{n} |)^2\}
\end{align}

```

その2

```math

\begin{align}
a_{n+1} &=　k \bigl\{ 
b_{n} c_{n} \{1-(| 1-2a_{n} |)\} + 
b_{n} (1 - c_{n}) \{1-(| 1-2a_{n} |)^2\} + 
(1 - b_{n}) d_{n} \{1-(| 1-2a_{n} |)^3\} + 
(1 - b_{n}) (1 - d_{n}) \{1-(| 1-2a_{n} |)^4\} \bigr\} \\
b_{n+1} &= 
b_{n} (1 - c_{n}) \{1-(| 1-2a_{n} |)\} + 
(1 - b_{n}) d_{n} \{1-(| 1-2a_{n} |)^2\} + 
(1 - b_{n}) (1 - d_{n}) \{1-(| 1-2a_{n} |)^3\} + 
b_{n} c_{n} \{1-(| 1-2a_{n} |)^4\} \\

c_{n+1} &= 
(1 - b_{n}) d_{n} \{1-(| 1-2a_{n} |)\} + 
(1 - b_{n}) (1 - d_{n}) \{1-(| 1-2a_{n} |)^2\} + 
b_{n} c_{n} \{1-(| 1-2a_{n} |)^3\} + 
b_{n} (1 - c_{n}) \{1-(| 1-2a_{n} |)^4\} \\

d_{n+1} &= 
(1 - b_{n}) (1 - d_{n}) \{1 - (| 1 - 2a_{n} |)\} + 
b_{n} c_{n} \{1 - (| 1 - 2a_{n} |)^2\} + 
b_{n} (1 - c_{n}) \{1 - (| 1 - 2a_{n} |)^3\} + 
(1 - b_{n}) d_{n} \{1 - (| 1 - 2a_{n} |)^4\}
\end{align}

```

###ソースコード
https://github.com/2a3oiUA3zfDtr3py/Misc/tree/master/Chaotic_Maps

###結果

**p=0.75**
![chaostic_map0.75.png](https://qiita-image-store.s3.amazonaws.com/0/198182/ba548f8f-6bfa-5d21-5980-d4a6c931f226.png)

**p=1.00 (テント写像)**
![chaostic_map1.00.png](https://qiita-image-store.s3.amazonaws.com/0/198182/ba7da844-f569-3e90-0239-dd54c69cf578.png)

**p=1.05**
![chaostic_map1.05.png](https://qiita-image-store.s3.amazonaws.com/0/198182/f6691c6b-8dad-dfec-232e-05c737a2654f.png)

**p=1.10**
![chaostic_map1.10.png](https://qiita-image-store.s3.amazonaws.com/0/198182/14064aa5-cc93-8616-ebc1-98291ef879ba.png)

**p=1.15**
![chaostic_map1.15.png](https://qiita-image-store.s3.amazonaws.com/0/198182/892bf2fa-caed-28b8-64de-0ed3c85a8cd6.png)

**p=1.20**
![chaostic_map1.20.png](https://qiita-image-store.s3.amazonaws.com/0/198182/be122f00-4f2a-2ab6-76af-5e1497d55fba.png)

**p=1.25**
![chaostic_map1.25.png](https://qiita-image-store.s3.amazonaws.com/0/198182/cb488d69-8be3-b0ff-56d2-dba4c18d544a.png)

**p=1.50**
![chaostic_map1.50.png](https://qiita-image-store.s3.amazonaws.com/0/198182/a483e738-5d1b-74f8-ee1f-fade198c9b71.png)

**p=1.75**
![chaostic_map1.75.png](https://qiita-image-store.s3.amazonaws.com/0/198182/f5abce10-a451-a1c0-c8f1-640f390a5a28.png)

**p=2.00 (ロジスティック写像)**
![chaostic_map2.00.png](https://qiita-image-store.s3.amazonaws.com/0/198182/1a53bfef-d388-0e26-5c01-c564e8da7d36.png)

**p=2.25**
![chaostic_map2.25.png](https://qiita-image-store.s3.amazonaws.com/0/198182/2d1da7d5-b5b3-23ab-cb67-b1a5a98a7d60.png)

**p=2.50**
![chaostic_map2.50.png](https://qiita-image-store.s3.amazonaws.com/0/198182/55c8283d-a7f6-930e-4129-31982ed5fd08.png)

**p=2.75**
![chaostic_map2.75.png](https://qiita-image-store.s3.amazonaws.com/0/198182/97cc7237-d20a-1ad4-bb8a-bb4342f4b244.png)

**p=3.00**
![chaostic_map3.00.png](https://qiita-image-store.s3.amazonaws.com/0/198182/7e881f21-7125-02a2-b2c7-03d8e6f979cb.png)

**その1**
![chaostic_2_map.png](https://qiita-image-store.s3.amazonaws.com/0/198182/568949c8-0d6e-d1a2-d251-4c894fca626d.png)

**その2**
![chaostic_3_map.png](https://qiita-image-store.s3.amazonaws.com/0/198182/20bbeb28-9887-f9ed-b7b8-e2fee919ace9.png)

###気がついた事
Cのpow関数が数値によっては遅くなる現象に遭遇した
pow(x,0.75)とpow(x,1.25)で速さが違う
遅いため仕方なく

```c
x = sqrt(x);
x = x * sqrt(x);
```

p=0.75はこれで計算した