On page 347 in his "Mathematical Thought, volume 1", Morris Kline writes:
"The work on the third class of problems, finding the maxima and minima of functions, may be said to begin with an observation by Kepler. He was interested in the shape of casks for wine; in his Stereometria Doliorum (1615) he showed that, of all right parallelepipeds inscribed in a sphere and having square bases, the cube is the largest. His method was to calculate the volumes for particular choices of dimensions. This in itself was not significant; but he noted that as the maximum volume was approached, the change in volume for a fixed change in dimensions grew smaller and smaller. Fermat in his Methodus ad Disquirendam gave his method, which he illustrated with the following example: Given a straight line (segment), it is required to find a point on it such that the rectangle contained by the two segments of the line is a maximum. He calls the whole segment B and lets one part of it be A. Then the rectangle is AB - A2. He now replaces A by A + E. The other part is then B - (A + E), and the rectangle becomes (A + E)(B - A - E). He equates the two areas because, he argues, at a maximum the two function values-that is, the two areas--should be equal, etc."
I am not sure if Kline implies a connection between Kepler and Fermat here but it would certainly be interesting to explore the issue.
Question. Did d'Espagnet's library at Bordeaux that Fermat had access to, contain works by Kepler?
Note that Mahoney's book on Fermat does not discuss such a possible influence directly.
Note 1. Related question at MO on d'Espagnet's library.