Chuyển đến nội dung

Bài 34 · Functions and Modeling

Modeling with Functions

Choose and build linear, quadratic or exponential models from data using differences and ratios, then use them to make predictions, with code checks.

A mathematical model is a function that describes how some real quantity behaves. Once you have a good model you can make predictions: how much will it cost, how high will the ball go, when will the population reach a million?

The hard part is choosing the right kind of function. This lesson shows you a simple test using the pattern in the data.

Three families of models

Family Form Pattern in equally spaced data
Linear y = mx + b constant first differences
Quadratic y = ax² + bx + c constant second differences
Exponential y = a · bˣ constant ratios

To use the test, take the outputs for equally spaced inputs (such as x = 0, 1, 2, 3, ...) and compute differences or ratios between neighbors.

Example 1. Outputs: 5, 9, 13, 17, 21. First differences: 4, 4, 4, 4. Constant, so the model is linear with slope 4. Since y = 5 at x = 0, y = 4x + 5.

Example 2. Outputs: 1, 3, 7, 13, 21. First differences: 2, 4, 6, 8. These are not constant. Second differences: 2, 2, 2. Constant, so the model is quadratic with a = 2/2 = 1 (the second difference equals 2a). Try y = x² + bx + 1: at x = 1, 1 + b + 1 = 3, so b = 1. The model is y = x² + x + 1. Check x = 3: 9 + 3 + 1 = 13. Correct.

Example 3. Outputs: 2, 6, 18, 54. Ratios: 3, 3, 3. The model is exponential, y = 2 · 3ˣ.

Python Which family fits the data?

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

From data to a model

You can find a model in three steps:

  1. Look at the pattern and choose the family.
  2. Use known points to find the unknown numbers (m and b, or a, b, c, or a and b).
  3. Test the model on a data point you did not use.

Example 4: a ball in the air. A ball is thrown upward. Its height (meters) at 0, 1, 2, 3 seconds is 2, 17, 22, 17. Second differences: first differences are 15, 5, −5; second differences are −10, −10. The data are quadratic, with 2a = −10, so a = −5. Then h = −5t² + bt + 2. At t = 1: −5 + b + 2 = 17, so b = 20. The model is h(t) = −5t² + 20t + 2. Check t = 2: −20 + 40 + 2 = 22. Correct.

The ball's highest point is at t = −b/(2a) = 2 seconds, with height 22 m. Since the model has a vertex at t = 2, the ball is at its peak there, as the symmetric data suggested.

Python Fit a quadratic model and test it

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Using and questioning a model

A model gives predictions, but it is only as good as its assumptions.

  • Interpolation (predicting inside the range of your data) is usually safe.
  • Extrapolation (predicting far outside the data) can be badly wrong. A plant that grew exponentially for 5 weeks will not keep doing it forever.
  • Pay attention to the domain: a negative time or a negative number of people makes no sense.
  • Real data are rarely perfect. Small measurement errors mean differences are only roughly constant; you then choose the family that fits best.

Always state what the variables mean and their units, such as "h is the height in meters and t is the time in seconds". Without that, a model is just an equation.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. Outputs 3, 7, 11, 15 at x = 0, 1, 2, 3 suggest which model?

    The first differences are all 4, so it is linear: y = 4x + 3.
  2. 2. Outputs 4, 8, 16, 32 suggest which model?

    Each output is twice the one before, so y = 4 · 2ˣ.
  3. 3. If the second differences of equally spaced data are all 6, what is a in ax² + bx + c?

    The second difference equals 2a, so a = 3.
  4. 4. Why is extrapolating far beyond the data risky?

    A model fitted to one range need not describe a very different range.

Summary

  • Constant first differences mean linear, constant second differences mean quadratic, and constant ratios mean exponential.
  • Choose the family, solve for the unknown numbers using data points, and test with a point you did not use.
  • Interpolate with confidence; extrapolate with caution.
  • Always state what the variables and units mean.

Next: Practice Set: Polynomials and Factoring

Theo dõi tiến độ của bạn

Tạo tài khoản miễn phí để đánh dấu bài đã học và tiếp tục từ chỗ bạn dừng lại trên mọi thiết bị.