More on Optimization

Every now and then, one sees articles about mathematicians and physicists who take up knitting and then begin analyzing their new craft from the standpoint of their academic specialty. The knitting itself is ordinary beginner work, but the scientist-knitters get very excited about the physical characteristics of how a one-dimensional material can create a three-dimensional product, and the journalists writing these articles, who are not knitters or physicists or mathematicians, hyperventilate about their surprise at discovering that it actually takes some brains to knit, and the headlines and captions always say some variation on “not your grandmother’s knitting”. An experienced knitter might be annoyed by the condescending tone.

But this particular experienced knitter is also fascinated by scientific and mathematical analyses of my craft in general and specifically I want to understand the math underlying the thought process I use to create my projects. It’s one of the regrets of my life that my math education was deficient and unsuited to my experiential learning style, but learning math for knitting has offered me a bit of an opportunity for a do-over. My previous post, Optimization, described the math assistance I got from a physics PhD candidate/knitter named Evan, who promised me that he would rewrite the notes he used to calculate that my just-enough yarn would be just enough for what I wanted to do with it, and clarify the thought process he used for the math.

It took math to turn this…
…into this.

Evan kept his promise! We sat down together at the back table at Lovelyarns and he proceeded to teach me math. He had handwritten four pages of explanations, starting with: “There are a handful of things to do when confronted with problems like ‘Does my planned design make sense for the yarn I have?’ The first thing I like to do is list out key elements and determine whether they simply are background information/framework; a constraint that I must work around; or something I have control over and can change as desired (variable).”

Framework, constraint, and variable are terminology used in expressing the elements of an optimization problem, and he provided me with a little chart that explained how he was defining these terms in my particular case. The raglan construction was the framework; the striping pattern of the colorwork was a variable; and the dimensions of the garment and the amount of yarn I had were the constraints.

As he went on to say in his written explanation, “This is a good way to take in the ‘lay of the land,’ as it were. We have our raglan framework, which tells us how the garment will be made, the ratios of how much yarn will go in the sleeves vs. body, etc. Next the colorwork, the principle variables we can change about the design, which include the ‘standard’ ratio of stripes you want and how the ratio changes when going from color A dominant to color B. Finally, the constraints that the sweater must fit your daughter and be done with the yarn you have, 3 skeins of color A and 1 of color B.”

Step 1, he went on to instruct: “Check that a solution can exist. In systems with multiple constraints, we should always check that they are not exclusive of one another. In this case, that boils down to answering ‘Are 4 skeins of fingering weight yarn enough for an adult sweater?’ Answer: Yes, but not by much.”

So far, so good. My personal experience with knitting many sweaters out of fingering weight, and weighing them afterward, has taught me that four 100-gram skeins will be enough, with not much to spare if the sweater is pretty long and has long sleeves, so as a matter of practicality, I would have to have to devise a design that would use just about every bit of my 400 grams of yarn. Logically, but not mathematically, I knew that the yarn usage would have to be at a 3:1 ratio. Evan compared my intuition about design and yarn use to AI, artificial intelligence, in which a computer database is fed vast amounts of related examples, which it uses to learn algorithms. But AI’s ability to make accurate predictions, like my ability to design around my constraints, is not mathematical, whereas the math quantifies how I’m going to make this sweater without running short and prevents those oh-so-exciting games of yarn chicken you play when you’re down to your last 15 grams of yarn. In fact, I got down to 11 grams of the aqua but stayed serene to the last stitch, thanks to Evan’s math.

As his Step 2, Evan provided definitions of the way quantitative sciences use the terms “intrinsic” and “extrinsic”. An intrinsic property is one that does not change regardless of the quantity of the material in question, whereas an extrinsic parameter does change with greater or lesser quantities of the material. His example was diamonds, the kind that are mined from the earth. Different diamonds can have different masses, cuts, or colors (extrinsic properties) but their density and crystal structure (intrinsic) will be the same no matter what. In this particular optimization problem, the fact that there wasn’t a whole lot of wiggle room around that 3:1 ratio made it an intrinsic constraint.

At Step 3, Evan expressed the situation in a form that could be reduced to a ratio.

That asterisk at the “3” is Evan pointing out that since I had actually used slightly less than all of my yarn, the completely accurate mathematical expression would have been less than or equal to 2.75 in the place of the 3. That would be very important if we were building airplane parts. But this was a sweater, so I’m OK with close enough.

This is the equation he wrote to express the need to use the four skeins:

“A” means the area of the knitting. “G, T” is the total number of stitches in green, “B, T” is the total number of stitches in blue (which I have been calling aqua), “sk” abbreviates skein. Evan is saying here that the total number of green stitches plus the total number of blue stitches is the same as the amount of yarn, which is equal to or less than four skeins.

Step 4 is calculating the actual yarn use for the various ways I might have arranged the stripes. As Evan said, “Make a plan, check if it works.” My plan was to have the green stripes dominate the aqua stripes at an 18:2 ratio from hem to bust, and then flip that ratio in several steps until the aqua dominated the green at 2:18 up at the final two 20-row sequences toward the neck. Actually, there was only one way that needed to be checked, because as Evan and I talked and drew sketches, it became evident that there was only one acceptable plan, since there was room for only three transitional sequences between the top of the bust, where the green-dominant area ended, and the last two aqua-dominant sequences up at the neck. So the ratio for the green-dominant section was 9:1, the ratio for the transitional area was 1:1 because the reversal of the colors made the color usage equal, and the ratio for the aqua-dominant area was 1:9. Therefore, the area of the total number of green stitches equals nine-tenths of the area of the green-dominant section plus half the area of the transitional section plus one-tenth of the area of the blue-dominant section. The area of the total number of aqua stitches equals one-tenth the area of the stitches in the green-dominant section plus half the area of the stitches in the transitional section plus nine-tenths the area of the stitches in the aqua-dominant section. Here’s the equation that says exactly that:

This is the point where we do the geometry and arithmetic to get the numbers that will tell us if the sweater will weigh 400 grams or less and how much of each color will be used, 300 grams or less of the green and 100 grams or less of the aqua. Evan broke my design down into rectangles and trapezoids. Calculating the area of a rectangle is easy– multiply width by height. Trapezoids are almost as easy– multiply the short width by height, multiply the long width by height, add the two sums together, and divide by two. We had worked out the dimensions of the sweater, so Evan plugged in those numbers to multiply the height and width of the rectangles of the lower body and the upper sleeves, and did the slightly more involved arithmetic for the trapezoids of the sleeve taper and the yoke. Then he calculated the ratio of green to blue for each of those shapes and added up the numbers for the green and the numbers of the blue. We weighed my 50-stitch-wide X 50-rows-high swatch, so Evan knew how much 250 stitches weighed, and that information was the basis for him giving me the green light to go ahead with my plan. He projected that I would use 366 grams of the yarn, and he was exactly right. I had 36 grams of the blue-green and 11 of the aqua left over, almost precisely 3:1.

When Evan explained his process of thinking through this optimization problem, I was thrilled by how easy it was to understand and by how much of it I was already doing. I was also gobsmacked, not necessarily in the good way, by how easy the math was when it had been so impenetrable back in high school geometry class. Was that only because the teaching methods of my youth had been so abstract and the attempts to make the concepts more tangible through word problems had been so clumsy and irrelevant? Or is it because solving knitting problems in my head during my morning walks has taught me the concepts, and all I need now is the terminology to express the ideas in an abstract form? Did it require mumblety-mumble years of knitting and life experience to prepare my mind for 10th grade math? Is the answer to all of these questions “yes”? If I’m any kind of example, and I think I am, a whole lot of knitters without a math background are much better mathematicians than they think they are. I said that to one of my machine knitter friends, and she replied that she can do the diophantic equation in her sleep. I had never heard of Diophantus or his equation, so I headed straight for Google and read that Diophantus was an ancient Greek mathematician who had devised the kind of differential equation that was named after him, and I watched a Scottish guy on YouTube go through an elaborate series of calculations to solve exactly what x and y were. All very abstract. Then my friend delivered the punch line of the joke: it’s the technical term for Magic Formula! Hey, look at me, solving differential equations!

I explained how to use Magic Formula in my post Trust The Numbers!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.