<p>For the first hour and the last 75 minutes, it appears you neglected to take into account the <strong>direction</strong> of the Sun. As shown on this first image, <a href="https://i.sstatic.net/IGHmC.jpg" rel="noreferrer"><img src="https://i.sstatic.net/IGHmC.jpg" alt="enter image description here" /></a> you are measuring the Sun as if it were along the black line stemming out of the top point; this will give a Sun at the intersection of the two black lines, which is about 12473.79 km away from the bottom point, indeed. But the Sun is then not in the direction of the black line, but in the direction of the red line. As you can see, it is very nearly parallel to the black line from the bottom point at that moment.</p>
<p>For the “middle” part of your experiment, let’s say from 5:30 to 9:15, there must be something wrong in your coding or formulas, as the following graphic, simulating the situation, shows the direction of the Sun from one location is parallel to the direction of the Sun from the other location. (Click on image to enlarge it.)
<a href="https://i.sstatic.net/MCkE0.jpg" rel="noreferrer"><img src="https://i.sstatic.net/MCkE0.jpg" alt="enter image description here" /></a></p>
<p>In both drawings, the dashed grey lines are the local horizons.</p>

CC BY-SA 4.0
2024-03-17T09:55:09.763Z
Thank you very much for your great answer. Yes indeed, for the first six and last six timestamps, I have not taken the suns direction into account, thank you for bringing this to my attention, I will write an edit to my post later. I've also fixed the links in my answer. Regarding the "middle part", what value did you use for the surface-distance between points A,B? I see that a slight variation in $d,\alpha$ and/or $\beta$ can significantly change the distance $|CS|$. Do you know where I can get more accurate numbers on these? ($r,d,\alpha,\beta$)
Parseval
CC BY-SA 4.0
2024-03-17T09:58:20.823Z
When it comes to "error in your coding or formulas" - I have not been able to find it. That was my first thought as well: "Oh I've must have made a calculation or coding error". My hope was that someone here can spot the mistake, or verify there is none. If there is none, then there has to be another explanation for the $\approx 450 000 km$ vs the $\approx 150 000000 km$ discrepancy. Btw, what tool did you use to draw that last figure?
Parseval
CC BY-SA 4.0
2024-03-17T10:09:20.510Z
@Parseval: The angle between A and B in both of my figures is (102-38) = 64°, from the values you give. I used Adobe Illustrator.
Pierre Paquette
CC BY-SA 4.0
2024-03-16T21:37:56.380Z
2024-03-16T21:37:56.380Z
Pierre Paquette
<p>This is an interesting experiment / project, and props for your significant effort toward executing it!</p>
<p>The gist of your approach is trying to work out the distance using the solar altitude measured at two different longitudes on the equator.  You did it for several different timestamps experimentally.</p>
<p><strong>TL;DR you didn't exactly make any mistakes, but you made several problematic approximations that resulted in your formula breaking down.  Moreover, the imprecision of the data you were working with, as well as approximation <em>in the calculator</em> made your attempt doomed anyway.  However, a real-world test might be barely possible.</strong></p>
<hr />
<h2>Data</h2>
<p>To start our analysis, let's take the center of your time series at 2023-03-20 07:30 UTC.  The equinox was at 21:24 UTC on that date, nowhere in your time series, a source of error which we'll return to later.</p>
<p>For 07:30 UTC, the site tells me that the altitude (&quot;the angle between horizon and the center of the Sun including refraction&quot;) for the locations chosen was:</p>
<ul>
<li>Kenya <a href="https://suncalc.org/#/0,38,7/2023.03.20/10:30/745/2" rel="noreferrer">0°N, 38°E</a> at 10:30 UTC+3 (07:30 UTC): 58.61° alt, 90.44° azi</li>
<li>Sumatra <a href="https://suncalc.org/#/0,102,7/2023.03.20/14:30/12/2" rel="noreferrer">0°N, 102°E</a> at 14:30 UTC+7 (07:30 UTC): 57.41° alt, 269.58° azi</li>
</ul>
<p>These figures agree with the numbers you collected.  One notices that the azimuths differ by about 180°.  This is because 07:30 UTC was 10:30 local time in Kenya (i.e. in the morning), but 14:30 local time in Sumatra, i.e. in the afternoon.  The altitudes are thus measured from opposite horizons.  Note it's almost a degree off from 180° apart because we're not using the right time of day for the equinox; that discrepancy makes your trig inaccurate.</p>
<p>Your formula / code assumes the azimuths are opposed (the intermediate <code>AS</code>, can be (nonsensically) negative otherwise.), and that assumption breaking seems to be the source of the jumps in your graph, as discussed somewhat and diagrammed in the <a href="https://astronomy.stackexchange.com/a/57170/">other answer</a>.  In the middle, we're fine, though.</p>
<hr />
<h2>Your Math and Code</h2>
<p>I checked your derivation of the distance and didn't see an error as written.  I feel like there's probably a simpler way, but your formula seems correct and the derivation very nice, so we'll go with it.</p>
<p>As for your code, you have <code>r</code> 6371 km, which is <a href="https://en.wikipedia.org/wiki/Earth_radius" rel="noreferrer">an average</a>.  The Earth is an ellipsoid, and since we're on the equator, it would be better and just as easy to instead use the equatorial radius of 6378.1370 km.</p>
<p>I don't know where you got the distance <span class="math-container">$d$</span> (var. <code>AB</code>), which you have listed as 7022 km.  That's about 100 km too small (regardless of the radius used).  The two points are separated by 102°-38°=64° of longitude, which is 64/360≈17.78% of the way around the equator, whose radius we now know precisely.  A precise calculation gives 7124.447 km, corroborated <a href="https://www.calculator.net/distance-calculator.html?la1=0&amp;lo1=38&amp;la2=0&amp;lo2=102&amp;lad1=38&amp;lam1=53&amp;las1=51.36&amp;lau1=n&amp;lod1=77&amp;lom1=2&amp;los1=11.76&amp;lou1=w&amp;lad2=39&amp;lam2=56&amp;las2=58.56&amp;lau2=n&amp;lod2=75&amp;lom2=9&amp;los2=1.08&amp;lou2=w&amp;type=3&amp;ctype=dec&amp;x=Calculate#latlog" rel="noreferrer">here</a> to the five places given.</p>
<p>This might seem like a small thing, but it's a major source of error, since the relatively small size of the Earth gets massively multiplied to get the AU, and so any error does too.  Just to give a flavor, using your code, I indeed get a result of 466,165.98 km, but with the more correct r=6378.1370, AB=7124.447, I get 19,362,488.85 km, which is still wrong, but 40 times bigger (in the correct direction, it happens).</p>
<hr />
<h2>Thinking About Error</h2>
<p>Digging into the error some more, we can start to see that this is really ill-posed.  The locations are separated by 64° of longitude, as above.  If the Sun were infinitely far away, its rays would be parallel and a 58.61° altitude in Kenya would mean a 57.39° altitude in Sumatra (from the opposite horizon).  However, the calculator says we measure 57.41° altitude.</p>
<p>The discrepancy is 0.02°. That's also the unit in last place, so we've only got precision to the nearest 0.005°, which is . . . 25% of the value itself!</p>
<p>It's much, <em>much</em> worse than that, though.  We didn't use the exact equinox, which means the Sun was not exactly on the Earth's orbital plane and we did not account for refraction at all.  A big part of your inaccuracy seems to be with the refraction; when you don't account for it, you can compute a negative φ, which will of course give bogus results.</p>
<hr />
<h2>Improving the Result</h2>
<p>Let's try to do a bit better.</p>
<p>First, all the data is coming from a calculator, so in principle we should be able to get a very accurate answer. In the following, I'll be using <a href="https://gml.noaa.gov/grad/solcalc/" rel="noreferrer">NOAA's calculator</a>.  While both calculators round their outputs and in SunCalc's case there is uncertainty in what formulae they use for refraction, SunCalc's code is minified and so is difficult to reverse-engineer, whereas NOAA's is human-readable.  It will turn out that we need to use the high-precision internals of the calculator to understand what's going on.</p>
<p>To drive the error down, we want to compute at the exact equinox, which unfortunately does not seem to be distributed to higher precision than the minute. We also want to select points that are far apart, but not so far apart that the Sun is low in the sky and refraction changes a lot (though we absolutely still compensate for it).</p>
<p>At the correct equinox of 2023-03-20 21:24 UTC, the Sun was below the horizon in both locations (it was mostly over the Pacific Ocean). To keep with the spirit of an experiment you could do on land, let's choose a different equinox.  I greatly prefer the season of Autumn, and the Autumnal Equinox of that year (2023-09-23 06:50) will do nicely, with the entire equator from Africa through Indonesia being suitable.  I'll pick points a bit farther apart:</p>
<ul>
<li>Gabon <a href="https://suncalc.org/#/0,10,7/2023.09.23/07:50/33/2" rel="noreferrer">0°N, 10°E</a> at 07:50 UTC+1 (06:50 UTC): 24.40° (24.396⋯°) alt, 90.00° azi</li>
<li>Indonesia <a href="https://suncalc.org/#/0,120,7/2023.09.23/14:50/515/2" rel="noreferrer">0°N, 120°E</a> at 14:50 UTC+8 (06:50 UTC): 45.66°  (45.655⋯°) alt, 270.00° azi</li>
</ul>
<p>Note that, because we're at the moment of the equinox, the azimuths are now parallel to the equator and separated by 180.00°, as we expect.</p>
<p>The parenthesized numbers are the first digits of the actual elevations the NOAA calculator is using extracted from the JavaScript debugger (their full values are 24.396176229009612° and 45.65502300416843°, respectively), while the unparenthesized numbers are the rounded values it displays.</p>
<p>The distance between the two longitudes is 120°-10°=110°, which is 110°/360°≈30.56% of the way around the Earth.</p>
<p>Using NOAA's formula for refraction <a href="https://gml.noaa.gov/grad/solcalc/calcdetails.html" rel="noreferrer">here</a> (see also their main.js:330) and inverting the 5°–85° band both zeniths fall into numerically, we get 24.361⋯° and 45.639⋯°.  Though small, this difference is significant; it changes the difference between the elevations by almost 0.02°, which as we saw above is as big as the entire discrepancy we're trying to measure!</p>
<pre><code>import math
import scipy

def refract_adjust_5to85deg( true_elev_deg ):
    #https://gml.noaa.gov/grad/solcalc/calcdetails.html
    T = math.tan( math.radians(true_elev_deg) )
    adjust_deg = (1.0/3600.0)*(
        58.1/T - 0.07/(T*T*T) + 0.000086/(T*T*T*T*T)
    )
    return true_elev_deg + adjust_deg
def refract_unadjust( apparent_elev_deg ):
    true_elev_deg = scipy.optimize.fsolve(
        lambda true_elev_deg:
            refract_adjust_5to85deg(true_elev_deg[0]) - apparent_elev_deg,
        apparent_elev_deg
    )[0]
    return true_elev_deg

alpha_deg = refract_unadjust(24.396176229009612)
beta_deg  = refract_unadjust(45.65502300416843 )
print(f&quot;True α={alpha_deg:.5}°, β={beta_deg:.5}°&quot;)
</code></pre>
<hr />
<h2>A High-Precision Revelation</h2>
<p>When we compute the formula, we get a large number, and checking why, we see that it's because φ is computed as 9.5716e-10° which, for the numerics we're using, is within the error of actual, literal 0.0.  This tells us the problem: the <em>calculators are not accounting for the solar distance</em>, and we've just reconstructed their parallel-rays approximation!  In fact, you can actually see this: NOAA does calculate the Sun distance (main.js:286), but it's pointless because that variable is <em>never used again</em>.  For the two decimals of precision they needed, they decided not to bother (I guess they planned to initially, but changed their mind and forgot to remove that line).  I don't know whether SunCalc shares this flaw, but I'd bet it does.</p>
<p>The implication is your calculation was always doomed to fail; the data you were working from simply did not include the effect you were trying to extract from it!</p>
<hr />
<h2>Getting a Real Answer</h2>
<p>It seems that we can't currently demonstrate your approach from these calculators' data, but we can calculate what would kind of precision would be required.</p>
<p>Say the Sun is 1 au away and on some equinox we're considering two points that (to simplify things) are spaced the same longitude before and after the Sun at that instant—say one is 60° ahead and the other is 60° behind.  The distance <span class="math-container">$\ell$</span> from each observatory to the Sun is given by law of cosines, and is related to the vertex angle at the Sun <span class="math-container">$\varphi$</span> by law of sines:
<span class="math-container">$$
\ell:=\sqrt{ r^2 + (1\text{ au})^2 - 2r(1\text{ au})\cos(60^\circ) }
,\hspace{1cm}
\frac{\sin(60^\circ)}{\ell} = \frac{\sin(\varphi/2)}{r}
$$</span>
The solution works out to be:
<span class="math-container">\begin{align*}
\varphi &amp;= 2 \arcsin\!\left(\frac{\sqrt{3}}{2}\cdot\frac{r}{\sqrt{ r^2 + (1\text{ au})^2 - r(1\text{ au}) }}\right)\\
&amp;\approx 0.004231^\circ
\end{align*}</span>
(which is consistent with <a href="https://www.wolframalpha.com/input?i=degrees%282*arctan%28+%28sqrt%283%29%2F2%29+%28radius+of+earth%29+%2F+%281au%29+%29%29" rel="noreferrer">a simplistic estimation</a>).</p>
<p>To measure the AU, we need measure this angle (via the elevation angles), which suggests immediately we need a precision of at least, like, 0.001° (and preferably a lot better), which is much worse than the calculators were giving (even besides that they weren't accounting for the distance at all).</p>
<p>We can get a more quantitative feel for this by, for example, solving for the AU and differentiating.  The AU is:
<span class="math-container">$$
1\text{ au} = \frac{r+\sqrt{r^2-4c}}{2},\hspace{1cm}c:=r^2-\frac{3r^2}{4\sin^2(\varphi/2)}
$$</span>
The differential with respect to <span class="math-container">$\varphi$</span> over the interesting domain <a href="https://www.wolframalpha.com/input?i=d%2Fdy+%28r%2Bsqrt%28+r%5E2+-+4*%28+++r%5E2+-+3r%5E2%2F%284+sin%5E2%28y%2F2%29%29+++%29+%29%29%2F2" rel="noreferrer">is</a>:
<span class="math-container">$$
\frac{d}{d\phi} 1\text{ au} = \frac{-\sqrt{3}}{8}\cdot
    \frac{ r \sin(\varphi) \csc^4(\varphi/2) }{ \cot{\varphi/2} }
$$</span>
For example, if you want 0.1%, 1%, or 10% error in your calculation, then you can estimate you need a precision of 0.015&quot;, 0.15&quot;, or 1.5&quot;, respectively.  Note that you can differentiate with respect to other parameters (e.g. <span class="math-container">$r$</span> and the (currently hardcoded) separation of 120° longitude).  A full error analysis would need to distribute the allowable error over such sources of inaccuracy as well.</p>
<p>The precision of JWST <a href="https://jwst-docs.stsci.edu/jwst-observatory-characteristics/jwst-pointing-performance" rel="noreferrer">is 0.1&quot;</a>, and it seems that some ground-based telescopes can get in the 1&quot; range under ideal conditions (don't quote me on that; I don't actually know).  Therefore, assuming you could find the center of the Sun with this accuracy, then it might actually possible to estimate the AU this way.  I would say it would be difficult and out of the capabilities of an amateur astronomer, though.</p>
<hr />
<h2>Conclusion</h2>
<p>Although your formula and code seem to be broadly correct, there were still several sources of error:</p>
<ul>
<li>You didn't use the correct time of the equinox, making the trig inaccurate.</li>
<li>For some times you calculated, the elevation was on the wrong side, breaking the formula's assumptions.</li>
<li>You didn't use the equatorial radius, and also you miscalculated the distance between the two points.</li>
<li>You ignored refraction entirely, usually causing the formula's assumptions to break.</li>
<li>The calculators round their outputs to a level that makes the calculation impossible.</li>
<li>The calculators don't figure the Sun's distance, making it impossible even in theory.</li>
</ul>
<p>The calculation is numerically ill-posed, and each of these sources of error individually doom the calculation to failure—so together they are more than sufficient.  Some of them are easy to fix (e.g. using the better radius), and some are not (fixing NOAA's calculator).</p>
<p>We can fix the errors related to the setup, and instead of trying to use the calculators (which aren't in the spirit of an actual &quot;terrestrial measurement&quot; anyway), we could imagine trying to do a real-world measurement.  One would need two very accurate telescopes taking a somewhat difficult measurement exactly at the equinox on the equator (or correcting for any differences mathematically).  Technologically I think it's at the edge of feasible.</p>

CC BY-SA 4.0
2024-03-18T04:19:35.370Z
We can get a more precise equinox time (2023-Sep-23 6:49:52 UTC) from JPL [Horizons](https://ssd.jpl.nasa.gov/horizons/). Here's a [declination plot](https://i.sstatic.net/H5kb2.png) using my script from [this answer](https://astronomy.stackexchange.com/a/49605/16685). The plot uses a numeric STEP_SIZE of 60 to get a 1 second time step. At this step size, quantization artifacts are visible. (The JPL DE stores positions as 14th order Chebyshev polynomials). Technically, equinox is defined in terms of RA, but for this task we obviously want the time when declination is 0°.
PM 2Ring
CC BY-SA 4.0
2024-03-18T04:29:28.523Z
Here's a Horizons [query](https://ssd.jpl.nasa.gov/api/horizons.api?format=text&COMMAND=10&CENTER=coord%40399&SITE_COORD=%2710%2C0%2C0%27&START_TIME=%272023-Sep-23+6%3A49%3A40%27&STOP_TIME=%272023-Sep-23+6%3A50%3A00%27&STEP_SIZE=20&QUANTITIES=%272%2C4%2C20%27&ANG_FORMAT=DEG&OBJ_DATA=NO) for RA, Dec, Azimuth, Elevation, and range & range-rate. Note that the site coords are given as `'lon, lat, altitude'`, with altitude in km. To get data using a simple refraction model, add `&APPARENT=REFRACTED` to the query URL.
PM 2Ring
CC BY-SA 4.0
2024-03-18T04:52:41.913Z
As mentioned [here](https://astronomy.stackexchange.com/a/34832/16685) it's possible for amateurs to measure star deflections during a solar eclipse with sub-arcsec precision, using good observations & clever statistical techniques. But I expect that precisely measuring the position of the Sun's centre is a bit tricky due to its brightness.
PM 2Ring
CC BY-SA 4.0
2024-03-19T07:39:01.383Z
Wonderful answer, this was exactly what I was looking for. Thank you so much! I've accepted this answer but I might ask some questions about some details when I have time. Respect & Take care.
Parseval
CC BY-SA 4.0
2024-03-17T23:00:02.240Z
2024-03-17T23:00:02.240Z
geometrian
<p>I have an interest in mathematics and astronomy, and my curiosity was piqued by the methodologies employed in contemporary solar distance measurement. Current practices use sophisticated instruments and celestial events, such as the transit of Venus, to calculate this distance. But then, how is the distance to Venus determined initially? Motivated by this inquiry, I undertook the challenge of calculating the Earth-Sun distance using only terrestrial measurements that are readily verifiable, coupled with basic trigonometry. However, as you will observe, there is a significant discrepancy between my findings and the accepted value of 1 Astronomical Unit (AU), which is approximately <span class="math-container">$\approx 150,000,000$</span> km. I am eager to understand and explain this variation. Below, I explain exactly what I did and what formula I derived.</p>
<hr />
<h2>Method</h2>
<hr />
<p>Start the process by selecting two points along the equator, separated by a distance <span class="math-container">$d$</span>, and proceed to measure the solar altitudes <span class="math-container">$\alpha$</span> and <span class="math-container">$\beta$</span> (the angular height of the sun above the horizontal plane) simultaneously, using Coordinated Universal Time (UTC) on March 20th, 2023, during the spring equinox. The choice of the spring equinox is deliberate, aimed at simplifying the calculations, as the sun is positioned directly above the equator at this time. By incorporating these measurements with known terrestrial distances, its possible to derive a formula that can calculate the distance to the sun. <a href="https://www.suncalc.org" rel="nofollow noreferrer">This site</a> was used to obtain the solar altitudes at different times at the two locations on Earth.</p>
<hr />
<h2>Mathematical derivation</h2>
<hr />
<p>I've drawn a figure in LaTex to explain the system and the measurements needed. The quantity of interest is the length <span class="math-container">$|CS|$</span>.</p>
<p><strong>Figure 1:</strong></p>
<p><a href="https://i.sstatic.net/NVysI.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/NVysI.png" alt="enter image description here" /></a></p>
<p>The notations are explained below.</p>
<ol>
<li><span class="math-container">$A$</span> is the first location on the equator</li>
<li><span class="math-container">$B$</span> is the second location on the equator</li>
<li><span class="math-container">$C$</span> is the center of the earth</li>
<li><span class="math-container">$D$</span> is the intersection of <span class="math-container">$\overline{CS}$</span> and Earth's surface</li>
<li><span class="math-container">$E$</span> is NOT NEEDED</li>
<li><span class="math-container">$S$</span> is the position of the sun</li>
<li><span class="math-container">$\alpha$</span> is the angle between <span class="math-container">$\overline{AS}$</span> and the Earth-tangent at point <span class="math-container">$A$</span></li>
<li><span class="math-container">$\beta$</span> is the angle between <span class="math-container">$\overline{BS}$</span> and the Earth-tangent at point <span class="math-container">$B$</span></li>
<li><span class="math-container">$\alpha'$</span> is the angle between <span class="math-container">$\overline{AB}$</span> and the Earth-tangent at point <span class="math-container">$A$</span></li>
<li><span class="math-container">$\beta'$</span> is the angle between <span class="math-container">$\overline{AB}$</span> and the Earth-tangent at point <span class="math-container">$B$</span></li>
<li><span class="math-container">$\varphi$</span> is the angle <span class="math-container">$\angle{BSA}$</span></li>
<li><span class="math-container">$\theta$</span> is the angle <span class="math-container">$\angle{ABC} = \angle{BAC}$</span></li>
<li><span class="math-container">$d$</span> is the distance between <span class="math-container">$A$</span> and <span class="math-container">$B$</span> along Earths surface (NOT IN FIGURE)</li>
<li><span class="math-container">$r$</span> is the radius of Earth (NOT IN FIGURE)</li>
</ol>
<p><strong>CALCULATIONS</strong></p>
<p>From figure 1, it's evident that <span class="math-container">$\alpha'=\frac{\pi}{2}-\theta$</span> and <span class="math-container">$\beta'=\frac{\pi}{2}-\theta$</span>, so <span class="math-container">$\alpha' = \beta'$</span>. The triangle <span class="math-container">$\triangle ACB$</span> is an Isosceles triangle since two of it's sides have the same length, <span class="math-container">$|AC|=|BC|=|DC|=r$</span>. Thus <span class="math-container">$\gamma = \frac{d}{r}$</span> radians and <span class="math-container">$\theta = \frac{\pi-\gamma}{2}$</span>. Moreover, <span class="math-container">$\angle{BAS} = \frac{\pi}{2}-\theta+\alpha$</span> and <span class="math-container">$\angle{ABS}=\frac{\pi}{2}-\theta+\beta$</span>, so</p>
<p><span class="math-container">$$\varphi = \pi-(\angle{BAS}+\angle{ABS})=2\theta-\alpha-\beta. \tag 1$$</span></p>
<p>Using the Law of Sines on the triangle <span class="math-container">$\triangle{ABS}$</span> we obtain the length <span class="math-container">$|AS|$</span> as</p>
<p><span class="math-container">$$\frac{\sin{\varphi}}{|AB|}=\frac{\sin{\angle{ABS}}}{|AS|}\Longleftrightarrow |AS|=\frac{|AB|\sin{\left(\frac{\pi}{2}+\beta-\theta\right)}}{\sin{\left(2\theta-\alpha-\beta\right)}},\tag 2$$</span>
where <span class="math-container">$|AB|$</span> is found using the Law of Cosines on the triangle <span class="math-container">$\triangle{ACB}$</span> as follows</p>
<p><span class="math-container">\begin{align}
|AB|^2 &amp;= r^2+r^2-2r^2\cos{\gamma} \tag 3  \\
&amp;= 2r^2-2r^2\cos{\gamma} \tag 4\\
&amp;= 2r^2(1-\cos{\gamma}) \tag 5 \\
&amp;\Leftrightarrow |AB|=r\sqrt{2(1-\cos{\gamma})}. \tag 6
\end{align}</span></p>
<p>It follows that</p>
<p><span class="math-container">\begin{align}
|AS| &amp;= \frac{r\sqrt{2(1-\cos{\gamma})}\sin{\left(\frac{\pi}{2}+\beta-\theta\right)}}{\sin{\varphi}} \tag 7 \\
&amp;= \frac{r\sqrt{2(1-\cos{\gamma})}\sin{\left(\frac{\pi}{2}+\beta-\theta\right)}}{\sin{(2\theta-\alpha-\beta)}}. \tag 8 
\end{align}</span></p>
<p>Since <span class="math-container">$\theta=\frac{\pi-\gamma}{2}$</span> we can rewrite equation <span class="math-container">$(8)$</span> as</p>
<p><span class="math-container">$$|AS|=\frac{r\sqrt{2(1-\cos{\gamma})}\sin{\left(\frac{\pi}{2}+\beta-\frac{\pi-\gamma}{2}\right)}}{\sin{\left(\pi-\gamma-\alpha-\beta\right)}}. \tag 9$$</span></p>
<p>At this stage, in triangle <span class="math-container">$\triangle{ACS}$</span> we have expressions for the side length <span class="math-container">$|AS|$</span> as well as the angle <span class="math-container">$\angle{CAS}=\frac{\pi}{2}+\alpha.$</span> We can now calculate the length of the line segment <span class="math-container">$|CS|$</span> using, again, the Law of Cosines. It follows that</p>
<p><span class="math-container">\begin{align}
|CS|^2 &amp;= |AS|^2+r^2-2|AS|r\cos{(\triangle{CAS})} \tag {10} \\
&amp;= |AS|^2+r^2+2|AS|r\sin{\alpha} \tag {11} \\
&amp;\Leftrightarrow |CS| = \sqrt{|AS|^2+r^2+2|AS|r\sin{\alpha}} \tag {12}.
\end{align}</span></p>
<p>Equation <span class="math-container">$(12)$</span> is the complete formula for calculating the distance <span class="math-container">$|CS|$</span> which is the sought distance. This expression is expressed in terms of the constant parameters <span class="math-container">$r,d$</span> and the solar altitude variables <span class="math-container">$\alpha,\beta$</span>. We can therefore write the solar distance as a two dimensional function of <span class="math-container">$\alpha,\beta$</span> as</p>
<p><span class="math-container">$$\boxed{f(\alpha,\beta) = \sqrt{|AS|^2+r^2+2|AS|r\sin{\alpha}},} \tag {13}$$</span></p>
<p>where</p>
<p><span class="math-container">$$|AS|=\frac{r\sqrt{2(1-\cos{\left(\frac{d}{r}\right)})}\sin{\left(\beta+\frac{d}{2r}\right)}}{\sin{\left(\frac{d}{r}+\alpha+\beta\right)}}.\tag{14}$$</span></p>
<hr />
<h2>Implementation and results</h2>
<hr />
<p>The the solar angle data was meticulously collected from <a href="https://www.suncalc.org" rel="nofollow noreferrer">this site</a> and the coordinates of the locations chosen were precisely <span class="math-container">$(0.00^{\circ} \ N \ \&amp; \ 38.00^{\circ} \ E)$</span> in Kenya and <span class="math-container">$(0.00^{\circ} \ N \ \&amp; \ 102.00^{\circ} \ E)$</span> in Indonesia.</p>
<p>The following Python function was implemented to compute the distances.</p>
<pre><code>def TrigSunDistCalc(alpha, beta, r=6371, d=7022) -&gt; float:
    alpha = np.radians(alpha)
    beta = np.radians(beta)
    AS = (r*np.sqrt(2-2*np.cos(d/r)) * np.sin(beta + d/(2*r)))/np.sin((d/r) + alpha + beta)
    return np.sqrt(AS**2 + r**2 + 2*AS*r*np.sin(alpha))
</code></pre>
<p>The data collected is listed below. The first three columns are the data collected, and the last column are the distance computations using formula <span class="math-container">$(13)$</span>.</p>
<pre><code>UTC timestamp            alpha (deg)      beta (deg)     f(alpha,beta) (km)
2023-03-20 04:00:00      70.09            6.23           12473.79
2023-03-20 04:15:00      73.84            9.93           14330.11
2023-03-20 04:30:00      77.59            13.66          17240.05
2023-03-20 04:45:00      81.34            17.39          22501.05
2023-03-20 05:00:00      85.09            21.13          35126.19
2023-03-20 05:15:00      88.81            24.88          107257.45
2023-03-20 05:30:00      87.39            28.62          401439.37
2023-03-20 05:45:00      83.65            32.37          420292.46
2023-03-20 06:00:00      79.9             36.12          432584.44
2023-03-20 06:15:00      76.15            39.86          437796.79
2023-03-20 06:30:00      72.41            43.61          451547.27
2023-03-20 06:45:00      68.66            47.36          458162.22
2023-03-20 07:00:00      64.91            51.11          462815.52
2023-03-20 07:15:00      61.16            54.86          465487.26
2023-03-20 07:30:00      57.41            58.61          466165.98
2023-03-20 07:45:00      53.66            62.36          464848.77
2023-03-20 08:00:00      49.91            66.11          461541.28
2023-03-20 08:15:00      46.16            69.86          456257.67
2023-03-20 08:30:00      42.41            73.61          449020.59
2023-03-20 08:45:00      38.66            77.36          439861.03
2023-03-20 09:00:00      34.92            81.11          434005.34
2023-03-20 09:15:00      31.17            84.85          415976.26
2023-03-20 09:30:00      27.42            88.59          396617.94
2023-03-20 09:45:00      23.68            87.64          63259.84
2023-03-20 10:00:00      19.94            83.89          29524.81
2023-03-20 10:15:00      16.2             80.14          20407.52
2023-03-20 10:30:00      12.46            76.39          16140.45
2023-03-20 10:45:00      8.74             72.64          13652.85
2023-03-20 11:00:00      5.05             68.89          12010.82
</code></pre>
<p>Below, the computed distances are plotted in a graph with varying UTC timestamps.</p>
<p><strong>Figure 2:</strong></p>
<p><a href="https://i.sstatic.net/PdZ9g.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/PdZ9g.png" alt="enter image description here" /></a></p>
<hr />
<h2>Conclusions &amp; Questions</h2>
<hr />
<p>Clearly my results differ a lot from today's accepted 1 AU. The distances are symmetrical around 07:30 UTC and there is a lot of variation, from roughly 12 000 km to 466 000 km. I want to explain why this is. I've listed some potential error sources:</p>
<ol>
<li>Error in my calculations. However I want to believe that they are all correct unless I'm missing some detail. I've also asked 2 other people with math knowledge to verify the derivation and none of them could find any error.</li>
<li>Angular measurements and their precision. The accuracy of the angles of elevation (alpha and beta) is crucial. Small errors in angle measurement can lead to large errors in the calculated distance. This is especially true for trigonometric functions, which can vary significantly with small changes in the input angles. This I can't verify since I do not know how these angles were measured but at least they are given with two decimals. Could a slight variation/error in these cause the distance to jump from 12 000km to 150 000 000 km? Even if there are minor errors in the angles, it seems far fetched and quite unbelievable that the distance should suddenly drop down to 0.00008 %. If this is the case, I'd want to know how.</li>
<li>Atmospheric refraction. However accounting for this, the distances computed should be closer since the perceived position is further away (larger solar angle) than the true position and the <span class="math-container">$\alpha,\beta$</span> are calculated based on the perceived position according to the website. So atmospheric refraction can't be the answer to the large discrepancy.</li>
</ol>
<p>Eventually, my question boils down to: why are my results so far away from 1 AU?</p>

CC BY-SA 4.0
2024-03-16T21:06:04.047Z
What order of magnitude is the angle phi - angle ASB. I suspect it is so small that you need much more accurate altitude "measurements" in order for it to work. (And most likely the theoretical calculated altitudes do not consider the distance to the Sun.)
JohnHoltz
CC BY-SA 4.0
2024-03-16T21:10:19.650Z
Something is wrong with your message, where it says “The solar angle data was meticulously collected from this site”: “this site” links to “about:blank#blocked". Checking the code of your post puts the link as your Python code…
Pierre Paquette
CC BY-SA 4.0
2024-03-17T10:01:05.223Z
@JohnHoltz - That angle is not measured, it's just derived via knowing $\alpha,\beta,\gamma$. Since the others are within 2 decimal places, $\gamma$ is as well. I don't know where to get more accurate measurements than this. Do you know any good source?
Parseval
CC BY-SA 4.0
2024-03-17T10:01:26.080Z
@PierrePaquette - Fixed the links!
Parseval
CC BY-SA 4.0
2024-03-17T10:01:26.753Z
Somewhat related question (by me) to compute the earth-sun distance from earth which unfortunately does not work in practice: https://astronomy.stackexchange.com/questions/35130/was-the-earth-sun-distance-ever-calculated-based-on-the-time-difference-between
quarague
CC BY-SA 4.0
2024-03-17T18:10:16.733Z
Most sites do not calculate the topocentric position of the Sun. Most are geocentric. The angle ASB is smaller than 0.01 degrees, so you need data that is much more accurate than that. This is probably why your technique has not been used in the past.
JohnHoltz
CC BY-SA 4.0
2024-03-17T18:35:17.303Z
@JohnHoltz: Yes, everything points to the accuracy of the measurements. In order for this method to be viable one would probably need precision to 10 decimals at least. Even measuring this is a challenge in itself. thanks for your comments!
Parseval
CC BY-SA 4.0
2024-03-20T07:53:18.627Z
_how is the distance to Venus determined initially?_ — with radar. See [Radar surveys of the solar system](https://www.semanticscholar.org/paper/Radar-surveys-of-the-solar-system.-Evans/8f0c18ae4305b2e5a008fcf7a5ef341be458bf82) for a 1968 review of the technique.
doubleunary
<the-sun><distances><equinox>
Calculating Earth-Sun distance only using trigonometry and terrestrial measurements
Parseval
# Calculating Earth-Sun distance only using trigonometry and terrestrial measurements

(Asked by: username_0 on 2024-03-16)

I have an interest in mathematics and astronomy, and my curiosity was piqued by the methodologies employed in contemporary solar distance measurement. Current practices use sophisticated instruments and celestial events, such as the transit of Venus, to calculate this distance. But then, how is the distance to Venus determined initially? Motivated by this inquiry, I undertook the challenge of calculating the Earth-Sun distance using only terrestrial measurements that are readily verifiable, coupled with basic trigonometry. However, as you will observe, there is a significant discrepancy between my findings and the accepted value of 1 Astronomical Unit (AU), which is approximately $\approx 150,000,000$ km. I am eager to understand and explain this variation. Below, I explain exactly what I did and what formula I derived.

Method

Start the process by selecting two points along the equator, separated by a distance $d$, and proceed to measure the solar altitudes $\alpha$ and $\beta$ (the angular height of the sun above the horizontal plane) simultaneously, using Coordinated Universal Time (UTC) on March 20th, 2023, during the spring equinox. The choice of the spring equinox is deliberate, aimed at simplifying the calculations, as the sun is positioned directly above the equator at this time. By incorporating these measurements with known terrestrial distances, its possible to derive a formula that can calculate the distance to the sun. This site was used to obtain the solar altitudes at different times at the two locations on Earth.

Mathematical derivation

I've drawn a figure in LaTex to explain the system and the measurements needed. The quantity of interest is the length $|CS|$.
Figure 1:

The notations are explained below.

$A$ is the first location on the equator
$B$ is the second location on the equator
$C$ is the center of the earth
$D$ is the intersection of $\overline{CS}$ and Earth's surface
$E$ is NOT NEEDED
$S$ is the position of the sun
$\alpha$ is the angle between $\overline{AS}$ and the Earth-tangent at point $A$
$\beta$ is the angle between $\overline{BS}$ and the Earth-tangent at point $B$
$\alpha'$ is the angle between $\overline{AB}$ and the Earth-tangent at point $A$
$\beta'$ is the angle between $\overline{AB}$ and the Earth-tangent at point $B$
$\varphi$ is the angle $\angle{BSA}$
$\theta$ is the angle $\angle{ABC} = \angle{BAC}$
$d$ is the distance between $A$ and $B$ along Earths surface (NOT IN FIGURE)
$r$ is the radius of Earth (NOT IN FIGURE)

CALCULATIONS
From figure 1, it's evident that $\alpha'=\frac{\pi}{2}-\theta$ and $\beta'=\frac{\pi}{2}-\theta$, so $\alpha' = \beta'$. The triangle $\triangle ACB$ is an Isosceles triangle since two of it's sides have the same length, $|AC|=|BC|=|DC|=r$. Thus $\gamma = \frac{d}{r}$ radians and $\theta = \frac{\pi-\gamma}{2}$. Moreover, $\angle{BAS} = \frac{\pi}{2}-\theta+\alpha$ and $\angle{ABS}=\frac{\pi}{2}-\theta+\beta$, so
$$\varphi = \pi-(\angle{BAS}+\angle{ABS})=2\theta-\alpha-\beta. \tag 1$$
Using the Law of Sines on the triangle $\triangle{ABS}$ we obtain the length $|AS|$ as
$$\frac{\sin{\varphi}}{|AB|}=\frac{\sin{\angle{ABS}}}{|AS|}\Longleftrightarrow |AS|=\frac{|AB|\sin{\left(\frac{\pi}{2}+\beta-\theta\right)}}{\sin{\left(2\theta-\alpha-\beta\right)}},\tag 2$$
where $|AB|$ is found using the Law of Cosines on the triangle $\triangle{ACB}$ as follows
\begin{align}
|AB|^2 &= r^2+r^2-2r^2\cos{\gamma} \tag 3  \\
&= 2r^2-2r^2\cos{\gamma} \tag 4\\
&= 2r^2(1-\cos{\gamma}) \tag 5 \\
&\Leftrightarrow |AB|=r\sqrt{2(1-\cos{\gamma})}. \tag 6
\end{align}
It follows that
\begin{align}
|AS| &= \frac{r\sqrt{2(1-\cos{\gamma})}\sin{\left(\frac{\pi}{2}+\beta-\theta\right)}}{\sin{\varphi}} \tag 7 \\
&= \frac{r\sqrt{2(1-\cos{\gamma})}\sin{\left(\frac{\pi}{2}+\beta-\theta\right)}}{\sin{(2\theta-\alpha-\beta)}}. \tag 8 
\end{align}
Since $\theta=\frac{\pi-\gamma}{2}$ we can rewrite equation $(8)$ as
$$|AS|=\frac{r\sqrt{2(1-\cos{\gamma})}\sin{\left(\frac{\pi}{2}+\beta-\frac{\pi-\gamma}{2}\right)}}{\sin{\left(\pi-\gamma-\alpha-\beta\right)}}. \tag 9$$
At this stage, in triangle $\triangle{ACS}$ we have expressions for the side length $|AS|$ as well as the angle $\angle{CAS}=\frac{\pi}{2}+\alpha.$ We can now calculate the length of the line segment $|CS|$ using, again, the Law of Cosines. It follows that
\begin{align}
|CS|^2 &= |AS|^2+r^2-2|AS|r\cos{(\triangle{CAS})} \tag {10} \\
&= |AS|^2+r^2+2|AS|r\sin{\alpha} \tag {11} \\
&\Leftrightarrow |CS| = \sqrt{|AS|^2+r^2+2|AS|r\sin{\alpha}} \tag {12}.
\end{align}
Equation $(12)$ is the complete formula for calculating the distance $|CS|$ which is the sought distance. This expression is expressed in terms of the constant parameters $r,d$ and the solar altitude variables $\alpha,\beta$. We can therefore write the solar distance as a two dimensional function of $\alpha,\beta$ as
$$\boxed{f(\alpha,\beta) = \sqrt{|AS|^2+r^2+2|AS|r\sin{\alpha}},} \tag {13}$$
where
$$|AS|=\frac{r\sqrt{2(1-\cos{\left(\frac{d}{r}\right)})}\sin{\left(\beta+\frac{d}{2r}\right)}}{\sin{\left(\frac{d}{r}+\alpha+\beta\right)}}.\tag{14}$$

Implementation and results

The the solar angle data was meticulously collected from this site and the coordinates of the locations chosen were precisely $(0.00^{\circ} \ N \ \& \ 38.00^{\circ} \ E)$ in Kenya and $(0.00^{\circ} \ N \ \& \ 102.00^{\circ} \ E)$ in Indonesia.
The following Python function was implemented to compute the distances.
def TrigSunDistCalc(alpha, beta, r=6371, d=7022) -> float:
    alpha = np.radians(alpha)
    beta = np.radians(beta)
    AS = (r*np.sqrt(2-2*np.cos(d/r)) * np.sin(beta + d/(2*r)))/np.sin((d/r) + alpha + beta)
    return np.sqrt(AS**2 + r**2 + 2*AS*r*np.sin(alpha))

The data collected is listed below. The first three columns are the data collected, and the last column are the distance computations using formula $(13)$.
UTC timestamp            alpha (deg)      beta (deg)     f(alpha,beta) (km)
2023-03-20 04:00:00      70.09            6.23           12473.79
2023-03-20 04:15:00      73.84            9.93           14330.11
2023-03-20 04:30:00      77.59            13.66          17240.05
2023-03-20 04:45:00      81.34            17.39          22501.05
2023-03-20 05:00:00      85.09            21.13          35126.19
2023-03-20 05:15:00      88.81            24.88          107257.45
2023-03-20 05:30:00      87.39            28.62          401439.37
2023-03-20 05:45:00      83.65            32.37          420292.46
2023-03-20 06:00:00      79.9             36.12          432584.44
2023-03-20 06:15:00      76.15            39.86          437796.79
2023-03-20 06:30:00      72.41            43.61          451547.27
2023-03-20 06:45:00      68.66            47.36          458162.22
2023-03-20 07:00:00      64.91            51.11          462815.52
2023-03-20 07:15:00      61.16            54.86          465487.26
2023-03-20 07:30:00      57.41            58.61          466165.98
2023-03-20 07:45:00      53.66            62.36          464848.77
2023-03-20 08:00:00      49.91            66.11          461541.28
2023-03-20 08:15:00      46.16            69.86          456257.67
2023-03-20 08:30:00      42.41            73.61          449020.59
2023-03-20 08:45:00      38.66            77.36          439861.03
2023-03-20 09:00:00      34.92            81.11          434005.34
2023-03-20 09:15:00      31.17            84.85          415976.26
2023-03-20 09:30:00      27.42            88.59          396617.94
2023-03-20 09:45:00      23.68            87.64          63259.84
2023-03-20 10:00:00      19.94            83.89          29524.81
2023-03-20 10:15:00      16.2             80.14          20407.52
2023-03-20 10:30:00      12.46            76.39          16140.45
2023-03-20 10:45:00      8.74             72.64          13652.85
2023-03-20 11:00:00      5.05             68.89          12010.82

Below, the computed distances are plotted in a graph with varying UTC timestamps.
Figure 2:


Conclusions & Questions

Clearly my results differ a lot from today's accepted 1 AU. The distances are symmetrical around 07:30 UTC and there is a lot of variation, from roughly 12 000 km to 466 000 km. I want to explain why this is. I've listed some potential error sources:

Error in my calculations. However I want to believe that they are all correct unless I'm missing some detail. I've also asked 2 other people with math knowledge to verify the derivation and none of them could find any error.
Angular measurements and their precision. The accuracy of the angles of elevation (alpha and beta) is crucial. Small errors in angle measurement can lead to large errors in the calculated distance. This is especially true for trigonometric functions, which can vary significantly with small changes in the input angles. This I can't verify since I do not know how these angles were measured but at least they are given with two decimals. Could a slight variation/error in these cause the distance to jump from 12 000km to 150 000 000 km? Even if there are minor errors in the angles, it seems far fetched and quite unbelievable that the distance should suddenly drop down to 0.00008 %. If this is the case, I'd want to know how.
Atmospheric refraction. However accounting for this, the distances computed should be closer since the perceived position is further away (larger solar angle) than the true position and the $\alpha,\beta$ are calculated based on the perceived position according to the website. So atmospheric refraction can't be the answer to the large discrepancy.

Eventually, my question boils down to: why are my results so far away from 1 AU?

**Tags:** the-sun, distances, equinox

> **Comments:**
> **username_1**: What order of magnitude is the angle phi - angle ASB. I suspect it is so small that you need much more accurate altitude "measurements" in order for it to work. (And most likely the theoretical calculated altitudes do not consider the distance to the Sun.)  
> **username_2**: Something is wrong with your message, where it says “The solar angle data was meticulously collected from this site”: “this site” links to “about:blank#blocked". Checking the code of your post puts the link as your Python code…  
> **username_0**: @username_1 - That angle is not measured, it's just derived via knowing $\alpha,\beta,\gamma$. Since the others are within 2 decimal places, $\gamma$ is as well. I don't know where to get more accurate measurements than this. Do you know any good source?  
> **username_0**: @PierrePaquette - Fixed the links!  
> **username_3**: Somewhat related question (by me) to compute the earth-sun distance from earth which unfortunately does not work in practice: https://astronomy.stackexchange.com/questions/35130/was-the-earth-sun-distance-ever-calculated-based-on-the-time-difference-between  
> **username_1**: Most sites do not calculate the topocentric position of the Sun. Most are geocentric. The angle ASB is smaller than 0.01 degrees, so you need data that is much more accurate than that. This is probably why your technique has not been used in the past.  
> **username_0**: @username_1: Yes, everything points to the accuracy of the measurements. In order for this method to be viable one would probably need precision to 10 decimals at least. Even measuring this is a challenge in itself. thanks for your comments!  
> **username_4**: _how is the distance to Venus determined initially?_ — with radar. See [Radar surveys of the solar system](https://www.semanticscholar.org/paper/Radar-surveys-of-the-solar-system.-Evans/8f0c18ae4305b2e5a008fcf7a5ef341be458bf82) for a 1968 review of the technique.  

---

## 2 answers

### Answer by username_5 on 2024-03-17. Score: 6 | Accepted answer

This is an interesting experiment / project, and props for your significant effort toward executing it!
The gist of your approach is trying to work out the distance using the solar altitude measured at two different longitudes on the equator.  You did it for several different timestamps experimentally.
TL;DR you didn't exactly make any mistakes, but you made several problematic approximations that resulted in your formula breaking down.  Moreover, the imprecision of the data you were working with, as well as approximation in the calculator made your attempt doomed anyway.  However, a real-world test might be barely possible.

Data
To start our analysis, let's take the center of your time series at 2023-03-20 07:30 UTC.  The equinox was at 21:24 UTC on that date, nowhere in your time series, a source of error which we'll return to later.
For 07:30 UTC, the site tells me that the altitude ("the angle between horizon and the center of the Sun including refraction") for the locations chosen was:

Kenya 0°N, 38°E at 10:30 UTC+3 (07:30 UTC): 58.61° alt, 90.44° azi
Sumatra 0°N, 102°E at 14:30 UTC+7 (07:30 UTC): 57.41° alt, 269.58° azi

These figures agree with the numbers you collected.  One notices that the azimuths differ by about 180°.  This is because 07:30 UTC was 10:30 local time in Kenya (i.e. in the morning), but 14:30 local time in Sumatra, i.e. in the afternoon.  The altitudes are thus measured from opposite horizons.  Note it's almost a degree off from 180° apart because we're not using the right time of day for the equinox; that discrepancy makes your trig inaccurate.
Your formula / code assumes the azimuths are opposed (the intermediate AS, can be (nonsensically) negative otherwise.), and that assumption breaking seems to be the source of the jumps in your graph, as discussed somewhat and diagrammed in the other answer.  In the middle, we're fine, though.

Your Math and Code
I checked your derivation of the distance and didn't see an error as written.  I feel like there's probably a simpler way, but your formula seems correct and the derivation very nice, so we'll go with it.
As for your code, you have r 6371 km, which is an average.  The Earth is an ellipsoid, and since we're on the equator, it would be better and just as easy to instead use the equatorial radius of 6378.1370 km.
I don't know where you got the distance $d$ (var. AB), which you have listed as 7022 km.  That's about 100 km too small (regardless of the radius used).  The two points are separated by 102°-38°=64° of longitude, which is 64/360≈17.78% of the way around the equator, whose radius we now know precisely.  A precise calculation gives 7124.447 km, corroborated here to the five places given.
This might seem like a small thing, but it's a major source of error, since the relatively small size of the Earth gets massively multiplied to get the AU, and so any error does too.  Just to give a flavor, using your code, I indeed get a result of 466,165.98 km, but with the more correct r=6378.1370, AB=7124.447, I get 19,362,488.85 km, which is still wrong, but 40 times bigger (in the correct direction, it happens).

Thinking About Error
Digging into the error some more, we can start to see that this is really ill-posed.  The locations are separated by 64° of longitude, as above.  If the Sun were infinitely far away, its rays would be parallel and a 58.61° altitude in Kenya would mean a 57.39° altitude in Sumatra (from the opposite horizon).  However, the calculator says we measure 57.41° altitude.
The discrepancy is 0.02°. That's also the unit in last place, so we've only got precision to the nearest 0.005°, which is . . . 25% of the value itself!
It's much, much worse than that, though.  We didn't use the exact equinox, which means the Sun was not exactly on the Earth's orbital plane and we did not account for refraction at all.  A big part of your inaccuracy seems to be with the refraction; when you don't account for it, you can compute a negative φ, which will of course give bogus results.

Improving the Result
Let's try to do a bit better.
First, all the data is coming from a calculator, so in principle we should be able to get a very accurate answer. In the following, I'll be using NOAA's calculator.  While both calculators round their outputs and in SunCalc's case there is uncertainty in what formulae they use for refraction, SunCalc's code is minified and so is difficult to reverse-engineer, whereas NOAA's is human-readable.  It will turn out that we need to use the high-precision internals of the calculator to understand what's going on.
To drive the error down, we want to compute at the exact equinox, which unfortunately does not seem to be distributed to higher precision than the minute. We also want to select points that are far apart, but not so far apart that the Sun is low in the sky and refraction changes a lot (though we absolutely still compensate for it).
At the correct equinox of 2023-03-20 21:24 UTC, the Sun was below the horizon in both locations (it was mostly over the Pacific Ocean). To keep with the spirit of an experiment you could do on land, let's choose a different equinox.  I greatly prefer the season of Autumn, and the Autumnal Equinox of that year (2023-09-23 06:50) will do nicely, with the entire equator from Africa through Indonesia being suitable.  I'll pick points a bit farther apart:

Gabon 0°N, 10°E at 07:50 UTC+1 (06:50 UTC): 24.40° (24.396⋯°) alt, 90.00° azi
Indonesia 0°N, 120°E at 14:50 UTC+8 (06:50 UTC): 45.66°  (45.655⋯°) alt, 270.00° azi

Note that, because we're at the moment of the equinox, the azimuths are now parallel to the equator and separated by 180.00°, as we expect.
The parenthesized numbers are the first digits of the actual elevations the NOAA calculator is using extracted from the JavaScript debugger (their full values are 24.396176229009612° and 45.65502300416843°, respectively), while the unparenthesized numbers are the rounded values it displays.
The distance between the two longitudes is 120°-10°=110°, which is 110°/360°≈30.56% of the way around the Earth.
Using NOAA's formula for refraction here (see also their main.js:330) and inverting the 5°–85° band both zeniths fall into numerically, we get 24.361⋯° and 45.639⋯°.  Though small, this difference is significant; it changes the difference between the elevations by almost 0.02°, which as we saw above is as big as the entire discrepancy we're trying to measure!
import math
import scipy

def refract_adjust_5to85deg( true_elev_deg ):
    #https://gml.noaa.gov/grad/solcalc/calcdetails.html
    T = math.tan( math.radians(true_elev_deg) )
    adjust_deg = (1.0/3600.0)*(
        58.1/T - 0.07/(T*T*T) + 0.000086/(T*T*T*T*T)
    )
    return true_elev_deg + adjust_deg
def refract_unadjust( apparent_elev_deg ):
    true_elev_deg = scipy.optimize.fsolve(
        lambda true_elev_deg:
            refract_adjust_5to85deg(true_elev_deg[0]) - apparent_elev_deg,
        apparent_elev_deg
    )[0]
    return true_elev_deg

alpha_deg = refract_unadjust(24.396176229009612)
beta_deg  = refract_unadjust(45.65502300416843 )
print(f"True α={alpha_deg:.5}°, β={beta_deg:.5}°")


A High-Precision Revelation
When we compute the formula, we get a large number, and checking why, we see that it's because φ is computed as 9.5716e-10° which, for the numerics we're using, is within the error of actual, literal 0.0.  This tells us the problem: the calculators are not accounting for the solar distance, and we've just reconstructed their parallel-rays approximation!  In fact, you can actually see this: NOAA does calculate the Sun distance (main.js:286), but it's pointless because that variable is never used again.  For the two decimals of precision they needed, they decided not to bother (I guess they planned to initially, but changed their mind and forgot to remove that line).  I don't know whether SunCalc shares this flaw, but I'd bet it does.
The implication is your calculation was always doomed to fail; the data you were working from simply did not include the effect you were trying to extract from it!

Getting a Real Answer
It seems that we can't currently demonstrate your approach from these calculators' data, but we can calculate what would kind of precision would be required.
Say the Sun is 1 au away and on some equinox we're considering two points that (to simplify things) are spaced the same longitude before and after the Sun at that instant—say one is 60° ahead and the other is 60° behind.  The distance $\ell$ from each observatory to the Sun is given by law of cosines, and is related to the vertex angle at the Sun $\varphi$ by law of sines:
$$
\ell:=\sqrt{ r^2 + (1\text{ au})^2 - 2r(1\text{ au})\cos(60^\circ) }
,\hspace{1cm}
\frac{\sin(60^\circ)}{\ell} = \frac{\sin(\varphi/2)}{r}
$$
The solution works out to be:
\begin{align*}
\varphi &= 2 \arcsin\!\left(\frac{\sqrt{3}}{2}\cdot\frac{r}{\sqrt{ r^2 + (1\text{ au})^2 - r(1\text{ au}) }}\right)\\
&\approx 0.004231^\circ
\end{align*}
(which is consistent with a simplistic estimation).
To measure the AU, we need measure this angle (via the elevation angles), which suggests immediately we need a precision of at least, like, 0.001° (and preferably a lot better), which is much worse than the calculators were giving (even besides that they weren't accounting for the distance at all).
We can get a more quantitative feel for this by, for example, solving for the AU and differentiating.  The AU is:
$$
1\text{ au} = \frac{r+\sqrt{r^2-4c}}{2},\hspace{1cm}c:=r^2-\frac{3r^2}{4\sin^2(\varphi/2)}
$$
The differential with respect to $\varphi$ over the interesting domain is:
$$
\frac{d}{d\phi} 1\text{ au} = \frac{-\sqrt{3}}{8}\cdot
    \frac{ r \sin(\varphi) \csc^4(\varphi/2) }{ \cot{\varphi/2} }
$$
For example, if you want 0.1%, 1%, or 10% error in your calculation, then you can estimate you need a precision of 0.015", 0.15", or 1.5", respectively.  Note that you can differentiate with respect to other parameters (e.g. $r$ and the (currently hardcoded) separation of 120° longitude).  A full error analysis would need to distribute the allowable error over such sources of inaccuracy as well.
The precision of JWST is 0.1", and it seems that some ground-based telescopes can get in the 1" range under ideal conditions (don't quote me on that; I don't actually know).  Therefore, assuming you could find the center of the Sun with this accuracy, then it might actually possible to estimate the AU this way.  I would say it would be difficult and out of the capabilities of an amateur astronomer, though.

Conclusion
Although your formula and code seem to be broadly correct, there were still several sources of error:

You didn't use the correct time of the equinox, making the trig inaccurate.
For some times you calculated, the elevation was on the wrong side, breaking the formula's assumptions.
You didn't use the equatorial radius, and also you miscalculated the distance between the two points.
You ignored refraction entirely, usually causing the formula's assumptions to break.
The calculators round their outputs to a level that makes the calculation impossible.
The calculators don't figure the Sun's distance, making it impossible even in theory.

The calculation is numerically ill-posed, and each of these sources of error individually doom the calculation to failure—so together they are more than sufficient.  Some of them are easy to fix (e.g. using the better radius), and some are not (fixing NOAA's calculator).
We can fix the errors related to the setup, and instead of trying to use the calculators (which aren't in the spirit of an actual "terrestrial measurement" anyway), we could imagine trying to do a real-world measurement.  One would need two very accurate telescopes taking a somewhat difficult measurement exactly at the equinox on the equator (or correcting for any differences mathematically).  Technologically I think it's at the edge of feasible.

> **Comments:**
> **username_6**: We can get a more precise equinox time (2023-Sep-23 6:49:52 UTC) from JPL [Horizons](https://ssd.jpl.nasa.gov/horizons/). Here's a [declination plot](https://i.sstatic.net/H5kb2.png) using my script from [this answer](https://astronomy.stackexchange.com/a/49605/16685). The plot uses a numeric STEP_SIZE of 60 to get a 1 second time step. At this step size, quantization artifacts are visible. (The JPL DE stores positions as 14th order Chebyshev polynomials). Technically, equinox is defined in terms of RA, but for this task we obviously want the time when declination is 0°.  
> **username_6**: Here's a Horizons [query](https://ssd.jpl.nasa.gov/api/horizons.api?format=text&COMMAND=10&CENTER=coord%40399&SITE_COORD=%2710%2C0%2C0%27&START_TIME=%272023-Sep-23+6%3A49%3A40%27&STOP_TIME=%272023-Sep-23+6%3A50%3A00%27&STEP_SIZE=20&QUANTITIES=%272%2C4%2C20%27&ANG_FORMAT=DEG&OBJ_DATA=NO) for RA, Dec, Azimuth, Elevation, and range & range-rate. Note that the site coords are given as `'lon, lat, altitude'`, with altitude in km. To get data using a simple refraction model, add `&APPARENT=REFRACTED` to the query URL.  
> **username_6**: As mentioned [here](https://astronomy.stackexchange.com/a/34832/16685) it's possible for amateurs to measure star deflections during a solar eclipse with sub-arcsec precision, using good observations & clever statistical techniques. But I expect that precisely measuring the position of the Sun's centre is a bit tricky due to its brightness.  
> **username_0**: Wonderful answer, this was exactly what I was looking for. Thank you so much! I've accepted this answer but I might ask some questions about some details when I have time. Respect & Take care.  

---

### Answer by username_2 on 2024-03-16. Score: 6

For the first hour and the last 75 minutes, it appears you neglected to take into account the **direction** of the Sun. As shown on this first image, [![enter image description here](https://i.sstatic.net/IGHmC.jpg)](https://i.sstatic.net/IGHmC.jpg) you are measuring the Sun as if it were along the black line stemming out of the top point; this will give a Sun at the intersection of the two black lines, which is about 12473.79 km away from the bottom point, indeed. But the Sun is then not in the direction of the black line, but in the direction of the red line. As you can see, it is very nearly parallel to the black line from the bottom point at that moment.

For the “middle” part of your experiment, let’s say from 5:30 to 9:15, there must be something wrong in your coding or formulas, as the following graphic, simulating the situation, shows the direction of the Sun from one location is parallel to the direction of the Sun from the other location. (Click on image to enlarge it.)
[![enter image description here](https://i.sstatic.net/MCkE0.jpg)](https://i.sstatic.net/MCkE0.jpg)

In both drawings, the dashed grey lines are the local horizons.

> **Comments:**
> **username_0**: Thank you very much for your great answer. Yes indeed, for the first six and last six timestamps, I have not taken the suns direction into account, thank you for bringing this to my attention, I will write an edit to my post later. I've also fixed the links in my answer. Regarding the "middle part", what value did you use for the surface-distance between points A,B? I see that a slight variation in $d,\alpha$ and/or $\beta$ can significantly change the distance $|CS|$. Do you know where I can get more accurate numbers on these? ($r,d,\alpha,\beta$)  
> **username_0**: When it comes to "error in your coding or formulas" - I have not been able to find it. That was my first thought as well: "Oh I've must have made a calculation or coding error". My hope was that someone here can spot the mistake, or verify there is none. If there is none, then there has to be another explanation for the $\approx 450 000 km$ vs the $\approx 150 000000 km$ discrepancy. Btw, what tool did you use to draw that last figure?  
> **username_2**: @username_0: The angle between A and B in both of my figures is (102-38) = 64°, from the values you give. I used Adobe Illustrator.  

---

