I believe you need to double check your return statement. If you want to refer to $sum_store outside the function, return that instead of $sum 😛
Now if $sum_store is a variable outside the function, you ought to pass it in by reference like so:
function do_math($a, $b, $delta_x, &$sum_store)
{
// ... your beautiful code in here
return $sum;
}
In this way, any changes to $sum_store in the function will affect the variable outside of it. I recommend you do this instead of making it global since that leads to problems if you call do_math() from within another function.
Is clear? If not, the documentation on "pass-by-reference" should answer many more of your questions.