Summary ('TLDR')
For most planets, to optimise income in respect of building farms, morale buildings, and economy buildings, you should get all economy buildings except for the planet containing your economic HQ, and/or planets where you'll be devoting at least 12 spaces to these types of building, where you should get 1 farm (or use your capital planet which effectively already has 1 farm).
Background/overview
One thing that confused me for a while was how TotA calculates income - a few google searches turned up some forum posts which gave some suggestions, but these weren't always consistent with in-game results, and/or only considered certain aspects (e.g. https://forums.galciv2.com/453640/page/1/#3461773).
Picking the game up again after many years, I thought I'd look at this properly, and have summarised my own notes on how income and approval are calculated below for people looking for a useful starting point (using TotA v2.20).
If anyone has looked into this further, please feel free to give any comments or refinements, as one point I've not been able to get to the bottom of is how the game calculates the base level of income given across different maps. There's also the possibility I've made an error somewhere along the way in my calculations!
Income formula
The gross income generated by a planet can be estimated with the following formula:
Income = {BaseIncome} * {Population}^0.5 * (1+{PlanetEconBonus}) * (1+{RaceEconBonus}) * (1+{GovernmentBonus}) * {TaxRateMod} * {20kIncomeMod}
I've included further comments on each of these variables below:
{BaseIncome}: I've been unable to figure out what determines this, as it varies between worlds (but not usually on the same world). It doesn't appear to change based on changes in the other variables noted above, research points spent, turns elapsed, or planets colonised (based on limited testing). For an 8bn population planet with 0 bonuses and a 100% tax rate, the base income suggested has varied between 45 to 62. When testing, I've not been able to significantly change this base income factor during the game (the amount that minimises the error rate of the formula at most might change by 1-2 units in the 45-62 scale, which is likely due to the impact of rounding for some of the data points).
{Population} - current population of the world
{PlanetEconBonus} - total planet economic bonus
{RaceEconBonus} - Total government/race economic bonus (i.e. aggregate of starting race bonus, research bonus, starbase bonus etc.)
{GovernmentBonus} - 0, 0.1, 0.2 or 0.4 depending on the type of government
{TaxRateMod} - interestingly, the tax rate chosen has a slightly different effect on the income than expected. If taking a 100% tax rate as a starting point, then an 80% tax rate would yield 80.8% of the income, 60% rate would yield 61.8% of the income, 40% rate 42.7%, and 20% 22.16% of the income (essentially, if you multiply the tax rate by a factor, then for tax rates from 1% to 29% the factor is 1.108, and after this point the factor decreases slightly as the tax rate increases, up to a factor of 1 for 100%)
{20kIncomeMod} - If your total credits are more than 20k, you suffer a penalty on income generated by planets. The penalty amount will vary based on the planet's income level. For example, a planet with 100 income (at below 20k) would suffer a 20.8% reduction; at 200 income it'd be a 22.9% reduction, at 400 income it'd be 25.9%, at 800 income 28.5%, and at 1600 income 30.8%
Approval formula
A planet's approval rating can be estimated by the following formula:
1 + {PopulationMoraleMod} * (1 + {PlanetMorale} + {RaceMorale}) + {PlanetQualityMod} - {TaxRateMod}
I've included further comments on each of these variables below:
Population morale mod: I took a lazy way out and approximated the approval mod based on different data points rather than trying to come up with a formula to determine it, but it can be approximated as follows based on each 1bn of population:
PopulationMoraleMod = 1 - {PopulationReduction}
Population reduction: marginal impact per each 1bn of extra population:
<1bn: 0
1-2bn: 0.01
3-4bn: 0.02
5-10bn: 0.03
11-18bn: 0.04
19-25bn: 0.05
25bn+ capped at a total reduction of 0.9
e.g. at 16bn, the population reduction will be 0.48. This impacts the benefit you get from morale bonuses, so you only get 52% of any morale bonus.
{PlanetMorale} - total morale bonus for the planet
{RaceMorale} - total of any morale boosts (race starting bonus; research bonus; trade goods, etc.)
{PlanetQualityMod} - 0.1 if the planet class is 11 or more, 0 otherwise
{TaxRateMod} - This ranges from 0 at 0% to -1.99 at 100%. Since there are a number of intervals where the approval drops significantly for just a 1% change in tax rate, I just got data for each 1% change rather than trying to come up with some weird formula to calculate it. E.g. 90% rate is -1.76, 80% rate is -1.23, 70% rate is -1.07, 60% is -0.83 and 50% is -0.65
Optimal building allocation scenarios
Starting scenario - mid-late game
Based on the above formula, I was then interested in what it meant for allocating buildings between food, morale and economic bonuses for a planet. For example, as an initial scenario, take a reasonably well advanced research tree, with access to the best food, morale and economic buildings, a 75% morale race boost, use of 1 counter espionage centre, a good quality planet (>=11), a 60% target approval (I lost some votes on a lower approval for a star federation but not at this level), star federation, a race economic bonus of 45%, <20k credits, and a base income factor (at 8bn) of 60 (this is to give a comparator for income amounts when changing over variables; the actual amount of income, as noted above, may be different).
If varying the number of spaces to devote to 'economy', the optimal allocation was:
1-8 buildings: all spaces to economy, with a 79% tax rate
9-11 buildings: 2 morale buildings, rest to economy, with a 94% tax rate
12-29 buildings: 1 food building, 4 morale buildings, rest to economy, with a 99% tax rate
30 buildings: 2 food buildings, 7 morale buildings, rest to economy, with a 100% tax rate
That is, the fact that population only boosts income by its square root means it's usually preferable to boost morale (to improve tax rate) or the economy bonus, than to improve the population (ignoring other benefits such as defence against invasion).
Economic capital
With an economic capital, the numbers for that planet in isolation make it better to get farms earlier, although the optimal allocation will be different since you'll want to set your tax rate (and number of morale buildings) based on your other planets:
1-4 buildings: all economy, 79% tax rate
5-8 buildings: 1 food, 1 morale, rest econ, 77% tax rate
9-26 buildings: 1 food, 4 morale, 100% tax rate
27-30 buildings: 2 food, 7 morale, 100% tax rate
Since you can only have a unified tax rate, in the above scenario you'd probably want to stick with a tactic of 8bn planets with all buildings put to economy, at a c.78% tax rate.
Morale tile boosts
One variant to the above analysis is if you have a morale boosting tile. In the first scenario noted above, he numbers change to the below if the planet has 2 morale tile boosting tiles (each giving +100% morale bonus to the morale building):
1-2 buildings: All econ, 79% tax rate
3-5: 1 morale rest econ, 94% tax rate
6-29: 1 food, 2 morale, rest econ, 100% tax rate
30: 2 food, 5 morale, rest econ, 100% tax rate
Lower tech scenario
The numbers don't change noticeably if looking at a lower tech version with lower race/global boosts to economy and morale. For example, taking the first scenario above, and then assuming extreme entertainment, banking centers and star democracy are unlocked, with no starting econ or morale bonus (and only +20% from trade goods), and the other assumptions unchanged (including access to +50% farms), this would suggest an optimal allocation of:
1-7 buildings: all econ, 67% tax rate
8-10: 1 morale, rest econ, 74% tax rate
11-22: 1 food, 3 morale, 77% tax rate
23-24: 1 food, 7 morale, 95% tax rate
25-30: 1 food, 8 morale, 100% tax rate
Special case of the Yor
The Yor don't get economy buildings, and their morale and food buildings are combined. In addition, they don't get access to governments.
Since Yor will struggle with their economy, I've assumed for the scenario they've maxed the econ research bonuses, and have max economy for their starting abilities, and are the federalist party, leading to a 125% economy boost.
The next question is what approval rating to target. Essentially the Yor's variables are just the number of income buildings to build (they have 1 building, which gives food and morale, ignoring 1-off buildings), their tax rate, and the population. In contrast to the above scenarios which targeted 60% approval (meaning maximum population would always be reached), the Yor instead will have their population limited by the 40% approval threshold, and hence can settle at a level below maximum. Therefore, lowering the tax rate can then increase the population size.
Applying the formula to the above scenario results in the following income achieved for each of the stalk food/morale building produced (based on the optimal tax rate) - I've given a few samples of the data rather than listing it all (income values are net of stalk maintenance costs):
1 building: 80% tax rate; 128 income
3 buildings: 80% tax rate, 151 income
6 buildings: 100% tax rate, 173 income
10 buildings: 98% tax rate, 189 income
20 buildings: 100% tax rate, 199 income
30 buildings: 57% tax rate, 257 income
For a reference point, in the first scenario above each stock market would be giving c.23 extra income for each building. The Yor's additional income for each building is 19, then 16, then 9. I.e. it's only really worth getting 2 stalks and no more.
Conclusion
Therefore it looks like farms (food buildings) from an income perspective are a very poor investment, and even on high quality planets (using all their spaces for economy) with an economic HQ the optimal income is likely to be achieved with only one 1 farm.
The main choice early on is whether to get morale buildings to support a higher tax rate or not. Although the above scenarios suggest you should usually focus on econ buildings, the difference between the two was closer, especially if you have a low overall morale bonus and/or morale boosting tiles.
For most races I expect a reasonably optimised position would be to go with all econ buildings for most planets (8bn size, <=8 spaces devoted to economy), to get 1 farm on the planet with your economic HQ, to get at least 1 morale building where you have bonus morale tiles (only get 2 if >=7 spaces are spent on income), and then to set the tax rate to a level where you don't lose votes for your government.