How to write a for-loop to find the limit of a function
Show older comments
lim x->(-inf) (x^3+x^2-x)/(4*x^6+x^2)
How to write a for loop for this function when x is closing in on -infinity (negative inf) And how do i make it loop it self, like 20 times or so ?
2 Comments
James Tursa
on 10 Oct 2012
Just curious, is the actual assignment to do this numerically in a loop to see what happens? (Which I see as pointless btw for a variety of reasons, one being that you will overflow the IEEE calculation before you will probably learn anything). Or is this something you made up? I think the only thing useful you might learn is that this is not the way to approach this problem.
Azzi Abdelmalek
on 10 Oct 2012
I don't think it's a good idea to use a for loop
Answers (1)
Sean de Wolski
on 10 Oct 2012
This oughtta do it:
for x = 1e40;
mylim = (x^3+x^2-x)/(4*x^6+x^2);
end
8 Comments
Martin Svendsen
on 10 Oct 2012
Jan
on 10 Oct 2012
@Martin: I strongly recommend to read the Getting Started chapters of the documentation. The public forum is not the right place to learn the fundamental basics as the numerical notation of powers of 10.
In addition a forum is not a homework solver and you will not learn, if you do not learn it by yourself. So please try to solve your problem as far as possible and show us, what you have tried so far.
Martin Svendsen
on 10 Oct 2012
Edited: Matt Fig
on 10 Oct 2012
Matt Fig
on 10 Oct 2012
Martin, in future posts, please do as I did for your code above. That is, put an empty line between your paragraph and the first line of code, then highlight all the code and press the button that looks like this: {}Code
Thanks
Jan
on 10 Oct 2012
@Martin: If the homework was due last week, why are you desperate? Too late means early enough for the next year.
The description of your problem is lean and not precise. "for x = 20:20" will not perform any loops.
Walter Roberson
on 10 Oct 2012
for x=20:20 will loop once, with x having the value 20
Star Strider
on 10 Oct 2012
You're not using limit correctly if you want the limit at -Inf. Using it as you did takes the bidirectional limit as x -> 0.
syms x
f = (x^3+x^2-x)/(4*x^6+x^2)
limf = limit(f, x, -Inf)
Jan
on 11 Oct 2012
@Walter: I like the idea of looping once. It reminds me to clapping with one hand.
Categories
Find more on Profile and Improve Performance in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!