How to write a for-loop to find the limit of a function

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

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.
I don't think it's a good idea to use a for loop

Sign in to comment.

Answers (1)

This oughtta do it:
for x = 1e40;
mylim = (x^3+x^2-x)/(4*x^6+x^2);
end

8 Comments

no "syms x;" ? how do i see the result ? Why do you write "x = 1e40" ? what does the e and 40 do ? Sorry for stupid questions im totally new to this.
@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.
I know this is not a homework solver, but if youre homework was due last week you would probably be desperate as well. So far i've tried:
EDU>> syms x;
EDU>> limit((x^3+x^2-x)/(4*x^6+x^2));
EDU>> x =(-inf);
EDU>> for x=20:20
end
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
@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.
for x=20:20 will loop once, with x having the value 20
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)
@Walter: I like the idea of looping once. It reminds me to clapping with one hand.

Sign in to comment.

Products

Asked:

on 10 Oct 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!