benchmarks.wiki / Public workspace

SciCode / 49.1 / Using Newton's law …

Problem

Answer published by the source. Consult the official source to check your work against its answer.

step background

Background Gravity follows an inverse square law for the magnitude of the force bewtween two masses. The gravitional force between acting on the first mass m1m_1 of masses m1m_1 and m2m_2 separated by a vector r\vec{r} of length rr is: F1=Gm1m2r2rr \vec{F_1} = - \frac{G m_1 m_2}{r^2} \frac{\vec{r}}{r} where $G = 6.67430\times10^{−11} N m^2/kg^2$ is the gravitational constant, rr\frac{\vec{r}}{r} is the unit vector pointing from mass m1m_1 to mass m2m_2.
Plain-text mathematical notation (without MathML)
Background
Gravity follows an inverse square law for the magnitude of the force bewtween two masses. The gravitional force between acting on the first mass m₁ of masses m₁ and m₂ separated by a vector (r)→ of length r is:

(F₁)→=−(Gm₁m₂)/(r²)((r)→)/(r)

where $G = 6.67430\times10^{−11} N m^2/kg^2$ is the gravitational constant, ((r)→)/(r) is the unit vector pointing from mass m₁ to mass m₂.
Original LaTeX notation
Background
Gravity follows an inverse square law for the magnitude of the force bewtween two masses. The gravitional force between acting on the first mass $m_1$ of masses $m_1$ and $m_2$ separated by a vector $\vec{r}$ of length $r$ is:

$$
\vec{F_1} = - \frac{G m_1 m_2}{r^2} \frac{\vec{r}}{r}
$$

where $G = 6.67430\times10^{−11} N m^2/kg^2$ is the gravitational constant, $\frac{\vec{r}}{r}$ is the unit vector pointing from mass $m_1$ to mass $m_2$.

step description prompt

Using Newton's law Fi,j=Gmimjrjri|rirj|3F_{i,j} = -G m_i m_j \frac{\vec{r}_j - \vec{r}_i }{|\vec{r}_i - \vec{r}_j|^3} of gravitational attraction between two bodies ii and jj of masses mim_i and mjm_j at location ri\vec{r}_i and rj\vec{r}_j, write a function that computes the forces acting on each particle. $G = 6.67430\times10^{−11} N m^2/kg^2$ is the gravitational constant. The function shall take as input the current location of the particles as a 1D array xin of size $3*N$ for NN particles. The output is the 1D array of forces acting on each particles also as a $3*N$ length array.
Plain-text mathematical notation (without MathML)
Using Newton's law F_(i,j)=−Gm_(i)m_(j)((r)→_(j)−(r)→_(i))/(|(r)→_(i)−(r)→_(j)|³) of gravitational attraction between two bodies i and j of masses m_(i) and m_(j) at location (r)→_(i) and (r)→_(j), write a function that computes the forces acting on each particle. $G = 6.67430\times10^{−11} N m^2/kg^2$ is the gravitational constant. The function shall take as input the current location of the particles as a 1D array xin of size $3*N$ for N particles. The output is the 1D array of forces acting on each particles also as a $3*N$ length array.
Original LaTeX notation
Using Newton's law $F_{i,j} = -G m_i m_j \frac{\vec{r}_j - \vec{r}_i }{|\vec{r}_i - \vec{r}_j|^3}$ of gravitational attraction between two bodies $i$ and $j$ of masses $m_i$ and $m_j$ at location $\vec{r}_i$ and $\vec{r}_j$, write a function that computes the forces acting on each particle. $G = 6.67430\times10^{−11} N m^2/kg^2$ is the gravitational constant. The function shall take as input the current location of the particles as a 1D array xin of size $3*N$ for $N$ particles. The output is the 1D array of forces acting on each particles also as a $3*N$ length array.

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import