# Sequence ## Microsim ### Live player <div class="microsim-player"> <iframe src="https://editor.p5js.org/sciencenibber/full/iLnN6bFev" width="100%" height="620" frameborder="0" sandbox="allow-scripts allow-same-origin"></iframe> </div> <div class="microsim-fallback"> <img src="Microsims/thumbs/Sequence.png" alt="Sequence microsim poster" style="width:100%;border:1px solid #4445;border-radius:6px;"> <p><em>Live microsim (desktop) · <a href="https://editor.p5js.org/sciencenibber/sketches/iLnN6bFev">open sketch in the p5.js editor</a></em></p> </div> **Editor URL:** https://editor.p5js.org/sciencenibber/sketches/iLnN6bFev **Description (100 words):** This microsim makes the abstract idea of a sequence concrete by enumerating its terms. A sequence is an ordered list a_n indexed by the natural numbers n = 1, 2, 3, ..., where order matters and repetition is allowed. The sketch draws the first N terms as a stem plot — index n along the horizontal axis, term value a_n along the vertical — for five classic families: arithmetic (a_n = a1 + (n-1)d), geometric (a_n = a1·r^(n-1)), harmonic (1/n), squares (n^2), and Fibonacci. Sliders vary the term count and the family parameter, letting you watch a run converge, diverge, or oscillate in real time. ```js // ===================================================================== // Article : Sequence // Slug : Sequence // Wikitube : en.wikitube.io/wiki/Sequence // Room : Information // // Idea : A sequence is an ordered, enumerated list of terms a_n // indexed by the natural numbers n = 1, 2, 3, ... This // microsim plots the first N terms of a chosen sequence as // a stem plot (index n on the horizontal axis, term value // a_n on the vertical axis). The reader can switch between // five classic families — arithmetic, geometric, harmonic, // squares, and Fibonacci — and watch how order and the // recurrence shape the run of terms, and whether the run // converges, grows without bound, or oscillates. // // Equation : General term a_n. Arithmetic: a_n = a1 + (n-1)d. // Geometric: a_n = a1 * r^(n-1). Harmonic: a_n = 1/n. // Squares: a_n = n^2. Fibonacci: a_n = a_{n-1} + a_{n-2}. // (ASCII forms are rendered in the equation footer below.) // ===================================================================== // Rule 3 — single source of truth for title line and save name. const ARTICLE = "Sequence"; // Rule 4 — disable the Friendly Error System for ship. p5.disableFriendlyErrors = true; // ---------- controls ---------- let typeSelect; // which sequence family to display let nSlider; // N, number of terms to enumerate let pSlider; // family parameter: d (arithmetic) or r (geometric) // ---------- layout constants (computed in setup) ---------- let plotLeft, plotRight, plotTop, plotBottom; // Accent palette (rule 8) — at most three colours. const C_STEM = [40, 90, 200]; // blue stems + dots const C_AXIS = [120]; // neutral grey axes const C_ZERO = [200, 60, 60]; // red zero baseline function setup() { // Rule 5 — canvas inside setup, standard size, 2x density. createCanvas(720, 520); pixelDensity(2); // Plot rectangle. Computed from width/height so layout survives resize. plotLeft = 70; plotRight = width - 40; plotTop = 90; plotBottom = height - 90; // Rule 6 — controls built in setup, positioned explicitly, ranges // chosen to be mathematically meaningful. typeSelect = createSelect(); typeSelect.option("arithmetic"); typeSelect.option("geometric"); typeSelect.option("harmonic"); typeSelect.option("squares"); typeSelect.option("fibonacci"); typeSelect.selected("geometric"); typeSelect.position(150, height - 52); typeSelect.style("width", "130px"); // N: enumerate between 4 and 30 terms. 12 is a comfortable default. nSlider = createSlider(4, 30, 12, 1); nSlider.position(150, height - 28); nSlider.style("width", "150px"); // Family parameter. Slider holds 0..100; mapped per-family in draw() // to d in [-3, 3] (arithmetic) or r in [-1.5, 1.5] (geometric). // 75 -> r = 0.5 by default, a textbook convergent geometric ratio. pSlider = createSlider(0, 100, 75, 1); pSlider.position(420, height - 28); pSlider.style("width", "150px"); } function draw() { background(248); // ---------- read controls ---------- const kind = typeSelect.value(); const N = nSlider.value(); // Map the raw slider to the family parameter the literature uses. const d = map(pSlider.value(), 0, 100, -3, 3); // common difference const r = map(pSlider.value(), 0, 100, -1.5, 1.5); // common ratio // ---------- compute the sequence terms ---------- const a = sequenceTerms(kind, N, d, r); // ---------- vertical scale: fit the terms into the plot box ---------- let lo = 0, hi = 0; for (let i = 0; i < a.length; i++) { if (a[i] < lo) lo = a[i]; if (a[i] > hi) hi = a[i]; } if (hi === lo) { hi = lo + 1; } // guard a flat run const pad = (hi - lo) * 0.08 + 1e-9; // breathing room above/below lo -= pad; hi += pad; // Map an index n (1-based) to an x pixel, and a value to a y pixel. const xOf = (n) => map(n, 1, max(N, 2), plotLeft + 18, plotRight - 10); const yOf = (v) => map(v, lo, hi, plotBottom, plotTop); // ---------- reference geometry (rule 8 layer 1) ---------- // Plot frame. stroke(C_AXIS[0]); strokeWeight(1); noFill(); line(plotLeft, plotTop, plotLeft, plotBottom); // y-axis line(plotLeft, plotBottom, plotRight, plotBottom); // x-axis (n) // Zero baseline (only if 0 is inside the visible value range). if (lo < 0 && hi > 0) { stroke(C_ZERO[0], C_ZERO[1], C_ZERO[2]); strokeWeight(1); const y0 = yOf(0); line(plotLeft, y0, plotRight, y0); } // ---------- active geometry: the stem plot (rule 8 layer 2) ---------- const baseY = (lo < 0 && hi > 0) ? yOf(0) : plotBottom; for (let i = 0; i < a.length; i++) { const n = i + 1; const px = xOf(n); const py = yOf(a[i]); // Stem from the baseline up (or down) to the term value. stroke(C_STEM[0], C_STEM[1], C_STEM[2]); strokeWeight(2); line(px, baseY, px, py); // Term dot. noStroke(); fill(C_STEM[0], C_STEM[1], C_STEM[2]); circle(px, py, 7); // Index tick label under the axis for the first, last, and a few // interior terms (avoid crowding when N is large). if (n === 1 || n === N || (N <= 14)) { fill(90); textSize(10); textAlign(CENTER, TOP); text(n, px, plotBottom + 6); } } // ---------- HUD watermark (rule 2) ---------- noStroke(); textFont("system-ui"); // 2a — top-left title block. fill(20); textSize(20); textAlign(LEFT, TOP); text("Sequence", 16, 14); textSize(12); fill(110); text("Wikitube microsim - en.wikitube.io/wiki/" + ARTICLE, 16, 40); // 2b — top-right control hints. textAlign(RIGHT, TOP); textSize(11); fill(110); text("select: family sliders: N (terms), parameter d or r", width - 16, 14); text("stem plot of a_n vs index n", width - 16, 30); // 2c — bottom-left live readouts (canonical symbols). textAlign(LEFT, BOTTOM); textSize(13); fill(20); const firstFew = a.slice(0, 5).map((v) => roundStr(v)).join(", "); text("a_n: " + firstFew + (a.length > 5 ? ", ..." : ""), 16, height - 64); // Behaviour readout: converging, diverging, or oscillating. textSize(12); fill(60); text("behaviour: " + behaviourOf(kind, r) + " N = " + N, 16, height - 8); // Slider / select labels (rule 7) — to the LEFT, right-aligned. textAlign(RIGHT, CENTER); textSize(12); fill(60); text("family", 144, height - 52 + 9); text("N", 144, height - 28 + 9); // Parameter label changes with the family it actually drives. const pLabel = (kind === "arithmetic") ? ("d = " + roundStr(d)) : (kind === "geometric") ? ("r = " + roundStr(r)) : "(unused)"; text(pLabel, 414, height - 28 + 9); // 2d — bottom-right equation footer (ASCII only — see pitfalls.md). textAlign(RIGHT, BOTTOM); textSize(11); fill(80); text(equationOf(kind), width - 16, height - 8); } // ---------- helpers (rule 10) ---------- // Build the first N terms of the named family. a1 is fixed at 1 so the // families are directly comparable; the slider varies d (arithmetic) or // r (geometric). Harmonic, squares, and Fibonacci are parameter-free. function sequenceTerms(kind, N, d, r) { const a = []; const a1 = 1; if (kind === "arithmetic") { for (let n = 1; n <= N; n++) a.push(a1 + (n - 1) * d); } else if (kind === "geometric") { for (let n = 1; n <= N; n++) a.push(a1 * pow(r, n - 1)); } else if (kind === "harmonic") { for (let n = 1; n <= N; n++) a.push(1 / n); } else if (kind === "squares") { for (let n = 1; n <= N; n++) a.push(n * n); } else { // fibonacci let p = 1, q = 1; for (let n = 1; n <= N; n++) { a.push(p); const next = p + q; p = q; q = next; } } return a; } // One-line ASCII statement of the general term for the footer. function equationOf(kind) { if (kind === "arithmetic") return "a_n = a1 + (n-1)*d"; if (kind === "geometric") return "a_n = a1 * r^(n-1)"; if (kind === "harmonic") return "a_n = 1/n -> 0"; if (kind === "squares") return "a_n = n^2 -> inf"; return "a_n = a_(n-1) + a_(n-2) (Fibonacci)"; } // Qualitative limit behaviour, used in the readout. function behaviourOf(kind, r) { if (kind === "harmonic") return "converges to 0"; if (kind === "squares") return "diverges to +inf"; if (kind === "fibonacci") return "diverges (ratio -> phi)"; if (kind === "arithmetic") return "diverges (linear) unless d=0"; // geometric if (abs(r) < 1) return "converges to 0 (|r| < 1)"; if (r === 1) return "constant (r = 1)"; if (r === -1) return "oscillates +/-1 (r = -1)"; if (r > 1) return "diverges (r > 1)"; return "oscillates, growing (r < -1)"; } // Compact numeric formatting for the readout row. function roundStr(v) { if (!isFinite(v)) return "inf"; if (abs(v) >= 1000 || (abs(v) < 0.01 && v !== 0)) return v.toExponential(1); return (Math.round(v * 100) / 100).toString(); } ``` ## Links (Wikipedia order) <!-- injected from _registry/childlinks/Sequence.json (2026-07-30T02:09:12Z) --> `1/2_+_1/4_+_1/8_+_1/16_+_⋯` · `1/2_−_1/4_+_1/8_−_1/16_+_⋯` · `1/4_+_1/16_+_1/64_+_1/256_+_⋯` · `1_+_1_+_1_+_1_+_⋯` · `1_+_2_+_3_+_4_+_⋯` · `1_+_2_+_4_+_8_+_⋯` · `1_−_1_+_2_−_6_+_24_−_120_+_⋯` · `1_−_2_+_3_−_4_+_⋯` · `1_−_2_+_4_−_8_+_⋯` · `Abel's_test` · `Absolute_convergence` · `Algebraic_function` · `Algebraic_structure` · `Algebraic_topology` · `Alternating_series` · `Alternating_series_test` · `Analytic_function` · `Arithmetic_progression` · `Arithmetico-geometric_sequence` · `Bijection` · `Binary_relation` · `Binomial_series` · `Bit` · `Boolean-valued_function` · `Boolean_function` · `Cantor's_diagonal_argument` · `Cantor_space` · `Cartesian_product` · `Cauchy_condensation_test` · `Cauchy_product` · `Cauchy_sequence` · `Character_(computing)` · `Codomain` · `Compact_space` · `Complete_metric_space` · `Complete_sequence` · `Completeness_of_the_real_numbers` · `Complex_conjugate` · `Complex_number` · `Computer_memory` · [[Computer_science]] · `Computing` · `Conditional_convergence` · `Connected_space` · `Constant-recursive_sequence` · `Constant_(mathematics)` · `Constant_function` · `Continuous_function` · `Convergent_series` · `Counting_measure` · `Cube_(algebra)` · `Direct_comparison_test` · `Dirichlet's_test` · `Dirichlet_series` · `Divergence_of_the_sum_of_the_reciprocals_of_the_primes` · `Divergent_series` · `Divisor` · `Domain_of_a_function` · `Ellipsis` · `Encyclopedia_of_Mathematics` · `Enumeration` · `Exact_sequence` · `FK-space` · `Factorial` · `Farey_sequence` · [[Fibonacci_sequence]] · `Field_(mathematics)` · `Figurate_number` · `Filter_on_a_set` · `Finite_set` · `Finiteness` · `Formal_language` · `Formal_power_series` · `Fourier_series` · `Free_monoid` · `Fréchet_space` · `Function_(mathematics)` · `Function_composition` · `Function_of_a_real_variable` · `Function_of_several_complex_variables` · `Function_of_several_real_variables` · `Function_space` · `Functor` · `Geometric_progression` · `Geometric_series` · `Grandi's_series` · `Group_(mathematics)` · `Group_homomorphism` · `Group_theory` · `Harmonic_progression_(mathematics)` · `Harmonic_series_(mathematics)` · `Heptagonal_number` · `Hexagonal_number` · `Higher-order_function` · `History_of_the_function_concept` · `Holonomic_function` · `Homological_algebra` · `Homotopy_theory` · `Hypergeometric_function` · `Hypergeometric_function_of_a_matrix_argument` · `Identity_function` · `Image_(mathematics)` · `Implicit_function` · `Index_set` · `Indexed_family` · `Injective_function` · `Integer` · `Integer-valued_function` · `Integer_sequence` · `Integral_test_for_convergence` · `Interval_(mathematics)` · `Inverse_function` · `Irrational_number` · `Jean_Leray` · `Kernel_(algebra)` · `Kleene_star` · `Lambda_calculus` · `Laurent_series` · `Lauricella_hypergeometric_series` · `Limit_comparison_test` · `Limit_of_a_sequence` · `Limit_ordinal` · `Linear_map` · `Linear_subspace` · `List_of_integer_sequences` · `List_of_mathematical_functions` · `List_of_mathematical_series` · `Look-and-say_sequence` · `Lp_space` · `Lucas_number` · `Mathematical_analysis` · `Mathematical_object` · `Mathematics` · `Measurable_function` · `Metric_space` · `Module_(mathematics)` · `Module_homomorphism` · `Monoid` · `Monotonic_function` · `Morphism` · `Multivalued_function` · `Natural_logarithm` · `Natural_number` · `Natural_topology` · `Neil_Sloane` · `Net_(mathematics)` · `Norm_(mathematics)` · `Number_theory` · `Numerical_digit` · `On-Line_Encyclopedia_of_Integer_Sequences` · `Order_topology` · `Ordered_pair` · `Partial_function` · `Pell_number` · `Pentagonal_number` · `Periodic_sequence` · `Permutation` · `Pi` · `Pointwise_convergence` · `Polygonal_number` · `Polynomial` · `Power_of_10` · `Power_of_three` · `Power_of_two` · `Power_series` · `Prime_number` · `Product_topology` · `Projection_(set_theory)` · `Pseudorandom_binary_sequence` · `Puiseux_series` · `Random_sequence` · `Range_of_a_function` · `Ratio_test` · `Rational_function` · `Rational_number` · `Real-valued_function` · `Real_analysis` · `Real_number` · [[Recurrence_relation]] · [[Recursion_(computer_science)]] · `Recursive_definition` · `Relation_(mathematics)` · `Restriction_(mathematics)` · `Riemann's_differential_equation` · `Riemann_zeta_function` · `Root_test` · `Separable_space` · `Sequence_space` · `Series_(mathematics)` · `Set-valued_function` · `Set_(mathematics)` · `Space_(mathematics)` · `Special_functions` · `Spectral_sequence` · `Square_number` · `Squeeze_theorem` · `Stream_(computing)` · `String_(computer_science)` · `Subsequence` · `Surjective_function` · `Taylor_series` · `Telescoping_series` · [[Tessellation]] · `Theoretical_computer_science` · `Thue–Morse_sequence` · `Topological_space` · `Topological_vector_space` · `Topology` · `Triangular_array` · `Triangular_number` · `Trigonometric_series` · `Tuple` · `Uniform_convergence` · `Vector_space` · [[Wayback_Machine]] ## From the Real GENERATIVE library ![Sequence](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7a/Cauchy_sequence_illustration2.svg/350px-Cauchy_sequence_illustration2.svg.png) *Sequence — placed from the Real G.E.N.E.R.A.T.I.V.E. course library (Information room). Source: Wikimedia Commons (via Wikipedia article media). [Details & license](https://commons.wikimedia.org/wiki/File:Cauchy_sequence_illustration2.svg).* > In mathematics, a sequence is an enumerated collection of objects in which repetitions are allowed and order matters. Like a set, it contains members (also called elements, or terms). ([Wikipedia](https://en.wikipedia.org/wiki/Sequence)) <!-- REAL-GENERATIVE-MEDIA:END --> <!-- LOCAL-MEDIA-PASS:START --> ## From the vault media library !Sequence thumb.png *Sequence — from the vault's own media holdings, placed 2026-07-09. MTN / Wikitube.io original · CC BY-SA 4.0.* <!-- LOCAL-MEDIA-PASS:END --> > **Room:** [[Information]] · **Status:** ✅ shipped ## Overview In mathematics, a sequence is an enumerated collection of objects in which repetitions are allowed and order matters. Like a set, it contains members (also called elements, or terms). The number of elements (possibly infinite) is called the length of the sequence. Unlike a set, the same elements can appear multiple times at different positions in a sequence, and unlike a set, the order does matter. Formally, a sequence can be defined as a function from natural numbers (the positions of elements in the sequence) to the elements at each position. The notion of a sequence can be generalized to an indexed family, defined as a function from an arbitrary index set. _(Overview is shorter than 200 words; the pipeline should expand it from textbook context before publishing.)_ ## See also - Room hub: [[Information]] - p5.js Editor conventions: P5 JS EDITOR - Wiki root: MAIN --- *Scaffolded by `generative-microsim` from row 10 of the Information sheet on 2026-06-03T16:49:24Z.* Letters: mined_sequence · harmonic · mined_information · oscillation · mined_geometry · mined_system · exponential · iteration <!-- REAL-GENERATIVE-MEDIA:START --> <!-- CRAFT-LINK:START g12 --> *Built to the [[WT!P5_js_Microsim_Master_Class|p5.js Master Class]].* <!-- CRAFT-LINK:END --> ## Wikipedia : Wikitube **Strict pair:** [Wikipedia](https://en.wikipedia.org/wiki/Sequence) : [Wikitube](https://en.wikitube.io/wiki/Sequence) ## Previous hub tags Tree parent: [[Dynamical_system]]. Legacy hubs: `GENERATIVE`. --- *Sources: 1 legacy note. Minted wave 1, 2026-07-30 (v1.6 order).*