DERIVE Strategies for Curve Fitting



Introduction

This page constitues an exercise using DERIVE to linearize data, obtain a linear fit, the 'unlinearize' the resulting function to obtain a model of the original data.  It will help you review the important concept of linearizing data by using a transformation, then using the inverse transformation to obtain the desired model.  It will also review and extend your capabilities with DERIVE.

You know how to use DERIVE to fit linear, quadratic, power and polynomial functions to data sets using syntax of the form

fit( [ x, ax^2 + bx + c ] , #1).

The DERIVE program finds best-fit values for the parameters a, b and c, and returns the quadratic function appropriate to the data.

We might be tempted to try a fit of the form fit( [x, A e^(kx) + c], #1) for exponential data, expecting the program to find good values of the parameters A, k and c. However, the parameter k is not a linear parameter like A and c. The parameter k appears in an exponent, and DERIVE can't deal with that.

Our strategy must be to first linearize our data, then use a linear fit to obtain a y = mx + b function which we then transform back to fit the original data.

Linearizing data using DERIVE

You will recall that we can linearize exponential or power-function data by transforming a y vs. x data set

into a log(y) vs. x data set if the data is exponential, or

into a log(y) vs. log(x) data set if the data is power-function in nature.

It is fairly easy to transform a data set in DERIVE.

For example, suppose we wish to transform the y vs. x data set [ [1,2], [2,4], [3,8], [4,16] ] into a ln(y) vs. x data set. (Note that we are using the natural log ln rather than the base-10 log. This is because DERIVE understands only the natural log.)

We simply rewrite the data set as [ [1,ln(2)], [2,ln(4)], [3,ln(8)], [4,ln(16)] ].

We can then plot this data set to see how nearly linear it appears. If the plot is reasonably linear, we can then do a linear fit to the data.

Exercises 1-2

1.  Author the above data set [ [1,2], ... ]. Then use Author and F3 to edit this set and insert the ln before each y value. Enter this expression, that simplify it and see if the resulting data set looks like it might be linear. Then plot it and see how linear it looks.

Perform a linear fit to this data using the syntax fit( [x,mx+b], dataSet ).

Plot your linear fit and see how well it fits the data.

2.  The data set [ [1,100], [2,25], [3,11], [4,6] ] can be nearly fit with a power function.

Repeat the procedure of the first problem, but take the natural log ln of both the x and the y values.

You should obtain a very good fit.

Inverse Transformations using DERIVE

After you obtain a mx + b function for your linearize data, you will have to 'unlinearize' the data with one or more inverse transformations.

If your linearized data was of the form ln y vs. x, then your function really means ln(y) = mx + b.

If your linearized data was of the form ln y vs. ln x, then your function really means ln(y) = m ln(x) + b.

Suppose for example that a ln(y) vs. x data set gave you the linear function

3x + 5 .

Then you know that the actual function is of form

ln(y) = 3x + 5.

From previous work you know that you can solve this equation easily enough by using the base e exponential function, which is the inverse of the natural log:

e^ [ ln(y) ] = e^(3x + 5)

y = e^(3x + 5)

y = e^5 * e^(3x)

y = 148 (e^3) ^ x

y = 148 * 20 ^ x.

This solution is not difficult and you should know how to do it. However once you know how to perform these steps DERIVE can save you a lot of work.

You can simply author the expression

ln(y) = 3x + 5 (use F3 to grab the 3x + 5 expression),

then use the soLve command, being sure to choose y as the variable for which you are solving.

Exercises 3-5

3.  Follow the above strategy for 'unlinearizing' a fit to exponential data, using the linear function you obtained in exercise 1.  Simplify your expression using the Simplify command.

Do the algebra required to verify that DERIVE has indeed obtained the correct expression.

Plot your original data for exercise 1, and plot the y vs. x function obtained in this exercise. How well does your model fit the data?

4.  Follow a similar strategy for 'unlinearizing' the fit you obtained for power-function data in exercise 2. This time you will of course replaced both x and y with their natural logs, replacing x with ln(x) and y with ln(y).

As before do the algebra and compare the plots.

5.  Determine whether the each of the following data sets is better linearized using the exponential function strategy ( ln y vs. x) or the power function strategy ( ln y vs. ln x), and obtain the y vs. x function corresponding to the better strategy:

[ [2,3], [4,8], [6,15], [8,23] ]

[ [1, 3], [2,10], [3,30], [4,80] ].