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.
Alternative approach:

Right ascension + declination + distance are spherical coordinates. Apply a standard conversion from spherical to rectangular coordinates and the distance calculation becomes easy.