Tags: madeof:atoms, madeof:bits
Update 2023-06-17: I had missed an N in the formulas, they have been updated, and since I was editing this I’ve added the haskell bit.
I’ve just realized that I’m not anywhere close to finishing the shawl I’m knitting, so I’ve done the perfectly logical and rational thing and started a new one.
This one is using some yarn from the stash, so its size is limited by the available yarn, and I wanted to estimate how long it may be, so I weighted the ball of yarn at the beginning and then again after knitting 10 and 20 rows.
It’s a top-down crescent, with 6 increases every two rows (but these calculations should work for any uniform top-down shawl with a regular number of increases), so each block of 10 rows should use an approximately fixed weight of yarn more than the previous block of 10 rows.
So, let w0 be the weight of the first block of rows, wr the (average) difference between two consecutive blocks and wT the total weight of the shawl. Then the weight used by block i should be wi = w0 + wr ⋅ i and the total weight of the shawl should be:
$$w_T = \sum_{i=0}^{N}w_i = N ⋅ w_0 + w_r ⋅ \frac{N ( N + 1)}{2}$$
where N is the number of blocks in the whole shawl.
This gives:
N2 + (1+2⋅w0/wr) ⋅ N − 2 * wT/wr = 0
and the only positive solution will be:
$$N = - 1/2 - w_0/w_r + \sqrt(1/4 + w_0^2/w_r^2 - w_0/w_r + 2 ⋅ w_T/w_r)$$
or, in a few lines of python that can be easily copypasted (changing the
values in ws
and w_T
, of course):
import math
import statistics
w_T = 200
ws = [2, 4, 6]
w_r = statistics.mean(map(lambda x: x[0] - x[1], zip(ws[1:], ws)))
-1/2 - ws[0] / w_r + math.sqrt(1/4 + ws[0]**2 / w_r**2 - ws[0]/w_r + 2 * w_T / w_r)
Or, in Haskell:
let ws = [2, 4, 6]
let w_T = 200
let w_0 = head ws
let w_r = ( sum (map (\(x,y) -> y-x) (zip ws (drop 1 ws))) ) / (fromIntegral (length ws - 1))
-1/2 - w_0 / w_r + sqrt (1/4 + (w_0/w_r)**2 - w_0/w_r + 2 * w_T / w_r)
Which right now (using the actual measured values) tells me I will have about 135 rows in my shawl, but I’d really want to do a few more blocks of 10 rows and have more datapoints before I trust the numbers I’ve put in.
Which means that this shawl will also take forever.