My initial investment is $\$100,$ and I earn $1\%$ interest per day. I can opt for any number of compoundings per day (if twice per day, then the interest rate per compounding period is $0.5\%,$ and so on), but I have to pay $\$0.01$ each time my interest is compounded. After $365$ days I will close the account.
What would this equation look like, and how should I include this to maximize my total deposit? How to generalize and figure out a good or optimal maximization?