Two mathematics books, 5 different physics books and 3 different chemistry books are to be arranged on a shelf. How many arrangements are possible if a) books on the same subject must stand together? b) only the physics books must stand together?

a) To solve this problem, let's first consider each group of books (mathematics, physics, and chemistry) as a single item. We have 3 items (groups of books) to arrange, which can be done in 3! = 3 × 2 × 1 = 6 ways.

Now, we have to arrange the books within each group. For the mathematics group, we have 2 books, which can be arranged in 2! = 2 ways. For the physics group, we have 5 books, which can be arranged in 5! = 120 ways. And for the chemistry group, we have 3 books, which can be arranged in 3! = 6 ways.

To find the total number of arrangements, we multiply the number of ways to arrange the groups and the number of ways to arrange the books within each group: 6 (group arrangements) × 2 (math) × 120 (physics) × 6 (chemistry) = 8640 arrangements.

b) To solve this problem, let's first consider the 5 physics books as a single item. We then have 6 total items (2 math books, 1 group of physics books, and 3 chemistry books). We can arrange these 6 items in 6! = 720 ways.

Now, we need to arrange the physics books within their group. As before, this can be done in 5! = 120 ways.

To find the total number of arrangements, we multiply the number of ways to arrange the items and the number of ways to arrange the physics books within their group: 720 (item arrangements) × 120 (physics) = 86400 arrangements.