#!/usr/bin/env python3
"""N15 — arithmetic from D1287 supplied sources.
No network, external packages, fitting operations or shared runtime files.
Printed source cells and unrounded arithmetic are distinct outputs.
"""

import math
from decimal import Decimal, ROUND_HALF_UP, getcontext
from fractions import Fraction

getcontext().prec = 40
PHI = (1.0 + math.sqrt(5.0)) / 2.0


def shown(value, places=9, signed=False):
    """Decimal half-up display; never use display-rounded inputs implicitly."""
    value = Decimal(str(value))
    rounded = value.quantize(Decimal(1).scaleb(-places), rounding=ROUND_HALF_UP)
    return format(rounded, ("+" if signed else "") + "." + str(places) + "f")

def main():
    print('=== row 15 ===')
    print('Scorecard (verbatim): y t (tree) cubic invariant / Peirce ½ theory 1 experiment y t (M Z ) ≈ 0.967 deviation — Structural (declared) —')
    carrier_diagonal = (PHI, 1.0, PHI**(-1))
    unit = carrier_diagonal[1]
    assert unit == 1.0
    print("carrier_middle_weight = " + shown(unit,0))
    print("declared_boundary_y_t = 1")
    print("reported_running_y_t_MZ = approximately 0.967 (source report; not rerun)")
    print("running_inputs = NOT IN SUITE (complete initial-value data absent from excerpts)")
    print("signed_percent = NOT ASSIGNED (different scales; no experimental comparator)")
    print("d = NOT ASSIGNED (not an experimental comparison)")
    print()


if __name__ == "__main__":
    main()
