Public
Edited
May 22, 2024
Insert cell
Insert cell
Insert cell
graphDiv = DOM.element('div')
Insert cell
viewof sigma = Inputs.range([9, 11], {value:10, label: "sigma", step: 0.1})
Insert cell
viewof beta = Inputs.range([2, 4], {value:8/3, label: "beta", step: 0.1})
Insert cell
viewof rho = Inputs.range([20, 30], {value:28, label: "rho", step: 0.1})
Insert cell
viewof x0 = Inputs.range([-5, 5], {value:1, label: "x0", step: 0.1})
Insert cell
viewof y0 = Inputs.range([-5, 5], {value:1, label: "y0", step: 0.1})
Insert cell
viewof z0 = Inputs.range([-5, 5], {value:0, label: "z0", step: 0.1})
Insert cell
viewof tol = Inputs.range([0.0001, 0.1], {value: 0.01, label:"tol", step:0.0001})
Insert cell
{
Plotly.react(graphDiv, [trace], {
autosize: true,
uirevision: "true",
});
}
Insert cell
trace = ({
x: sol.y.map((u) => u[0]),
y: sol.y.map((u) => u[1]),
z: sol.y.map((u) => u[2]),
line: { color: [0, ...math.diff(sol.t)], colorscale: "Jet" },
type: "scatter3d",
mode: "lines",
})
Insert cell
Insert cell
Plot.plot(
{
x : {label: 'x →'},
y : {label: '↑ y'},
marks: [
Plot.line(lorenzTable, {x: "x", y: "y", stroke:"z", z:null})
],
color:{legend:true}
})
Insert cell
Insert cell
lorenz = (t, a) => {
const [x, y, z] = a
return [
sigma*(y-x),
x*(rho-z)-y,
x*y-beta*z
]
}
Insert cell
Insert cell
sol = math.solveODE(lorenz, [0, 100], [x0, y0, z0], {tol})
Insert cell
Insert cell
lorenzTable = sol.t.map((t, i)=>({t, x:sol.y[i][0], y:sol.y[i][1], z:sol.y[i][2]}))
Insert cell
viewof table = Inputs.table(lorenzTable)
Insert cell
Insert cell
Insert cell
Insert cell
math = import("https://cdn.skypack.dev/mathjs@12.4.2")
Insert cell
Plotly = require("https://cdn.plot.ly/plotly-2.32.0.min.js")
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more