instagram

Students investigate logarithmic relationships in demographic data about countries of the world, using an inquiry-based model, involving hypothesizing, experimental and computational modeling, and sense-making.

Lesson Goals

Students will be able to…​

  • Model logarithmic relationships using functions

Student-facing Lesson Goals

  • Let’s use Pyret to model logarithmic relationships in data

Materials

Supplemental Materials

Preparation

  • Much of the exploration in this lesson hinges on a custom-built interactive Desmos activity.
    You will want to:

    • Open Fitting Wealth-v-Health and Exploring Logarithmic Models (Desmos).

    • Make a link or code to share with your students.

    • Decide how you will share the link or code with students and, if you are using our Google Slides, add the appropriate link to the slide deck.

    • Set the pacing so that students are only able to interact with the first three slides. (As the lesson progresses you will be directed to adjust the pacing or sync students to you so that they have access to relevant slides.)

  • If you’re a first-time Desmos user, fear not! Here’s what you need to do.

Key Points For The Facilitator

  • This lesson assumes that students have been introduced to logarithms before, and are familiar with computation involving logarithmic functions.

  • The focus of this lesson is about applications of log functions, and builds an intuition for logarithmic computation by motivating substantial trial and error.

🔗Looking for Patterns 30 minutes

Overview

Students explore the Countries of the World Starter File, and find a relationship between wealth and median life expectancy. They also learn how to build a new column for a table in Pyret.

Launch

Discuss students' findings. Pay special attention to the form that students use to describe the pattern in the scatter plot. Is it linear, or something else? Is it strong or weak? If there’s some disagreement among the students, that’s a good thing!

Be attentive to sense-making: If a wealthy country is suffering heavy casualties in a war, where would we expect to see that country’s datapoint? Why? What other conditions would cause a point to shift up, down, left or right?

Investigate

Make sure you have created a link or code for your class to Fitting Wealth-v-Health and Exploring Logarithmic Models (Desmos) and paced the class so they have access to only slides 2 and 3 (or to only the first 3 slides if you want them to also be able to play with a slider for a linear model).

  • Open the Desmos link I’ve shared with you. (The file should be called Fitting Wealth-v-Health and Exploring Logarithmic Models.)

  • Working in pairs or small groups, complete Fitting Models for the Countries Dataset.

This activity involves lots of trial and error, as students try to come up with a good linear, quadratic, or exponential model.
The goal is to discover that a new kind of model is necessary, not to find a perfect fit with linear, quadratic, or exponential models!

Synthesize

Direct students to look at the scatter plot they created in Pyret of median-lifespan versus pc-gdp.

  • What’s the best model you came up with?

  • What kinds of lines or curves did you draw?

  • How would you describe the shape of the scatter plot for median-lifespan versus pc-gdp?

    • It starts out rising fast on the left, before tapering off as pc-gdp increases to the right.

  • How well did our linear, quadratic, and exponential models fit this data?

    • None of the kinds of functions we’ve seen so far exhibit the behavior we see here! In some ways, this behavior is the exact opposite of exponentials: instead of starting slow and taking off like a rocket, this curve explodes up the y-axis right away, before leveling off.

🔗Logarithmic Functions

Overview

Having identified that the wealth-v-lifespan scatter plot is neither linear, nor quadratic, nor exponential, students learn about characteristics of logarithmic functions in graphical, tabular, and function notation form.

Launch

All of the models we just found for our dataset made predictions with too much error. Even though this shape looks familiar, it’s just not any kind of growth we’ve seen before.

Exponential growth started really slowly, and then suddenly shot up like a rocket to numbers so large we can’t even reason about them. This kind of growth feels like the exact opposite, growing really quickly but then leveling off to something very slow.

A graph showing the exponential rise in positive test cases in Massachusetts over timeLet’s think back to the graph of our model for Covid spread, from Exploring Exponential Models.

  • Our model answers the question "how many positive cases do we predict after π‘₯ days?"

  • The graph is showing us the relationship from
    days β†’ cases, x β†’ y, or Domain β†’ Range.

But what if we want to answer the opposite question: "how many days will it take to reach 𝑦 cases?"

  • Now we want to flip the relationship around, asking for
    cases β†’ days, y β†’ x, or Range β†’ Domain.

  • What would this graph look like?

A graph showing the exponential rise in positive test cases in Massachusetts over time

Swapping the x’s and y’s is like reflecting the graph across the diagonal, making the axes trade places and swapping the x- and y-values for point on the line. Let’s do that with our Covid model…​

A graph showing the exponential rise in positive test cases in Massachusetts over time, reflected across y=x to show the inverse, logarithmic relationshipSwapping the x- and y-axes makes the graph start with rapid growth, and then flatten out. Now we can answer those inverted questions!

  • During the pandemic, our initial value was roughly 120,000 cases.

  • By 150,000 cases, it was 75 days later.

  • By 300,000 cases, it was 112 days later.

  • By 400,000 cases, it was 122 days after.

This kind of growth is much easier to understand, and much more alarming! By switching the axes, we’ve given our brains a much better chance of understanding what was really happening.

A graph showing the exponential rise in positive test cases in Massachusetts over time, reflected across y=x to show the inverse, logarithmic relationship

But our inverted model isn’t exponential at all. In fact, it looks a lot more like our Wealth-v-Lifespan data!

What kind of growth is this?

This kind of growth is called logarithmic growth. Logarithmic functions are closely related to exponential functions!

Exponential Logarithmic

𝑓(π‘₯) = 3π‘₯

𝑔(π‘₯) = π‘™π‘œπ‘”3(π‘₯)

Tells us "what 3 to the power of 'the input' is"

Tells us "what power 3 needs to be raised to reach 'the input'"

𝑓(2) = 32 = 9

𝑔(9) = π‘™π‘œπ‘”3(9) = 2

  • What will 𝑓(4) evaluate to?

    • 𝑓(4) = 34 = 27

  • What will 𝑔(27)) evaluate to?

    • 𝑔(27) = π‘™π‘œπ‘”3(27) = 2

"A logarithmic relationship looks exponential, if your π‘₯'s and 𝑦's trade places!"

By "reversing the question", logarithmic functions and exponential functions serve as inverses of one another:

  • The inputs and outputs are reversed

  • The Domain and Range are swapped

  • The curve is reflected over 𝑦 = π‘₯

To practice spotting logarithmic curves and their connection to exponentials, complete What Kind of Model? (Graphs & Plots).

Exponential Function Logarithmic Function

We know that exponential functions grow by equal factors over the same interval. We can describe their growth by calculating the growth factor: "what 𝑦 is multiplied by" in order to produce the next value over a constant interval.

Instead of multiplying 𝑦 by a constant to find the next value, we need to multiply the size of our x-interval by a constant (called the base) in order to get a constant growth in 𝑦!

A table with columns for x (1,2,3,4,5) and y (2,4,8,16,32), arrows showing the factor by which each y-value value is multiplied (2,2,2,2) over a constant increase in x

A table with columns for x (2,4,8,16,32) and y (1,2,3,4,5), arrows showing the factor by which each x-value value is multiplied (2,2,2,2) to get a constant increase in y

Just as swapping the Domain and Range makes a logarithmic curve look exponential, swapping the (x,y) columns of a table makes a logarithmic sequence look exponential.

  • Turn to What Kind of Model? (Tables) and decide whether you think each table is best modeled by a quadratic, exponential or logarithmic function.

  • If the table shows an exponential or logarithmic relationship, identify the base.

  • What strategies did you use to decide if a table represented a quadratic, exponential, or logarithmic function?

  • Was it especially difficult (or simple) to recognize any these function types? Why?

For practice translating logarithmic expressions into words and evaluating them turn to Evaluating Logarithmic Expressions.

A table showing varying sound intensity levels (i.e., whisper, fortissimo, jet take-off) in watts per square meter and in decibelsLogarithmic relationships allow us to compare things of very different sizes!

  • We perceive loudness on a logarithmic scale. We can hear a pin drop, but we can also process sounds as loud as a fog horn without getting hurt. A fire alarm is thousands of times louder than a dog barking, but our brains don’t process that difference.

  • For us to perceive one sound as being twice as loud as another, it actually has to be a hundred times as loud.

We don’t hear the world as it really is. We hear a logarithmically compressed version of it!

The sky and land below, when see from an airplane window. The tip of the wing is also in view.

  • When looking out airplane window, our eyes take in hundreds of miles' worth of visual data all at once!

  • A fraction of our field of view shows us just a few feet of the airplane wing, but that same fraction shows us hundreds of miles when looking at the ground far away.

Railroad tracks stretching out into the distance, appearing to almost meet at the horizon

  • We know that parallel lines never intersect.

  • But when looking at a railroad track this compression makes the rails grow closer and closer in the distance, until it looks like they might touch.

We don’t see the world as it really is. We see a logarithmically compressed version of it!

Railroad tracks stretching out into the distance, appearing to almost meet at the horizon

  • The Scoville Scale measures how spicy a pepper is on a scale from 1-10+++. (JalepeΓ±os, for example, rank near the bottom of the scale!)

  • Each unit on the scale is exponentially hotter, so a pepper that measures a 4.0 is actually ten times spicier than a 3.0.

We don’t taste spiciness as it really is. We taste a logarithmically compressed version of it!

Investigate

Sync or pace students to Slide 4: Exploring Logarithmic Functions of Fitting Wealth-v-Health and Exploring Logarithmic Models (Desmos).

Decide whether you want to debrief this activity with your students after they complete each section or wait until they have finished completing Graphing Logarithmic Models: f(x) = a logb x + c.

Logarithmic models have the form 𝑓(π‘₯) = π‘Ž log𝑏(π‘₯) + 𝑐

  • Let’s return to the Desmos file and explore how the constants in a logarithmic function definition impact the shape of its graph.

  • You should now be on Slide 4: Exploring Logarithmic Functions

  • Use it to complete Graphing Logarithmic Models: f(x) = a logb x + c

Review students answers, and then debrief via class discussion. Invite students to consider what new information they have gained by looking at graphical representations rather than tables.

Base 𝑏

The base of the logarithm is similar to the base (or growth factor) in an exponential expression…​it just answers the opposite question!

Exponential Expression Logarithmic Expression

32

log3(9)

"calculate 3 to the power of 2"

"calculate what power 3 is raised to in order to reach 9"

Evaluates to 9

Evaluates to 2

The expression π‘™π‘œπ‘”2(1) is asking "to what power must 2 be raised to reach 1?

  • What power of 2 will evaluate to 1?

    • Zero

  • What question is π‘™π‘œπ‘”5(1) asking?

    • "To what power must 5 be raised, to reach 1?"

  • What power of 5 will evaluate to 1?

    • Zero

  • What can we conclude about logs that evaluate to 1?

    • They will always be zero, regardless of base!

No matter the base, π‘™π‘œπ‘”(1) will always be zero!

  • Turn to What Kind of Model? (Descriptions) and practice identifying whether the scenarios are best modeled by linear quadratic, exponential, or logarithmic functions.

  • What clues did you use to help you identify which relationships were which?

Have students share their answers. Be especially attentive to students who mis-label logarithmic relationships as "exponential" — the relationship between the two is extremely subtle!

Most math books, Desmos, calculators, and programming languages offer a simple "log" function that doesn’t specify a base. By convention, if the base isn’t specified, it’s assumed to be base-10. Pyret’s log function works the same way:

log(1000) # returns 3, because 10^3 = 1000

If you want to work with a different base, you can look up Pyret’s log-base function in the contracts pages.

Vertical Shift 𝑐

The term 𝑐 is the vertical shift of the function, which moves the curve up or down.

Since π‘™π‘œπ‘”π‘Žπ‘›π‘¦π‘‘π’½π‘–π‘›π‘”(1) = 0, the value of a standard log model at π‘₯ = 1 will always be 0 + 𝑐.

(We’ve seen vertical shifts in other kinds of functions given different names, like π‘˜ for quadratics and 𝑏 for linear functions.)

Logarithmic Coefficient π‘Ž

The term π‘Ž is called the logarithmic coefficient, which - like 𝑏 - helps determine how quickly the function grows.

  • What do you remember about the asymptote of a function with exponential growth?

    • It’s horizontal at π‘˜, where 𝑦 grows or shrinks by smaller and smaller amounts approaching zero

Functions with logarithmic growth have a vertical asymptote where the function gets closer and closer, but never crosses the line.

In this data exploration, the asymptote will always be located on the y-axis (π‘₯ = 0).

Extremely observant students may notice that there’s a relationship between π‘Ž and 𝑏, where the value of 2 log10(10) = log10(102 )!

Synthesize

  • What similarities do you see between exponential and logarithmic functions?

  • What differences do you see between exponential and logarithmic functions?

🔗Fitting by Changing Scale 30 minutes

Overview

Students discover that when a logarithmic relationship is graphed on an exponential scale, the point cloud appears linear. When trying to use linear regression with those points, however, they are reminded that merely changing the scale of a graph does not actually change the data.

This section builds the foundation for linearization, transforming the points themselves, which students will do in the following section. (Note: this also opens the door for teaching inverse functions!)

Launch

Sync or pace students to Slide 5: Wealth-v-Health (Logarithmic) of Fitting Wealth-v-Health and Exploring Logarithmic Models (Desmos).

  • Let’s return to the Fitting Wealth-v-Health and Exploring Logarithmic Models Desmos file.

  • You should now be on the slide 5: "Wealth-v-Health (Logarithmic)".

  • Use it to complete the first section of Changing the Scale.

  • What values did you come up with for π‘Ž and 𝑐 in your best-guess logarithmic model?

    • Record different students' responses for π‘Ž and 𝑐 on the board.

  • How do your π‘Ž and 𝑐 values compare with those of other students'? Are they very similar or very different?

  • What were the 𝑆 values for these models?

Trial-and-error only gets us so far, and it’s not clear that we would ever stumble upon the optimal model.

We need something like Pyret’s lr-plot, which uses computational methods to find the optimal model.

Unfortunately, lr-plot only finds linear models in data with linear relationships.

Data Scientists often use transformations to stretch their data into shapes that are easier to work with, and then reverse the transformation when they are done. If only we could transform this data to make it appear linear. Then we could use lr-plot to fit the optimal model, and then reverse the transformation to get the optimal logarithmic model!

Investigate

  • Imagine that the scatter plot is printed on a sheet of rubber, and can be stretched or squashed in any way we want…​

  • With that image in mind, follow the directions on the last section of Changing the Scale.

Students will be switching the x-axis of their graph from linear to logarithmic in this section. Make sure they are toggling back and forth between the two views as they look for the best-fitting model.

  • A person running on a treadmill doesn’t change location. Why not?

    • Their forward movement is balanced by the backwards movement of the treadmill.

  • If they run faster and faster, what needs to happen to the treadmill to keep them in the same place?

    • The treadmill needs to go faster as well. As long as the treadmill speed increases at the same rate as the runner, they will balance one another’s growth.

  • How is the treadmill example comparable to what we’ve done with our x-axis transformation?

    • We are speeding up the growth intervals on the x-axis to "keep up with" the speed of growth in the data so that we can see the pattern better.

When we changed Desmos’s view from "Linear" to "Logarithmic", we made the x-axis grow faster and "squish" the dots so they appear linear. By transforming the x-axis to grow exponentially, we are squashing the coordinate plane so that each interval on the x-axis represents 10x the growth in pc-gdp as the one before it. This balances out the logarithmic growth in median-lifespan, and warps our logarithmic model so the curved looks like linear.

Going Deeper: Connecting to Inverse Functions

While this metaphor doesn’t cover inverses in any real depth, the treadmill analogy opens the door to discussing how one kind of change can "cancel out" or "undo" another.

We are working to add additional material on inverse functions to our Algebra 2 materials, and hope to release them in the coming year!

Synthesize

  • How does seeing the point cloud as linear help us think about logarithmic growth?

  • Transforming the axes only makes things look linear - the actual points haven’t changed at all, and we still can’t use linear regression to find the best logarithmic model…​ Can you think of a way we could transform the data, instead of the axes?

🔗Fitting by Transforming Data 45 minutes

Overview

Having discovered that changing the scale of a graph allows us to see logarithmic growth as linear, but still doesn’t allow us to treat it as linear, students learn to transform the data by applying a function to each row and building a new column that can be fit with a linear model. By applying the inverse of this transformation to their computed linear model, students can derive the optimal logarithmic model.

Launch

We tried changing the scale on the x-axis from linear to logarithmic, which cancels out the logarithmic behavior by shrinking the x-axis to make intervals that grow exponentially. Exponentially-bigger intervals on the x-axis cancel out the logarithmic growth on the y-axis, by squishing the points to appear linear.

Unfortunately, this transformation is only skin-deep: the underlying data is still logarithmic, which makes it impossible for us to use linear regression to obtain an optimal model.

Another strategy is to shrink the data, by transforming the x-coordinates themselves. Instead of plotting pc-gdp on a logarithmic x-axis, we could plot log(pc-gdp) on a linear one.

Sync or pace students to Slide 6: Wealth-v-Health (Transformed) of Fitting Wealth-v-Health and Exploring Logarithmic Models (Desmos).

  • Let’s return to the Fitting Wealth-v-Health and Exploring Logarithmic Models Desmos file.

  • You should now be on slide 6: "Wealth-v-Health (Transformed)".

  • Use it to complete Transforming the Data (the whole page, not just the first section).

  • What values did you come up with for our coefficients π‘š and 𝑏 in your best-guess linear model?

    • Record different students' responses for π‘š and 𝑏 on the board.

    • These numbers should be somewhat close to their earlier responses for π‘Ž and 𝑐!

  • Were those values very similar or very different?

  • How close were the values from our best-guess logarithmic model?

  • How was transforming the data similar to changing the scale on the x-axis?

    • Transforming the data and changing the scale both made the logarithmic relationship look linear.

  • How was it different?

    • Changing the scale just made things look linear, but the data wasn’t any different so we still couldn’t use linear regression on it.

Transforming the points instead of the axis has the same visual effect: the dots appear to fall in a straight line. But now we can plot them on a linear-scale axis, and use linear regression to find the best-possible model!

This transformation changed the kind of growth from logarithmic to linear: instead of increasing logarithmically by π‘Ž, our new function increases linearly by π‘Ž.

The term went from π‘Ž log10(π‘₯) to π‘Žπ‘₯, turning our logarithmic coefficient into…​*slope*.

Investigate

We transformed the pc-gdp column in three steps:

  1. We defined a transformation function, 𝑔(π‘₯), which produces the log of whatever it’s given (the pc-gdp column).

  2. We defined a new column to use as our x-values, populating it by applying the transformation to each of our original x-values.

  3. We displayed these transformed datapoints as a scatter plot.

If we can do this in Pyret, we could run linear regression on the transformed data, and then use what we know about the coefficients to turn our optimal linear model into an optimal logarithmic one!

  • Turn to Logarithmic Models.

  • Complete the first part ("Transforming: From Logarithmic Plots to Linear Ones"), then pause for class discussion.

Address any student questions about build-column, the Pyret function they’ve just discovered. Verify that students have recorded the slope and vertical shift for their regression line. Then, emphasize the key ideas below.

  • At each point in our linear model, 𝑦 is the predicted median lifespan, and π‘₯ is the log of per-capita gdp in thousands.

  • We want π‘₯ to represent the original, un-transformed value, simply using per-capita gdp in thousands as-is…​

We’ve learned that:

  • the slope in the transformed, linear model is the same as the log coefficient in the un-transformed logarithmic model

  • the vertical shift in the transformed, linear model is the same as the vertical shift in the un-transformed logarithmic model

Use this knowledge to complete the second part ("Inverting: From Linear Models to Logarithmic Ones") of Logarithmic Models.

A pyret lr-plot comparing log(pc-gdp) to median-incomeJust like in Desmos, transforming the pc-gdp column with a log function produces a scatter plot showing a linear pattern in the data!

Pyret’s lr-plot tool computes the best possible linear model for our transformed data:

𝑦 = 11.9011π‘₯ + ~59.967

Our 𝑆 has dropped to 4.49, showing a much better correlation than before.

A pyret fit-model plot showing a logarithmic model for pc-gdp and median-incomeFrom Transforming the Data, we know that the coefficients used in the transformed, linear model are the same ones used in the logarithmic, un-transformed model:

π‘™π‘œπ‘”π‘Žπ‘Ÿπ‘–π‘‘π’½π‘šπ‘–π‘3(π‘₯) = 11.9011 log10(π‘₯) + 59.967

fun logarithmic3​(​x​): (​11.9011 * log​(​x​)​) + 59.967 end

The resulting logarithmic model can be fit to our original scatter plot, showing a much better fit than our 2-point-derived estimates.

  • How do you interpret this model?

Optional Activity: Guess the Model!

  1. Divide students into teams of 2-4, and have each team come up with a logarithmic, real-world scenario, then have them write down a logarithmic function that fits this scenario on a sticky note. Make sure no one else can see the function!

  2. On the board or some flip-chart paper, have each team draw a scatter plot for which their logarithmic function is best fit. They should only draw the point cloud - not the function itself! Finally, students title display to describe their real-world scenario (e.g. - "Age of a Person from Birth to 16 vs. Number of Cells in their Body").

  3. Have teams switch places or rotate, so that each team is in front of another team’s scatter plot. Have them figure out the original function, write their best guess on a sticky note, and stick it next to the plot.

  4. Have teams return to their original scatter plot, and look at the model their colleagues guessed. How close were they? What strategies did the class use to figure out the model?

    • The coefficients can be constrained to make the activity easier or harder. For example, limiting these coefficients to whole numbers, positive numbers, etc.

    • To extend the activity, have the teams continue rotating so that each group adds their sticky note for the best-guess model. Then do a gallery walk so that students can reflect: were the models all pretty close? All over the place? Were the guesses for one coefficient grouped more tightly than the guesses for another?

Synthesize

  • Why is the S-value for our logarithmic model the same as the S-value for our linear model after transforming?

  • Why were our coefficients for linear and logarithmic models the same, even though they were for different terms?

  • Why do you think the relationship between wealth and median lifespan is logarithmic?

🔗Additional Exercises

For more practice transforming data and programming with filters:

Does Wealth impact lifespan equally if there’s Universal Healthcare? is a guided activity that repeats the Data Science and Linearization techniques used here, but with the idea of exploring the relationship of universal healthcare with respect to wealth and median lifespan.

Coming Soon!

We are working on collecting more datasets that can be modeled with logarithmic functions so that we can offer students more practice with using linear regression to build logarithmic models.

These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, 1738598, 2031479, and 1501927). CCbadge Bootstrap by the Bootstrap Community is licensed under a Creative Commons 4.0 Unported License. This license does not grant permission to run training or professional development. Offering training or professional development with materials substantially derived from Bootstrap must be approved in writing by a Bootstrap Director. Permissions beyond the scope of this license, such as to run training, may be available by contacting contact@BootstrapWorld.org.