<p>I tried running your script exactly as it is and it gives me</p>
<pre><code>a: should be: 12.15 is: 12.153517320591716
</code></pre>
<p>Try clearing your python console and running it again, it should work!</p>

CC BY-SA 4.0
2022-07-07T09:25:20.857Z
Thank you very much
Anna-Kat
CC BY-SA 4.0
2022-07-07T08:14:30.683Z
2022-07-07T08:14:30.683Z
Prallax
<p>I tried this formula for WW Aur:</p>
<p><span class="math-container">$$a(R_\mathrm{nom}) = \sqrt[3]{\frac{P(\mathrm{d})^2}{365.2564^2}[M_1(M_{\mathrm{nom}})+M_2(M_{\mathrm{nom}})]} \cdot \frac{149597870.7}{695700}$$</span></p>
<p>What is wrong, please?</p>
<pre><code># WW Aur test

R_sol_km = 695700
year_day = 365.2564
AU_km = 149597870.7



P = 2.52501941 # d
M1 = 1.964     # M_sol
M2 = 1.814     # M_sol
a = 12.15      # R:sol


print('a: should be:', a, 'is:', (P**2/year_day**2*(M1+M2))**(1/3)*AU_km/R_sol_km)
</code></pre>
<p>Output:</p>
<pre><code>a: should be: 12.15 is: 0.012941299276573308
</code></pre>

CC BY-SA 4.0
2022-07-06T13:19:46.833Z
It's unit conversion.  You're squaring the period in days, but you're not squaring the number of years per day. As a result, the formula you're using is giving an incorrect value.
notovny
CC BY-SA 4.0
2022-07-06T13:47:46.523Z
Thank you very much. And now? Is factor 1000 missing somewhere, please?
Anna-Kat
CC BY-SA 4.0
2022-07-06T14:33:45.360Z
You're probably hitting an Order of operations issue with your exponentiation occurring before the division, so you need to wrap parentheses around `(1/3)`.  I also have no idea why you're multiplying the result by `AU_km/R_sol_km`
notovny
CC BY-SA 4.0
2022-07-06T14:40:48.770Z
The parentheses around 1/3 give the same result. I am sorry, the result should be in solar radius; thus, I am converting the result in au to km and then to solar radius.
Anna-Kat
CC BY-SA 4.0
2022-07-06T14:51:08.683Z
You aren't showing the values you are using for `year_day`, `AU_km`, or `R_sol_km` in your python code snippet. You should indeed get about 12.15 solar radii.
David Hammen
CC BY-SA 4.0
2022-07-06T14:52:14.187Z
@notovny The questioner is trying to express the semi-major axis length of the orbit of the two components of WW Aur about one another in units of solar radii.
David Hammen
CC BY-SA 4.0
2022-07-07T06:16:37.313Z
I added the values to my question. I am sorry.
Anna-Kat
<binary-star>
Binary - semi-major axis computation
Anna-Kat
# Binary - semi-major axis computation

(Asked by: username_0 on 2022-07-06)

I tried this formula for WW Aur:
$$a(R_\mathrm{nom}) = \sqrt[3]{\frac{P(\mathrm{d})^2}{365.2564^2}[M_1(M_{\mathrm{nom}})+M_2(M_{\mathrm{nom}})]} \cdot \frac{149597870.7}{695700}$$
What is wrong, please?
# WW Aur test

R_sol_km = 695700
year_day = 365.2564
AU_km = 149597870.7



P = 2.52501941 # d
M1 = 1.964     # M_sol
M2 = 1.814     # M_sol
a = 12.15      # R:sol


print('a: should be:', a, 'is:', (P**2/year_day**2*(M1+M2))**(1/3)*AU_km/R_sol_km)

Output:
a: should be: 12.15 is: 0.012941299276573308

**Tags:** binary-star
> **Comments:**
> **username_1**: It's unit conversion.  You're squaring the period in days, but you're not squaring the number of years per day. As a result, the formula you're using is giving an incorrect value.  
> **username_0**: Thank you very much. And now? Is factor 1000 missing somewhere, please?  
> **username_1**: You're probably hitting an Order of operations issue with your exponentiation occurring before the division, so you need to wrap parentheses around `(1/3)`.  I also have no idea why you're multiplying the result by `AU_km/R_sol_km`  
> **username_0**: The parentheses around 1/3 give the same result. I am sorry, the result should be in solar radius; thus, I am converting the result in au to km and then to solar radius.  
> **username_2**: You aren't showing the values you are using for `year_day`, `AU_km`, or `R_sol_km` in your python code snippet. You should indeed get about 12.15 solar radii.  
> **username_2**: @notovny The questioner is trying to express the semi-major axis length of the orbit of the two components of WW Aur about one another in units of solar radii.  
> **username_0**: I added the values to my question. I am sorry.  

---

## 1 answers

### Answer by username_3 on 2022-07-07. Score: 2 | Accepted answer

I tried running your script exactly as it is and it gives me
a: should be: 12.15 is: 12.153517320591716

Try clearing your python console and running it again, it should work!

> **Comments:**
> **username_0**: Thank you very much  

---

