Using the following values:
p = initial value = 2500
n = compounding periods per year = 12
r = nominal interest rate, compounded n times per year = 4% = 0.04
i = periodic interest rate = r/n = 0.04/12 = 0.00333333
y = number of years = 5
t = number of compounding periods = n*y = 12*5 = 60
d = periodic deposit = 100
The formula for the future value of an annuity due is
d*(((1 + i)^t - 1)/i)*(1 + i)
See Calculating The Present And Future Value Of Annuities
In an annuity due, a deposit is made at the beginning of a period and the interest is received at the end of the period. This is in contrast to an ordinary annuity, where a payment is made at the end of a period.
The formula is derived, by induction , from the summation of the future values of every deposit.
The initial value, with interest accumulated for all periods, can simply be added.
pfv = p*(1 + i)^t = 3052.49
total = pfv + fv = 3052.49 + 6652 = 9704.49
So the overall formula is