Madrid is the geographical center of Spain, and all major train lines depart from one of its two main train stations (Chamartín and Atocha) or pass through Madrid. Though train travel is comfortable, for some destinations buses run more frequently and make fewer stops; this is true for Segovia and Toledo, unless you take the more expensive high-speed train.
Commuter trains to El Escorial, Aranjuez, and Alcalá de Henares run frequently. The best way to get a ticket for such trains is to use one of the automated reservation terminals at the station (they're in the cercanías area), but you can buy tickets online for the high-speed AVE regional lines. You can reach Segovia from the Atocha station in a half hour, the same time it takes you to get to Toledo; if you return the same day, the ticket may cost less than €22. The AVE stations in Toledo and Segovia are outside the city, meaning once there you'll have to take either a bus or a taxi to get to their old quarters.
The AVE line can get you to Barcelona in less than three hours. If you buy the ticket more than two weeks ahead and are lucky enough to find an online fare (with discounts up to 60% off the official fare), you may pay less than €50 each way for tickets that will often carry some change and cancellation restrictions. Otherwise expect to pay between €106 and €128 each way—the more expensive being the nonstop service.
Estación Chamartín. Calle Agustín de Foxá s/n, Chamartín, Madrid, Madrid, 28036. 902/240505.
Estación de Atocha. Glorieta del Emperador Carlos V, Atocha, Madrid, Madrid, 28045. 902/240505.
Estación de Príncipe Pío (Norte). Estación de Príncipe Pío (Norte) Paseo de la Florida s/n, Moncloa, Madrid, Madrid, 28008. 902/240202.