Clearly, the optimal number of trees is at least 20 per hectare. If there were fewer than 20 trees, we could add more trees without decreasing the number of apples per tree.
So let's say the number of trees is t+20. Then the number of apples produced per tree is 600-15t; we start at 600 when t=0 (at 20 trees), and decrease by 15 per extra tree.
The total number of apples produced is (number of trees) times (number of apples per tree), which is now (t+20)(600-15t). We need to maximize this quantity.
Expand the product: 600t+12,000-15t2-300t=12,000+300t-15t2. We can maximize this by completing the square.
First take out the -15: -15(t2-20t-800)
When a quadratic like is written as (x-a)2, it expands as x2-2ax+a2. In our case, -2a=-20, so a=10 and a2=100
Rewrite the expression as -15(t2-20t+100-100-800)=-15((t-10)2-900)=13,500-15(t-10)2
Remember, we're trying to pick t (20 less than the number of trees) to maximize this expression for the number of apples produced. Since (t-10)2 is always positive, we've expressed the number of apples as 13,500 minus (a positive number); clearly, we want to subtract 0 from the amount of apples, so we set -15(t-10)2=0 and solve.
(t-10)2=0
t-10=0
t=10, so there are 10+20=30 trees
So we get a maximum of 13,500 apples when there are 30 trees.