Question: If I have the following information about star A and Star B, how can I compute the distance between A and B?

* Distance from Sol for Star A
* Right Ascension/Declination of Star A
* Parallax/Absolute Magnitude of Star A
* Distance from Sol for Star B
* Right Ascension/Declination of Star B
* Parallax/Absolute Magnitude of Star B

I can use the parallax and absolute magnitude to compute distance from Sol, but I don't know how to get the distance between A and B.

Obviously there will be errors in the parallax, but I'm looking for a best effort means to calculate this.

**Edit**

I've implemented this in Java and made it available via this link:

<https://gist.github.com/fergusonjason/fa4794dc0dc5d45f7a7ed12296577ed5>

I realize for actual science work most people wouldn't use Java, but this is for a project that is part of my Java portfolio.

Answer: 
If you know the right ascension and declension of the stars, then you know the angle between them (ie the A-Sun-B angle). Working this out is an exercise in spherical trigonometry. The cosine of angular separation of the stars $\cos(C)$ is given by
$$\cos(C) = \sin(d\_a)\sin(d\_b) + \cos(d\_a)\cos(d\_b)\cos(r\_a-r\_b)$$

Where $d\_i$ is the declension of the star $i$ and $r\_i$ is the right ascension (in degrees or radians as necessary)

Then the distance between the stars is just an application of the cosine law.
$$c^2=a^2+b^2 -2ab\cos(C).$$ In which $a$ and $b$ are the distances to each star and $c$ is distance between the stars.
The really, really easy way to find the distances between two stars with kown directions and distances from Earth is to use an application which calculates those distances.

See:

[What is the closest stellar neighbour to Sirius?](https://astronomy.stackexchange.com/questions/45105/what-is-the-closest-stellar-neighbour-to-sirius/45135#45135)

In my answer I say that my first impression is that Procyon would probably be the closest stellar neighbor to Sirius. Then I investigate a few stars, listing their differences in angles from the right ascension and the declination of Sirius, and also by how much their distances from Earth differ from that of Sirius.

And then I tried using an app which calculates the distance between two stars. And of all the star pairs I tried, Procyon was the closest to Sirius according to that online app.

<https://www.wolframalpha.com/widgets/view.jsp?id=1ece06643e87f3c4d90813af5ee12223>