Applied mathematics for optimization processes in medical treatments: radiotherapy and radiosurgery