Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

A limit problem. (Is something wrong with matlab?)

  1. Oct 13, 2007 #1
    With the following code segment ;
    limit((sin(z+h)-sin(z))/h,h,0)
    matlab gives the result cos(z). (which is the differential of the sin(z)).
    However, with the code ;
    limit((sinh(z+h)-sinh(z))/h,h,0)
    matlab gives an absurd result;
    limit((sinh(z+h)-sinh(z))/h,h = 0)
    newertheless, the result should be cosh(z). Why does matlab makes such a wrong calculation also what is the meaning of this result? Does anybody have an idea about that?
     
  2. jcsd
  3. Oct 13, 2007 #2
    I tried the same code, and i got:

    ans=
    NaN

    I don't know why this answer is given. However, if you are looking for the derivitive of a function, try this line:

    > syms x; diff(sinh(x))
    ans =
    cosh(x)
     
  4. Oct 14, 2007 #3

    Dick

    User Avatar
    Science Advisor
    Homework Helper

    Just for the record, Maxima does it right.

    (%i1) limit((sinh(x+h)-sinh(x))/h,h,0);

    gives exp(-x)*(exp(2x)+1)/2;
     
  5. Oct 14, 2007 #4
    actually this is the problem. The teacher asks us to find the derivative with;
    syms x; diff(sinh(x)) and after that finding it with;
    syms z h; limit((sinh(z+h)-sinh(z))/h,h,0)

    and he wants us to comment on the difference.

    With my matlab(R2007a) I find the first result as cosh(z) as expected however with the second code it gives me ;
    limit((sinh(z+h)-sinh(z))/h,h = 0).

    Some of my friend said that Maxima finds the correct result. I wonder if it is something about the limit algorithm of Matlab or I do not know? What kind of comment can I write for the difference?
     
  6. Oct 14, 2007 #5

    HallsofIvy

    User Avatar
    Staff Emeritus
    Science Advisor

    I'm wondering if you didn't accidently enter a "=" instead of "," and MatLab just echoed it back to you.
     
  7. Oct 14, 2007 #6
    I checked it 1000 times. This is the copy of the command window;

    >> syms z h;
    >> limit((sinh(z+h)-sinh(z))/h,h,0)

    ans =

    limit((sinh(z+h)-sinh(z))/h,h = 0)
     
  8. Oct 14, 2007 #7
    If limits have to be used to find the derivitive, use the exponents definition of sinh(x) and find the limit:

    >> syms z h; limit((((exp(z+h)-exp(-z-h))/2)-((exp(z)-exp(-z))/2))/h,h,0)
    ans =
    (1/2*exp(2*z)+1/2)*exp(-z)

    The answer, when simplified, is cosh(x).
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: A limit problem. (Is something wrong with matlab?)
Loading...