{ "cells": [ { "cell_type": "markdown", "metadata": { "pedagogy": { "role": "meta", "difficulty": 1, "kind": "orientation", "title": "Studio Goals" } }, "source": "## META | difficulty 1 | Studio Goals\n\nThis studio is about comparison and diagnosis.\nThe learner should leave with a strong visual distinction between cyclic and negacyclic wraparound.\n" }, { "cell_type": "markdown", "metadata": { "pedagogy": { "role": "mandatory", "difficulty": 3, "kind": "explanation", "title": "Two Folds, Same Raw Tail, Different Result" } }, "source": "## MANDATORY | difficulty 3 | Two Folds, Same Raw Tail, Different Result\n\nIf the raw convolution is fixed, the only thing that changes is the ring rule.\nThat is exactly why the same tail can produce two different reduced polynomials.\n" }, { "cell_type": "code", "execution_count": null, "metadata": { "pedagogy": { "role": "mandatory", "difficulty": 3, "kind": "demo", "title": "Compare The Two Fold Rules" } }, "outputs": [], "source": "# MANDATORY | difficulty 3 | Compare The Two Fold Rules\n\nfrom IPython.display import display\n\nfrom ntt_learning.toy_ntt import schoolbook_convolution\nfrom ntt_learning.visuals import plot_wraparound\n\nraw = schoolbook_convolution([1, 2, 3, 4], [5, 6, 7, 8])\nprint(\"raw convolution:\", raw)\ndisplay(plot_wraparound(raw, n=4, negacyclic=False, title=\"Positive wrap into x^4 - 1\"))\ndisplay(plot_wraparound(raw, n=4, negacyclic=True, title=\"Negative wrap into x^4 + 1\"))\n" }, { "cell_type": "markdown", "metadata": { "pedagogy": { "role": "mandatory", "difficulty": 2, "kind": "exercise", "title": "Debug Checklist" } }, "source": "## MANDATORY | difficulty 2 | Debug Checklist\n\nIf a wraparound result looks wrong, inspect these in order:\n\n1. Was the raw convolution itself correct?\n2. Was the divisor `x^n - 1` or `x^n + 1`?\n3. Did the wrapped tail land in the right slot?\n4. Did the sign flip happen on the wrapped term?\n" }, { "cell_type": "code", "execution_count": null, "metadata": { "pedagogy": { "role": "mandatory", "difficulty": 2, "kind": "exercise", "title": "See A Wrong-Sign Failure" } }, "outputs": [], "source": "# MANDATORY | difficulty 2 | See A Wrong-Sign Failure\n\nfrom ntt_learning.toy_ntt import schoolbook_convolution, negacyclic_reduce\n\nraw = schoolbook_convolution([1, 2, 3, 4], [5, 6, 7, 8])\nwrong = [raw[0] + raw[4], raw[1] + raw[5], raw[2] + raw[6], raw[3]]\n\nprint(\"raw:\", raw)\nprint(\"wrong sign fold:\", wrong)\nprint(\"correct negacyclic fold:\", negacyclic_reduce(raw, n=4))\n" }, { "cell_type": "markdown", "metadata": { "pedagogy": { "role": "mandatory", "difficulty": 2, "kind": "reflection", "title": "Reflection" } }, "source": "## MANDATORY | difficulty 2 | Reflection\n\nExplain the exact visual difference between \u201cthe wrong-sign fold\u201d and \u201cthe correct negacyclic fold\u201d.\n" }, { "cell_type": "code", "execution_count": null, "metadata": { "pedagogy": { "role": "facultative", "difficulty": 4, "kind": "exploration", "title": "Optional: Fold A Larger Tail" } }, "outputs": [], "source": "# FACULTATIVE | difficulty 4 | Optional: Fold A Larger Tail\n\nfrom IPython.display import display\n\nfrom ntt_learning.visuals import plot_wraparound\n\nraw = [4, 8, 12, 16, 9, 5, 1, 7, 11]\ndisplay(plot_wraparound(raw, n=4, negacyclic=True, title=\"Longer tail, same fold rule\"))\n" }, { "cell_type": "markdown", "metadata": { "pedagogy": { "role": "meta", "difficulty": 1, "kind": "handoff", "title": "Next Notebook" } }, "source": "## META | difficulty 1 | Next Notebook\n\nNext notebook: `../../../foundations/02_negative_wrapped_ntt/lecture.ipynb`\n" } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "name": "python" }, "ntt_learning": { "title": "Studio: Convolution To Toy NTT", "contract_version": "0.2", "sequence": [ "notebooks/START_HERE.ipynb", "notebooks/COURSE_BLUEPRINT.ipynb", "notebooks/foundations/01_convolution_to_toy_ntt/lecture.ipynb", "notebooks/foundations/01_convolution_to_toy_ntt/lab.ipynb", "notebooks/foundations/01_convolution_to_toy_ntt/problems.ipynb", "notebooks/foundations/01_convolution_to_toy_ntt/studio.ipynb", "notebooks/foundations/02_negative_wrapped_ntt/lecture.ipynb", "notebooks/foundations/02_negative_wrapped_ntt/lab.ipynb", "notebooks/foundations/02_negative_wrapped_ntt/problems.ipynb", "notebooks/foundations/02_negative_wrapped_ntt/studio.ipynb", "notebooks/butterfly_mechanics/03_fast_forward_ct/lecture.ipynb", "notebooks/butterfly_mechanics/03_fast_forward_ct/lab.ipynb", "notebooks/butterfly_mechanics/03_fast_forward_ct/problems.ipynb", "notebooks/butterfly_mechanics/03_fast_forward_ct/studio.ipynb", "notebooks/butterfly_mechanics/04_fast_inverse_gs/lecture.ipynb", "notebooks/butterfly_mechanics/04_fast_inverse_gs/lab.ipynb", "notebooks/butterfly_mechanics/04_fast_inverse_gs/problems.ipynb", "notebooks/butterfly_mechanics/04_fast_inverse_gs/studio.ipynb", "notebooks/kyber_mapping/05_kyber_ntt_and_base_multiplication/lecture.ipynb", "notebooks/kyber_mapping/05_kyber_ntt_and_base_multiplication/lab.ipynb", "notebooks/kyber_mapping/05_kyber_ntt_and_base_multiplication/problems.ipynb", "notebooks/kyber_mapping/05_kyber_ntt_and_base_multiplication/studio.ipynb", "notebooks/professional/06_debugging_ntt_failures/lecture.ipynb", "notebooks/professional/06_debugging_ntt_failures/lab.ipynb", "notebooks/professional/06_debugging_ntt_failures/problems.ipynb", "notebooks/professional/06_debugging_ntt_failures/studio.ipynb", "notebooks/COURSE_COMPLETE.ipynb" ] } }, "nbformat": 4, "nbformat_minor": 5 }