First we'll arrange the books only subject-wise, as if the math books were
indistinguishable and the science books were also indistinguishable. Then we'll
rearrange (permute) them.
We start out with this configuration of all 5 math books with only 3 of the
science books separating them.
_ M S M S M S M _
I have underlined the 5 places we can put the other two science books. Each of
the three underlined S indicates that you can put one or both of them in with that
S, since science books can be placed together. The 2 empty underlines indicate
places where they can go as well, left or right of the others.
Case 1. You imagine "gluing" the 2 science books together and inserting the
"glued pair" in one of those 5 underlined places. That's 5 ways.
Case 2. You pick 2 separate underlined places to put them separately in. That's
C(5,2)=10 more ways.
So altogether, there would be only 5+10=15 ways to arrange them if the math
books were indistinguishable, and the science books were also indistinguishable.
But since none are indistinguishable books, we multiply by 5! to permute the
science books and by 4! to permute the math books.
Answer (15)(5!)(4!) = (15)(120)(24) = 43200 ways.
Edwin