Computing Atlas

How Computing Was Built
Sign In
Text size
100%
Theme
Algorithm

Barnes-Hut simulation

Numerical Algorithm

The Barnes-Hut simulation, named after Joshua Barnes and Piet Hut, is an approximation algorithm for n-body simulation. A direct sum over every pair of bodies costs on the order of n squared, while this method has order n log n. It divides the simulated volume into cells with an octree, or a quadtree in two dimensions, and stores the total mass and center of mass in each internal node. To find the force on one body, the tree is walked from the root: a cell that is far enough away, judged by the ratio of its width to its distance compared with a threshold theta, is treated as one large particle, and a nearer cell is opened into its children. Larger theta values are faster but less accurate, and theta of zero reduces to the direct sum. It is used in computational astrophysics treecodes.

Facts
Time Complexity
Time Complexity (category)
Linearithmic Time -- O(n log n) 1
Connections

In Field

Source Barnes-Hut simulation (Wikipedia)
Sources
1. Princeton University Computer Science Department: Barnes-Hut Galaxy Simulator (COS 126 programming assignment)
Princeton University Computer Science DepartmentIntroduction
Quote, Introduction
simulate each step in time proportional to N log N
View the Source
Barnes-Hut simulation (Wikipedia)
  • In Group: Modeling and Simulation, Lead
    is an approximation algorithm for performing an n-body simulation
  • In Field: Algorithms and Complexity Theory, Lead
    is an approximation algorithm for performing an n-body simulation
View the Source
Comments (0)
No comments yet. Be the first to share a thought.
Reader Challenges (0)
No disputes yet. Spotted an error or a better source? Open the first one.