// SPDX-License-Identifier: Apache-2.0
; specs/widgets/golden-lucas.t27 -- the infographic of lesson 3 of the GoldenFloat course (specs/course/goldenfloat.t27)
; Source of truth for public/widgets/golden-lucas/ (gHashTag/trinity): scripts/widget-pages-from-spec.mjs compiles
; this file, checks its constants, evaluates the tests below and writes the page. tool.js is one import of
; ../infographic.js, which draws SAY_TABLE_* as a real
and SAY_FLOW_* as an SVG diagram with a
; , black and white, and holds no words of its own. ASCII only (L3), English only (LANG-EN).
; The lesson spec it illustrates: public/t27/files/specs/numeric/lucas_accumulator.t27.
; phi^2 + 1/phi^2 = 3 | TRINITY
module widget_golden_lucas;
pub const KIND : str = "widget-tool";
pub const ID : str = "golden-lucas";
pub const TITLE : str = "GoldenFloat 3: Lucas numbers stay whole";
pub const DESCRIPTION : str = "phi^(2n) + phi^(-2n) against L_2n, read from lucas_accumulator.t27. Lesson 3 of the GoldenFloat course.";
pub const IMAGE_ALT : str = "A black and white table, phi^(2n) + phi^(-2n) against L_2n: 0, L_0, 2; 1, L_2, 3; 2, L_4, 7; 3, L_6, 18; 4, L_8, 47; 5, L_10, 123; 6, L_12, 322.";
pub const HOOK : str = "phi is irrational, but phi^(2n) + phi^(-2n) is always a whole number.";
pub const CATEGORY : str = "compiler";
pub const DATA_SOURCES : [2]str = ["The lesson spec public/t27/files/specs/numeric/lucas_accumulator.t27, read when the course was authored; every number in the table is a constant, a test value or arithmetic of that file", "Nothing on this page was measured on hardware or timed; a value written into a test is said to be written in, not computed"];
pub const READS_LOCAL_FILES : bool = false;
pub const SENDS_NOTHING : bool = true;
; --- The table -----------------------------------------------------------------------------
pub const SAY_TABLE_CAPTION : str = "phi^(2n) + phi^(-2n) against L_2n";
pub const SAY_TABLE_HEAD : [3]str = ["n", "Lucas number", "Value"];
pub const SAY_TABLE_CELLS : [21]str = ["0", "L_0", "2", "1", "L_2", "3", "2", "L_4", "7", "3", "L_6", "18", "4", "L_8", "47", "5", "L_10", "123", "6", "L_12", "322"];
pub const K_TABLE_COLS : u8 = 3;
pub const K_TABLE_ROWS : u8 = 7;
pub const K_TABLE_CELLS : u16 = 21;
; --- The diagram and the note ----------------------------------------------------------------
pub const SAY_FLOW_TITLE : str = "How the ladder grows";
pub const SAY_FLOW_STEPS : [3]str = ["L_0 = 2, L_1 = 1", "L_k = L_(k-1) + L_(k-2)", "L_2 = 3 = phi^2 + phi^(-2)"];
pub const K_FLOW_STEPS : u8 = 3;
pub const SAY_NOTE : str = "lucas_accumulator.t27 tests each row, n = 0 to 6, with a tolerance of 1e-9.";
test the_cells_fill_whole_rows {
assert K_TABLE_ROWS * K_TABLE_COLS == K_TABLE_CELLS;
}
test the_table_has_a_body {
assert K_TABLE_ROWS > 0;
assert K_TABLE_COLS > 0;
}
test the_diagram_has_every_step {
assert K_FLOW_STEPS == 3;
assert K_FLOW_STEPS > 1;
}