<p>To fix the bug, maybe try something like this</p>

<p>Assume you have managed to calculate <span class="math-container">$\sin(f)$</span> and <span class="math-container">$\cos(f)$</span> of the true anomaly <span class="math-container">$f$</span>. Then the true anomaly can be expressed in code as <span class="math-container">$$f = (\sin(f) &gt; = 0)\arccos\big(\cos(f)\big)\, + \, 
(\sin(f) &lt; 0) \Big(\, 360^{\circ} - \arccos\big(\cos(f)\big)\,\Big)$$</span> In this expression the logical operation <span class="math-container">$(\sin(f) &gt; = 0)$</span> produces as output either <span class="math-container">$1$</span> or <span class="math-container">$0$</span> and so does <span class="math-container">$(\sin(f) &lt; 0)$</span>. Also make sure the your <span class="math-container">$\arccos$</span> function produces output in degrees and not radians, because that's what <span class="math-container">$\arccos$</span> does mathematically. If it produces radians, then multiply the output by <span class="math-container">$\frac{180^{\circ}}{\pi}$</span> i.e. 
 <span class="math-container">$$f = (\sin(f) &gt; = 0)\frac{180^{\circ}}{\pi}\,\arccos\big(\cos(f)\big)\, + \, 
(\sin(f) &lt; 0) \Big(\, 360^{\circ} - \frac{180^{\circ}}{\pi}\,\arccos\big(\cos(f)\big)\,\Big)$$</span></p>

CC BY-SA 4.0
2019-01-03T18:46:58.627Z
2019-01-03T18:46:58.627Z
Futurologist
<p>I've found an almanac for Earth perihelion up to the year 2100. 2019 perihelion occurred at roughly 5:00 January 3, 2019. Thus the angle now of true anomaly is some extent past 0 degrees. And Wolfram Alpha is wrong by negative 180 degrees. By Wikipedia and other standard definitions of mean anomaly which have persisted since Kepler's time.</p>

CC BY-SA 4.0
2019-01-03T15:18:31.177Z
2019-01-05T01:32:20.350Z
2019-01-05T01:32:20.350Z
marshal craft
<p>I wrote software which uses GMT real time to calculate Earth's mean, eccentric, and true anomaly. I encountered a bug where after reaching 360 degrees, instead of flipping back to zero, it subtracts from 360.</p>

<p>So I checked Wolfram Alpha with search for Earth's true anomaly, just to see if we had passed through 0 degrees triggering the bug. As of a few days ago Wolfram and I were in agreement, approaching 360 degrees. But now Wolfram reads 179 degrees approx. I remember passing 180 in July or August.</p>

<p>So it appears Wolfram is also experiencing an error. To double check, true anomaly is the angle between Earth and perihelion side of major axis. We know Earth reaches its closest point to the Sun in the northern hemisphere winter, January roughly. And aphelion in summer months.</p>

<p>Additionally the j2000 epoch I uses 358 degrees roughly, putting the perihelion or closest approach right around early january roughly. </p>

<p>Thus I can only conclude Wolfram is in error as well?</p>

CC BY-SA 4.0
2019-01-03T15:44:18.290Z
Cross-posted at physics.SE: https://physics.stackexchange.com/questions/451856/what-is-earths-current-true-anomaly-from-j2000#451888
David Hammen
CC BY-SA 4.0
2019-01-03T15:46:26.047Z
I'm voting to close this question as off-topic because the same question was asked earlier on physics.stackexchange.com .
David Hammen
CC BY-SA 4.0
2019-01-03T15:51:16.103Z
Seems interdiscipline. I had suggestion already to move here. It has received positive vote here, I think would be better to have closed on physics, myself, if in fact either should really be closed.
marshal craft
CC BY-SA 4.0
2019-01-03T15:55:19.190Z
It seems physicist and astronomer use true anomaly for different purpose, say understanding gravity, or viewing a nebula. Perhaps one uses reference to aphelion and one to perhelion? I think it isn't completely unreasonable to have two questions.
marshal craft
CC BY-SA 4.0
2019-01-03T21:50:32.920Z
@DavidHammen while cross-posting on SE is certainly discouraged, it's neither forbidden, nor is it a valid reason for closure. The question is about celestial mechanics, which is without doubt **on-topic** on our site. I'm therefore voting to leave this question open.
Chappo Hasn't Forgotten
<orbit><earth>
Is Earth's true anomaly roughly 1 degree currently?
marshal craft
# Is Earth's true anomaly roughly 1 degree currently?

(Asked by: username_0 on 2019-01-03)

I wrote software which uses GMT real time to calculate Earth's mean, eccentric, and true anomaly. I encountered a bug where after reaching 360 degrees, instead of flipping back to zero, it subtracts from 360.

So I checked Wolfram Alpha with search for Earth's true anomaly, just to see if we had passed through 0 degrees triggering the bug. As of a few days ago Wolfram and I were in agreement, approaching 360 degrees. But now Wolfram reads 179 degrees approx. I remember passing 180 in July or August.

So it appears Wolfram is also experiencing an error. To double check, true anomaly is the angle between Earth and perihelion side of major axis. We know Earth reaches its closest point to the Sun in the northern hemisphere winter, January roughly. And aphelion in summer months.

Additionally the j2000 epoch I uses 358 degrees roughly, putting the perihelion or closest approach right around early january roughly.

Thus I can only conclude Wolfram is in error as well?

**Tags:** orbit, earth
> **Comments:**
> **username_1**: Cross-posted at physics.SE: https://physics.stackexchange.com/questions/451856/what-is-earths-current-true-anomaly-from-j2000#451888  
> **username_1**: I'm voting to close this question as off-topic because the same question was asked earlier on physics.stackexchange.com .  
> **username_0**: Seems interdiscipline. I had suggestion already to move here. It has received positive vote here, I think would be better to have closed on physics, myself, if in fact either should really be closed.  
> **username_0**: It seems physicist and astronomer use true anomaly for different purpose, say understanding gravity, or viewing a nebula. Perhaps one uses reference to aphelion and one to perhelion? I think it isn't completely unreasonable to have two questions.  
> **username_2**: @DavidHammen while cross-posting on SE is certainly discouraged, it's neither forbidden, nor is it a valid reason for closure. The question is about celestial mechanics, which is without doubt **on-topic** on our site. I'm therefore voting to leave this question open.  

---

## 2 answers

### Answer by username_3 on 2019-01-03. Score: 1

To fix the bug, maybe try something like this

Assume you have managed to calculate $\sin(f)$ and $\cos(f)$ of the true anomaly $f$. Then the true anomaly can be expressed in code as $$f = (\sin(f) > = 0)\arccos\big(\cos(f)\big)\, + \,
(\sin(f) < 0) \Big(\, 360^{\circ} - \arccos\big(\cos(f)\big)\,\Big)$$ In this expression the logical operation $(\sin(f) > = 0)$ produces as output either $1$ or $0$ and so does $(\sin(f) < 0)$. Also make sure the your $\arccos$ function produces output in degrees and not radians, because that's what $\arccos$ does mathematically. If it produces radians, then multiply the output by $\frac{180^{\circ}}{\pi}$ i.e.
$$f = (\sin(f) > = 0)\frac{180^{\circ}}{\pi}\,\arccos\big(\cos(f)\big)\, + \,
(\sin(f) < 0) \Big(\, 360^{\circ} - \frac{180^{\circ}}{\pi}\,\arccos\big(\cos(f)\big)\,\Big)$$


---

### Answer by username_0 on 2019-01-03. Score: 1

I've found an almanac for Earth perihelion up to the year 2100. 2019 perihelion occurred at roughly 5:00 January 3, 2019. Thus the angle now of true anomaly is some extent past 0 degrees. And Wolfram Alpha is wrong by negative 180 degrees. By Wikipedia and other standard definitions of mean anomaly which have persisted since Kepler's time.


---

