This ticket can only be bought from Renfe.es, Spain's official rail website, which has been described as "like Alice in Wonderland, where nothing seems to be what it really is" by Trip Advisor. I recommend buying your ticket in person at the train station.
Trains from Madrid to Jaen depart from Atocha train station. Read more about Bus and Train Stations in Madrid
For other train tickets in Spain, residents of Canada and USA should use Rail Europe instead to have their tickets delivered to their home address. Other citizens should also use the link below to check timetables and then buy tickets in person.
Madrid to Jaen by Bus
There are buses each day between Madrid and Jaen, but they aren't very frequent. The journey takes four hours and costs about 20 euros. I'd take the train.
Buses from Madrid to Jaen depart from Mendez Alvaro. Read more about Bus and Train Stations in Madrid
Madrid to Jaen by Car
The 340km journey from Madrid to Jaen takes about 3h45, traveling mainly on the A-4.
Flights from Madrid to Jaen
Jaen shares an airport with Granada (though it is much closer to Granada). There are several flights a day to Granada and flights can be cheap if booked well in advance.