Do I need a medium or large cage rear derailleur? My SRAM x5 rear derailleur got caught on something and broke. I went to order a new one and learned there are different cage sizes. I don't know which size cage I currently have. While trying to figure out which one I need I figured out that I need to know my Total Drivetrain Capacity. All of the sources that I have come across say 

Maximum Chainring Difference + Maximum Cassette Cog Difference = Total Drivetrain Capacity

Not sure what the formula is when you only have 1 chainring. The answer to this question appears to just be 

Maximum Cassette Cog Difference = Total Drivetrain Capacity

Is that correct? So in my case it would be 34 - 11 = 23? So a medium cage would be plenty? The sources I have come  across say if in doubt, get a large. I would rather have a smaller cage though to hopefully not have it catch on something again. 

My current setup
Crankset: alloy arm with 34T single ring
Shifters: SRAM x4 9 speed
Rear Derailleur: SRAM X5, 9 Speed
Rear Cogs: SRAM PG950 Cassette, 9 Speed, 11-34T

SRAM x5 medium cage specs 
Largest Cog: 34
Chain Wrap Capacity: 37 

SRAM x5 long cage specs
Largest Cog: 36
Chain Wrap Capacity: 45
You have it right. Between medium and long cage, medium is the one to get here.

As you say, you only need a capacity of 23, which is short cage. SRAM is still listing a short cage X7 on their site, but I couldn't find anyone selling or distributing it. If you can track one down and if you're staying with this gearing, that would be more ideal than medium cage. But the medium X5 is fine too. Sadly the short cage 10-speed GX with a clutch is not compatible.