In how many ways can the letters in "WONDERING" be arranged with exactly two consecutive vowels ?
The solution is $18 \times 7!$ by classical counting technique
(because firstly choose $2$ adjacent vowels out of $3$ vowels by $3$ ways.Lets say we chose $O,E$ After that , arrange them by $2!\times (8!/2!)$ ways because there are double N. Result = $3 \times 8!$ . However , when we arrange $2$ vowels ,there will be cases where the third vowel $I$ is adjacent to them , so we must subtract the cases where $3$ vowels are adjacent. The result is $3 \times 2 \times 2 \times (7!/2!)$ , so the main result is $3 \times 8! - 3 \times 2 \times 2 \times (7!/2!) =18 \times 7!$) .
However , when i wanted to solve it by using formula , i encounter with different result.
My formula is $E_m=S_m - (\frac{m+1}{1})S_{m+1} + (\frac{m+2}{1})S_{m+2} - ...$ where $m$ represent the number of elements in $S$ that satisfy exactly $m$ of the conditions. Here , $S_m$ means that the number of the arrangements of $m$ adjacent vowels. For example $S_2= 3\times 8!$
Then , $E_2=S_2 - (\frac{2+1}{1})S_{2+1} =C(3,2) \times 2! \times \frac{8!}{2!} - 3 \times 3! \times \frac{7!}{2!} =15 \times 7!$
What am i missing ? This formula is working when the letters are CORRESPONDENTS , in that case , we write $C(5,2)[12! / (2!)^3]-C(3,1)C(5,3)[11! / (2!)^2]+C(4,2)C(5,4)[10! / (2!)]-C(5,3)C(5,5)[9!]$ for the case where there are exactly 2 pairs of consecutive identicsl letters.
However , the formula does not work for WONDERING , WHY ??
Your first calculation is correct.
Method 1: First, arrange the six consonants N, N, D, G, R, W. This can be done in $$\binom{6}{2}4! = \frac{6!}{4!2!} \cdot 4! = \frac{6!}{2!}$$ ways since we must select two of the six positions for the Ns, then arrange the remaining four distinct letters in the remaining six positions. This creates seven spaces in which to place the vowels, five between successive consonants and two at the ends of the row. $$\square C_1 \square C_2 \square C_3 \square C_4 \square C_5 \square C_6 \square$$ Choose one of those seven spaces in which to place a block of two vowels. To ensure that there are exactly two consecutive vowels, choose one of the six remaining spaces in which to place the remaining vowel. Arrange the three distinct vowels from left to right in the selected spaces in $3!$ ways. Hence, there are $$\frac{6!}{2!} \cdot 7 \cdot 6 \cdot 3! = 6! \cdot 7 \cdot 6 \cdot 3 = 18 \cdot 7!$$ distinguishable arrangements of the letters of the word WONDERING in which exactly two of the three vowels are consecutive.
Method 2: We apply the Inclusion-Exclusion Principle.
A pair of consecutive vowels: Choose which two of the three vowels will form a block. We now have eight objects to arrange, the six consonants, the block of two vowels, and the remaining vowel. Choose two of those eight positions for the Ns, arrange the remaining six distinct objects in the remaining six positions, then arrange the two vowels within the block. This can be done in $$\binom{3}{2}\binom{8}{2}6!2! = \frac{3!}{2!1!} \cdot \frac{8!}{2!6!} \cdot 6!2! = 3 \cdot 8!$$ ways, which agrees with your calculation.
However, we have counted each case in which there are two pairs of consecutive vowels twice, once for each pair of consecutive vowels. We only want to count such arrangements once, so we must subtract them from the total.
Two pairs of consecutive vowels: Since there are only three vowels, this can only occur if the three vowels are consecutive since the two pairs of consecutive vowels must overlap. Thus, we have seven objects to arrange, the six consonants and the block of three consecutive vowels. The objects can be arranged in $7!$ ways. The three vowels can be arranged within the block in $3!$ ways. Hence, there are $$7!3!$$ arrangements with two pairs of consecutive vowels.
Thus, by the Inclusion-Exclusion Principle, the number of distinguishable arrangements of the letters of the word WONDERING with exactly two adjacent vowels is $$3 \cdot 8! - 7!3! = 3 \cdot 8 \cdot 7! - 6 \cdot 7! = (24 - 6) \cdot 7! = 18 \cdot 7!$$ as we found above.
Notice that I subtracted the number of arrangements with two pairs of adjacent vowels from cases with one pair of adjacent vowels rather than subtracting arrangements with three consecutive vowels from arrangements with two consecutive vowels. This is where you made your error.