PDA

View Full Version : microsoft excel graphs


mfuller_uk
28th Feb 2002, 22:38
does anyone know how within excel you can get the gradient of a curve at the points plotted, i.e. take the tangent of the curve at the point and then take the gradient of that curve.

Any help Much appreciated

Michael Fuller PAFP. [email protected]

GeneralElectric
7th Mar 2002, 18:17
Vaguely, although you can't do it directly with the plotted line.. .. .<thinks back to A level Maths>. .. .Gradient of curve at a point = dy/dx .. .. .You know that the gradient can be expressed as the angle between the x-axis and the point on the curve. Simple Trigonometry tells you that:. .. .Tan A = Opposite / Adjacent. .(where A is the Gradient). .Therefore:. .A = ArcTan (Opposite / Adjacent). .. .which in our case is :. .. .Gradient = ArcTan (Y/X) . .. .Now, remember I said that gradient = dY / dX ?. .That says that for a very small change in the values of Y and X this is true.. .. .So you need to have 2 points very close to one another on your curve to be able to calculate the gradient. Assuming you have 2 such points in your data, called X1,Y1 and X2,Y2:. .. .Gradient = ArcTan ((X2-X1) / (Y2-Y1)) in degrees.. .. .So find the ARCTAN function on the Excel menu and find the 2 coordinates you need. . .. .Hope this helps

Evo7
7th Mar 2002, 20:54
Depends on the curve though. You've got to worry about it being both smooth and differentiable (I think) - books have been written on this <img border="0" title="" alt="[Smile]" src="smile.gif" /> . .. .For example, if you're trying to work with tan(theta), it breaks down at theta = pi/2 radians as the function is discontinuous there. . .. .If you're really keen on this then I'd look up a suitable method in <a href="http://www.ulib.org/webRoot/Books/Numerical_Recipes/bookfpdf.html" target="_blank">Numerical Recipes</a> and then try to implement this using Excel - if that's possible. . .. .Another possible approach is to fit something differentiable to your data and then differentiate it yourself, which will give you an analytic expression for the gradient at any point. For example, say your data is well fit by a polynomial y(x) = x**3 - 2x + 1, this can be differentiated trivially to give the gradient y'(x).. .. .It's hard to know without the function <img border="0" title="" alt="[Smile]" src="smile.gif" />

bblank
8th Mar 2002, 01:52
Correct Evo7. Don't see much of x**3 or references to the Fortran version of Numerical Recipes these days! . .. .I don't think Excel is the right tool for the job but if it is a requirement that the wrong tool be used, then one of Excel's curve-fitting algorithms can be used (linear, logarithmic, polynomial, power, exponential). On the Options tab select "Display equation on chart". This will produce an equation of the form y = f(x). It will be smooth and therefore have a tangent line. The slope at (c,f(c)) can then be calculated by (f(c+h/2)-f(c-h/2))/h where h is a small number. How small? Depends on how many decimal places Excel uses. If single precision, I'd try h = E-04; if double, then h = E-06 will work fine. Because of "loss of significance" too small a value will give inaccurate results.. .. .One caveat - a curve might fit data very well without its slope doing the same. For example, y = x + sin((10**20)*x)/(10**14) is a good fit of y = x but its slope is not close to 1 for most x.. .. .As Samuel Johnson said of graphing with Excel: "It is not done well; but you are surprised to find it done at all." Maple is the thing to use.

GeneralElectric
8th Mar 2002, 13:42
Gosh, it's all coming back now.... time to reach for my old course books again!. .. .Brian - noticed you're a learned mathematician, do you know of any decent online text books on (eg) calculus, trig, etc?

bblank
8th Mar 2002, 22:19
I'm still learning GE. For now I think standard textbooks remain the best option. Three reasons for that. 1) To write a good tutorial one needs the hope of some compensation for the effort. 2) Web authors are pretty much on their own without a publisher to get feedback. 3) The web has not yet reached the point of properly supporting mathematical typography. Most technical reports are now written using a typesetting program called TeX (or a derivative of it such as LaTeX). There is a tool for converting TeX source to HTML but each mathematical formula must be converted to a gif. Even small documents often contain hundreds of files. It is not too pleasant for the web author and not too pleasant for the browser either. . .. .The World Wide Web Consortium (W3C) has had a committee working on math support for several years now. The ultimate goal is for browsers to utilize MathML, an application of XML. For most surfers that means MS IE. Microsoft does have a member on the committee (as does Boeing) but its interest in the project appears to be limited - there isn't much of a commercial payoff.. .. .If you want to investigate web supplements to a standard textbook then you might try links at. .<a href="http://directory.google.com/Top/Science/Math/Calculus/" target="_blank">http://directory.google.com/Top/Science/Math/Calculus/</a>. .But the ones that I've looked at don't seem to merit a recommendation.