velocity function

double velocity(
  1. double a,
  2. double r
)

Velocity of a body at distance r in an orbit with semimajor axis a.

Both in AU. Result in AU/day.

Implementation

double velocity(double a, double r) {
  return 0.0172021 * math.sqrt(2 / r - 1 / a);
}