I'm a programmer an I think my problem related to mathematics! I want when CPU have a static percentage of load (for example $10\%$) fan also have static rpm (Rotations per minute). But for now I have very change in fan speed when CPU have a static percentage of load. I try the follow algorithm and have this problem:
if (temp > max_temp)
speed := full_speed
else if (temp < min_temp)
speed := min_speed
else
speed := min_speed +
(full_speed - min_speed)*((temp - min_temp)/(max_temp - min_temp))
This is a control problem rather than mathematics, but as there is no Control SE we might as well discuss it here.
In the absence of limiting you need to adjust the fan speed to achieve whatever you desire, I will assume you wish to control the temperature $c$ to a set value $c_{dem}$ by varying the fan speed $v$.
One of the simplest ways of doing this is using proportional control, this would use approximate knowledge of the relationship between the fan speed and temperature $c=f(v)$, then set the fan speed accordingly. The problem with this is that the relationship between fan speed and temperature is not fixed but depends on a number of factors you don't know, like the ambient temperature and the processor loading.
The next simplest way of approaching this is derivative control (which is what I would recomend), where the rate of change of fan speed is set proportional to the temperature error:$$ v'=k(c-c_{set}) $$ With such a control law the fan speed arrives at a constant value when the temperature error is zero. There is a problem here in choosing an appropriate gain $k$ in that we don't know the relationship between fan speed and temperature. You will probably need to find an acceptable gain by trial and error.
The control law will need to be discretised for use in your code, this should give you something like:$$ v_{new}=v_{old}+k \Delta t (c-c_{set}) $$ where $\Delta t$ is the control loop update time step.