First, we should distinguish between "fasting" and "calorie restriction" because they are two quite different fields of study. Fasting is abstaining from food, while calorie restriction simply means consuming less energy-producing food such as carbohydrate and fat. There is some evidence on positive mental functioning on caloric restriction, particularly on the memory of elderly [1, 2]. However, a recent randomized controlled trial on 48 adults did not find any difference between the cognitive functions between the caloric restricted group and the comparison group . The general conclusion is that larger and longer human studies are needed.
In animal models, much more have been done on restrictive calories and longevity and so far in the tested animals, there have been some good results. However, the one most commonly tested subject is just fruit fries . We still have a long way to go until we can see some human data.
Now, fasting is a completely different story. In terms of research, scientists have not ventured into studying fasting as a healthy behavior but rather from the angle of school performance and breakfast consumption. Two studies that involve school children reveal a general benefit of NO fasting. One concluded that both overnight and morning fasting regimes can “included slower stimulus discrimination, increased errors, and slower memory recall.”  And another one describes a “gain some, lose some” effect that fasting hurts the accuracy during problem solving, but enhances immediate recall in short-term memory . I haven't been able to identify similar studies done on adults; the results could differ in another age range.
I would suggest that informed caloric restriction is perhaps a better approach: fasting is associated with too much risk, and its benefits have been largely anecdotal. One particular risk is that prolonged fasting can increase the concentration of a chemical called ketones in our body. Ketones are formed when our body has to resort to rely on fat as the primary energy producer. Too much ketones in our body can cause loss of consciousness. However, this is an extreme outcome in famine, prolonged ketogenic diets , and poorly managed diabetes. Usual therapeutic type of fasting is unlikely to cause a healthy person to fall into coma. The reason of mentioning this ketone chemical is that the perceived “clear mind” in a lot of fasting participants could be an indicator of mild ketone intoxication. If you have not fasted before and would like to try it, consult some professionals (dietician, physician, and fasting treatment specialist) before doing so. Do not attempt fasting by yourself without noticing anyone, especially if you have metabolic diseases such as diabetes.
- Gillette-Guyonnet S, Vellas B: Caloric restriction and brain function. Current opinion in clinical nutrition and metabolic care 2008, 11(6):686-692.
- Witte AV, Fobker M, Gellner R, Knecht S, Floel A: Caloric restriction improves memory in elderly humans. Proceedings of the National Academy of Sciences of the United States of America 2009, 106(4):1255-1260.
- Martin CK, Anton SD, Han H, York-Crowe E, Redman LM, Ravussin E, Williamson DA: Examination of cognitive function during six months of calorie restriction: results of a randomized controlled trial. Rejuvenation research 2007, 10(2):179-190.
- Pijl H: Longevity. The allostatic load of dietary restriction. Physiology & behavior 2012, 106(1):51-57.
- Pollitt E, Cueto S, Jacoby ER: Fasting and cognition in well- and undernourished schoolchildren: a review of three experimental studies. The American journal of clinical nutrition 1998, 67(4):779S-784S.
- Pollitt E, Leibel RL, Greenfield D: Brief fasting, stress, and cognition in children. The American journal of clinical nutrition 1981, 34(8):1526-1533.
- Hartman AL, Vining EPG: Clinical aspects of ketogenic diet. Epilepsia 2007, 48(1):31-42.