Charles in NJ
Introduction: Units are the bridge from learning abstract arithmetic operations on numbers to actually using maths to navigate the world of objects, distance, time, rates, volume, temperature, heat, current, voltage, and even cooking using recipes. Goal for the series: Embracing units, and carrying them along as you go, can help you work with confidence in using maths in your life. When you start to use maths to solve real problems, you are going to run into units. This series is intended to show you that units are your friends, and that they're here to help you. Goal for this episode: We want to look at what units are, what they do, types of units, and how to mix unitless numbers with units. Resource for the series: * Khan Academy pages on Rates, Ratios and Units https://www.khanacademy.org/math/arithmetic/rates-and-ratios Most articles that would be relevant to this introductory episode were about teaching physics and chemistry, or discussions of philosophical implications of doing what we will be doing at every turn in this series. All of the formal operations that we will learn to do with units are done every day in real life by experts in their respective fields. I am not worried about what it means to say, "There are 12 inches in a foot." Later shows will have more links and resources. Segment 1: What do we mean by units? 1. Definition: Two types of units are useful in practical maths: a. Counting units: An individual thing treated as single or complete. Units can also apply to an individual component of a larger or more complex system. E.g., mufflers can become part of a car. - Think of objects that you would keep in an inventory in your pantry or in a warehouse. b. Measurement units: A quantity chosen as a standard that you can use as a common benchmark for comparing other quantities (of the same kind). - "Same kind": Don't try to compare distances to times or volumes. - "Standards": Communication tool for talking about quantities without being face-to-face. If you have standard units, you avoid expressions like "yea long", "kind of tall", etc. - Probably invented by buyers and sellers, or by the spouse of an avid fisherman. c. Composite units: Units can be multiplied together (or divided) to create new types of units. Some people call these "derived quantities", but that may sound too much like programming talk. I use composite units because of the mental picture it creates of putting things together, or doing one operation after another. - Dimensionality changes: * 1 ft * 1 ft = 1 square foot: distance^2 --> area * 1 ft * 1 ft * 1 ft = 1 cubic foot: distance^3 --> volume - Rates: * Speed: distance / time = average speed, as in kilometers/hour * Flow rates: volume / time, as in liters/minute * Pressure: force / area, as in pounds / square foot * Density: mass / volume, as in kilograms / liter * Rationing: (1 period) counting units / time, as in apples/day (longer time) apples / family_member / day - We will run more of these types of units in later shows. 2. Other kinds of numbers: Not every quantity has units attached a. Numbers can be unitless. Unitless numbers help you make sense of quantities with units through comparisons, extrapolations, etc. - Example: Percent changes are unitless floating point numbers, unless it is tied to an elapsed time. That's a "rate", which has units of "% per year" (say). - Example: Percentage of Total values are unitless fractions, too. - Example: Any unit can be multiplied by a unitless integer. * 2 feet, 3 apples, 4 quarts, 10 meters, etc. * "Twice as many", "ten times as far", "double a recipe" - Counting units can be multiplied by a unitless fraction, but the result will be rounded off to the nearest integer value. * "Mary has 2-1/2 times as many apples as John," is fine if John has 4 apples, and Mary has 10 apples. - Example: Measurement units can be multiplied by any arbitrary scale factor. * How big: "A land area 3.6 times the size of New Jersey..." * How far: "I'll meet you halfway..." * How much: "If using white flour, you'll need 30% more..." b. When values with units are divided by other values with the very same units, the result is a unitless number. - Percent of Total and Percent Change are prime examples - Comparison of distances: * "St. Johnsbury is 45 miles away, and Barton is only 15 miles. So you have to drive 3 times as far to get to St. J." c. Conversion factors between units work in this way. They are given as ratios of some number of new_units divided by some other number of original_units. * The original_unit quantities cancel in multiplication, just as numbers do, so you get an answer with the correct units! * You could call conversion factors "derived quantities", because you create them from something called an identity, or a statement of equality that you know to be true. d. Conversion factors will be covered next time. 3. Why bother with "counting units"? Aren't these just names? a. Counting units are labels or names applied to individual items in a total count, but they are still useful. b. Using counting units helps us to make distinctions between items that are not interchangeable, so we can keep track of the counts for each individual kind of item. - If you need 2 apples, having 10 onions does not help you. - Thinking with units will help you keep inventories and to start setting up accounting systems for your business. It will also help you manage your kitchen and your budget at home. Segment 2: Counting Units? Are you serious? 1. Counting units give context to the numbers that you are using in any calculations that arise when you are buying, selling, trading or just using up items in a beginning inventory. Here's what happens when you don't track units in counting problems. - Example: "John has 9 apples in his basket. If he gives 2 apples to Mary, how many does he have left?" - Speed test preparation textbooks seem to teach you to parse the problem as if you were a word problem "compiler": a. Fish out the numbers and their roles. --> Notice that 9 is near "in his basket", and "how many does he have left?", It must be the source. --> Notice that 2 is next to "gives away". It must be the change in quantity. b. Parse out the operation: "gives away" is code for subtraction. c. Do the calculation and supply a numerical answer: 9 - 2 = 7 2. Re-work the problem by tracking units. a. Read the problem. I'll wait. We will parse it together. b. John has a basket with 9 apples in it --> beginning inventory c. John gives away two (2) apples to Mary. - John's inventory of 9 apples is reduced by 2 apples, - John now has 7 apples in his basket. d. Mary now has 2 additional apples in her inventory. - The apples were neither created out of nothing nor destroyed. - They came from somewhere (John), and they went somewhere (Mary). - If "apples out" does not equal "apples in", something's wrong. e. Having this information lets you answer questions with confidence. f. Answer the question: "John now has 7 apples." - John does not have '7'. John has '7 apples'. 3. Ho hum. That solution is exactly the same. You're picking nits. a. For a trivial problem, this looks the same. But there are some benefits of using units, even if they appear to be "just labels". b. If the problem had said that "John gave 2 oranges to Mary", we would have spotted the discrepancy immediately. - Giving away oranges does not affect John's apple inventory - The oranges must have come from another supply (account) - We can still talk about an increase in Mary's oranges count, and the decrease in John's oranges -- even though we don't know the beginning or ending balances. c. What if the problem had said, "Mary has three times as many apples as John. How many apples would Mary have to give to John to leave each of them with the same number of apples?" d. Better yet, what if the problem read: "John has 19 apples, and Mary has 14 oranges. Now John likes oranges twice as much as he likes apples, but Mary likes apples three times as much as she likes oranges. How can John and Mary exchange apples and oranges to get the best (equal) gain in happiness?" - This problem involves not only the tracking of apples and oranges, but probably some type of "happiness" function that gives a value that carries some kind of units. Warning: There's not enough information to really solve this problem without further assumptions. It is meant as an illustration of how complicated a setup can become when you get into real life situations. - Problems like this are what make people hate economics. One way to solve it is to define utility functions for each party. - Their preferences are so different from their inventories, that simply trading baskets is pretty close to an optimal solution. e. If the problem had involved trading some of John's apples for some of Mary's oranges, and possibly an offsetting cash payment to correct an imbalance, we would make the best use of our information about the sources and uses of resources by tracking the units of each object or currency involved in the exchange. Point: Problems can become complicated. Units can help with the bookkeeping needed to work through to the answers. If someone poses a problem like this one to a group at a dinner party, it is time to remember that you forgot to iron your curtains. 4. Final properties of counting units a. Compatible counting units can be added and subtracted. - Example: 6 apples + 4 apples = (6 + 4) apples, or 10 apples. - Example: 6 apples + 2 oranges is a mixed expression. They cannot be added, except as part of a fruit salad. b. An amount that's given in counting units can be multiplied by an integer, since that is like repeated additions. They can also be multiplied by a fractional amount, but we would want to interpret the result as a whole number. c. Any multiplication by a floating point number would have to be defined, and it's usually not worth the effort. d. Counting units have weaknesses, especially in classification: - Organic items are usually not identical. Apples can vary. * Size: A recipe calls for "3 large apples". Are these large? * Varieties: "Apples" in the US can include Macintosh, Rome, Gala, Granny Smith, etc. These can be quite different. - Animals also vary within categories: * Cats: Lions, lynxes and Little Puff can all qualify * House cats: Siamese, Persians, Tabby cats are all just cats, until you have them living in your home. - Some living things are hard to pin down: sponges, paramecia - Other items can also create classification issues, depending on your purpose. * Units are just tools. Let them work for you, and not the other way round. Segment 3: Units of measurement 1. Measurement units are often continuous (or just about), so they can be divided conceptually into smaller and smaller subunits as many times as we like. - They can also be lumped together into larger and larger wholes. - Physical limitations place practical limits on how finely we can actually chop things up, and still get a measurement. - There are real world limitations on how much we can lump together. - But you get the idea. 2. Measurement units can be applied to distance, time, area, volume, weight or mass, energy, frequencies of light or radio waves, voltages, current, heat, temperature, and a host of other things. - We can measure these quantities with differing levels of precision, based on the instruments and abilities that we have. - For all practical purposes, we measure within tolerances that we can meet without spending our whole lives measuring. 3. Applications of measurement units a. Understanding the news: hectares of forest endangered by a fire, square miles of arable farmland in South Africa, temperatures given in unfamiliar scales such as Fahrenheit, snowfall measurements in Canada versus neighboring Montana, etc. b. Following recipes to make bread, cookies, beer and other items that promote World Peace c. Mixing chemicals for an old-school darkroom, or for a very cool low-tech electronics home "fab lab" d. Buying gasoline (petrol) in other countries, and understanding their speed limits in foreign units. - Can't help you with driving on the wrong side of the road e. Helping your kids with their maths homework, and understanding it for once! f. Checking the dosages of your medications against your prescription to find out if this is my medicine or my child's. You just have to be able to get this one right. We'll get to all of this and more in future episodes in this series.
Last Episode on Conway's Doomsday Rule ends with teaser on MOD(), a "remainder" function defined for integer values (whole numbers): MOD(K, m) = remainder when K is divided by "modulus" m. Examples: a. MOD(207, 7) = MOD(207 - 140, 7) = MOD(67, 7) = 4 b. MOD(1234567, 2) = 1 because the number is odd MOD() function found in most spreadsheet programs, but it also shows up as an operator in some programming languages: (a % b), or (a mod b). Other functions referenced: DIV(K, m) = quotient in integer division where K = m * quotient + remainder (not returned) 0 <= remainder < m DIVMOD(K, m) = (quotient, remainder) when K is divided by m where remainder = MOD(K, m) quotient = DIV(K, m) K = m * quotient + remainder
Full Show Notes
HPR Episode: Doomsday Perpetual Calendar Method What is it? http://en.wikipedia.org/wiki/Doomsday_rule (due to John H. Conway, a mathematician born in Liverpool) * He's done other research that hackers might like to check out. * Look up the "Game of Life" and "cellular automata". * There may be episodes on these topics, but those should come with visualization software. John H. Conway http://en.wikipedia.org/wiki/John_Horton_Conway Game of Life http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life Doomsday Rule lets you find the day of the week for any date * Dates in history, in immediate past or in future are all good. * Works for both the Gregorian and Julian calendar. - I'll only be looking at Gregorian dates for now. - Method should work well for dates from 1800 onward. - If dates for non-Gregorian calendars are converted to their (extrapolated) Gregorian equivalents, this method works. Wikipedia entry (includes recent optimization): http://en.wikipedia.org/wiki/Doomsday_algorithm Why do this? It came up in Episode Zero of my "N Days" show on calendar counting, where I used it without explanation. http://hackerpublicradio.org/eps.php?id=1143 Demos: Check these answers at www.day-calculator.com * Some listeners may now adjourn to the latest Linux Outlaws episode. Method: Get Century Anchor Day, calculate offset for the year to find Doomsday's reference location for current year, find closest reference date to target date, and count off to the answer. a) Isaac Newton's date of birth: - 25 December 1642 - 1600's Tuesday. Year 42 = 3*12 + 6 and (6/4) = 1. Hence 3 + 6 + 1 = 10 for an offset of 3. Tuesday + 3 = Friday. 12/12 is Friday, so 12/26 is Friday Newton was born 12/25, so that was a Thursday b) My grandfather's date of birth: - 20 January 1898 - 1800's anchor is Friday. Year 98 = 8*12 + 2, (2/4) = 0. So 8 + 2 + 0 = 10 gives an offset of 3. - 1898 wasn't a leap year, so 10 January was Monday - That means 17 January was a Monday, too. - So 20 January 1898 was a Thursday. c) A wedding anniversary that I like to remember: 15 May 2000 - 2000 has anchor day on Tuesday, and no offset. - Rule: "I work 9 to 5 at 7-11", so 9 May (16 May) are on Tuesday. - 15 May 2000 was a Monday. True. 'Twas the day after Mother's Day. d) My parent's wedding day: 19 May 1957 - 1900 has anchor day Wednesday. 57 = 4*12 + 9 and (9/4) = 2. - So 4 + 9 + 2 = 15 or an offset of 1. - 9 May is Thursday, as is 16 May. The 19th is 3 days later. - So 19 May 1957 was a Sunday. Plan: I'm going to reveal the magic behind this, and introduce some mental shortcuts to help you learn to do this in your head. If you can master the 12's row in your times tables up to 8 times 12, and the 4's row up the 20s or 30s, and you can tell time on a 12-hour clock, you should be able to do this. We're not in school, so paper and pencil to track the numbers, and finger-counting offsets to days of the week are all allowed. Explanation: 1. Certain memorable dates fall on the same day of the week as "Doomsday" = last day of February, whatever that is. 2. Dates recycle every 400 years, and Doomsday Anchor dates by Century are 1600: Tuesday, 1700: Sunday, 1800: Friday, 1900: Wednesday. 3. That's enough, but to simplify mental math notice 12-year cycles. - Every completed 12 years pushes the days of the week ahead by +1 - Each year within the current incomplete cycle adds +1 - Each leap year in current cycle adds +1 (including current year) 4. Doomsday dates are: a. January 10 and Doomsday (last day of February) b. Odd months: Add +4 through July, then subtract 4. 7 March, 9 May, 11 July 5 September, 7 November c. Even months are reflexive: 4/4, 6/6, 8/8, 10/10, 12/12 See the attached spreadsheets for examples and annotated calculations. - LibreOffice Calc: 229-Charles-in-NJ-Doomsday-Rule-v1.ods - Excel 5/95 'xls' for LibreOffice or Gnumeric: 229-Charles-in-NJ-Doomsday-Rule.xls - Gnumeric: 229-Charles-in-NJ-Doomsday-Rule-v1.gnumeric Bonus Content: - Excel VBA module: 229-Charles-in-NJ-Doomsday-Rule.vbaxl.bas * Import the .bas module * Input is an Excel "Date" object * Very proprietary formats and code, but some people use it. - Python: doomsday.py * Contains two functions: Each returns a string value for the day of the week, e.g., "Sunday" dayOfWeek(year, month, day): Doomsday is last day of February, and the (month, day) are converted to relative ordinal dates. For leap years, we have to push both Doomsday and any target date after 28 February up by one for the leap day. dayOfWeek2(year, month, day): Doomsday date anchors are computed for each month, so leap years require adjustments to the anchors for January and February to account for the shift in the February ending date. Later months are fine. - Script for GNU 'bc': doomsday.bc is a bc 'port' of the Python code * Differences: Return value is a number from 0-6 that represents the day of the week by its relative position. 0 = Sunday, 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday * In a shell, run 'bc' with the filename as an argument: catintp@Derringer:~$ bc doomsday.bc - This loads the two functions in the file. You can invoke them within 'bc' like any other function: dayofweek(1981, 5, 15) dayofweek2(1642, 12, 25) dayofweek(2013, 11, 22) dayofweek2(2059, 5, 19) - Alternate Script for GNU 'bc': doomsday2.bc * Return value is still a number from 0-6 that represents the day of the week by its relative position. * Uses a side effect to print a human-friendly answer. * English only, but localisation should be easy.
Edited version - re sent
The Sonar Project has $9,838 raised with 256 people contributing. A big thanks to all the !HPR Listeners who helped out.
It's not too late to contribute to the ACF. See http://accessiblecomputingfoundation.org/ for more information.
Tomorrow The Eleventh Annual Southern California Linux Expo starts. Running from February 22 to the 24, 2013 in the Hilton Los Angeles International Airport. Speakers include Kyle Rankin, Joe Brockmeier and Matthew Garrett.
See http://www.socallinuxexpo.org/scale11x for more information
The N Days of Christmas? Intro to Recreational Math Part One: Counting Partridges and Gold Rings
The complete shownotes can be found here:
Background on Pascal's Triangle and the Binomial Theorem, see the excellent videos by Sal Khan at http://KhanAcademy.org
Contact: Charles in NJ Email: email@example.com
Charlie + Alpha + Tango + India + November + Tango + Papa.
Hacker Public Radio: 206 203 5729 The N Days of Christmas? Intro to Recreational Math Part Zero: Calendar Counting First episode of HPR that contains a direct discussion of a math topic. - Episode 479 Ohio Linux Fest, Klaatu interviews DWick about math software for Linux - Episode 523 Using Petunia software to teach math Inspired by a traditional song that is proof that some songs do not need to be recorded by William Shatner to be annoying. - Repetitive and formulaic - Involves a lot of counting, and that's our focus here. What is the 12 Days of Christmas? - Starts on Christmas Day, runs through the day before the next Season - Hint: That's 'Epiphany', which starts January 6. - Counting calendar days comes hard, so we tend to use our fingers - Turns out that using our fingers is quite mathematical. Here's why. Finger Counting: How do I count Twelve Days? - Let's start easy, with the fingers on one hand. My hands have five. - To name the Five Days of New Years is easy: January 1-5