No disrespect to Al-Ghazali Psyah Bahi;
But I disagree with the detailed and yet in itself flawed definition.
First of all it is not a definition purely by itself, it is a comparison between stupidity and insanity.
and;
How do we know that the intention of insane person is not sound?
The means of realizing it are defective in both kind of people.
Both choose what should not be chosen.
Hence the basis of the decision and ‘preferences’ are same in both.
For a person to be called insane and not be labled merely as stupid, the same act must be performed consistently and irrationally.
A stupid person has temporary insanity by what I understand.
Also, stupid is just a lighter term and insanity is more of a heavy and serious term.