Python playground

Read side by side

Explore Komorebi's special functions, physics examples, sequences, and worked calculations. Change the inputs, inspect the graphs, and follow the links to the written mathematics.

Python starts when you press Run. The first run downloads about 13 MB of runtime files. The library example also loads NumPy and Komorebi Math. Calculations run in your browser. Use Save draft to keep edited code in this browser, or download it as a Python file. Unsaved code and selected data may be lost when you leave or reload the page.

The editor is a plain text field. Tab moves to the next control. Run uses a fresh Python namespace. Stop ends the runtime. Reset restores the selected preset. Fixed expected values may need updating when you change an input.

Upload data or open saved Python code

Up to 5 UTF-8 files, 2 MB each and 4 MB in total. The page reads them locally. It does not upload them to a server. Python receives their text in the uploaded_files dictionary. Try the Plot CSV or JSON data preset.

No data files selected.

Sample CSV · Sample JSON

This replaces the selected editor's text. It does not run the code. Maximum 256 KB.

Choose an example, then press Run.

Separate equal histograms with an arithmetic projector

Use the book’s modulus-12 Ramanujan projector to distinguish signed, unsigned, and dephased states. Edit a rational unit phase; download exact probabilities.

Physics collection, hand calculations and proof sources

Plotting, data and saving guide

Download original codeJump to results
Expected output for the published preset
Common coordinate probabilities sum: 1
Selected probability, edited phase: 1/5
Unsigned coherent: 0
Signed coherent: 1
Complete coordinate dephasing: 1/3
Exported 5 exact phase comparisons.

This is the original example's output. Your edits may change it.

Recover a state after partial dephasing

Edit a rational unit phase and retained coherence t. Compare three measurement settings, reconstruct the density matrix, and export exact probabilities and purity.

Physics collection, hand calculations and proof sources

Plotting, data and saving guide

Download original codeJump to results
Expected output for the published preset
Phase: (3/5) + (4/5)i
Retained coherence: 1/2
Measured X+, Y+, Z+: 161/250, 173/250, 9/25
Output purity: 409/625
Recovered original upper-right entry: (36/125) + (-48/125)i
Exported 9 exact partial-dephasing rows.

This is the original example's output. Your edits may change it.

Watch probability move between packets

Rotate a two-component state, follow its packet squared norms, and check the receiving-first current signs. This is a finite mathematical example.

Physics collection, hand calculations and proof sources

Plotting, data and saving guide

Download original codeJump to results
Expected output for the published preset
Initial packet squared norms: 1, 1
Initial incoming currents: -2, 2
Total squared norm: 2
Plotted 161 times on [0, 2 pi].

This is the original example's output. Your edits may change it.

See quantum phase change a measurement

Compare (3/5, 4i/5) and (3/5, 4/5). Exact rational probabilities agree in the coordinate basis and differ after a Hadamard change of basis.

Physics collection, hand calculations and proof sources

Plotting, data and saving guide

Download original codeJump to results
Expected output for the published preset
Coordinate probabilities: 9/25, 16/25
Hadamard probabilities with phase i: 1/2, 1/2
Hadamard probabilities with phase 1: 49/50, 1/50
Purity after coordinate dephasing: 337/625

This is the original example's output. Your edits may change it.

Compare a centered symbol with its continuum limit

Plot sin(h k)/h beside k, then compare a fixed three-momentum modal error with the quadratic envelope. Floating-point samples illustrate the source theorem.

Physics collection, hand calculations and proof sources

Plotting, data and saving guide

Download original codeJump to results
Expected output for the published preset
Fixed momentum: (1, 2, -1)
Spacings: 0.5, 0.25, 0.125, 0.0625
Exported 4 modal error comparisons.
These floating-point samples illustrate the bound; the Lean source supplies the general theorem.

This is the original example's output. Your edits may change it.

Explore coupled contraction functions

Compute exact rational coefficients for two coupled series, plot their degree-23 Taylor polynomials, and display the source majorant on the unit disk.

Function definitions, reading volumes and proof sources

Plotting, data and saving guide

Download original codeJump to results
Expected output for the published preset
Scales (q, r, a, b): 1/3, 2/3, 1/2, 3/4
Coefficients retained per component: 12 (through degree 23)
u_1 = 2/27; v_1 = 1/8
Uniform omitted-tail envelope on |z| <= 1: 1/2048
Exported exact rational coefficients for both components.

This is the original example's output. Your edits may change it.

Reciprocal sequences and factorial growth

Use Komorebi Math to compare exact reciprocal coefficients with (Nn)!, then inspect the coefficients after factorial normalization. Start with N = 4 and r = 1.

Definitions, exact values and how to read this plot · Komorebi Math sequence API

Plotting, data and saving guide

Download original codeJump to results
Expected output for the published preset
Reciprocal family: N=4, r=1
Computed n=0 through 15 with exact integers.
A(0..4): (1, 1, 69, 33661, 60376809)
Exported exact coefficients and rational normalizations.

This is the original example's output. Your edits may change it.

Compare reciprocal families in 2D and 3D

Start with a labelled 2D comparison of N = 2 through 8. A separate 3D view follows. Both show the same factorial-normalized values, with exact fractions available as CSV.

Definitions, exact values and how to read this plot · Komorebi Math sequence API

Plotting, data and saving guide

Download original codeJump to results
Expected output for the published preset
Reciprocal landscape: N=2..8, r=1, n=0..15
Exact coefficient samples: 112
Secant anchor A_2(0..5): (1, 1, 5, 61, 1385, 50521)
Exported exact coefficients. Plot heights are approximate logarithms.

This is the original example's output. Your edits may change it.

Factorial weights in the sequence atlas

Compare a Stirling row with its factorial-weighted row using ordinary counts. Then inspect a 2D map of contributions, with a separate 3D view below it.

Definitions, exact values and how to read this plot · Komorebi Math sequence API

Plotting, data and saving guide

Download original codeJump to results
Expected output for the published preset
Stirling row n=5: [0, 1, 15, 25, 10, 1]
Factorial-weighted row: [0, 1, 30, 150, 240, 120]
Bell row sum: 52
Fubini row sum: 541
All 19 weighted row sums match Komorebi Math.
Exported exact contributions through n=18.

This is the original example's output. Your edits may change it.

Reconstruct an operator

Hand calculation, expected output and source connections

Download original codeJump to results
Expected output for the published preset
Input: (2, 3)
Packet parts: ((2, 0), (0, 3))
Block contributions: ((2, 0), (6, 0), (0, 6), (0, 12))
Direct result: (8, 18)
Reconstructed result: (8, 18)
Without the final block: (8, 6)
PASS: packets

This is the original example's output. Your edits may change it.

Refine a signal

Hand calculation, expected output and source connections

Download original codeJump to results
Expected output for the published preset
Input: (1, 2, 3, 4, 5, 6, 7, 8)
Two packets: ((1, 3, 5, 7), (2, 4, 6, 8))
Four packets: ((1, 5), (2, 6), (3, 7), (4, 8))
Interleaved: (1, 2, 3, 4, 5, 6, 7, 8)
Without remainder 2: (1, 2, 0, 4, 5, 6, 0, 8)
Residual: (0, 0, 3, 0, 0, 0, 7, 0)
Squared residual norm: 58
PASS: refinement

This is the original example's output. Your edits may change it.

Test recovery from a summary

Hand calculation, expected output and source connections

Download original codeJump to results
Expected output for the published preset
Inputs: (1, 0) and (0, 1)
Same summary: 1
Requested first coordinates: (1, 0)
Kernel witness: (1, -1)
R(w): 0
F(w): 1
Compatible observation coefficients: (2, 2)
PASS: recovery

This is the original example's output. Your edits may change it.

Use Komorebi Math

This uses the published Komorebi Math library for packet reconstruction and exact rational coordinate changes. These two operations are tested here. The sequence research presets separately test reciprocal coefficients and Fubini row sums in their documented finite ranges. Optional backends and other operations remain outside that scope.

Installation and expected output · Komorebi Math guide

Download original codeJump to results
Expected output for the published preset
Numerical reconstruction: [2.0, 3.0]
Exact coordinate change: (7/2, 3)
Exact inverse: (2, 3)
PASS: first examples

This is the original example's output. Your edits may change it.

Plot a signal in 2D

Two sine waves and their sum. Zoom or inspect individual samples. This is a plotting tutorial, not a claim about a paper.

Plotting, data and saving guide

Download original codeJump to results
Expected output for the published preset
Plotted 201 samples of two waves and their sum.

This is the original example's output. Your edits may change it.

Explore a 3D surface

Rotate the saddle surface z = x squared minus y squared. Keyboard view buttons and a data table provide other ways to inspect it.

Plotting, data and saving guide

Download original codeJump to results
Expected output for the published preset
Surface grid: 41 x 41
Center height: 0.0

This is the original example's output. Your edits may change it.

Explore a 3D curve

A sampled helix with labelled axes, rotation, zoom, and downloadable coordinates.

Plotting, data and saving guide

Download original codeJump to results
Expected output for the published preset
Helix samples: 201

This is the original example's output. Your edits may change it.

Make a Matplotlib figure

Use ordinary Matplotlib commands to produce a PNG. This preset also exports the plotted numbers as CSV.

Plotting, data and saving guide

Download original codeJump to results
Expected output for the published preset
Created a Matplotlib figure and parabola.csv.

This is the original example's output. Your edits may change it.

Calculate with SymPy

Differentiate, integrate and factor a polynomial using exact symbolic expressions.

Plotting, data and saving guide

Download original codeJump to results
Expected output for the published preset
Polynomial: x**3 - 3*x + 2
Derivative: 3*x**2 - 3
Integral on [0, 1]: 3/4
Factorization: (x - 1)**2*(x + 2)

This is the original example's output. Your edits may change it.

Calculate with SciPy

Numerically integrate x squared on [0, 1] and compare with the known value one third. The printed value is rounded.

Plotting, data and saving guide

Download original codeJump to results
Expected output for the published preset
Integral of x squared on [0, 1]: 0.333333
Within 1e-12 of one third: True

This is the original example's output. Your edits may change it.

Plot CSV or JSON data

Upload a CSV with x,y columns or a JSON array of objects with x and y fields. With no upload, this uses the supplied sample. When several files are loaded, the first filename in alphabetical order is used.

Plotting, data and saving guide

Download original codeJump to results
Expected output for the published preset
Using sample data.
Plotted 4 rows.

This is the original example's output. Your edits may change it.

Output

Choose another preset
Run an example to see its output here.

Errors

None.
Plotting, data and saving guide

Matplotlib figures appear as downloadable PNGs. Use plt.show() or show_matplotlib(fig, description="..."). Interactive plots use from komorebi_browser import show_plot and Plotly-style trace dictionaries. Supported traces are scatter, bar, heatmap, surface, and scatter3d. The playground supplies this helper. It is separate from the Komorebi Math package.

Use show_plot(data, layout, description="...") to label a figure and its axes. Interactive plots have series checkboxes, an Enlarge plot button, zoom controls, image and data downloads, and a table of the first 100 samples. 3D views also have keyboard buttons for front, top, and default views. The sequence family and factorial weights presets start with 2D views of the same data. If WebGL is unavailable, use those views, the table or the data downloads.

NumPy, Matplotlib, SymPy and SciPy load when selected presets or direct imports need them. Optional Komorebi backends remain outside the tested browser scope. Each run has a two minute limit, up to 50,000 samples per interactive figure, a 2 MB limit per figure or export, and an 8 MB combined figure and export limit.

Use export_file("result.csv", text) for CSV, JSON, or text downloads. Saved drafts remain in this browser until you delete them. Restore draft is explicit. Download edited code saves the current editor as a .py file. The run report records the executed code, output, package versions, source revision, and input-file checksums. It omits uploaded file contents. Downloaded plotting scripts can be reopened in this playground. The browser helper source documents the display functions.

Runtime, library revision, and source records

Pyodide 314.0.7, Python 3.14.2, NumPy 2.4.6. Matplotlib, SymPy, and SciPy are available on demand. Interactive plotting uses Plotly.js 4.1.1. These files are served by this site.

Example checksums and pinned library file list · Runtime sources and checksums · Runtime licenses · Plotly license · Pinned library source ZIP with license