Is there a general solution for the integral that gives the force of gravity created by a 2-Dimensional body defined by a sum of cosines?

46 Views Asked by At

I'm trying to solve the integral which would provide the force of gravity in a 2-Dimensional universe on an object being influenced by a body with uniform density who's perimeter is defined by function $f(\theta)$. Where $f(\theta) = \sum_{n=0}^N c_ncos(s_n\theta + o_n) $, $\{c_n,o_n\in \Bbb{R}| c_n,o_n >= 0\}$, and $s_n\in \mathbb{N}\cup\{0\}$.

If this can be solved, I feel it would be a fast way to compute the gravity field created by shapes defined by signed distance functions. It could be used for a simple, but scalable 2D gravity simulation. It is trivial to derive/integrate $f(\theta)$, so any answer that has a derivative or integral $f(\theta)$ without an infinite series would be a sufficient solution.

The integral

$$\int_{0}^{2\pi}\frac{2if(\theta)f'(\theta)}{\boldsymbol {x}} ln \left(\boldsymbol {x} - \frac{f(\theta)}{\boldsymbol {x}}e^{i\theta}\right)d\theta$$ Where $\boldsymbol {x}$ is the distance to the gravitational body and is of the form $a + ib$.
And because $f(\theta) = \sum_{n=0}^N c_ncos(s_n\theta + o_n)$, it follows $f'(\theta) = \sum_{n=0}^N -s_nc_nsin(s_n\theta + o_n)$.

How I got to this integral

This post in the physics stack exchange gave that the gravitational potential in a 2D universe can be defined as $\frac {-2GMm \hat{x}}{x} $. Combining this with the information on this forum post and the Wikipedia page for gravitational potential, I was able to derive the function $\boldsymbol V$ for the Gravitational potential of a given body $A$. The Gravitational potential at position $\boldsymbol x$ is relative to a "zero" potential reference point at position $Z$.

$$ \boldsymbol {V}(\boldsymbol {x}) = -2G\iint_{A} ln(\boldsymbol x - x - iy) - ln(Z) dA $$

Because the gravitational force is the gradient of gravitational potential, I think the force of gravity $\boldsymbol F$ can be given by the following.

$$ \boldsymbol {F}(\boldsymbol {x}) = -2G\frac{d}{d\boldsymbol{x}}\iint_{A} ln(\boldsymbol x - x - iy) - ln(Z) dA = -2G \iint_{A} \frac{\partial}{\partial\boldsymbol x} ln(\boldsymbol x - x - iy) - ln(Z) dA = -2G \iint_{A} \frac{dA}{\boldsymbol x - x - iy} $$

I then switch from Cartesian coordinates to Polar and put the appropriate values into the limits of the integral.

$$\begin{aligned} \boldsymbol {F}(\boldsymbol {x}) &= -2G\int_{0}^{2\pi}\int_{0}^{f(\theta)}\frac{r}{\boldsymbol x - rcos(\theta) - irsin(\theta)}dr\,d\theta \\ &=-2G\int_{0}^{2\pi}\int_{0}^{f(\theta)}\frac{e^{-i\theta}re^{i\theta} + xe^{i\theta} - xe^{i\theta}}{\boldsymbol x - re^{i\theta}} dr\,d\theta \\ &= -2G\int_{0}^{2\pi}\int_{0}^{f(\theta)}\frac{-e^{-i\theta}(\boldsymbol x - re^{i\theta}) - \boldsymbol x e^-{i\theta} }{\boldsymbol x - re^{i\theta}} dr\,d\theta \\ &= -2G\int_{0}^{2\pi}\int_{0}^{f(\theta)}-e^{-i\theta} + \frac{\boldsymbol x e^{-2i\theta}e^{i\theta}}{\boldsymbol x - re^{i\theta}} dr\,d\theta \\ &= \left. -2G\int_{0}^{2\pi} \right|_{r=0}^{f(\theta)} -re^{-i\theta} - \boldsymbol x e^{-2i\theta} ln \left(\boldsymbol x - re^{i\theta} \right) d\theta \\ &= -2G\int_{0}^{2\pi} -f(\theta)e^{-i\theta} - \boldsymbol x e^{-2i\theta}ln \left(\boldsymbol x - f(\theta)e^{i\theta} \right) + \boldsymbol x e^{-2i\theta}ln \left(\boldsymbol x \right) d\theta \\ &= 2G\int_{0}^{2\pi} f(\theta)e^{-i\theta} + \boldsymbol x e^{-2i\theta}ln \left( 1 - \frac{f(\theta)e^{i\theta}}{\boldsymbol x} \right) d\theta \end{aligned}$$

Using the identity of $ ln(1-x) = -\sum_{n=1}^{\infty}\frac{x^{n}}{n} $, I change the integral to the following.

$$\begin{aligned} F(\boldsymbol x) &= G\int_0^{f\theta} 2f(\theta)e^{-i\theta} -2 \boldsymbol x e^{-2i\theta}\sum_{n=1}^{\infty}\frac{f(\theta)^ne^{ni\theta}}{nx^n} d\theta \\ &= G\int_0^{f\theta} 2f(\theta)e^{-i\theta} - 2f(\theta)e^{-i\theta} -2 \frac{f(\theta)^2}{2 \boldsymbol x} -2 \frac{f(\theta)^3e^{i\theta}}{3\boldsymbol x^2} -2 \frac{f(\theta)^4e^{2i\theta}}{4\boldsymbol x^3} ... d\theta \end{aligned}$$ Using integration by parts, I end up at the integral in question.

$$ \begin{equation} \left. G\sum_{n=0}^{\infty} \frac{2f(\theta)^{n+2} \,i\, e^{ n i \theta}}{(n+2)(n) \boldsymbol x^{n+1}} \right|_{\theta=0}^{2pi}\end{equation}\tag{1} $$

$$ -G\int_{0}^{2\pi} \frac{f(\theta)^2}{\boldsymbol x} + \frac{2\,i\,f'(\theta)f(\theta)}{x}\sum_{n=1}^{\infty}\frac{f(\theta)^{n}e^{ni\theta}}{n \boldsymbol x^n}d\theta = -G\int_{0}^{2\pi}\frac{f(\theta)^2}{\boldsymbol x} d\theta\; + G\int_{0}^{2\pi}\frac{2if(\theta)f'(\theta)}{\boldsymbol {x}} ln \left(1 - \frac{f(\theta)}{\boldsymbol {x}}e^{i\theta}\right)d\theta $$

Because (1) is periodic with a period of 2pi, it will evaluate to zero.
I like this final form of the integral because if the derivative of $f(\theta)$ is zero (like with circles), then the gravitational force is just two times the mass of the shape divided by the distance. I am not 100% sure this is the correct representation of the gravitational force in a 2d universe, but it produces values that are close to what I would expect for a given shape and distance.


Examples

Below are some examples of shapes and distances that would be similar to what would be used in the simulation. For all examples, I've set $G = 1$. All of the graphs were made in Desmos and WolframAlpha was used to solve the integrals. This Desmos graph provides all of the values for the examples below.

1 - $ f(\theta) = 2 \;|\; \boldsymbol x = 3 + 3i $

This uniform circle gives a force of -4.18879 in the x direction and -4.18879 in the y direction. When I derived by $\boldsymbol x$, it would have made the force in the y direction negative when compared to what WolframAlpha gives in the i value due to an extra $i$ being multiplied to the result.

2 - $ f(\theta) = 2 + \frac{1}{2}cos(\theta +\frac{7\pi}{4}) \;|\; \boldsymbol x = -2 + 3i $

This slight modification to a simple circular body provides a different center of mass and WolframAlpha provides a force of -6.09171 for the x direction and -5.34478 for the y direction.

3 - $ f(\theta) = 1 + \frac{1}{16}cos(4\theta + \pi) \;|\; \boldsymbol x = -0.5 - i $

This soft square gives a force of 2.33496 in the x direction and 5.1778 in the y direction. WolframAlpha Result for the soft square.


Any help would be appreciated! I've thought about this problem a lot recently and I have completely run out of ideas in how to solve this. Most solutions and approximations I have found so far result in solving the integral of a product of cosines which is an NP-complete problem. I'm not quite at a grad level for Mathematics, but I am willing to learn more advanced concepts for this problem if it is technically solvable!