It is amazing what human ingenuity can come up with! In this case, you have thousands of astronomers peering at the heavens every night using a relatively small set of tools (telescopes gathering light or radio waves), so they spend a great deal of time thinking of different ways to use these tools. To be able to sense objects as small as a planet at a distance of trillions of miles using these tools is a major accomplishment.
You can understand what astronomers are doing if you think about our own sun and the planets that orbit it. The largest of these planets is Jupiter. Jupiter weighs about 1/1000th of the sun, and it orbits the sun every 11.8 years or so at a distance of 5 Astronomical Units (AU) [an AU is the average distance between the earth and the sun, which is 92,955,800 miles or 149,597,870 kilometers].
The sun is not anchored in space with Jupiter orbiting around it. As Jupiter moves around the sun, Jupiter pulls on the sun and moves it. The distance it pulls the sun is proportional to the weight of the two bodies, so the sun moves 1/1000th of the distance that Jupiter does. As Jupiter moves through its orbit, the sun moves through a circle 1,000 times smaller. In other words, the sun moves through a circle about 1,000,000 miles (1.6 million kilometers) in diameter. [The other planets that orbit the sun all have effects on the sun's motion as well -- Jupiter just happens to have the biggest effect, so it is most noticeable].
In astronomical terms, the 1,000,000 miles that the sun moves is tiny. It also takes a long time to move that distance (11.8 years). However, motions like these are still detectable. There are two ways that someone could detect them:
See the links below for lots more detail.
- Side-to-side motion - You can detect side-to-side motion by simply looking at the star, plotting the course that you think it should follow and then looking for variations in the path. If the star seems to move side-to-side periodically, then it has a "wobble" that an orbiting planet might produce.
- Front-to-back motion - You can detect front-to-back motion by detecting the Doppler shift in light that the star produces. When anything moves toward you or away from you, the color of its light changes (see How Radar Works for details). By measuring the change in color of a star and looking for a pattern, you can detect front to back motion.
One star that has a very noticeable wobble is 51 Pegasi. It wobbles every 4.2 days, implying a planet that orbits it very quickly. That's hard to imagine, but it made detection very easy (compared to 11.8 years...). Two of the links below go into lots of detail about 51 Pegasi , including a table of its motion data, some nice diagrams and the formulas astronomers use to calculate planet mass and distance.
Here are several interesting links if you would like to learn more: