From the SRD:
Bonus Spells (by Spell Level)
Score 0 1 2 3 4 5 6 7 8 9
----- - - - - - - - - - -
1 Can't cast spells tied to this ability
2-3 Can't cast spells tied to this ability
4-5 Can't cast spells tied to this ability
6-7 Can't cast spells tied to this ability
8-9 Can't cast spells tied to this ability
10-11 - - - - - - - - - -
12-13 - 1 - - - - - - - -
14-15 - 1 1 - - - - - - -
16-17 - 1 1 1 - - - - - -
18-19 - 1 1 1 1 - - - - -
20-21 - 2 1 1 1 1 - - - -
22-23 - 2 2 1 1 1 1 - - -
24-25 - 2 2 2 1 1 1 1 - -
26-27 - 2 2 2 2 1 1 1 1 -
28-29 - 3 2 2 2 2 1 1 1 1
30-31 - 3 3 2 2 2 2 1 1 1
32-33 - 3 3 3 2 2 2 2 1 1
34-35 - 3 3 3 3 2 2 2 2 1
36-37 - 4 3 3 3 3 2 2 2 2
38-39 - 4 4 3 3 3 3 2 2 2
40-41 - 4 4 4 3 3 3 3 2 2
42-43 - 4 4 4 4 3 3 3 3 2
44-45 - 5 4 4 4 4 3 3 3 3
etc. . .
Thus...
[(1/2x, rounded down)-5] = number of bonus spell levels, maximum of 9
[(1/2x, rounded down)-2]/4 (rounded down)= number of bonus 1st level spells.
[(1/2x, rounded down)-3]/4 (rounded down)= number of bonus 2nd level spells.
[(1/2x, rounded down)-4]/4 (rounded down)= number of bonus 3rd level spells.
... thus...
X= Primary Characteristic
N= Spell Level
[(1/2x, rounded down) - (N+1)]/4 (rounded down)= number of bonus spells for level N.
Hope that helps,
Greg