Notebooks
Programs as notebooks
A Viv notebook is an ordinary .viv file. A line that is exactly ### opens a
block of prose that runs to the next ### line; the compiler skips it, and this view renders it.
The code between two prose blocks is a cell. Running a cell runs it together with every cell above it,
as one program, and its output appears under it. The file still runs from the command line, in both
engines, exactly as written.
38 files have prose cells so far; every other file opens as a single code cell, split nowhere, with its output under it.
With prose cells
- Forward Euler loses the planet 12 code cells
- The quadratic formula, applied 1 code cells
- A transformer trained with Muon 16 code cells
- The tension in each of two ropes holding up a box 14 code cells
- Hartree-Fock for water 2 code cells
- Newton's method doubles the correct digits 4 code cells
- A random walk spreads as 2Dt and turns Gaussian 5 code cells
- BFGS against gradient descent on the Rosenbrock valley 5 code cells
- Black-Scholes by Monte Carlo, against the closed form 4 code cells
- Burgers' equation in nonconservative form puts the shock in the wrong place 4 code cells
- Excitation energies of water from the Casida equation, with and without de-excitations 4 code cells
- The double scroll of Chua's circuit 5 code cells
- Crank-Nicolson is second order in time, backward Euler first 4 code cells
- Electron mobility fitted to NIST's certified digits 3 code cells
- Forward and backward Euler on either side of h = 2/λ 3 code cells
- Gauss-Legendre quadrature against tanh-sinh on a smooth and a singular integral 4 code cells
- Grad-Shafranov by finite differences, against Solov'ev's closed form 4 code cells
- Graphene's Dirac cones 6 code cells
- RHF, UHF and full CI for H₂ in STO-3G along the bond 7 code cells
- Jacobi's eigenvalue method 4 code cells
- Jacobi, SOR and conjugate gradients on the Poisson equation 6 code cells
- Three floating-point failures in summation, cancellation and RANDU 4 code cells
- Kinetic Monte Carlo against the master equation 4 code cells
- Lanczos finds the largest eigenvalue three times 4 code cells
- Landau damping from the root of the dispersion relation 5 code cells
- Metropolis sampling finds Onsager's magnetization 5 code cells
- Nuclear level density, by counting the states 5 code cells
- Neutron pairing in a neutron-star crust 3 code cells
- Silicon's band structure, from the crystal up 17 code cells
- Skyrme Hartree-Fock of oxygen-16 4 code cells
- A gyro-orbit and the E×B drift by the Boris push 4 code cells
- The error of a linear solve follows the condition number 3 code cells
- A star of free neutrons can weigh at most 0.71 suns 4 code cells
- The two-pion loop function, built and differentiated by a small computer algebra system 4 code cells
- Tunneling through one and two barriers by transfer matrices 4 code cells
- The bounce period of an electron trapped in a plasma wave 5 code cells
- The two-stream instability in a particle-in-cell code 5 code cells
- Upwind advection smears the pulse by its modified equation 4 code cells
Posts
- Forward Euler loses the planet 12 code cells
- The Gibbs overshoot never shrinks 5 KB
- The logistic map at r = 4 has Lyapunov exponent ln 2 3 KB
- Which root does Newton's method find? 2 KB
- How far a finite-difference Hamiltonian's levels sit below n + 1/2 2 KB
- Pi from escape counts at the cusp of the Mandelbrot set 2 KB
- The Runge phenomenon, where more points give a worse fit 4 KB
- The eigenvalues of a random matrix fill Wigner's semicircle 3 KB
- Building a four-bit adder out of NAND gates 19 KB
- A cart-pole, balanced by a PD controller 3 KB
- Compound interest 2 KB
- Doubling time 3 KB
- LQR computes the cart-pole's gains from the Riccati equation 8 KB
- A Lennard-Jones liquid by molecular dynamics in two dimensions 7 KB
- Solve the quadratic 1 KB
- Building the derivative from its definition 7 KB
- The geometric series adds up 3 KB
- The quadratic formula, applied 1 code cells
- The quadratic formula, derived 3 KB
- Two lines cross 2 KB
- A swing-up policy trained offline 13 KB
- A transformer trained with Muon 16 code cells
- Solving the Riccati equation without integrating it 13 KB
- The tension in each of two ropes holding up a box 14 code cells
- Doubling time breaks at tiny rates and at negative ones 6 KB
- Doubling time, fixed for tiny and negative rates 5 KB
- Hartree-Fock for water 2 code cells
- LOBPCG finds the lowest states of a particle in a box 17 KB
- Muon orthogonalizes the update 18 KB
- Newton's method doubles the correct digits 4 code cells
- The rule of 72 against the rule of 70 4 KB
- Two methods compute water's 6-31G integrals 11 KB
- A random walk spreads as 2Dt and turns Gaussian 5 code cells
- BFGS against gradient descent on the Rosenbrock valley 5 code cells
- Black-Scholes by Monte Carlo, against the closed form 4 code cells
- Burgers' equation in nonconservative form puts the shock in the wrong place 4 code cells
- Excitation energies of water from the Casida equation, with and without de-excitations 4 code cells
- The double scroll of Chua's circuit 5 code cells
- Crank-Nicolson is second order in time, backward Euler first 4 code cells
- Electron mobility fitted to NIST's certified digits 3 code cells
- Forward and backward Euler on either side of h = 2/λ 3 code cells
- Gauss-Legendre quadrature against tanh-sinh on a smooth and a singular integral 4 code cells
- Grad-Shafranov by finite differences, against Solov'ev's closed form 4 code cells
- Graphene's Dirac cones 6 code cells
- RHF, UHF and full CI for H₂ in STO-3G along the bond 7 code cells
- The Hasegawa-Wakatani drift-wave model 13 KB
- Jacobi's eigenvalue method 4 code cells
- Jacobi, SOR and conjugate gradients on the Poisson equation 6 code cells
- Three floating-point failures in summation, cancellation and RANDU 4 code cells
- Kinetic Monte Carlo against the master equation 4 code cells
- Lanczos finds the largest eigenvalue three times 4 code cells
- Landau damping from the root of the dispersion relation 5 code cells
- Make Euler stable on a stiff equation 4 KB
- Make Gram-Schmidt orthogonal to rounding 5 KB
- Make Numerov find the decaying solution 4 KB
- Make power iteration converge on a tied pair 4 KB
- Make the heat-equation step stable past r = 1/2 4 KB
- Metropolis sampling finds Onsager's magnetization 5 code cells
- Nuclear level density, by counting the states 5 code cells
- Neutron pairing in a neutron-star crust 3 code cells
- Silicon's band structure, from the crystal up 17 code cells
- Skyrme Hartree-Fock of oxygen-16 4 code cells
- A gyro-orbit and the E×B drift by the Boris push 4 code cells
- The error of a linear solve follows the condition number 3 code cells
- A star of free neutrons can weigh at most 0.71 suns 4 code cells
- The two-pion loop function, built and differentiated by a small computer algebra system 4 code cells
- Tunneling through one and two barriers by transfer matrices 4 code cells
- The bounce period of an electron trapped in a plasma wave 5 code cells
- The two-stream instability in a particle-in-cell code 5 code cells
- Upwind advection smears the pulse by its modified equation 4 code cells
- Finite differences and spectral methods 7 KB
Example programs
- examples/annotated 2 KB
- examples/area 0 KB
- examples/autodiff_deriv 1 KB
- examples/autodiff_forward 2 KB
- examples/autodiff_reverse 3 KB
- examples/control 1 KB
- examples/debye_scf 5 KB
- examples/fem_poisson 4 KB
- examples/fem_poisson_records 5 KB
- examples/fft_poisson 3 KB
- examples/fused_views 4 KB
- examples/geomopt 12 KB
- examples/geomopt_water 13 KB
- examples/grad_shafranov 5 KB
- examples/h2_sto3g 12 KB
- examples/hasegawa_wakatani 7 KB
- examples/hchain_sto3g 7 KB
- examples/lenses/scf_demo 3 KB
- examples/level_density 2 KB
- examples/md_polymer 5 KB
- examples/meijer_g 7 KB
- examples/mini_cas 15 KB
- examples/nn_symmetry 12 KB
- examples/oneil_trapping 4 KB
- examples/scf_mcmurchie 11 KB
- examples/scf_sto3g 26 KB
- examples/scf_water 13 KB
- examples/scf_water_631gd 16 KB
- examples/spitzer_harm 4 KB
- examples/symbolic_regression 7 KB
- examples/tov 3 KB
- examples/two_stream_pic 5 KB
- examples/vlasov_landau 3 KB
- examples/xyz_atoms 1 KB
PDE solvers
- pde/advection_1d 3 KB
- pde/black_scholes 6 KB
- pde/burgers_shock 3 KB
- pde/burgers_viscous 3 KB
- pde/drum_modes 4 KB
- pde/euler_sod 9 KB
- pde/fisher_kpp 3 KB
- pde/heat_1d 4 KB
- pde/heat_2d_adi 4 KB
- pde/kdv_soliton 6 KB
- pde/laplace_2d 3 KB
- pde/nls_soliton 3 KB
- pde/poisson_2d 4 KB
- pde/schrodinger_1d 5 KB
- pde/wave_1d 4 KB
Modules (lib/)
- lib/algo/cases 4 KB
- lib/algo/legacy/bench_qsort 1 KB
- lib/algo/legacy/cmp_insertion_sort 1 KB
- lib/algo/legacy/cmp_merge_sort 1 KB
- lib/algo/legacy/cmp_quicksort 1 KB
- lib/algo/legacy/eig_sort 1 KB
- lib/algo/legacy/gcd_julia 0 KB
- lib/algo/legacy/gcd_post 1 KB
- lib/algo/legacy/gcd_ta 1 KB
- lib/algo/legacy/heaps 4 KB
- lib/algo/legacy/order 3 KB
- lib/algo/legacy/permutations 1 KB
- lib/algo/legacy/searches 1 KB
- lib/algo/legacy/seq_argsort 1 KB
- lib/algo/legacy/ta_sorting 5 KB
- lib/algo/legacy/tests/bench_qsort 3 KB
- lib/algo/legacy/tests/cmp_insertion_sort 2 KB
- lib/algo/legacy/tests/cmp_merge_sort 2 KB
- lib/algo/legacy/tests/cmp_quicksort 2 KB
- lib/algo/legacy/tests/eig_sort 2 KB
- lib/algo/legacy/tests/gcd_julia 2 KB
- lib/algo/legacy/tests/gcd_post 2 KB
- lib/algo/legacy/tests/gcd_ta 3 KB
- lib/algo/legacy/tests/heaps 9 KB
- lib/algo/legacy/tests/permutations 2 KB
- lib/algo/legacy/tests/searches 3 KB
- lib/algo/legacy/tests/seq_argsort 2 KB
- lib/algo/legacy/tests/ta_sorting 12 KB
- lib/algo/legacy/tests/topo 2 KB
- lib/algo/legacy/topo 2 KB
- lib/algo/props 11 KB
- lib/algo/tests/builtins 10 KB
- lib/are 14 KB
- lib/balance 10 KB
- lib/basis/all 1 KB
- lib/basis/basis 4 KB
- lib/basis/ccpvdz 17 KB
- lib/basis/ccpvtz 20 KB
- lib/basis/def2svp 11 KB
- lib/basis/def2tzvp 16 KB
- lib/basis/named 5 KB
- lib/basis/pople631g 11 KB
- lib/basis/pople631gs 12 KB
- lib/basis/pople631gss 12 KB
- lib/basis/sto3g 9 KB
- lib/cartpole 3 KB
- lib/cartpole_api 2 KB
- lib/cas/calculus 36 KB
- lib/cas/cas 2 KB
- lib/cas/check/acceptance 3 KB
- lib/cas/check/acceptance_check 13 KB
- lib/cas/check/hermite_e 4 KB
- lib/cas/check/pion_loop 3 KB
- lib/cas/check/pion_loop_check 2 KB
- lib/cas/codegen 10 KB
- lib/cas/derivs 2 KB
- lib/cas/eval 11 KB
- lib/cas/parse 8 KB
- lib/cas/phrases 16 KB
- lib/cas/rational 8 KB
- lib/cas/show 11 KB
- lib/cas/store 23 KB
- lib/cc/codegen 9 KB
- lib/cc/driver 1 KB
- lib/cc/lexer 6 KB
- lib/cc/parser 16 KB
- lib/cc/tests/corpus 15 KB
- lib/cc/tests/steps 6 KB
- lib/cc/types 3 KB
- lib/chain 12 KB
- lib/corpus 35 KB
- lib/eigen/lowest 11 KB
- lib/gates 6 KB
- lib/gguf/api 3 KB
- lib/gguf/header 12 KB
- lib/gguf/quants 11 KB
- lib/gguf/tensors 8 KB
- lib/gguf/tests/header 3 KB
- lib/gguf/tests/quants 2 KB
- lib/gguf/tests/tensors 2 KB
- lib/gpt/api 7 KB
- lib/gpt/gpt 8 KB
- lib/gpt/story_gpt 2 KB
- lib/graphdraw 46 KB
- lib/graphlayout 39 KB
- lib/gto 17 KB
- lib/gto_md 28 KB
- lib/hf/accelerate 17 KB
- lib/hf/ao 3 KB
- lib/hf/basis 16 KB
- lib/hf/boys 13 KB
- lib/hf/cart2sph 12 KB
- lib/hf/casida 6 KB
- lib/hf/coupling 10 KB
- lib/hf/density 8 KB
- lib/hf/eigen 21 KB
- lib/hf/eri_store 9 KB
- lib/hf/fuzz 16 KB
- lib/hf/gallery/boys 2 KB
- lib/hf/gh_onebody 13 KB
- lib/hf/guess 9 KB
- lib/hf/hermite 20 KB
- lib/hf/hf 13 KB
- lib/hf/hgp_eri 18 KB
- lib/hf/integrals 19 KB
- lib/hf/interval 21 KB
- lib/hf/iv_boys 11 KB
- lib/hf/iv_ints 42 KB
- lib/hf/iv_sweep 13 KB
- lib/hf/jk 9 KB
- lib/hf/jk_direct 7 KB
- lib/hf/md_direct 15 KB
- lib/hf/md_eri 32 KB
- lib/hf/md_onebody 9 KB
- lib/hf/mdg_eri 30 KB
- lib/hf/mdg_kernels 545 KB
- lib/hf/mole 4 KB
- lib/hf/molecule 9 KB
- lib/hf/opts 9 KB
- lib/hf/orthogonalize 11 KB
- lib/hf/os_onebody 16 KB
- lib/hf/rhf 16 KB
- lib/hf/rohf 14 KB
- lib/hf/rys_eri 25 KB
- lib/hf/scf 6 KB
- lib/hf/scf_loop 23 KB
- lib/hf/stab 23 KB
- lib/hf/sweep 24 KB
- lib/hf/tests/ao 2 KB
- lib/hf/tests/boys 7 KB
- lib/hf/tests/cart2sph 3 KB
- lib/hf/tests/density 2 KB
- lib/hf/tests/eigen 2 KB
- lib/hf/tests/gh_onebody 5 KB
- lib/hf/tests/guess 5 KB
- lib/hf/tests/hf 3 KB
- lib/hf/tests/hgp_eri 11 KB
- lib/hf/tests/integrals 5 KB
- lib/hf/tests/jk 5 KB
- lib/hf/tests/jk_direct 5 KB
- lib/hf/tests/md_direct 4 KB
- lib/hf/tests/md_eri 12 KB
- lib/hf/tests/md_onebody 7 KB
- lib/hf/tests/mdg_eri 7 KB
- lib/hf/tests/mole 1 KB
- lib/hf/tests/orthogonalize 5 KB
- lib/hf/tests/os_onebody 7 KB
- lib/hf/tests/rys_eri 6 KB
- lib/hf/tests/stab 8 KB
- lib/hf/tests/transform 9 KB
- lib/hf/transform 14 KB
- lib/hf/uhf 10 KB
- lib/hfref/boys 26 KB
- lib/hfref/breadth_631gs 274 KB
- lib/hfref/c2s 13 KB
- lib/hfref/h4_diffuse 34 KB
- lib/hfref/h_sto3g 15 KB
- lib/hfref/he 24 KB
- lib/hfref/hf_631gs 184 KB
- lib/hfref/o2_631g 250 KB
- lib/hfref/o2_631gs 109 KB
- lib/hfref/o2_sto3g 59 KB
- lib/hfref/oh_631g 56 KB
- lib/hfref/oh_631gs 228 KB
- lib/hfref/oh_sto3g 22 KB
- lib/hfref/prims 118 KB
- lib/hfref/pyscf_tests 33 KB
- lib/hfref/water_631g 160 KB
- lib/hfref/water_631g_stretched 99 KB
- lib/hfref/water_631gs_cart 285 KB
- lib/hfref/water_631gs_sph 237 KB
- lib/hfref/water_ccpvdz 96 KB
- lib/hfref/water_sto3g 26 KB
- lib/hfref/water_svp 96 KB
- lib/hfref/water_tzvp 251 KB
- lib/ising 24 KB
- lib/linalg 2 KB
- lib/lobpcg 16 KB
- lib/lqr 5 KB
- lib/lyap 11 KB
- lib/minpack/enorm 3 KB
- lib/minpack/fit 6 KB
- lib/minpack/lmder 22 KB
- lib/minpack/lmpar 10 KB
- lib/minpack/mgh 11 KB
- lib/minpack/mgh_check 6 KB
- lib/minpack/mgh_ls 1 KB
- lib/minpack/mgh_ref 567 KB
- lib/minpack/qrfac 6 KB
- lib/minpack/qrsolv 5 KB
- lib/minpack/rosenbrock_figures 15 KB
- lib/minpack/story_osborne1 1 KB
- lib/minpack/story_rosenbrock 1 KB
- lib/nistref 14 KB
- lib/nn 13 KB
- lib/nn_adjoints 5 KB
- lib/nprandom/bits 2 KB
- lib/nprandom/generator 8 KB
- lib/nprandom/legacy 5 KB
- lib/nprandom/mt19937 6 KB
- lib/nprandom/pcg64 5 KB
- lib/nprandom/seedseq 3 KB
- lib/nprandom/selftest 150 KB
- lib/nprandom/ziggurat_tables 17 KB
- lib/nuclear/shell/interactions 4 KB
- lib/nuclear/shell/shell 26 KB
- lib/nuclear/shell/shellmodel 8 KB
- lib/ode/bdf 11 KB
- lib/ode/core 11 KB
- lib/ode/dopri5 8 KB
- lib/ode/gallery_robertson 2 KB
- lib/ode/lu 3 KB
- lib/ode/nonstiff_events 7 KB
- lib/ode/problems 8 KB
- lib/ode/radau 12 KB
- lib/ode/solve 11 KB
- lib/ode/stiff_reference 4 KB
- lib/optim 14 KB
- lib/params 6 KB
- lib/polar 9 KB
- lib/power/api 7 KB
- lib/power/case 4 KB
- lib/power/contingency 18 KB
- lib/power/cpf 11 KB
- lib/power/matpower_ref 5 KB
- lib/power/pf 27 KB
- lib/power/raw 19 KB
- lib/power/shortcircuit 6 KB
- lib/power/splu 13 KB
- lib/power/study 8 KB
- lib/power/ybus 6 KB
- lib/proggraph 4 KB
- lib/qcfuzz 8 KB
- lib/qcref 464 KB
- lib/radial 12 KB
- lib/randla/api 3 KB
- lib/randla/dense 6 KB
- lib/randla/gallery_trace 3 KB
- lib/randla/lowrank 9 KB
- lib/randla/lstsq 6 KB
- lib/randla/philox 5 KB
- lib/randla/repro 2 KB
- lib/randla/sketch 9 KB
- lib/randla/trace 3 KB
- lib/randlc 3 KB
- lib/random 6 KB
- lib/rv32/asm 25 KB
- lib/rv32/bits 3 KB
- lib/rv32/sim 20 KB
- lib/rv32/system 1 KB
- lib/rv32/tests/asm 3 KB
- lib/rv32/tests/riscv/rv32ui_add 5 KB
- lib/rv32/tests/riscv/rv32ui_addi 3 KB
- lib/rv32/tests/riscv/rv32ui_and 4 KB
- lib/rv32/tests/riscv/rv32ui_andi 2 KB
- lib/rv32/tests/riscv/rv32ui_auipc 1 KB
- lib/rv32/tests/riscv/rv32ui_beq 3 KB
- lib/rv32/tests/riscv/rv32ui_bge 3 KB
- lib/rv32/tests/riscv/rv32ui_bgeu 4 KB
- lib/rv32/tests/riscv/rv32ui_blt 3 KB
- lib/rv32/tests/riscv/rv32ui_bltu 3 KB
- lib/rv32/tests/riscv/rv32ui_bne 3 KB
- lib/rv32/tests/riscv/rv32ui_jal 1 KB
- lib/rv32/tests/riscv/rv32ui_jalr 2 KB
- lib/rv32/tests/riscv/rv32ui_lb 3 KB
- lib/rv32/tests/riscv/rv32ui_lbu 3 KB
- lib/rv32/tests/riscv/rv32ui_ld_st 12 KB
- lib/rv32/tests/riscv/rv32ui_lh 3 KB
- lib/rv32/tests/riscv/rv32ui_lhu 3 KB
- lib/rv32/tests/riscv/rv32ui_lui 1 KB
- lib/rv32/tests/riscv/rv32ui_lw 3 KB
- lib/rv32/tests/riscv/rv32ui_or 4 KB
- lib/rv32/tests/riscv/rv32ui_ori 2 KB
- lib/rv32/tests/riscv/rv32ui_sb 4 KB
- lib/rv32/tests/riscv/rv32ui_sh 4 KB
- lib/rv32/tests/riscv/rv32ui_simple 1 KB
- lib/rv32/tests/riscv/rv32ui_sll 5 KB
- lib/rv32/tests/riscv/rv32ui_slli 3 KB
- lib/rv32/tests/riscv/rv32ui_slt 5 KB
- lib/rv32/tests/riscv/rv32ui_slti 3 KB
- lib/rv32/tests/riscv/rv32ui_sltiu 3 KB
- lib/rv32/tests/riscv/rv32ui_sltu 5 KB
- lib/rv32/tests/riscv/rv32ui_sra 6 KB
- lib/rv32/tests/riscv/rv32ui_srai 3 KB
- lib/rv32/tests/riscv/rv32ui_srl 5 KB
- lib/rv32/tests/riscv/rv32ui_srli 3 KB
- lib/rv32/tests/riscv/rv32ui_st_ld 6 KB
- lib/rv32/tests/riscv/rv32ui_sub 5 KB
- lib/rv32/tests/riscv/rv32ui_sw 5 KB
- lib/rv32/tests/riscv/rv32ui_xor 4 KB
- lib/rv32/tests/riscv/rv32ui_xori 2 KB
- lib/rv32/tests/riscv/rv32um_div 2 KB
- lib/rv32/tests/riscv/rv32um_divu 2 KB
- lib/rv32/tests/riscv/rv32um_mul 5 KB
- lib/rv32/tests/riscv/rv32um_mulh 5 KB
- lib/rv32/tests/riscv/rv32um_mulhsu 5 KB
- lib/rv32/tests/riscv/rv32um_mulhu 5 KB
- lib/rv32/tests/riscv/rv32um_rem 2 KB
- lib/rv32/tests/riscv/rv32um_remu 2 KB
- lib/rv32/tests/trace 1 KB
- lib/rv32/trace 2 KB
- lib/scf/loop 4 KB
- lib/scf/mix 8 KB
- lib/schur 24 KB
- lib/skyrme/skyrme 16 KB
- lib/skyrme/skyrmehf 7 KB
- lib/skyrme/spherical 27 KB
- lib/skyrme/story_o16 1 KB
- lib/sparse 3 KB
- lib/stats/api 6 KB
- lib/stats/describe 5 KB
- lib/stats/dist 18 KB
- lib/stats/gallery_glm 2 KB
- lib/stats/gallery_longley 4 KB
- lib/stats/gallery_special 5 KB
- lib/stats/glm 10 KB
- lib/stats/lens/nist_digits 2 KB
- lib/stats/linmod 10 KB
- lib/stats/special 30 KB
- lib/stats/tables 4 KB
- lib/stats 1 KB
- lib/svd 10 KB
- lib/vlasov 12 KB
- lib/xyz 4 KB
- lib/zfunc 5 KB