**Diminishing returns = decreasing derivative**

- Since you still want some returns even at higher levels means that the derivative should be positive, otherwise building more farms would decrease the food production (which might even make sense if you take into account logistics and upkeep costs)
- It should approach zero assymptotically, if it goes towards a non-zero value you will end up with constant increase per farm at some level
- depending on how fast it goes to zero you can have an upper limit or an unbounded function

So what do you need to do? Pick a function that fits the above criteria and integrate it.  
The simplest choice for this task is `g(t,n) = 1/(t+1)^n` where `n=1` marks the boundary between ever increasing and bounded functions.  
The integral of g from 0 to x is what you need: `f(x,n) = ((x+1)**(1-n) - 1)/(1-n)`  
Here is how it looks for different `n`

![enter image description here][1]
And here its normalized to the same final value

![enter image description here][2]
By changing the exponent `n` you can easily adjust the balancing


  [1]: https://i.sstatic.net/l91M5.png
  [2]: https://i.sstatic.net/uaVLY.png