I hope you had a great Camino by the time you get on one of these forms of transport!
Bus is eight hours. Train is four hours. Plane is 60 to 90 minute ride plus an hour or two at the airport and 30 minutes to get to from santiago.
The price of the tickets will depend on how far you book in advance. Tickets sell out, so don’t wait until the absolute last minute. Of course, the bus is usually the cheapest, but the only way to know for a particular day, as noted above, is to check.
The apps or websites for either Google Maps or Rome2Rio will give you specific information on specific days.
In the future, you can use these apps to give you quicker information then posting on a forum like this. The apps are what most people here use . There is no secret.
The website for the Spanish train service is renfe.es. The website for the Spanish bus service is alsa.es
In my experience, taking the train is the easiest and most comfortable. The train and bus stations are (near each other) a 20 to 30 minute walk from the cathedral. It also puts you in central Madrid. Also the lowest carbon footprint, if you care about these things.