How to include successful saves when calculating Fireball’s average damage?

I want to know how to calculate the average damage of a spell that also deals half damage on a successful save. For this example, I’ll be taking the most popular evocation spell, Fireball.

As far as calculating damage goes, I know how to calculate the expected damage of attacks using an attack roll, using the following formula:

Expected damage = Probability x Damage + Crit chance x Additional damage on crits
Probability = (21 – target’s AC + attacker’s attack roll modifiers) x 5%

Now I would assume that you just need to reverse the probability formula to calculate a spell that forces a saving throw’s chance of success, like so:

Probability = 1 – (21 – your save DC + target’s save modifiers) x 5%

However, calculating Probability x Damage (omitting the crit chance in the process) using the above formula does not take into account the half damage dealt on a successful save. So how to take this into account when calculating expected damage of spells like Fireball?