Algorithmic approach to the treatment of insomnia

The author of the material tells how he managed to overcome insomnia with the help of mathematics.

I have been struggling with insomnia all my adult life. The problem first manifested itself in college, and subsequently, the strength of the illness grew and then decreased, often, although not always, correlating with the level of stress.

It usually starts with the active work of the mind in the evening. Activity can be associated with finding a solution to a difficult task at work, or playing a lively conversation in the head at dinner. Or I travel and therefore I am in an excited state. That is, these are not always tense thoughts, rather very exciting ones. I go to sleep, but my mind does not calm down. Half an hour later, I realize that I am not sleeping and I begin to think that it would be time for me to fall asleep already, because tomorrow there is a lot to do. And this only exacerbates the situation. I begin to become dissatisfied with myself and reproach myself: “What's wrong? Tomorrow I will walk dissatisfied. I really need to try to sleep. ” And so it is repeated to exhaustion. For hours on the span I lie awake.

The next day, as one would expect, really passes awfully, and in the evening my mind is filled with negative thoughts about my ability to go to sleep. Further the script repeats again. In the worst case scenario, I stay completely awake for five to six nights a month. Well, one or two nights a month in general have become commonplace. Of course, both the peaks of insomnia and its downturns very destructively affect the quality of life and the efficiency of labor.

Over the years, I have learned to take similar situations as a given and to overcome them. I decided that I just didn’t have the best gene lot, and this burden is an integral part of my existence. Sometimes I took sleeping pills, but I always remembered about the side effects and the risk of being addicted to them.

In early 2016, I realized that I was tired of enduring it. I could then afford not to work and was in a relaxed state, because after leaving work I started on a long journey. Still, problems with sleep — the very one or two sleepless nights a month — continued to haunt me. Since it was like some kind of absurdity, I decided to deal with the situation.

I tried to get acquainted with the latest research in this area, but I came to the conclusion that it was simply impossible for people who were uninitiated to master the enormous amount of academic literature. In addition, all these studies were focused on pharmacological development, which I sought to circumvent. Almost all of the information published outside the publications on this topic turned out to be simply terrible - this is either the generally accepted wisdom retold in a new way, or an attempt to sell you something.

Therefore, in the end, I turned to a Stanford researcher who leads a private practice. After making sure that a number of more serious mental ills were not related to the problem in my case, she assigned me a set of therapeutic measures, also known as cognitive-behavioral therapy for people suffering from insomnia. 1 This program turned out to be extremely effective and now I have a clear outline of actions that allow me to achieve a good sleep even though my stress loads have returned to their previous level.

This breakthrough inspired me. But knowledge cost me a lot of time and money. It is amazing that the solution of the problem has been reduced to a very simple algorithm, even if it requires a lot of willpower, but it is not easy to invent it yourself.

It is a pity that no one told me about this many years ago. Here I share this knowledge in the hope that it will be useful for everyone who is experiencing similar problems.

Common and useful tips

If you have trouble sleeping, then hardly any of the following will be new information for you. In my experience, all this is necessary, but not enough:

Unobvious new ideas

The bottom line is: "Do not force yourself and do not roll in bed just like that."

  1. Never try to go to bed simply because "it's time to go to bed." Sleep when you really want it.
  2. If you are in bed and cannot sleep for more than 20 minutes, get up and do something else. 3
  3. Get out of bed immediately after waking up in the morning. Do not roll in it and do not try to sleep more.
  4. Do not make changes to the daily schedule, based on the quality of sleep. No matter how bad everything is, do not deviate from the normal schedule, do not cancel the meeting, do not miss training, do not try to fall asleep early the next evening.


The essence is briefly: "Restrict yourself in every way in relation to sleep, keeping within the strictly allotted time for him."

  1. Begin to set the alarm so as to free up more time in the morning. I set for 6 hours.
  2. Choose a bedtime that will make your sleep two hours shorter than you need (according to your impressions). For me it's midnight.
  3. Set a goal not to sleep until that time. Do not sleep and do not go to bed, no matter how you feel. Also strictly follow the implementation of the above general recommendations.
  4. When awake, briefly record the following data:
    a. What time did
    b. When they felt sleep
    c. How much time in the middle of the night spent awake
    d. What time woke up
    e. How quickly got out of bed
  5. At the end of each week, calculate the sleep efficiency by dividing the average sleep time by the time you are in bed.
    It turns out this is the formula 4 :

     textefficiency= textaverage( frac texttimeasleep texttimeinbed text)= frac17 sumi=17 fracdibicieiai

    a. If the effectiveness is less than 0.8, move the target bedtime to another 20 minutes later.
    b. If the efficiency is in the range of 0.9–0.95, “push” it for 20 minutes closer.
    c. In other cases, leave everything as is.
  6. Go back to step 3 and repeat this pattern forever.

What is the essence of the method?

It turns out that for the most part insomnia is a collection of bad sleep episodes accumulated over the years, associated with stress, travel, environmental change, and the accompanying psychological fear of possible failure that grows with time. Your mind gradually loses confidence in the possibility of going to sleep and already in bed quickly moves to counter-productive thoughts. You begin to expect that sleep will be bad, and so it will happen.

Restriction of sleep using this mode takes control of the situation from the mind and sends it back to the "rightful owner", that is, your body and its biorhythms 5 . By adhering to these rules, you actually perform an algorithm for finding the optimal schedule for your body.

He begins by searching for an aggregate amount of sleep that is low enough to overcome the barriers created by your mind. To find this lower threshold can be quite difficult and painful, but it is quite realistic, because it always is. As soon as you do this, the mind gradually weakens its grip and begins to build up confidence that a good sleep is reality, and the bed is an oasis of relaxation. 6

Ultimately, the algorithm allows you to find the optimal mode, after which you no longer need to keep records. It remains only to adhere to general recommendations in order not to disturb the established rhythm. If a severe stressful situation or a long journey knocks you out, just run the algorithm again.


1 A lot of literature has been written about it. The algorithm described below is a type of CPT called “therapy with a limited sleep time”
2 I thought that the therapist would scold me for using devices in the evening, but she believes that this rule does not matter as much as is commonly believed.
3 It is useful to come up with a simple and neutral lesson that does not return you to everyday worries. I like reading or watching a video about chess.
4 There are special applications for this. I took advantage of this .
5 The modern sleep model describes two related processes, one of which is a biological (circadian) rhythm. This mode is mainly aimed at increasing the "need for sleep", regulated by sleep homeostasis, the second process. Here you can read more about this.
6 I think that improving the skills of evening meditation would also help well, but the approach described in the article seems to me to be simpler and more direct.



All Articles