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

  • Context: MATLAB 
  • Thread starter Thread starter oahsen
  • Start date Start date
  • Tags Tags
    Limit Matlab
Click For Summary

Discussion Overview

The discussion revolves around the behavior of MATLAB when calculating limits related to the derivative of the hyperbolic sine function, sinh(z). Participants explore discrepancies in MATLAB's output compared to expected mathematical results and other software like Maxima.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant notes that MATLAB correctly computes the limit for sin(z) but produces an unexpected result for sinh(z), suggesting a potential error in MATLAB's calculation.
  • Another participant reports receiving NaN as the output when attempting the same limit calculation in MATLAB, expressing confusion over this result.
  • A third participant mentions that Maxima provides the correct limit for the derivative of sinh(z), indicating a difference in software performance.
  • One participant highlights that their instructor requires both the derivative using diff and the limit approach, prompting a discussion on the differences in results.
  • Another participant speculates that a syntax error may have occurred, suggesting that an "=" was mistakenly used instead of a "," in the command.
  • A later reply proposes using the exponential definition of sinh to compute the limit, which leads to a correct expression for cosh(z) when simplified.

Areas of Agreement / Disagreement

Participants express differing experiences with MATLAB's output, with some receiving NaN and others encountering unexpected limit expressions. There is no consensus on whether the issue lies with MATLAB's algorithm or user error, and the discussion remains unresolved regarding the correct interpretation of the results.

Contextual Notes

Participants mention potential limitations in MATLAB's limit algorithm and the importance of syntax in command entry, but these aspects are not fully resolved within the discussion.

oahsen
Messages
58
Reaction score
0
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?
 
Physics news on Phys.org
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 derivative of a function, try this line:

> syms x; diff(sinh(x))
ans =
cosh(x)
 
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;
 
atqamar said:
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 derivative of a function, try this line:

> syms x; diff(sinh(x))
ans =
cosh(x)

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?
 
I'm wondering if you didn't accidently enter a "=" instead of "," and MatLab just echoed it back to you.
 
HallsofIvy said:
I'm wondering if you didn't accidently enter a "=" instead of "," and MatLab just echoed it back to you.
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)
 
If limits have to be used to find the derivative, 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).
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
6K
  • · Replies 8 ·
Replies
8
Views
2K