With an ultimate magus, it’s more important to keep yourself as close as possible to a single-classed spellcaster on one side than it is to keep the two even.
Thus you want to circumvent as much as possible ultimate magus’s attempts to progress your lower-level class.
Because at 1st, 4th, and 7th level, ultimate magus advances the class with lower caster level (your choice in the case of a tie), this has a tendency to even out your two classes. If you avoid that, and continue to progress in the more advanced class, you will have more of your highest-level spell slots, which are also higher level than they would be.
Practiced Spellcaster is the solution to taking manual control over which class ultimate magus progresses. Practiced Spellcaster increases a class’s caster level (but no other facet of its spellcasting) by up to 4 (capped at the spellcaster’s HD, so the feat is only beneficial to multiclassed spellcasters). Normally, caster level is nice but not as crucial as things like spell slots or higher spell levels. Ultimate magus switches this up, though.
If a Wizard 4/Sorcerer 1 takes Practiced Spellcaster for sorcerer, his weaker class, his sorcerer caster level is 5th. This puts it higher than his wizard spellcasting’s 4th caster level, so first level of ultimate magus advances wizard. This is despite the fact that the ultimate magus’s wizard spellcasting is, for most purposes, more advanced than his sorcerer spellcasting.
Now you have some control over your advancement, and that allows you to maximize your spell slots.
At 4th level, both classes are even, so you should choose wizard. At 7th, barring finding some other bonus to sorcerer caster level, though, you have to accept some sorcerer progression, which is a shame but not the end of the world. You’ll end up “missing” a total of two wizard spellcasting levels (compared to a single-classed wizard), but gain a total of nine sorcerer levels, plus of course all the rest of the ultimate magus class features.
Otherwise, you need to improve the abilities that grant you bonus spells. Consider the beguiler (Player's Handbook II) instead of sorcerer: you'll use Intelligence for both classes.
Versatile Spellcaster is another feat that will make your slots more flexible.
And pearls of power and rings of wizardry can help by letting you reuse slots. Memento magicka are like pearls of power for spontaneous spellcasters but they are 50% more expensive, which is badly overpriced.