The magic number would be correlated with long term real economic growth rate. Trying to set the money supply growth constant at 2% is likely closer than setting it to 0% yet it has the same flaw that if your number is lower than the observed monetary demand, you will get deflation, if your number is higher you will have built in inflation.
If the algo to set money supply growth rate can take in real values of what is transacted on a regular basis then it would solve the problem completely. Not sure if this is feasible.
What variables would need to taken in?
For example take a look at Bitcoin mining with the massive resources being put towards it. This is clearly a case of huge monetary demand, would the perfect algorithm increase or decrease the supply based on that demand? Would it be better to disallow mining altogether and use another variable, perhaps unique transaction info? In that case only transactions between aged unique wallets might allow for a input to allow for inflation or deflation. (aged wallets that are only transferring between other unique wallets that do not have too many connections to determine that they do not belong to the same person)