<jupyter_start><jupyter_text>Hierarchical and low-rank techniquesSome processes are represented by dense matrices that have structured representations.  The most common technique is to approximate blocks using a truncated SVD $U S V^T$.Inverses of differential operators sometimes have this property.<jupyter_code>%matplotlib notebook
import numpy

m = 101
A = numpy.eye(m) - .5*numpy.eye(m,k=1) - .5*numpy.eye(m,k=-1)
#A[-1,-1] = 0.5
Ainv = numpy.linalg.inv(A)

B = Ainv[:m//2,m//2+1:]
U, S, V = numpy.linalg.svd(B)

from matplotlib import pyplot
pyplot.style.use('ggplot')
pyplot.figure()
pyplot.plot(S, '.')
pyplot.figure()
pyplot.plot(V.T[:,0])<jupyter_output><empty_output><jupyter_text>Particle interactionsThe gravitational (or electrostatic) force between particles is proportional to $1/|r|^2$ where $r$ is the distance between them.  The direction of this force is in the direction $r$ with magnitude equal to the product of the masses (or charges).  Let's consider two separated groups of particles.<jupyter_code>m, n = 100, 200
x = numpy.random.randn(m,3)  # first cluster of particle locations
y = numpy.random.randn(n,3)
y[:,0] += 100 # second cluster is translated away

A = numpy.zeros((3*m,n))
for i in range(m):
    r = y.T - numpy.outer(x[i,:], numpy.ones(n))
    A[3*i:3*i+3, :] = r / numpy.linalg.norm(r, axis=0)**3

U, S, V = numpy.linalg.svd(A, full_matrices=False)

pyplot.figure()
pyplot.semilogy(S, '.')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14324880054832076, 'fraction_numerical': 0.023989033584647018, 'mean_word_length': 5.008230452674897, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '286275', 'license': 'MIT', 'n_tokens_mistral': 552, 'n_tokens_neox': 532, 'n_words': 151, 'path': 'Hierarchical.ipynb', 'repo_name': 'cucs-hpla/class', 'size': '1459'}