I remember when I was younger I had bad depression, and as a result I was put on several different drugs. One in particular, Tegretol, made me especially good at math. I remember seeing a drastic change. My memory suffered, but my ability to think logically and carry on long trains of thought increased significantly.
However, it didn't help the primary reason I was put on it, so I switched. I ended up taking Prozac, which didn't do anything for the thought process but really helped me with the depression.