David Hoxie David Hoxie

Field lines and Ants Part II

Emergent Field Lines & Heuristic Force Carriers

Module ID: PHYS-ELEC-004
Core Concept: Agent-Based Field Mapping and Localized Momentum Exchange

Collaborative Attribution:
  • Concept & Physics Architecture: David J. Hoxie, PhD
  • Code Rework & Implementation: Gemini

Using an agent-based approach (where genetic algorithms, ant colony optimization, and slime mold pathfinding share a similar mathematical foundation), we can create a dynamic, heuristic model to visualize electric field lines.

While the macroscopic visualization is emergent, the underlying engine is built on rigorous physics. Each "ant" acts as a discrete test charge, calculating its local trajectory based on the exact $1/r^2$ Coulomb force exerted by the source charges in the space. This allows for real-time, interactive investigations into how different charge configurations interact, how equipotential gradients shift, and how field lines behave dynamically over time.

Part 1: The Global Field Map

In our first iteration, we model the test charges as our "ants." They spawn randomly across the entire canvas, evaluate the local electrostatic landscape, and trace a path along the steepest gradient.

Carefully note the trajectories of the test charges. Why is this visualization not exactly the same cohesive field map you calculate on paper in class?

Left-Click: + Charge | Shift+Click: - Charge

The Core Architecture

To achieve this, we do not program continuous lines. We program discrete particle intelligence. Here is the foundational source code for the global field engine, establishing the physics loop and the entropy management (respawning particles to maintain system equilibrium).

// The Physics Loop (The Student Free Body Diagram)
for (let i = particles.length - 1; i >= 0; i--) {
    let pt = particles[i];
    let force = p.createVector(0, 0);
    let hitSource = false;

    // Calculate the net pull from ALL sources on this single test particle
    for (let s of sources) {
        let dir = s.pos.copy().sub(pt.pos); 
        let d = dir.mag();
        
        // If the particle hits a source, it terminates
        if (d < 15) hitSource = true; 
        
        // Prevent infinite division singularities
        if (d < 5) d = 5; 

        // Apply F = k * (q1*q2) / r^2
        let strength = (k * s.charge) / (d * d); 
        dir.normalize();
        dir.mult(strength);
        
        force.add(dir);
    }

    // Apply F=ma (assuming mass = 1)
    pt.vel.add(force);
    pt.vel.limit(5); // Terminal velocity
    pt.pos.add(pt.vel);
    pt.life--;

    // Entropy Management: Respawn dead, out-of-bounds, or absorbed particles
    if (pt.life <= 0 || hitSource || outOfBounds(pt)) {
        particles.splice(i, 1);
        spawnParticle(); // Spawns randomly on the canvas
    }
}

Part 2: Localized Spawning & Temporal Dynamics

One issue with Part 1 is that because we are starting the test charges at completely random coordinates, we cannot readily observe the unbroken continuity of the field lines radiating specifically from the sources.

To fix this, we change the code to localize the test charges. By editing the spawnParticle() function, we change pos = random(x), random(y) to anchor around the sources: pos = source.x + random(offset), source.y + random(offset).

We also add the ability to drag and drop the charges. Now, we can see how movement physically alters the local field lines. As you drag a charge, watch how the directional vectors of the surrounding space update in real-time, illustrating temporal behavior in the fields without explicitly coding a vector potential.

Click & Drag charges to warp the field.

Part 3: The Heuristic Force Carrier

We now have electric field lines changing over time, but we still have an inherent physics problem: we don't have a true mechanism for force. The source charges are anchored in space, interacting via an omniscient, faster-than-light "force at a distance."

Is there a way to communicate the force between the macro-charges without actually calculating their distance from each other?

Let's make a tiny change. We won’t use rigorous classical integration, but rather a heuristic experiment. In our code, when a test charge hits a source charge, it is destroyed. What if, rather than just destroying the test charge, we destroyed it AND applied a tiny change in position to the source charge, effectively transferring momentum in the direction of the collision?

if (d < 15) {
    hitSource = true; 
    // Back-reaction: The test charge imparts its momentum onto the source!
    sources[S].pos.add(dir.mult(-1));
}

Try it. Watch what happens when you place multiple source charges near each other and let the swarm of test charges act as physical mediators of force.

Observe the autonomous movement driven entirely by particle collisions.

Pedagogical Inquiries

Intro-Level Questions:
  • What did we just accomplish physically?
  • Is this a valid model for photons mediating the electromagnetic force? Why or why not?
  • Is there another statistical model this simulation mimics? (Hint: search for Brownian motion).
Upper-Level Undergrad Questions:
  • We are not currently modeling a magnetic field. Do we have to? Consider Poynting vectors, the electroweak force, vector potentials, and gauge transforms.
  • If this model has a relation to Brownian motion, how could this mathematical framework relate to t-SNE, CVAE, and other Helmholtz machines that rely on KL Divergence?
  • What is the strict physical equivalent of KL Divergence in this system?
  • If you watch the charges move, they sometimes repel and sometimes attract. When does this state change happen? (Hint: what is the limit that determines repulsion vs. collapse?)
Graduate-Level Considerations:
  • Why is it that like charges in this specific model may not always fly apart? (Hint: consider exactly when the test charges are generated and destroyed.)
  • What happens to the effective generation rate (density) of the test charges as the macro-sources move closer together or farther apart?
  • Why do the different charges eventually fly completely apart? (Hint: what conservation laws are we explicitly violating in this heuristic code? Consider test charge conservation and energy conservation as particles move off the screen.)

  

<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.0/p5.js"></script>

<div id="emergent-field-container" style="display: flex; justify-content: center; width: 100%; padding: 20px;"></div>

<script>

const emergentFieldSim = (p) => {

let sources = [];

let particles = [];

let numParticles = 1000;

let k = 150; // The Coulomb constant multiplier

p.setup = () => {

let container = document.getElementById('emergent-field-container');

let w = container.offsetWidth > 0 ? container.offsetWidth : 800;

let canvas = p.createCanvas(w, 600);

canvas.parent('emergent-field-container');

‍ ‍

// Start with a standard Dipole setup

sources.push({ pos: p.createVector(p.width * 0.33, p.height / 2), charge: 1 });

sources.push({ pos: p.createVector(p.width * 0.66, p.height / 2), charge: -1 });

// Spawn the initial swarm

for (let i = 0; i < numParticles; i++) {

spawnParticle();

}

};

function spawnParticle() {

particles.push({

pos: p.createVector(p.random(p.width), p.random(p.height)),

vel: p.createVector(0, 0),

life: p.random(100, 300) // Gives them a finite lifespan so the screen doesn't clump

});

}

p.draw = () => {

// The Slime Mold trick: A slightly transparent background creates the visual trails

p.background(15, 23, 42, 20);

// 1. Draw the Source Charges

for (let s of sources) {

p.noStroke();

if (s.charge > 0) {

p.fill(239, 68, 68); // Red (+)

} else {

p.fill(59, 130, 246); // Blue (-)

}

‍ ‍p.circle(s.pos.x, s.pos.y, 25);

}

// 2. The Physics Loop (The Student Free Body Diagram)

for (let i = particles.length - 1; i >= 0; i--) {

let pt = particles[i];

let force = p.createVector(0, 0);

let hitSource = false;

// Calculate the net pull from ALL sources on this single test particle

for (let s of sources) {

// FIX: Use copy() to safely perform vector math in Instance Mode

let dir = s.pos.copy().sub(pt.pos);

let d = dir.mag();

‍ ‍

// If the particle hits a source, it terminates

if (d < 15) hitSource = true;

‍ ‍

// Prevent infinite division singularities

if (d < 5) d = 5;

// F = k (q1q2) / r^2

let strength = (k s.charge) / (d d);

dir.normalize();

dir.mult(strength);

‍ ‍

force.add(dir);

}

// Apply F=ma (assuming mass = 1)

pt.vel.add(force);

pt.vel.limit(5); // Terminal velocity so they don't break the spacetime continuum

pt.pos.add(pt.vel);

‍ ‍pt.life--;

// 3. Draw the Test Particle

p.stroke(148, 163, 184, 150);

p.strokeWeight(2);

p.point(pt.pos.x, pt.pos.y);

// 4. Entropy Management: Respawn dead, out-of-bounds, or absorbed particles

if (pt.life <= 0 || hitSource || pt.pos.x < 0 || pt.pos.x > p.width || pt.pos.y < 0 || pt.pos.y > p.height) {

particles.splice(i, 1);

spawnParticle();

}

}

};

p.mousePressed = () => {

// Only trigger if clicking inside the physical canvas

if (p.mouseX > 0 && p.mouseX < p.width && p.mouseY > 0 && p.mouseY < p.height) {

let chargeType = p.keyIsDown(p.SHIFT) ? -1 : 1;

sources.push({ pos: p.createVector(p.mouseX, p.mouseY), charge: chargeType });

}

};

‍ ‍

p.windowResized = () => {

let container = document.getElementById('emergent-field-container');

if(container.offsetWidth > 0) {

p.resizeCanvas(container.offsetWidth, 600);

sources[0].pos.set(p.width * 0.33, p.height / 2);

sources[1].pos.set(p.width * 0.66, p.height / 2);

}

};

};

new p5(emergentFieldSim);

</script>

Read More
David Hoxie David Hoxie

Field lines and Ants Part II

Emergent Field Lines & Heuristic Force Carriers

Module ID: PHYS-ELEC-004
Core Concept: Agent-Based Field Mapping and Localized Momentum Exchange

Collaborative Attribution:
  • Concept & Physics Architecture: David J. Hoxie, PhD
  • Code Rework & Implementation: Gemini

Using an agent-based approach (where genetic algorithms, ant colony optimization, and slime mold pathfinding share a similar mathematical foundation), we can create a dynamic, heuristic model to visualize electric field lines.

While the macroscopic visualization is emergent, the underlying engine is built on rigorous physics. Each "ant" acts as a discrete test charge, calculating its local trajectory based on the exact $1/r^2$ Coulomb force exerted by the source charges in the space. This allows for real-time, interactive investigations into how different charge configurations interact, how equipotential gradients shift, and how field lines behave dynamically over time.

Part 1: The Global Field Map

In our first iteration, we model the test charges as our "ants." They spawn randomly across the entire canvas, evaluate the local electrostatic landscape, and trace a path along the steepest gradient.

Carefully note the trajectories of the test charges. Why is this visualization not exactly the same cohesive field map you calculate on paper in class?

Left-Click: + Charge | Shift+Click: - Charge

The Core Architecture

To achieve this, we do not program continuous lines. We program discrete particle intelligence. Here is the foundational source code for the global field engine, establishing the physics loop and the entropy management (respawning particles to maintain system equilibrium).

// The Physics Loop (The Student Free Body Diagram)
for (let i = particles.length - 1; i >= 0; i--) {
    let pt = particles[i];
    let force = p.createVector(0, 0);
    let hitSource = false;

    // Calculate the net pull from ALL sources on this single test particle
    for (let s of sources) {
        let dir = s.pos.copy().sub(pt.pos); 
        let d = dir.mag();
        
        // If the particle hits a source, it terminates
        if (d < 15) hitSource = true; 
        
        // Prevent infinite division singularities
        if (d < 5) d = 5; 

        // Apply F = k * (q1*q2) / r^2
        let strength = (k * s.charge) / (d * d); 
        dir.normalize();
        dir.mult(strength);
        
        force.add(dir);
    }

    // Apply F=ma (assuming mass = 1)
    pt.vel.add(force);
    pt.vel.limit(5); // Terminal velocity
    pt.pos.add(pt.vel);
    pt.life--;

    // Entropy Management: Respawn dead, out-of-bounds, or absorbed particles
    if (pt.life <= 0 || hitSource || outOfBounds(pt)) {
        particles.splice(i, 1);
        spawnParticle(); // Spawns randomly on the canvas
    }
}

Part 2: Localized Spawning & Temporal Dynamics

One issue with Part 1 is that because we are starting the test charges at completely random coordinates, we cannot readily observe the unbroken continuity of the field lines radiating specifically from the sources.

To fix this, we change the code to localize the test charges. By editing the spawnParticle() function, we change pos = random(x), random(y) to anchor around the sources: pos = source.x + random(offset), source.y + random(offset).

We also add the ability to drag and drop the charges. Now, we can see how movement physically alters the local field lines. As you drag a charge, watch how the directional vectors of the surrounding space update in real-time, illustrating temporal behavior in the fields without explicitly coding a vector potential.

Click & Drag charges to warp the field.

Part 3: The Heuristic Force Carrier

We now have electric field lines changing over time, but we still have an inherent physics problem: we don't have a true mechanism for force. The source charges are anchored in space, interacting via an omniscient, faster-than-light "force at a distance."

Is there a way to communicate the force between the macro-charges without actually calculating their distance from each other?

Let's make a tiny change. We won’t use rigorous classical integration, but rather a heuristic experiment. In our code, when a test charge hits a source charge, it is destroyed. What if, rather than just destroying the test charge, we destroyed it AND applied a tiny change in position to the source charge, effectively transferring momentum in the direction of the collision?

if (d < 15) {
    hitSource = true; 
    // Back-reaction: The test charge imparts its momentum onto the source!
    sources[S].pos.add(dir.mult(-1));
}

Try it. Watch what happens when you place multiple source charges near each other and let the swarm of test charges act as physical mediators of force.

Observe the autonomous movement driven entirely by particle collisions.

Pedagogical Inquiries

Intro-Level Questions:
  • What did we just accomplish physically?
  • Is this a valid model for photons mediating the electromagnetic force? Why or why not?
  • Is there another statistical model this simulation mimics? (Hint: search for Brownian motion).
Upper-Level Undergrad Questions:
  • We are not currently modeling a magnetic field. Do we have to? Consider Poynting vectors, the electroweak force, vector potentials, and gauge transforms.
  • If this model has a relation to Brownian motion, how could this mathematical framework relate to t-SNE, CVAE, and other Helmholtz machines that rely on KL Divergence?
  • What is the strict physical equivalent of KL Divergence in this system?
  • If you watch the charges move, they sometimes repel and sometimes attract. When does this state change happen? (Hint: what is the limit that determines repulsion vs. collapse?)
Graduate-Level Considerations:
  • Why is it that like charges in this specific model may not always fly apart? (Hint: consider exactly when the test charges are generated and destroyed.)
  • What happens to the effective generation rate (density) of the test charges as the macro-sources move closer together or farther apart?
  • Why do the different charges eventually fly completely apart? (Hint: what conservation laws are we explicitly violating in this heuristic code? Consider test charge conservation and energy conservation as particles move off the screen.)

  

<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.0/p5.js"></script>

<div id="emergent-field-container" style="display: flex; justify-content: center; width: 100%; padding: 20px;"></div>

<script>

const emergentFieldSim = (p) => {

let sources = [];

let particles = [];

let numParticles = 1000;

let k = 150; // The Coulomb constant multiplier

p.setup = () => {

let container = document.getElementById('emergent-field-container');

let w = container.offsetWidth > 0 ? container.offsetWidth : 800;

let canvas = p.createCanvas(w, 600);

canvas.parent('emergent-field-container');

‍ ‍

// Start with a standard Dipole setup

sources.push({ pos: p.createVector(p.width * 0.33, p.height / 2), charge: 1 });

sources.push({ pos: p.createVector(p.width * 0.66, p.height / 2), charge: -1 });

// Spawn the initial swarm

for (let i = 0; i < numParticles; i++) {

spawnParticle();

}

};

function spawnParticle() {

particles.push({

pos: p.createVector(p.random(p.width), p.random(p.height)),

vel: p.createVector(0, 0),

life: p.random(100, 300) // Gives them a finite lifespan so the screen doesn't clump

});

}

p.draw = () => {

// The Slime Mold trick: A slightly transparent background creates the visual trails

p.background(15, 23, 42, 20);

// 1. Draw the Source Charges

for (let s of sources) {

p.noStroke();

if (s.charge > 0) {

p.fill(239, 68, 68); // Red (+)

} else {

p.fill(59, 130, 246); // Blue (-)

}

‍ ‍p.circle(s.pos.x, s.pos.y, 25);

}

// 2. The Physics Loop (The Student Free Body Diagram)

for (let i = particles.length - 1; i >= 0; i--) {

let pt = particles[i];

let force = p.createVector(0, 0);

let hitSource = false;

// Calculate the net pull from ALL sources on this single test particle

for (let s of sources) {

// FIX: Use copy() to safely perform vector math in Instance Mode

let dir = s.pos.copy().sub(pt.pos);

let d = dir.mag();

‍ ‍

// If the particle hits a source, it terminates

if (d < 15) hitSource = true;

‍ ‍

// Prevent infinite division singularities

if (d < 5) d = 5;

// F = k (q1q2) / r^2

let strength = (k s.charge) / (d d);

dir.normalize();

dir.mult(strength);

‍ ‍

force.add(dir);

}

// Apply F=ma (assuming mass = 1)

pt.vel.add(force);

pt.vel.limit(5); // Terminal velocity so they don't break the spacetime continuum

pt.pos.add(pt.vel);

‍ ‍pt.life--;

// 3. Draw the Test Particle

p.stroke(148, 163, 184, 150);

p.strokeWeight(2);

p.point(pt.pos.x, pt.pos.y);

// 4. Entropy Management: Respawn dead, out-of-bounds, or absorbed particles

if (pt.life <= 0 || hitSource || pt.pos.x < 0 || pt.pos.x > p.width || pt.pos.y < 0 || pt.pos.y > p.height) {

particles.splice(i, 1);

spawnParticle();

}

}

};

p.mousePressed = () => {

// Only trigger if clicking inside the physical canvas

if (p.mouseX > 0 && p.mouseX < p.width && p.mouseY > 0 && p.mouseY < p.height) {

let chargeType = p.keyIsDown(p.SHIFT) ? -1 : 1;

sources.push({ pos: p.createVector(p.mouseX, p.mouseY), charge: chargeType });

}

};

‍ ‍

p.windowResized = () => {

let container = document.getElementById('emergent-field-container');

if(container.offsetWidth > 0) {

p.resizeCanvas(container.offsetWidth, 600);

sources[0].pos.set(p.width * 0.33, p.height / 2);

sources[1].pos.set(p.width * 0.66, p.height / 2);

}

};

};

new p5(emergentFieldSim);

</script>

Read More
David Hoxie David Hoxie

Diffraction and Shaders

Brush Settings

Live GLSL Editor

✓ Shader compiled successfully!
Read More
David Hoxie David Hoxie

Electric Fields

Physics & ML Basis Function: The Ant Model

Module ID: PHYS-ELEC-003
Core Concept: Visualizing Vector Fields via Trajectory Integration
Analogous System (The Scalar): An ant dropped onto a hilly landscape in the pitch black. It cannot see the whole mountain; it only knows the local slope right under its feet, and it takes a step in the steepest direction.
Collaborative Attribution:
  • WriteUp Designer: David J. Hoxie, PhD & Gemini
  • WriteUp Author: Gemini
  • WriteUp Reviewer: David J. Hoxie, PhD
  • Code Designer: David J. Hoxie, PhD & Gemini
  • Code Author: Gemini
  • Code Reviewer: David J. Hoxie, PhD

1. The AS-Level (The Heuristic)

  • The Analogy: We often draw "field lines" radiating out from a point charge like spokes on a wheel. But those lines aren't physical ropes. Instead, imagine placing a tiny, blind robotic ant near a central charge. The ant has one rule: measure the push/pull exactly where it is standing, and take one tiny step in that direction. If it keeps doing this, the path it leaves behind is the field line.
  • The Key Takeaway: Field lines are just the recorded history of local, step-by-step decisions made by a test particle.
  • Self-Assessment (Open Question): If we place two identical positive charges near each other, and drop our "ant" exactly halfway between them, where does it go?
Click & Hold: Fire continuous beam of ants.
Shift + Click: Place a random charge (+ or -).
Drag: Move existing charges to warp the field.

2. The BS/MS-Level (The Classical Mechanics)

  • The Mechanics: The "Ant Model" is computationally known as Euler Integration of a vector field. The electric field \(\mathbf{E}\) of a point charge is a continuous vector space defined by Coulomb's Law. Our test particle updates its position \(\mathbf{r}\) iteratively based on the local field vector.
  • The Universality of the Solver: Because Coulomb's Law and Newton's Law of Universal Gravitation share the exact same geometric \(1/r^2\) decay, this exact same mathematical solver handles multiple physical regimes. By adding an initial velocity vector (momentum), the massless "field line tracer" instantly becomes a massive particle navigating a potential well.
  • The Math: The generalized central force field at position \(\mathbf{r}\) from a source at the origin is:
    $$\mathbf{F}(\mathbf{r}) = C \frac{1}{|\mathbf{r}|^2} \mathbf{\hat{r}}$$
    (Where \(C\) represents either \(k_e q_1 q_2\) for electrostatics or \(-G m_1 m_2\) for gravity).

    The computational trajectory updates via a discrete time step \(\Delta t\) using basic kinematics (\(\mathbf{v}_{n+1} = \mathbf{v}_n + \mathbf{a}\Delta t\) and \(\mathbf{r}_{n+1} = \mathbf{r}_n + \mathbf{v}_{n+1}\Delta t\)).
Caption: Utilizing the 1/r² solver to demonstrate stable, elliptical orbits under a simulated gravitational gradient.
Caption: High-velocity test particles exhibiting hyperbolic deflection trajectories as they approach a massive, localized central charge, mirroring the classic gold-foil experiment.
  • Self-Assessment (Open Question): Why do field lines mathematically never cross in a static, conservative vector field?

3. The PhD-Level (The Unshielded Physics / ML Mapping)

The ML Bridge: The Ant Model is fundamentally Gradient Descent. The central source creates a scalar potential field \(V(\mathbf{r})\) (the loss landscape). The force vector is the negative gradient of that potential (\(\mathbf{F} \propto -\nabla V\)).

  • When \(v_0 = 0\) (no momentum), we are computationally executing a first-order optimization algorithm tracing the steepest descent.
  • When \(v_0 > 0\) (momentum added), we see orbital slingshots and Rutherford scattering. This physically proves why the Momentum parameter in ML optimizers (like Adam or SGD with momentum) allows algorithms to conserve kinetic energy, roll through local minima, and escape shallow potential wells.
Physics / ML Bridge:
v₀ = 0 acts as pure Gradient Descent.
v₀ > 0 adds momentum to roll through the landscape.
  • The Foundational Reality: A "field line" is a macroscopic, continuous illusion derived from taking the limit as \(\Delta t \to 0\). In reality, the interaction is mediated by discrete, quantized photon exchanges. The continuous trajectory we see—whether it's an orbiting moon or a deflected electron—is a statistical expectation value of the particle's most probable quantum path.
  • Self-Assessment (Open Question): If we add a frictional "drag" parameter to our scattering simulation (\(\mathbf{a}_{net} = \mathbf{a}_{coulomb} - \gamma \mathbf{v}\)), how does the resulting orbital decay map mathematically to the concept of Learning Rate Decay in a neural network?
Read More
David Hoxie David Hoxie

Pump Probe Simulation

Read More
David Hoxie David Hoxie

Game of Life

Read More
David Hoxie David Hoxie

Diffraction



Basic Instructions: Try clicking below.
ToDo: Chang background color so the applet click region is visible.







Read More
David Hoxie David Hoxie

Gradients: Motion and Learning

It all begins with an idea.

How does a machine actually "learn"? Before we can build complex simulations of planets or analyze thermodynamic systems, we need to understand the fundamental physics of a single guess. 

In this lecture, we'll start from first principles, using the simple, intuitive game of "Hot or Cold" to build a physical model for gradient descent. We'll explore how changing a single parameter—the "learning rate"—can mean the difference between finding a solution and getting stuck in a chaotic loop.

This is the first step in our journey to derive deep learning from the ground up, using the language of physics, not just computer science.

In the next video: We'll take these 1D principles and expand them into a 2D universe, using orbital mechanics to build a creative drawing tool from scratch. 

Eventually we will discuss the physical intuition behind motion, entropy and thermodynamics. Feel free to look ahead, where we discuss more physics explanations of the gradient descent algorithm that provided the basis for providing an ‘energy landscape’ in learning models, in the post “Hooks Law and Perceptrons” This will be the underlying basis for the next lecture.

https://www.djhoxie.net/samplelectures/blog-hooks-law-and-learning


Connect & Support

  • Website: http://www.djhoxie.net

  • Google Scholar: https://scholar.google.com/citations?user=iwsajtAAAAAJ&hl=en

  • Patreon: (Coming Soon!)

  • arXiv Pre-prints: (Coming Soon!)

AI Collaboration Note: This video, its title, description, and the concepts explored within were developed in a deep collaboration with Google Gemini. Gemini's role included acting as a Socratic partner, a reviewer, and a tool for structuring and refining the final presentation.

Acknowledgments: Thank you to Daniel Shiffman (The Coding Train) for providing excellent conceptual starting points for the p5.js demonstrations.

References: 

[1] Imran, Muhammad, and Norah Almusharraf. "Google Gemini as a next generation AI educational tool: a review of emerging educational technology." Smart Learning Environments 11, no. 1 (2024): 22. 

[2] Marquardt, F., and Marquardt, F., 2021, "Machine learning and quantum devices," SciPost Physics Lecture Notes, p. 29. 

[3] Shannon, C. E., 1948, "A mathematical theory of communication," The Bell system technical journal, 27(3), pp. 379-423.

[4] Shiffman, D. (2024). The nature of code: simulating natural systems with javascript. No Starch Press.

[5] Landauer, Rolf. "Information is physical." Physics Today 44, no. 5 (1991): 23-29.


Read More
David Hoxie David Hoxie

Lecture 1: The Foundations of Insight

Video Description: This lecture demonstrates two things simultaneously: core concepts in physics, such as emergent behavior, and a new model for human-AI collaboration in scientific education, as suggested in recent literature [1]. It showcases a process of using an AI partner (Google Gemini) to achieve a deep, intuitive understanding of graduate-level physical concepts. This dynamic serves as a real-time example of a dialogic, collaborative learning model—in this case, a human-AI partnership—focused on generating insight through shared discovery.

Show Notes & Chapter Guide:

Act I: The Philosophical Introduction (00:00 - 27:10)

  • Authenticity and Engagement: The opening establishes a genuine, relatable tone, moving from personal anecdotes to foundational principles.

  • The Dice & Rubber Band Demos: These tactile analogies demonstrate emergent behavior, high-surprisal events, stability, and underlying forces.

  • Observation as Perturbation: A deep, philosophical argument that "no observation without perturbation" is fundamental to science, using analogies from black-body radiation to quantum mechanics.

  • Our Collaborative Intro [25:11 - 26:38]: A live, unscripted demonstration of the human-AI partnership model in action.

Act II: The Core Lesson - p5.js Sketches (27:11 - 42:27)

  • Debugging as Learning: A real-time walkthrough of chaotic vs. ordered flow fields, highlighting the crucial difference between programming intent and emergent behavior.

  • The "Trapped Charges" Analogy: A visually compelling explanation of how particles can collectively influence their own environment.

  • Mathematical Foundations: Connecting the emergent patterns back to the underlying "generative structure" of mathematical basis functions (e.g., Fourier series).

Act III: The Philosophical Conclusion (42:28 - End)

  • Complexity & High-Surprisal: Discussing the limits of analytical solutions (like the three-body problem) and how computational models help build intuition around high-surprisal events.

  • The Value of Foundational Models: Emphasizing that simple, conceptual simulations are crucial tools for learning and debugging, preventing costly errors in more complex research code.

Connect & Support:

  • Website: http://www.djhoxie.net

  • Google Scholar: https://scholar.google.com/citations?user=iwsajtAAAAAJ&hl=en

  • Patreon: (Coming Soon!)

  • arXiv Pre-prints: (Coming Soon!)

AI Collaboration Note: This video, its title, description, and the concepts explored within were developed in a deep collaboration with Google Gemini. Gemini's role included acting as a Socratic partner, a reviewer, and a tool for structuring and refining the final presentation.

Acknowledgments: Thank you to Daniel Shiffman (The Coding Train) for providing excellent conceptual starting points for the p5.js demonstrations.

References:

[1] Imran, Muhammad, and Norah Almusharraf. "Google Gemini as a next generation AI educational tool: a review of emerging educational technology." Smart Learning Environments 11, no. 1 (2024): 22.

[2] Schmidgall, S., Su, Y., Wang, Z., Sun, X., Wu, J., Yu, X., ... & Barsoum, E. (2025). Agent laboratory: Using llm agents as research assistants. arXiv preprint arXiv:2501.04227.

[3] Marquardt, F., and Marquardt, F., 2021, "Machine learning and quantum devices," SciPost Physics Lecture Notes, p. 29.

[4] Hinton, G. E., & Zemel, R. (1993). Autoencoders, minimum description length and Helmholtz free energy. Advances in neural information processing systems, 6.

[5] Shannon, C. E., 1948, "A mathematical theory of communication," The Bell system technical journal, 27(3), pp. 379-423.

[6] Hopfield, J. J. (2007). Hopfield network. Scholarpedia, 2(5), 1977.

[7] Wootters, W. K. (1981). Statistical distance and Hilbert space. Physical Review D, 23(2), 357.

[8] Leshno, M., Lin, V. Y., Pinkus, A., and Schocken, S., 1993, "Multilayer feedforward networks with a nonpolynomial activation function can approximate any function," Neural Networks, 6(6), pp. 861-867.

[9] Konen, W. (2011). Self-configuration from a machine-learning perspective. arXiv preprint arXiv:1105.1951.

[10] Por, E., van Kooten, M., and Sarkovic, V., 2019, "Nyquist–Shannon sampling theorem," Leiden University, 1(1).

[11] Shiffman, D. (2024). The nature of code: simulating natural systems with javascript. No Starch Press.

[12] Landauer, Rolf. "Information is physical." Physics Today 44, no. 5 (1991): 23-29.

Read More
David Hoxie David Hoxie

Using a Private, Local AI as a Physics Research Assistant

It all begins with an idea.

Title: Using a Private, Local AI as a Physics Research Assistant

The Post

Researchers have begun exploring the use of Large Language Models as automated research assistants in many domains {Schmidgall et al., 2025}. Here, we explore a more specific application: utilizing a private, locally-run model as a direct collaborator in the field of optical physics. The debate around AI in research often focuses on public, cloud-based models. But for scientists concerned with intellectual property, privacy, and data control, the real revolution is happening locally. I've been incorporating a private, locally-run Large Language Model into my daily workflow, not as a simple chatbot, but as a true research collaborator. In this video, I'll give you a look inside that process.


A Researcher's Deep Dive: The First-Principles Justification

Modern physics research presents a fundamental conflict. High-precision experiments often demand controlled environments where all sources of noise—electromagnetic, vibrational, and acoustic—must be eliminated. This has historically forced a trade-off between experimental precision and real-time information access. Here, we explore a new solution: utilizing a locally-run, generative AI model on a silent, portable device. With modern MacBooks, iPads, and iPhones now running on the same powerful Apple Silicon platform, it's possible to deploy the same powerful AI model across a researcher's entire ecosystem. This provides access to a saved state of sparsely sampled data from the internet and literature without the physical or electronic noise of a live network connection.

This ability to operate from a "saved state" is made possible by techniques rooted in the physics of information. The principles of entropy and sparse sampling, seen in methods from Shannon [1] to Monte Carlo, have given us profound methods for data compression [2]. Modern machine learning models, particularly regenerative architectures like Transformers, are built on these same principles, such as minimizing Helmholtz free energy [3]. They are capable of learning from a sparsely sampled dataset and then reconstructing vast amounts of information from those compressed patterns.

This public, notebook-style research serves three primary goals. First, it aims to correct the record on common misinterpretations of AI behavior, such as "confabulations" [4]. Second, it is intended to be a learning space for other researchers, providing a transparent look into a process that will eventually translate into STEM education. Finally, we will deliberately explore this model outside of its typical boundary conditions. For a physicist, understanding how a system behaves at its limits is the most fundamental test of its validity, ensuring we are observing true extrapolation, not just memorization [5].

This leads to a crucial insight for the future of collaborative AI. Just as two human experts communicate, they can infer meaning and average out minor errors because they share a vast amount of correlated information. An AI should not be used as an expert source without a similar awareness that its conversational partner has their own knowledge and biases. True AI alignment may therefore require models that can adapt their certainty based on their user's expertise. The AI should know whether it's talking to a student or a professor, enabling it to say, "I'm not sure, this is questionable, let me check my resources"—as any good teacher or research collaborator does.

References

Schmidgall, S., Su, Y., Wang, Z., Sun, X., Wu, J., Yu, X., ... & Barsoum, E. (2025). Agent laboratory: Using llm agents as research assistants. arXiv preprint arXiv:2501.04227.

[1] Shannon, C. E. (1948). A mathematical theory of communication. The Bell System Technical Journal, 27(3), 379–423.

[2] Brunton, S. L., & Kutz, J. N. (2022). Data-driven science and engineering: Machine learning, dynamical systems, and control. Cambridge University Press.

[3] Hinton, G. E., & Zemel, R. (1993). Autoencoders, minimum description length and Helmholtz free energy. Advances in Neural Information Processing Systems, 6.

[4] Moscovitch, M. (1995). Confabulation. In Schacter, D. L. (Ed.), Memory distortion: How minds, brains, and societies reconstruct the past (pp. 226-251). Harvard University Press.

[5] Perdue, G. N., et al. (2018). Reducing model bias in a deep learning classifier using domain adversarial neural networks in the MINERvA experiment. Journal of Instrumentation, 13(11), P11020.

Read More
David Hoxie David Hoxie

Hooks law and perceptrons: How can physical systems learn? 

It all begins with an idea.

PLACE HOLDER

Read More
David Hoxie David Hoxie

Blog Post Title Four

It all begins with an idea.

It all begins with an idea. Maybe you want to launch a business. Maybe you want to turn a hobby into something more. Or maybe you have a creative project to share with the world. Whatever it is, the way you tell your story online can make all the difference.

Don’t worry about sounding professional. Sound like you. There are over 1.5 billion websites out there, but your story is what’s going to separate this one from the rest. If you read the words back and don’t hear your own voice in your head, that’s a good sign you still have more work to do.

Be clear, be confident and don’t overthink it. The beauty of your story is that it’s going to continue to evolve and your site can evolve with it. Your goal should be to make it feel right for right now. Later will take care of itself. It always does.

Read More