To jump through these arithmetic hoops, Evelyn, who gave up her career to take on the now full-time job of feeding Sam, plans meals on the kitchen computer using a Web-based program called KetoCalculator. It is hard to imagine how to administer keto without it. A meal for Sam might have eight ingredients. Mathematically, there are potentially millions of combinations — a bit more of this; a bit less of that — that gets you to a 400-­calorie meal and a 3-to-1 ratio. KetoCalculator does the math. Every ingredient — butter, cream, bacon, oil, eggs, nuts and fruit — is weighed to the 10th of a gram on an electronic jeweler’s scale. When Evelyn comes up with a recipe that works, she hits “print” and files it in a black loose-leaf binder. We now have more than 200 recipes.

Doing all this once is fascinating. Who knew that a cup of milk had more carbs than half a slice of toast or that macadamia nuts have more than twice the fat of pork rinds? But administering the diet for three meals and two snacks a day, seven days a week for two years is relentless. There is no “Let’s just order pizza” in our house, no matter how crazy the week has been. A barbecue at a friend’s house takes Evelyn 30 minutes of prep time. A sleepover takes two hours, because she labels all the food and writes out heating and serving instructions for the parents. Evelyn spent six hours preparing food for a three-day camping trip in August. Unexpected events that barely register in most families — like the fact that I recently ate the applesauce that was to be part of Sam’s breakfast — create mad scrambles to recalculate and reweigh meals so Sam gets out the door on time.

The diet is administered like medicine, and parents need to work with their neurologist and a keto dietitian to come up with an appropriate caloric intake for the child. You receive a log-in to KetoCalculator, which is only available through a clinician. Every three months, Sam’s height and weight are measured, and a baseline blood test is administered. This medical oversight lessens the worry that we are going to poison Sam with all the fat he eats. Children can fall into ketoacidosis — essentially overdoing keto. It’s rare, and easily reversible, but it can be fatal if you don’t know what to look for.

Ultimately what makes the diet so stressful is that on top of all the gross recipes and weird mechanics, there is no margin for error. Just as you can’t take blood-pressure medicine sporadically or vary its dose day to day, on keto you can’t just dump beaten eggs into a pan; you have to take a rubber spatula and scrape out the two or three grams that typically adhere to the measuring bowl. Then Sam needs to finish every bite of every meal. (Two other, somewhat less restrictive diets are also being prescribed for epileptic children, but neither worked as well for Sam.) The penalty for cheating, at least in Sam’s case, is seizures. During the first few weeks on the diet, a friend in his carpool shared a piece of toast. We lost seizure control for a week. Miraculously, Sam has done this only once.

Will the diet doom Sam to a lifetime of heart disease and high cholesterol? Thiele and Pfeifer don’t think so. There is research, published this year, suggesting that there are few lingering effects in the years after stopping the diet. Johns Hopkins Children’s Hospital in Baltimore, where the diet was pioneered in the 1920s, surveyed 101 former patients, most of whom had been off the diet for more than six years, and found that they had normal cholesterol and cardiovascular levels, no preference for fatty foods and, for those off the diet the longest, normal growth rates.

Certainly Sam’s appearance shows no sign that he is eating so much fat. There are reports that the diet can stunt children’s growth even if they are on vitamin supplements. But Sam started the diet when he was 4 feet 3 inches tall and weighed 51 pounds. He is now 4 feet 8 inches tall and 68 pounds. His cholesterol and related measures of fat in the bloodstream are elevated, as is typical for children on the diet. But the other tests are normal.

We don’t know how long Sam will be on this diet. It won’t be forever. Most who respond stay on it for about two years — which for Sam would be in April. But there is no magic number. I’ve read about some children who started in infancy and were on the diet for more than five years. Typically the diet is stopped at one of three junctures: when children have been seizure-­free for two years; when they outgrow their seizures, as about 60 percent do; or when families decide the sacrifices required to stay on the diet have become too onerous.