As many have stated before, Affliction is the specialization with the most complex optimal spell casting sequence in game. It depends on many variables. I recently sat down and tried to condense it into a spreadsheet. Here's a link to it:
AffSeq.xls
Note that the Spreadsheet isn't perfect, and omits three talents for reasons to be explained:
1) Death's Embrace. This talent has diffrent effects dependant on at what time the mob goes below 35%. It could be included by adding another 'below 35 time' variable, and adding another 'IF' to the base damages, that multiplies them with 1.12 after T > T35, with the latter being the condition. However, the 'below 35 time' is dependant on your own dps as well, thus reducing the model's accuracy. Just leaving it out means it'll be very accurate for the first 65%. To see the 'sequence' for after that, simply edit the spell base damages for all shadow spells to be multiplied with 1.12, and continue with your sequencing.
2) Nightfall and Eradication. These talents are RNG haste procs. There's no real way you can simulate them with a spreadsheet made like this, because the whole thing about the sheet is the assumption that haste stays approximately equal.
3) It also omits the Corruption glyph.
4) It assumes spell travel time is insignificant to the DPS outcome. This is a necessary assumption, as the first varies a lot from situation to situation.
The spreadsheet assumes that you have the following talents:
Ruin, ISB, Bane, Improved Corruption, Improved CoA, Improved Life Tap, amplify Curse, Empowered Corruption, Siphon Life, Shadow Embrace, Shadow Mastery, Contagion, Dark Pact (although you can easily leave this one out), Unstable Affliction, Pandemic, Everlasting Affliction and Haunt, all filled up.
With those assumptions, is it possible to easily experiment with rotations and dps? The answer is yes. The spreadsheet might appear daunting at first, and it works as follows:
1) There's some stats in the top-left corner of the screen. Damage, Spirit, Crit, Haste, Mana, and MPS should all be filled in with values after all talents and gear are factored in, so basically what you see on your Character sheet.
2) In the bottom-left, you might notice a table with 'action codes'. This is simply attaching a number to each spell.
3) Now the rest of the sheet mainly consists of a huge table, where the columns represent values, and the rows represent 'timestamps'. Basically, each time stamp exactly matches the casting of one spell. So if you wanted to see what your DPS, MPS, mana, etc. would become after casting corruption and then four shadowbolts with this spec, all you have to do is add '3,9,9,9,9' into the 'ACTION'-column.
Technical information: Question: What do all those values in the columns do?
Long Answer:
Note: A time frame is defined as all the time within a time stamp and the next time stamp.
Num, delta T, and T count the timestamps, their number, the diffrence between each stamp and the next, and basically the time of stamping respectively.
The plm.∂m/∂T column tells you the mana cost per second during each delta T.
The Mana column tells just how much mana you have at each time stamp.
The larger 'tick-timestamp'-section tells you exactly when which DoTs tick. Each number represents the time-stamp of a DoT tick. Notice how CoA has two rows since the largest time stamp diffrence (2.5) is larger than it's ticking time (2).
The 'damagers' section tells you how much damage each of your spell (components) deal in each time-frame.
The next three columns tell the total damage in each time stamp, the grand damage total, and the average dps so-far. Note that the latter number will tend be smaller for shorter fights because of the nature of DoTs.
The next two columns are to determine for how much of each timeframe haunt is active. Normally it's 0 or the length of the time-frame, but it might be haunt just pops off in the middle of a time-frame. When that happens, we need to know which DoT ticks within the time frame were affected by the haunt buff and which ones not.
The next six columns basically show you the time all of the DoTs have left on the target at the time of the time-stamp. So a '23' in the UA column at the '15.6' timestamp means your UA has 23 seconds left 15.6 seconds into the fight with your cast sequence.
All of the next columns are models for the uptime of ISB and Shadow Embrace similar to the haunt one.
Question: How do I actually determine my 'best sequence'?
Answer: There's no way to tell that immediately other than to enter your stats and start experimenting with spell orders. When doing that, make sure you do only legal things. (This means that you keep your mana above zero, don't cast haunt before the cooldown is off, and more such things).