His profits are 13x - (x^2 + 5x + 7) if x <= 3 and 13x - (x^2 + 5x + 7) - 3(x - 3) if x > 3.

Assuming x <= 3; the maximum for f(x) = 13x - (x^2 + 5x + 7) = -x^2 + 8x - 7 is where f'(x) = 0. f'(x) = -2x + 8, solving -2x + 8 = 0 gives x = 4.

Assuming x > 3; the maximum for g(x) = 13x - (x^2 + 5x + 7) - 3(x - 3) = -x^2 + 5x + 2 is where g'(x) = 0. g'(x) = -2x + 5, solving -2x + 5 = 0 gives x = 2.5.

This means our combined curve has a positive derivative for x <= 3 (since f(x) goes to x = 3 and grows to x = 4) and negative for x > 3 (since g(x) starts at x = 3, but starts decreasing already at x = 2.5). Conclusion: his profits are maximized @ x = 3.