##
Carbculus

I am a newbie at doing any kind of detailed carb and insulin counting. Previously I just tried to count from labels and make my meal hit specific targets like 60g and keep the insulin constant. I have no idea how much any of this lines up with reality, so I am experimenting with it to see if I can find out what these actual values are (in as much as the equations line up with reality). Obviously, there are always confounding factors like exercise. But the point of this is near the bottom where I try to figure out how many carbs I ate by looking at the difference between what I tried to do, and what happened.

*U is the units for insulin*

*CIR = Carb To Insulin Ratio (carbgrams / U)*

*SIR = Sugar To Insulin Ratio ((mg/dL) / U)*

*T = Target sugar reading (mg/dL)*

*R = Sugar reading just before eating (mg/dL)*

*F = Food (carbgrams)*

*I = Insulin (U)*

Example values that mostly stay the same:

*CIR=4, SIR=15, T=120*

Example values that you plug in every time you eat:

*F=45, R=93*

Basic Insulin Calculation, of how much you need to stay on target while eating:

*InsulinTotal = InsulinForFood + InsulinForCorrection*

*I = F / CIR + (R-T) / SIR*

So I always divide food carbs by 4 (CIR) and how far off I am by 15 (SIR) and try to reach 120 (T). If I eat what I thought was 45g of food and I am at 93. This is simple enough that you can routinely do the calculation in your head:

*I = 45/4 + (93-120)/15*

* = 45/4 - 27/15*

Roughly 10 insulin required. But one thing I never hear anybody talking about is trying to actually measure how many carbs you actually ate; because all of the carb amounts are guesses unless you revise the estimates with actual measurements. The problem is that all the variables that we plugged in were exact except for F which is a guess; one that could be very wrong. If you actually did eat 45g of carbs, then you should be at 120 later; which is the whole point of taking the insulin.

So, I take another measurement when I expect it to be 120. I got a new variable

*L = Landing sugar reading (mg/dL)*

*G = Actual food (carbgrams)*

So, you inject the insulin with a guess of F carbs at reading R, then measure your sugar later and call it L, and find the actual carbs G. And I rewrite the basic insulin calculation to plug in landing sugar instead of target sugar and solve for food. In essence, I write it as if my landing blood sugar was intentional and figure out how many carbs I ate:

*I = G / CIR + (R-L)/SIR*

Which you manipulate to get:

*G = CarbsWeInjectedFor + CarbsPerSugar * HowFarOffWeWere*

*G = CIR * I + CIR/SIR * (L - R)*

So say I landed at 130 rather than 120. You do it in your head like this:

*G = 4*13 + 4/15 * (130 - 120)*

* = 4*13 + 4/15 * 10 #off by 10 sugar, injected 13*

* = 4*13 + 8/30 * 10*

* = 2*26 + 8/3*

* = 52 + 8/3*

Roughly 55 carbs. You can memorize CIR/SIR (ie: 8/30), so that this isn't any harder than the basic equation. There doesn't seem to be a lot of point in getting highly precise because carb counting involves guesswork, as does the way that you are going to consume it in your body. But this tells me that I can go over all the numbers in my pump and look for systematic carb counting errors (ie: I assume that I am always trying to reach 120 and I have before/after meal readings). So, you get the number I from the pump, which will take in F and R as parameters each time you eat(with all of the others set to constants), and plug in L 2 hours later as a check. A little python program that I haven't used yet (I just came up with the carb regression a little while ago... So I will see how it goes):

*CIR = 4.0*
*SIR = 15.0*
*T = 120.0*

*def EatAt(records,n, F, R):*
* records[n] = {}*
* records[n]["F"] = F*
* records[n]["R"] = R*
* records[n]["I"] = F/CIR + (R-T)/SIR*

*def Regress(records,n,L):*
* R = records[n]["R"]*
* F = records[n]["F"]*
* I = records[n]["I"]*
* records[n]["L"] = L*
* records[n]["G"] = CIR * I + CIR/SIR * (L-R)*

*records = {}*
*EatAt(records, 0.0, 60.0, 80.0)*
*Regress(records, 0.0, 130.0)*

*print records[0]*

Also, when my sugar is low, I would like to know how many carbs to reach my target without injecting (ignoring Basal for the moment):

*I = F / CIR + (R-T) / SIR*
*0 = F / CIR + (R-T) / SIR*

*(T-R)/SIR = F/CIR*

*CIR/SIR * (T-R) = F*

*4/15 * (T-R) = F*

So again, memorize CIR/SIR, which is 4/15 for me. If I am 50 points under (ie: 120 is Target, and 70 is Reading), then I want 4/15 * 50 carbs. 4/15 is roughly one fourth, so I need 13 grams of carb.

4/15 * 50 is about 13

http://www.github.com/rfielding/BloodSugar