How can i use L'hospital rule i.e sin(x)/x for x tends to zero?
Afficher commentaires plus anciens
I have a simple program
n=[0:7] x=sin((pi*n)/2)./(pi*n)
which returns,
n =
0 1 2 3 4 5 6 7
x =
NaN 0.3183 0.0000 -0.1061 -0.0000 0.0637 0.0000 -0.0455
Only the problem is that,according to L'Hospital rule,value of x for n=0 should be 0.5 instead getting NaN.. How can i get this? Is there any command?
Réponse acceptée
Plus de réponses (1)
Wayne King
le 23 Sep 2012
Modifié(e) : Wayne King
le 23 Sep 2012
You can do this:
x = -5:0.001:5;
y = sin(x)./x;
plot(x,y)
Since the increment in the x-variable is 0.001 and the range is 10, the total number of x-samples is 10^4, 0 will be at index 5001. Look at the y-values in a neighborhood of 0.
y(4950:5050)
You can see that the left-hand and right-hand limits are 1.
If you have the Symbolic Toolbox.
ezplot('sin(x)/x',[-5,5])
Catégories
En savoir plus sur Startup and Shutdown dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!