(Originally posted 15 January 2021)
Usually when I’m writing for this blog, I’m trying to communicate both to engineers / nerds / machines-and-math people and to knitters / that other kind of nerd / fabric people. Usually. This post is going to end up rolling towards no-holds-barred nerddom. There’s math. There’s spreadsheets. I’m going to say the name of some classes I took in engineering school. We’re going places in this one, folks. As much as you’re normally not obligated to read these, you’re definitely not obligated to read this one if that’s not something that seems interesting to you. This is about me solving a math problem. The end result is nice to have, and now that it exists, I’ll share it so you don’t ever have to actually do the solving yourself if you don’t want to, and if you want to leave it at the end of this paragraph, that’s totally fine and dandy. Here comes the math.
Now that many of the knitters are gone (that’s bold, Rowan, assuming anyone was even reading this from the get-go), I guess I have to explain some knitting stuff, finally. It’s a fairly common problem in knitting (especially with what I’m doing and the way in which I’m doing it) that you start off with some number of stitches (horizontal dimension), and you have some number of rows (vertical dimension) over which to decrease to some new number of stitches. For a sleeve, I start off with a very wide piece where the shoulder is, and over the length of the sleeve, I’ll decrease down to something more narrow where the wrist is. The whole thing looks like a kind of lumpy trapezoid. Maybe I’ll come back and populate this with images, we’ll see.
For this type of machine, it’s easiest to decrease stitches on the outside (far left and far right) of the needle bed. This is because the further in you go, you have to pick up the stitches on the outside and move them in, which gets pretty annoying if you’re doing more than four or five. That leaves me with a maximum of 2 decreases per row, because I can decrease 1 on the left, and 1 on the right, every time. Man, I need to explain how this machine works in another post. The question becomes: How often do I need to decrease stitches in order for me to get from length A to length B fairly evenly, while having a symmetrical end product that is to-spec? Here, let’s define the space.
Decrease S stitches over R rows.
In one row, you can decrease either 0, 1, or 2 stitches.
When I was doing this, it’s about all I thought about for like a day and a half, and I managed to do it in two and a half different ways. The first two approaches really walked so my final iteration could run. I have so many pictures of my whiteboard from these couple of days, I’m sure it makes me look like I’ve lost my mind. I had a great time working on this.
Treat it like any line with a slope. You’re decreasing 2 stitches per row, so you should do a decreasing row every 2R/S rows. Rows are discrete, so do the ceiling or the floor of that number, whichever has the least error, and go for it. I could have stopped here.
The problem is that, depending on what your parameters are and how close they are to multiples of each other, you can end up with some pretty egregious error. For the second sweater, I was trying to decrease 75 stitches over 204 rows, which would have meant decreasing every 5th or 6th row. That left us decreasing 7 fewer or 5 more stitches than I need. For some things that’s ok, but 1. that’s an almost 10% error, and 2. the whole point of this is to have clothes that fit people, and I don’t think I can do a great job of that if my stuff can be an inch off in either direction. I did this in Excel, and ended up implementing not only a tool where you could input gauge and pick a tolerance in inches, but I set up a data table that would highlight any combination of S and R from 1-400 in blue if it was within your tolerance, and red if it wasn’t. It’s a neat looking table, I think. Here’s what it looked like for that example, with a tolerance of 1”:
So, that wasn’t going to cut it. Neat. What else could I do?
Well, check out…
So, I took a linear programming course last year, and by and large it was really neat. I like trying to use it to solve problems when I can, because it usually does a good job. Here’s how I formulated the problem: Basically, you’re adding up groups of rows. Each group has n rows in it, and exactly 1 row in each group will decrease 2 stitches. So, we are trying to find a solution to the system of linear equations that says how many groups of n (for all n) I need to add up in order to get a total of R rows and a total of S/2 groups. I thought I was being really clever, but I plugged some stuff into Desmos, and started looking at a state space, and for my toy example at least, it was looking like there wasn’t actually a linear combination of the [n 2/n] family of vectors which wouldn’t require me to knit negative rows. As it happens, knitting negative rows on my machine is very expensive and requires lots of labor and probably extra parts, so I figured I’d do something else. I think I could have gotten somewhere by adding in the 1 stitch decrease row (of course, NOW I think of it), because I was dealing with some odd numbers, but it ended up being a little more trouble than it was worth. Maybe I’ll look back into it in the future, because it’s nifty business, but with regards to this project, I don’t even need it because of…
So approach 1 had leftovers, and number 2 was provably impossible. Cool.
So let’s just play with our food a little- I’m talking about rearranging some leftovers, folks! Approach 1.5 does some really nifty shit, to be quite frank, and it’s simple and elegant but cheeky at the same time. I poured an entire day of my break into figuring out approaches 1 and 2, but 1.5 came together in maybe 20 minutes, and I spent the next hour playing with it, trying to break it, and then I guess just using it. Check this shit out.
Step 1: Do approach 1, but only do as many rows as you can evenly fit into groups without going over. Then count up all of the leftovers. For this example, that means 37 groups of 5, leaving 19 rows. 1/2 of one of these rows is a decreasing row, the other 18.5 are non-decreasing row. Don’t worry about the fractions, they get handled later.
Step 2: Realize that instead of having 37 groups of 5 with 19 extras, you can have 18 groups of 6 by shoving your extra non-decreasing rows into their own group. That leaves 19 groups of 5, with 1 row left over which is half decrease and half non-decrease. Easy. That’s just a row where you decrease on one side. That’s fine if you do it once. We just did it once. Tack that on the end.
Step 3: Go get a snack. That’s it, it’s done.
Practically no error, it’s about as smooth as you really can get it, and it only leaves you with really 3 different steps as a knitter. I’m sure there are some really weird combinations of R and S that’ll leave really nasty leftovers, but if you really need to you can just run Step 2 on the second set of groups and the leftovers. I’ve got checks in the spreadsheet that make sure everything adds up appropriately, and it doesn’t take really any time to run. It’s neat. I like it.
Anyways, that’s how I got some stuff working that wasn’t before. I’m sure it’s been done before, and this wasn’t a particularly neat way to get what I wanted, but this is what I figured out and I’m pretty pleased with how it works. I haven’t implemented it into the master pattern spreadsheet yet, because I still want to refine it further, at least in presentation, and because I want to be able to use it for other things as well- I think I’ll use this math to help me do torso shaping, which is the next big step for the sweater being something that fits people.
Cheers!
Rowan