From b0e770f3efb6b61d5c8f910dc5ac0e8919609255 Mon Sep 17 00:00:00 2001
From: Orestis <orestis.malaspinas@pm.me>
Date: Fri, 5 Mar 2021 21:26:42 +0100
Subject: [PATCH] added chaos map

---
 travaux_pratiques/tpChaos/map.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 travaux_pratiques/tpChaos/map.c

diff --git a/travaux_pratiques/tpChaos/map.c b/travaux_pratiques/tpChaos/map.c
new file mode 100644
index 0000000..5750975
--- /dev/null
+++ b/travaux_pratiques/tpChaos/map.c
@@ -0,0 +1,23 @@
+#include <stdio.h>
+
+double map(double x, double lambda) {
+    return lambda * x * (1.0 - x);
+}
+
+int main() {
+    const double lambda_min = 0.0;
+    const double lambda_max = 4.0;
+    const int N = 100;
+    const double dl = (lambda_max - lambda_min) / N;
+    
+    int max_iter = 1000;
+    for (double lambda = 0.0; lambda < lambda_max; lambda += dl) {
+        double x = 0.5;
+        for (int i = 0; i < max_iter; ++i) {
+            printf("x(%d, %g) = %g\n", i, lambda, x);
+            x = map(x, lambda);
+        }
+        printf("\n");
+    }
+
+}
-- 
GitLab