Final answer:
There are 24 ways to place the 9 textbooks on the bookshelf, following the given restrictions.
Step-by-step explanation:
To solve this problem, we can break it down into several steps. Firstly, we need to place a mathematics textbook at each end, which leaves 3 mathematics textbooks and 4 psychology textbooks to be placed in the remaining spaces on the bookshelf. Secondly, since there must be a psychology textbook exactly in the middle, we have restricted one space for a psychology textbook. This leaves 2 mathematics textbooks and 3 psychology textbooks to be placed in the remaining spaces.
Now, we can calculate the number of ways to arrange these remaining textbooks on the bookshelf. We have 2 choices for the first mathematics textbook, then 3 choices for the first psychology textbook, then 2 choices for the second mathematics textbook, and finally 2 choices for the second psychology textbook. Using the multiplication principle, we can multiply these choices together to calculate the total number of arrangements: 2 * 3 * 2 * 2 = 24.
Therefore, there are 24 ways to place the 9 textbooks on the bookshelf, following the given restrictions.