Public
Edited
Apr 16
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.35.3.min.js")
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more