How can I calculate the optimum loiter airspeed for an aircraft?
The optimum cruise speed is the speed at which fuel consumption is minimized per unit of velocity. So, you need to compute the derivative (C/v)' where C is rate of fuel consumption and v is rate of travel (airspeed). (I assume you want this by "loiter". If you want to minimize fuel consumption, that is called "maximum endurance" and that is explained below on the chart.)

Since fuel consumption is proportional to power, and power divided by velocity is thrust, we can graphically determine this point by the thrust required curve. The diagram below shows the relevant relationships:



So, to compute the optimum cruise speed, first draw the thrust-required curve, as shown in the lower part of the diagram above, then you draw a line from the origin tangential to the thrust required curve. The point of tangency lies above the optimum cruise speed on the x-axis.

Maximum Endurance

If by "loiter" your goal is to minimize the fuel flow while maintaining a particular altitude, then you use the power required chart (the upper chart in the figure above). The fuel flow is proportional to power, so the maximum endurance speed is found by locating the lowest point on the power required curve. In the example above, that point is located at 80 CAS. Mathematically, the maximum endurance is found by solving the equation P'=0, where P is the power required function.