# Dumb calculus question...July 19, 2006 3:27 PM   Subscribe

Stupid calculus question inside.

So I have a detailed plot of a curve that looks rather like exponential decay, but no equation has been given to me to describe the curve.

I would like to find the instantaneous slope of the curve at any given point along its length. Am I correct in assuming that this is really just the first derivative? (I took calculus a long time ago).

I have been provided with a method for finding slope at any point along the curve by physically drawing a tangent to the point and computing ITS slope. Given my desire to use basic calculus to solve this instead, is there an easier/better way for me to calculate slope that doesn't involve irritating sketching of tangent lines and use of straight edges?

A concise, simple-to-grok explanation of what I need to do will win the day....
posted by killdevil to Science & Nature (15 answers total) 1 user marked this as a favorite

Yes instantaneous slope is just the first derivative (assuming a continous function). If you want to calculate the first derivate and you dont have a functional formula for the curve, plug the data you have into Excel and fit an exponential trend line to it to get the best fit exponential curve. Then take the first derivative.
posted by vizsla at 3:31 PM on July 19, 2006

It is indeed the first derivative. Pick a small section, and divide the rise (y distance) by the run (x distance) to get the slope in that area.
posted by Mapes at 3:32 PM on July 19, 2006

Hi, I teach calculus, among other things. The first derivative of a function (no matter whether you have a formula for that function or not) at a point is the slope of the tangent line to the graph at that point. What's the method you're given for finding the slope of the tangent line?
posted by gleuschk at 3:33 PM on July 19, 2006

You say you have a detailed plot but no equation—in looking for the slope at any point you are indeed searching for the first derivative, but without an equation you're going to have a hell of a time taking a derivative of same.

You could replace your draw-and-measure calculations with some guess-and-check overlaying of possible graphs on your existing plot. If you have the correct kind of graph and get the coefficients lined up right, you might be able to effectively duplicate the mystery equation, and then, voila, take the derivative of that.

If your only goal here is to get the slope measurements without tearing your hair out, you might consider which method will get it over with quicker...
posted by cortex at 3:34 PM on July 19, 2006

If the 'method' is just what you mention in the question, "drawing a tangent to the point and computing ITS slope", then does the question use words like "estimate" or "approximate"? I think it's likely that what you're really being asked to do is to eyeball the tangent line at the specified point and guesstimate its slope.
posted by gleuschk at 3:35 PM on July 19, 2006

The method used is really gonna depend on how accurate you need to be. I'd go with Mapes suggestion, and "guesstimate" values in between the smallest division - if this isn't accurate enough, then go with vizsla's approach.

Hell, if you make that excell spreadsheet, you could write a formula to do that rise over run calc for you, then compare the results of the two methods. That's what I would do.

Disclamer: I'm a bit of a math geek.
posted by muddgirl at 3:36 PM on July 19, 2006

You have a detailed graph. What you are doing now is finding the derivitave, point by point, numerically and graphically.

If you want it to be more universal and less hassle, you want to get a table of x and y values for the curve from your plot (the more patience you use in creating this, and the more points you tabulate, the better your results will be). Put them into Excel, Mathematica, Maple, Minitab, SPSS, etc... and try and fit an exponential function to it.

It will give you a best guess (the fit that minimizes the least squared error, generally) equation of the type you specify. You could then take derivatives of that symbollically, and thus have a function that any point could be plugged into to give the slope at that point. These would be as good as the estimate you have for the function, minus any penalty of error propagation for taking the derivative.

Note that fitting curves is not simply plug and chug. You have to make a decent guess as to what kind of curve it is first. All of the tools above will happily fit a line your data -- the fit will just suck and the errors will be huge. Ditto if your guess of an exponential function is wrong.

Any text on numerical analysis will have scads of information on this kind of thing, and estimation in general. I like the one I have, which is by Burden and Faires.
posted by teece at 3:42 PM on July 19, 2006

If the graph is well approximated by an exponential curve, then there's a much simpler way to estimate the derivative. The form of the equation will be y=A*exp(-b*x)

Find the y-value of the curve at x=0. This is A in the above equation. Then find the x-value where the curve is exactly half that value. Divide ln(2) (0.693) by this x-value and you've got your b value. Now the slope at any point should be approximately -A*b.

A quick way to check if this is really exponential decay is to look twice as far out. The curve should have a value that is 1/4 that at x=0. If it's very close, you've got a decent fit.
posted by dsword at 3:52 PM on July 19, 2006

If it truly is an exponential curve (if a exponential fit works best for your data) that makes things fairly interesting. Interesting for a math nerd...

Here is the basic idea. To take a derivative of a single point you take the limit of the slope between two points as those two points get closer and closer together. Draw a line between two points on a graph. The slope of that line is the average slope along that section of the graph. If the points are infintesimally close together it's the average slope over a very small section, or functionally, at a point. So this is how you get the slope at one point. Well using this definition (which is how what I just described is annotated, h being the distance between the points) you can derive a function that gives the derivative at any x-value. Cool, but really tedius to do (lots of algerbra), and difficult for all but the simplest functions. But it turns out there are lots of simple rules to find the derivative function for a given function. This is most of what you learn in the first half of a calculus class (the second half is doing the opposite, integrals). Here are some of those rules, but these things cannot be easily turned into a simple plug-n-chug most of the time. You may have to learn basic calc... or use a program.

Mathematica can do this, most "normal" programming languages have libraries, Excel can, this snazzy web form can do it, lots of TI calculators can do it, and many punk teenagers can do it.
posted by phrontist at 3:57 PM on July 19, 2006

Whoa whoa whoa. All this talk of Excel and curve-fitting and least-squares and limits and Maple and exponential functions is almost certainly waaay beside the point.

killdevil, please post the question you're asked (without the graph, of course). My best guess is that the question has nothing at all to do with the particular curve you're looking at, and is designed only to make sure that you know that the derivative is the slope of the tangent line. Past that, it's just all estimation and justification.
posted by gleuschk at 4:03 PM on July 19, 2006

Response by poster: Actually, gleuschk, this is all incredibly helpful. Generally speaking, the questions I'm trying to develop a plan of attack for are chemistry-related -- specifically, chemical kinetics questions that ask me to consider rates of reaction (for different types of reactions) instantaneously or over a given span of time.

All this talk about exponential decay has helped me to understand how some of the other shortcuts we've been given (invariably involving ln 2 or the natural log of various concentration values) were derived in the first place.
posted by killdevil at 4:21 PM on July 19, 2006

Sorry, the slope at any point x will be -A*b*exp(-b*x).
posted by dsword at 4:26 PM on July 19, 2006

posted by gleuschk at 5:29 PM on July 19, 2006

Ah, chemical kinetics. I assume the plot is the concentration of one of the reactants (or something that's proportional to the concentration of one of the reactants) vs. time?

You have to be careful with those, because a first-order reaction will indeed be an exponential decay over time, but in a second-order reaction, the concentration of a reactant is proportional to the reciprocal of time. To the naked eye, the two graphs look much the same, and you can't easily tell which is which just by eyeballing the graph of concentration ([A]) vs. time.

The way to tell them apart is to also make graphs of ln [A] vs. time, and of 1/[A] vs. time. The former will be linear for a first-order reaction, and the latter will be linear for a second-order reaction. More at Wikipedia.

(Feel free to ignore me if I'm explaining things you already know.)
posted by DevilsAdvocate at 5:39 PM on July 19, 2006

That's the geometrical interpretation of first derivative of point x0. I regret I must run right now, but basically what you have to do is to do an educate guess by measuring the variation (equal difference aka delta) of Y and X ...so if for instance Y increases by two if x increase by one , you have 2/1=2 ..now the limit must be used for an exact estimation

Ops sorry I just noticed a little error, you should add lim dx->0 to Dy/Dx as well....you NEED the limit of Dy/Dx if you want an accurate extimation, otherwise Dy/Dx does NOT represent the inclination of the slope in a point, but just an approximation
posted by elpapacito at 5:00 AM on July 20, 2006

« Older Apple Remote Play   |   MT PHP API? Newer »