Logistic Map
This sample shows a computational note. It introduces a model, gives the equation, lets readers change parameters, and renders the result from a Rust/Wasm cell.
What This Demonstrates
Section titled “What This Demonstrates”- Math notation near the code that implements it.
- Reactive Rust inputs for model parameters.
- A helper crate referenced with
crates: [doc-rust]. - Text and chart output from one cell.
The logistic map is a discrete dynamical system where complex behavior emerges from a simple recurrence relation.
Here, is the state at step , and r is the growth rate. Changing r or x0 recomputes the series in Rust/Wasm and updates the plot.
Rust + Wasm
Explore logistic map parameters
let steps = u32::try_from(steps).map_err(|_| "steps must be non-negative".to_owned())?;
let points = doc_rust::logistic_series(r, x0, steps).map_err(|error| error.to_string())?;
let final_point = points.last().ok_or_else(|| "series is empty".to_owned())?;
println!("x_{} = {:.6}", final_point.n, final_point.x);
emit_line_plot!(&points, "n", "x");Waiting for the runtime to start.
How to Read It
Section titled “How to Read It”For smaller values of r, the series approaches a stable value. As r increases, periodic behavior appears. At larger values, the output becomes sensitive to the initial state.
This page shape works well for computational notes: explain the model with math, let readers adjust parameters in an executable cell, and show the result as a plot.