Why does this exist?
My wife and I started raising chickens, and we had a feed with too much protein in it. There's wasn't any online handy calculator for just plugging in your numbers of how to get to the correct amount of feed to mix in at a different protein percentage.
Our book on chickens had a reference to Pearson's Square, which I'd never heard of at all. The approach was interesting for sure, and is a handy way to calculate it by hand. My wife was familiar with it from some papers she had written relating to population studies (one of her master's degrees is in public health).
Protip on the code: if you think that amount1 and amount2 are labeled backwards, then you need to read the pdf of Pearson's Square again. They go across the diagonal, hence the seeming inversion. This really took me a while to wrap my mind around, particularly the second case, but I'd say that was time well spent.
Hopefully for some actual farmers, or other backyard chicken enthusiasts, this will come up in search results and be handy. These two formats are opposites of one another, so you can check your work (or my work, as the case may be) and verify that the math works both directions. Looks good so far.
If you want to use this code anywhere else, attribution would be nice but is not required. Consider this to be released under as permissive a license as you can imagine.
Website Design and Content Copyright 2007-2020 Chris McElligott Park. Photography Copyright 2020 Merritt Chesson.