Multiple 40*40 to determine the actual square inches. Then multiply 5*9 to determine the square inches of the frame. Compare the two numbers. If 40*40 is bigger than 5*9, then the picture will not fit in the frame. If 40*40 is smaller than 5*9, then the picture will fit in the frame.
40^2= 40 * 40= 160" squared
5*9= 45" squared
A 160" squared picture would be too big for a 45" squared frame.
Hope this helps! :)