FacebookTwitterGoogle+Share

Knitting math

Janice, my sister, does a lot of knitting. A lot. And occasionally, she asks me to double-check her math.

In this case, she wanted to decrease from 152 stitches in one row, to 114 stitches in the next row, and wondered if she could knit [1 1 1 2] repeatedly (where 2 means knitting together two stitches in the previous row). She tried that and ended up with a row of 122 stitches instead of 114.

So I mathed it out: Ss=p/(p−d)S_s = p/(p-d) and Cs=d/(p−d)C_s = d/(p – d)

SsS_s (the sum of stitches) should be the number in the previous row, over the difference between the previous and desired stitches, in this case 152/(152−114)152/(152 – 114), or 3838.

Ss=4S_s = 4

Similarly, CsC_s (the count of stitches) should be the desired number of stitches, over the same difference: 114/38114/38.

Cs=3C_s = 3

So the repeating segment should have 3 entries, and should sum to 4, which could be any of: [1 1 2], [1 2 1], or [2 1 1].


Which works fine when things divide nicely, but it wasn’t long until she wanted to decrease from 148 stitches in one row, to 120 in the next (a delta of 28 stitches).

Which meant that Ss≈5.3S_s \approx 5.3, and Cs≈4.3C_s \approx 4.3.

If we take a step back, across the entire row length, SsS_s should be pp (the number of stitches in the previous row), and CsC_s should be dd (the desired stitches in the active row), in this case: SsS_s = 148, and Cs C_s = 120.

Which means that the number of 2s (or, k2tog—knit 2 together) should be Δ=28\Delta = 28. The remaining 9292 (Cs−ΔC_s – \Delta) stitches should be regular knits (1s), and it becomes a matter of spreading those 28 2s out relatively evenly amongst the 1s.

However, if Δ>d \Delta > d (if the difference is greater than the desired stitch number in the active row), we can no longer simply rely on k2togs. For example, if we have p=10p = 10 and d=3d = 3, what we need to do is [3 4 3] (or any other permutation of those values): knit 3 together, knit 4 together, knit 3 together.

Luckily, this is easy enough to deal with:

Vm=⌊Δ/d⌋+2V_m = \lfloor\Delta/d\rfloor + 2

Vb=Vm−1V_b = V_m – 1

The value of the maximum merge is the floor of the difference divided by the desired number of stitches, plus 2. In the case of p=10p = 10 and d=3d = 3:

Vm=⌊7/3⌋+2=4V_m = \lfloor 7 / 3 \rfloor + 2 = 4

Vb=4−1=3V_b = 4 – 1 = 3

Which matches up with the values in [3 4 3], above. As to how many of each we need:

Nb=d∗Vb−ΔN_b = d * V_b – \Delta

Nm=d−NbN_m = d – N_b

In our case, NbN_b, the number of base merges works out to Nb=3∗3−7=2N_b = 3 * 3 – 7 = 2. And NmN_m, the number of maximum merges, works out to Nm=3−2=1N_m = 3 – 2 = 1. Which matches the 2 3s and the 1 4 in [3 4 3].

Now that we have Vm,Vb,NbV_m, V_b, N_b, and NmN_m, it’s just a matter of spreading out the NmN_m (1) VmV_m (4) amongst the NbN_b (2) VbV_bs (3s). Which is pretty easy with a bid of programming code. Something along the lines of:

const occurance = Math.floor(dest/number_of_max_merges)
const padding = dest % number_of_max_merges
const lpad = Math.floor(padding/2)
const rpad = Math.ceil(padding/2)

Then we throw a VmV_m in the middle of a set of occurance VbV_bs, and do that NmN_m times, padding at the start and the end of the row by lpad and rpad VbV_bs.

Easy as a peasy, as the kids say.

In the case of p=148p = 148, and d=120d = 120, that works out to: start with [1 1 1 1], repeat some permutation of [1 1 2 1] 28 times, end with [1 1 1 1].

But, since this came up more than once, I made to calculate your knitting decreases so you and future brad don’t have to think about any of this:

Comments

Comments are closed.