There's an old story about a farmer who decided to hire a scientist so he could impress all his friends, and after a few months of work, the scientist announced he was ready to present his results, so all the farmers came over to see what he'd come up with. And he drew a circle on the blackboard, and said "assume a spherical cow of uniform density..."
You have certainly done a wonderful job of constructing a model of a spherical melee of uniform density, but in the 35+ years I've been playing, I don't think I've yet ever seen a fight for which the necessary simplifying assumptions would apply. You've quantified what the impact of a fireball would be in a circumstance that doesn't actually happen, and the answer as to its actual impact is "that depends a great deal on the specific ways in which this combat is different from the arbitrary assumptions".
In the fights where I've seen a large number of creatures with the same number of hit points, they've most often been weak creatures that a fireball would probably take out. When there's tougher creatures, they don't have the same number of hit points, they don't do the same amount of damage, some of them are healers or buffers/debuffers whose primary action isn't attacking, and so on -- so an evaluation of what a fireball would do on M creatures with KD hit points turns out to have no relevance at all to an evaluation of the choices you'd make in the real situation.
In real combats, it is extremely rare to be able to conveniently arrange to focus all damage on one target at a time in turn, so it's fairly common to have situations where there's many somewhat-wounded targets. And they might not be wounded enough for a fireball to kill them -- but if they're wounded enough that two fireballs would kill them, or that a fireball would bring several of them down to a point where a single good attack could drop them, that will impact healing choices, if there's a healer available. Which there might not be.
You have certainly done a wonderful job of constructing a model of a spherical melee of uniform density, but in the 35+ years I've been playing, I don't think I've yet ever seen a fight for which the necessary simplifying assumptions would apply. You've quantified what the impact of a fireball would be in a circumstance that doesn't actually happen, and the answer as to its actual impact is "that depends a great deal on the specific ways in which this combat is different from the arbitrary assumptions".
In the fights where I've seen a large number of creatures with the same number of hit points, they've most often been weak creatures that a fireball would probably take out. When there's tougher creatures, they don't have the same number of hit points, they don't do the same amount of damage, some of them are healers or buffers/debuffers whose primary action isn't attacking, and so on -- so an evaluation of what a fireball would do on M creatures with KD hit points turns out to have no relevance at all to an evaluation of the choices you'd make in the real situation.
In real combats, it is extremely rare to be able to conveniently arrange to focus all damage on one target at a time in turn, so it's fairly common to have situations where there's many somewhat-wounded targets. And they might not be wounded enough for a fireball to kill them -- but if they're wounded enough that two fireballs would kill them, or that a fireball would bring several of them down to a point where a single good attack could drop them, that will impact healing choices, if there's a healer available. Which there might not be.