Intersect Prep

Regression and choosing a model for AP Precalculus

Updated

AP Precalculus asks you to build models from data, not just use them. You look at a table, decide which kind of function fits, run a regression in Desmos, and then judge the fit with residuals. The second free-response question, Modeling a Non-Periodic Context, is built around exactly this, and it's on a calculator part of the exam.

This guide covers how to choose a model, the Desmos syntax for each regression, how to read a residual plot, and what a semi-log plot tells you. Every example uses coefficients from a regression that was actually run on the data shown.

Choosing a model from a table

When the inputs are equally spaced, look at how the outputs change from one row to the next. The pattern points to a model type.

  • Linear: the differences between outputs are about constant. The output changes by the same amount each step.
  • Quadratic: the differences change by about the same amount each step, so the second differences are about constant.
  • Cubic: the third differences are about constant.
  • Exponential: the ratios of outputs are about constant. The output is multiplied by the same factor each step.
  • Logarithmic: multiplying the input by a constant factor adds about the same amount to the output. Look at inputs like 1,2,4,81, 2, 4, 8.
  • Sinusoidal: the outputs rise and fall in a repeating cycle.

Real data won't match a pattern exactly, so check two more things. Shape: does the scatter plot curve, level off, or turn around? A quadratic turns around once, and an exponential never does. Context: a drug in the bloodstream decays toward 00, so a linear model that goes negative can't be right for long. Population growth by a percent each year suggests exponential.

Running a regression in Desmos

  1. 1Click the + in the expression list and choose table. Desmos names the columns x1x_1 and y1y_1.
  2. 2Type the inputs in the x1x_1 column and the outputs in the y1y_1 column. The points appear on the graph.
  3. 3On a new line, type the model with a tilde, ~, in place of the equals sign. Desmos finds the best values of the letters and prints them below the line.
  • Linear: y1∼mx1+by_1 \sim m x_1 + b
  • Quadratic: y1∼ax12+bx1+cy_1 \sim a x_1^2 + b x_1 + c
  • Cubic: y1∼ax13+bx12+cx1+dy_1 \sim a x_1^3 + b x_1^2 + c x_1 + d
  • Exponential: y1∼abx1y_1 \sim a b^{x_1}
  • Logarithmic: y1∼a+bln⁡(x1)y_1 \sim a + b \ln(x_1)
  • Sinusoidal: y1∼asin⁡(bx1+c)+dy_1 \sim a \sin(b x_1 + c) + d

After the regression runs, the letters are defined everywhere in that graph. Type f(x)=abxf(x) = a b^{x} on a new line and you can evaluate f(8)f(8), or graph y=6y = 6 and click where it crosses ff. Desmos uses the full unrounded values, so your predictions don't pick up rounding error.

Worked example: an exponential model

A car losing value

The value VV of a used car, in thousands of dollars, tt years after it was bought is shown. tt: 0,1,2,3,4,50, 1, 2, 3, 4, 5. VV: 24.0,20.5,17.6,15.1,12.9,11.024.0, 20.5, 17.6, 15.1, 12.9, 11.0. (a) Explain why an exponential model is appropriate. (b) Find an exponential regression V=abtV = a b^{t}. (c) Use the model to predict the value at t=8t = 8, and say what bb means in context.

(a) The ratios of consecutive values are 20.524.0≈0.854\frac{20.5}{24.0} \approx 0.854, then 0.8590.859, 0.8580.858, 0.8540.854, and 0.8530.853. Over equal one-year steps, the value is multiplied by about the same factor, which is the pattern of an exponential model.

(b) Enter the table and type y1∼abx1y_1 \sim a b^{x_1}. Desmos gives a≈23.990a \approx 23.990 and b≈0.856b \approx 0.856, so V=23.990(0.856)tV = 23.990(0.856)^{t}.

2468510152025(8, 6.927)
y=23.990(0.856)xy = 23.990(0.856)^{x}The data points and the exponential regression. The curve passes very close to every point.

(c) Type f(x)=abxf(x) = a b^{x} and then f(8)f(8). Desmos shows 6.9276.927, so the model predicts a value of about 6.9276.927 thousand dollars. If you use the rounded values instead, 23.990(0.856)8≈6.91523.990(0.856)^{8} \approx 6.915, which is slightly off. The base b≈0.856b \approx 0.856 means the car keeps about 85.6%85.6\% of its value each year, so it loses about 14.4%14.4\% per year.

Answer: (a) Nearly constant ratios, about 0.850.85 to 0.860.86. (b) V=23.990(0.856)tV = 23.990(0.856)^{t}. (c) About 6.9276.927 thousand dollars; the car loses about 14.4%14.4\% of its value each year.

Reading residuals

A residual is the actual value minus the predicted value: residual =y−y^= y - \hat{y}. A positive residual means the model predicted too low for that point. A negative one means it predicted too high.

Under a regression line, Desmos lists the residuals as a new variable, e1e_1, with an option to plot them. Plotting e1e_1 against x1x_1 gives a residual plot. A good model leaves small residuals scattered above and below 00 with no pattern. A curved pattern, such as positive at both ends and negative in the middle, means the model is missing the shape of the data.

Linear or quadratic for stopping distance

A car's stopping distance dd, in feet, at speed ss, in miles per hour, is measured. ss: 20,30,40,50,60,7020, 30, 40, 50, 60, 70. dd: 40,73,117,169,231,30540, 73, 117, 169, 231, 305. Use residuals to decide whether a linear or a quadratic model is more appropriate, then use that model to predict the stopping distance at 4545 miles per hour.

The first differences are 33,44,52,62,7433, 44, 52, 62, 74, so the data aren't linear. The second differences are 11,8,10,1211, 8, 10, 12, close to constant, which already hints at a quadratic.

A linear regression, y1∼mx1+by_1 \sim m x_1 + b, gives d=5.289s−82.152d = 5.289s - 82.152. Its residuals are about 16.4,−3.5,−12.4,−13.3,−4.2,17.016.4, -3.5, -12.4, -13.3, -4.2, 17.0: positive at both ends and negative in the middle.

203040506070-15-10-551015
y=0y = 0Residuals of the linear model. The U shape means a line misses the curve in the data.

A quadratic regression, y1∼ax12+bx1+cy_1 \sim a x_1^2 + b x_1 + c, gives a≈0.049a \approx 0.049, b≈0.837b \approx 0.837, and c≈3.586c \approx 3.586. Its residuals are −0.1,−0.2,0.8,−0.1,−0.9,0.5-0.1, -0.2, 0.8, -0.1, -0.9, 0.5: all under 11 foot, with no pattern.

203040506070-15-10-551015
y=0y = 0Residuals of the quadratic model, on the same scale.

The quadratic model is more appropriate. Define f(x)=ax2+bx+cf(x) = a x^2 + b x + c and evaluate f(45)f(45): about 141.406141.406 feet. With the rounded coefficients you'd get about 140.476140.476, a full foot off, which is why you let Desmos keep the unrounded values.

Answer: Quadratic, because its residuals are small and patternless while the linear residuals form a U shape; about 141.406141.406 feet at 4545 mph.

Semi-log plots

A semi-log plot puts ln⁡y\ln y (or log⁡y\log y) on the vertical axis and keeps xx as it is. If the points on a semi-log plot form a line, the data are exponential. Here's why: if y=abxy = a b^{x}, then ln⁡y=ln⁡a+xln⁡b\ln y = \ln a + x \ln b, which is linear in xx with slope ln⁡b\ln b and intercept ln⁡a\ln a.

To go back from a line ln⁡y=mx+k\ln y = mx + k to an exponential model, undo the log: y=emx+k=ek(em)xy = e^{mx + k} = e^{k}(e^{m})^{x}. So a=eka = e^{k} and b=emb = e^{m}. For a base-10 log, use 1010 in place of ee. In Desmos, make the new column by typing L=ln⁡(y1)L = \ln(y_1), then fit L∼mx1+kL \sim m x_1 + k.

Views of a new video

A video's views vv on day dd after posting were 150,260,470,820,1450,2560150, 260, 470, 820, 1450, 2560 for d=1d = 1 to 66. (a) Fit a line to the points (d,ln⁡v)(d, \ln v). (b) Turn it into an exponential model for vv. (c) Predict the views on day 88.

(a) The logs are about 5.011,5.561,6.153,6.709,7.279,7.8485.011, 5.561, 6.153, 6.709, 7.279, 7.848. They go up by about 0.570.57 each day, so the semi-log plot is close to a line. The regression L∼mx1+kL \sim m x_1 + k gives m≈0.569m \approx 0.569 and k≈4.437k \approx 4.437.

1234565678
y=0.569x+4.437y = 0.569x + 4.437On a semi-log plot the points fall on a line, so the views grow exponentially.

(b) v=e4.437(e0.569)dv = e^{4.437}(e^{0.569})^{d}. With the unrounded values, a=ek≈84.515a = e^{k} \approx 84.515 and b=em≈1.766b = e^{m} \approx 1.766, so v=84.515(1.766)dv = 84.515(1.766)^{d}. The views grow by about 76.6%76.6\% per day.

(c) v=e8m+k≈7983v = e^{8m + k} \approx 7983 views. That's extrapolation past the last measured day, and growth this fast can't last, so treat it as a rough estimate.

Answer: (a) ln⁡v=0.569d+4.437\ln v = 0.569d + 4.437. (b) v=84.515(1.766)dv = 84.515(1.766)^{d}. (c) About 79837983 views.

Worked example: a logarithmic model

A new worker speeding up

A new warehouse worker packs yy boxes per hour after xx days on the job. xx: 1,2,4,8,161, 2, 4, 8, 16. yy: 20,26,31,37,4220, 26, 31, 37, 42. Explain why a logarithmic model fits, find a logarithmic regression model for yy, and predict the rate after 3030 days.

Each input is double the one before, and each doubling adds about the same amount: 6,5,6,56, 5, 6, 5. Equal factors in the input giving equal changes in the output is the logarithmic pattern. A linear model would need equal changes for equal steps in xx, and these steps get longer.

Type y1∼a+bln⁡(x1)y_1 \sim a + b\ln(x_1). Desmos gives a≈20.200a \approx 20.200 and b≈7.935b \approx 7.935.

5101520253020304050(30, 47.188)
y=20.200+7.935ln⁡(x)y = 20.200 + 7.935\ln(x)The logarithmic curve rises quickly at first, then slows down.

20.200+7.935ln⁡(30)≈47.18820.200 + 7.935\ln(30) \approx 47.188 boxes per hour. The model keeps rising without bound, which can't be true forever, so it's best used near the measured days.

Answer: y=20.200+7.935ln⁡(x)y = 20.200 + 7.935\ln(x); about 47.18847.188 boxes per hour after 3030 days.

A quick check

From a semi-log line to a model

A data set of positive values lies very close to the line ln⁡y=0.2x+1.5\ln y = 0.2x + 1.5 on a semi-log plot. Which model fits the data?
  1. A. y=4.482(1.221)xy = 4.482(1.221)^{x}
  2. B. y=1.5(0.2)xy = 1.5(0.2)^{x}
  3. C. y=0.2x+1.5y = 0.2x + 1.5
  4. D. y=1.5(1.221)xy = 1.5(1.221)^{x}

Undo the log: y=e1.5(e0.2)xy = e^{1.5}(e^{0.2})^{x}, and e1.5≈4.482e^{1.5} \approx 4.482 and e0.2≈1.221e^{0.2} \approx 1.221. Choice C is the line for ln⁡y\ln y, not for yy. Choice D forgets to exponentiate the intercept.

Answer: A

The algebra behind these models, like turning e0.2xe^{0.2x} into (1.221)x(1.221)^{x}, is in the exponential and logarithmic equations guide. For everything else Desmos does on test day, see Desmos on the AP Precalculus exam.

Keep going

Practice on exam-style questions

Intersect Prep has 112 multiple-choice questions for Unit 2, with a full solution for each one. Create a free account to try a full lesson with the calculator. One payment of $29 unlocks the course for 3 months, or $39 for 6 months.

Questions

How do I know whether data are linear or exponential?
With equally spaced inputs, check the outputs. About constant differences point to linear, and about constant ratios point to exponential.
What does a residual plot tell me?
Whether the model has the right shape. Small residuals scattered above and below zero with no pattern mean the model fits, and a curved pattern means it misses the shape of the data.
What does a linear pattern on a semi-log plot mean?
The data are exponential. A line for ln y with slope m and intercept k means y = a times b to the x, where a is e to the k and b is e to the m.
How do I type an exponential regression in Desmos?
Put the data in a table, then type y_1 ~ ab^(x_1) on a new line, with the tilde in place of an equals sign. Desmos prints the best values of a and b.

Desmos is a trademark of Desmos Studio PBC.