It might be worth seeing somebody; you may be suffering from burnout or depression. 40 is not the age you'll see cognitive decline; rather, in many situations, you will begin to approach peak mastery. That's not to minimize or say that you may be experiencing some kind of true decline; rather, it's that I think it's potentially more probable that it's something else. I am of course not a trained medical professional.