Skip to content

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.

  • 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.

xn+1=rxn(1xn)x_{n+1} = r x_n (1 - x_n)

Here, xnx_n is the state at step nn, 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

Cell actions
Cell inputs
3.20
0.20
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.

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.