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.
Your sorcerer cannot swap in a 2nd level spell
As you have noted, multiclassing rules state that:
You determine what spells you know and can prepare for each class individually, as if you were a single-classed member of that class.
When you are replacing spells, you are determining what spell you no longer know, and what spell you do. That is, put more generally, you are determining what spells you know from one of your classes. So, the multiclassing rules apply.
In your example, you determine what spells you know as if you were only a level 2 sorcerer and nothing else. A pure level 2 sorcerer has no 2nd-level spell slots, so they cannot not replace a known spell for a 2nd-level spell at level up. And by following the multiclass rules, that tells us that a multiclassed level 2 sorcerer also cannot replace one of their known sorcerer spells with a 2nd-level spell either.
Best Answer
No.
Multi-classing rules for spells are described in detail on page 164 and 165 of the Player's Handbook. The paragraph on page 164 that begins with the bolded text "Spell Slots." tells you how to calculate what "Lvl." you should use for the purposes of consulting the table on page 165. The table, in turn, determines how many spell slots you have.