From bd414ae7410e64ceab9555b307aff06f3f386c00 Mon Sep 17 00:00:00 2001 From: David Contreras Date: Thu, 1 Feb 2024 17:23:59 -0600 Subject: [PATCH 1/5] Interactive lorenz --- examples/browser/lorenz.html | 101 ++++++++++++++++++++++++++--------- 1 file changed, 75 insertions(+), 26 deletions(-) diff --git a/examples/browser/lorenz.html b/examples/browser/lorenz.html index a751280ee3..245ed9b0a8 100644 --- a/examples/browser/lorenz.html +++ b/examples/browser/lorenz.html @@ -6,48 +6,97 @@ math.js | Lorenz Attractor - + + + +

Lorenz Attractor

+
+
+ Inputs: + +
+ +
+ + +
+
+
(dx/dt) = sigma(y-x); (dy/dt) = x(rho-z)-y; (dz/dt) = x*y - beta*z
- \ No newline at end of file + From 5a4fe882ed0c3364ab114c16a9545e5b1f2039b1 Mon Sep 17 00:00:00 2001 From: David Contreras Date: Fri, 9 Feb 2024 01:34:07 +0000 Subject: [PATCH 2/5] Separate Interactive Lorenz --- examples/browser/lorenz.html | 101 ++++---------- examples/browser/lorenz_interactive.html | 159 +++++++++++++++++++++++ 2 files changed, 185 insertions(+), 75 deletions(-) create mode 100644 examples/browser/lorenz_interactive.html diff --git a/examples/browser/lorenz.html b/examples/browser/lorenz.html index 245ed9b0a8..a751280ee3 100644 --- a/examples/browser/lorenz.html +++ b/examples/browser/lorenz.html @@ -6,97 +6,48 @@ math.js | Lorenz Attractor - - - + -

Lorenz Attractor

-
-
- Inputs: - -
- -
- - -
-
-
(dx/dt) = sigma(y-x); (dy/dt) = x(rho-z)-y; (dz/dt) = x*y - beta*z
- + \ No newline at end of file diff --git a/examples/browser/lorenz_interactive.html b/examples/browser/lorenz_interactive.html new file mode 100644 index 0000000000..15c0e868c4 --- /dev/null +++ b/examples/browser/lorenz_interactive.html @@ -0,0 +1,159 @@ + + + + + + math.js | Lorenz Attractor + + + + + + + + +

Lorenz Attractor

+
+
+
+ Inputs: + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + + + + + + + + + +
+ + + +
+
+
+
(dx/dt) = sigma(y-x); (dy/dt) = x(rho-z)-y; (dz/dt) = x*y - beta*z
+ + + + \ No newline at end of file From 4376d602dea6eed9dc13fd40c53c179547c11462 Mon Sep 17 00:00:00 2001 From: David Contreras Date: Thu, 8 Feb 2024 19:51:15 -0600 Subject: [PATCH 3/5] Cleanup --- examples/browser/lorenz_interactive.html | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/examples/browser/lorenz_interactive.html b/examples/browser/lorenz_interactive.html index 15c0e868c4..5cbee1d6c1 100644 --- a/examples/browser/lorenz_interactive.html +++ b/examples/browser/lorenz_interactive.html @@ -86,7 +86,6 @@

Lorenz Attractor

katex.render(String.raw`z_0`, document.querySelector("#z0Label")) katex.render(String.raw`\epsilon`, document.querySelector("#epsilonLabel")) - const inputs = document.querySelector("#inputs") // define the constants for the Lorenz attractor @@ -94,24 +93,24 @@

Lorenz Attractor

const beta = document.querySelector("#beta") const rho = document.querySelector("#rho") + // define the initial location const x0 = document.querySelector('#x0') const y0 = document.querySelector('#y0') const z0 = document.querySelector('#z0') + // define the tolerance for the solution const epsilon = document.querySelector('#epsilon') const layout = { - uirevision: 'true', height: 600 + uirevision: 'true', height: 500 } const t_span = [0, 100] - let y_0 = [x0.value, y0.value, z0.value] inputs.addEventListener("change", updateSolution) + let trace // solve the Lorenz attractor with the initial values - let sol = math.solveODE(createLorenz(sigma.value, rho.value, beta.value), t_span, y_0) - let trace = createTrace(sol) updateSolution() // crates a trace in the format needed for plotly @@ -147,8 +146,8 @@

Lorenz Attractor

} function updateSolution() { - y_0 = [x0.value, y0.value, z0.value] - sol = math.solveODE(createLorenz(sigma.value, rho.value, beta.value), t_span, y_0, { tol: epsilon.value }) + const y_0 = [x0.value, y0.value, z0.value] + const sol = math.solveODE(createLorenz(sigma.value, rho.value, beta.value), t_span, y_0, { tol: epsilon.value }) trace = createTrace(sol) // reactively render the plot on update Plotly.react('LorenzGraph', trace, layout) @@ -156,4 +155,4 @@

Lorenz Attractor

- \ No newline at end of file + From 4a1f9acdf06af5848d1c229ad6eb6e396b5fdd0f Mon Sep 17 00:00:00 2001 From: David Contreras Date: Sun, 11 Feb 2024 13:01:01 -0600 Subject: [PATCH 4/5] Bigger graphs --- examples/browser/lorenz.html | 12 +++++++++++- examples/browser/lorenz_interactive.html | 18 ++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/examples/browser/lorenz.html b/examples/browser/lorenz.html index a751280ee3..fe8792483d 100644 --- a/examples/browser/lorenz.html +++ b/examples/browser/lorenz.html @@ -7,6 +7,16 @@ + @@ -36,7 +46,7 @@ type: "scatter3d", mode: "lines" }], - { width: 800, height: 600 } + { height: 600 } ) // define the lorenz attractor diff --git a/examples/browser/lorenz_interactive.html b/examples/browser/lorenz_interactive.html index 5cbee1d6c1..9a6612ab9c 100644 --- a/examples/browser/lorenz_interactive.html +++ b/examples/browser/lorenz_interactive.html @@ -13,6 +13,20 @@ + @@ -102,7 +116,7 @@

Lorenz Attractor

const epsilon = document.querySelector('#epsilon') const layout = { - uirevision: 'true', height: 500 + uirevision: 'true', height: 600 } const t_span = [0, 100] @@ -155,4 +169,4 @@

Lorenz Attractor

- + \ No newline at end of file From aec4f7952bc70cffa8aca72e64a7df01552613e7 Mon Sep 17 00:00:00 2001 From: David Contreras Date: Sun, 3 Mar 2024 10:37:54 -0600 Subject: [PATCH 5/5] Full screen examples --- examples/browser/lorenz.html | 12 ++++++++- examples/browser/lorenz_interactive.html | 32 +++++++++++++++++++----- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/examples/browser/lorenz.html b/examples/browser/lorenz.html index fe8792483d..6919e1623a 100644 --- a/examples/browser/lorenz.html +++ b/examples/browser/lorenz.html @@ -8,6 +8,12 @@ -

Lorenz Attractor

@@ -88,10 +96,8 @@

Lorenz Attractor

-
(dx/dt) = sigma(y-x); (dy/dt) = x(rho-z)-y; (dz/dt) = x*y - beta*z