Search code examples
matlabmathlimitinfinity

Matlab: Limit as t approaches positive and negative infinity?


I'm trying to write some code which would find the limit of a function as x approaches positive and negative infinity. The code I have so far is as follows:

pos = limit(exp(atan(x)), x = infinity)
neg = limit(exp(atan(x)), x = -infinity)

However, it gives me an error saying "invalid syntax at =. Possibly, a ), }, or ] is missing. When I looked at the Matlab documentation for how to compute a limit, they had this as their example:

limit((1 + 1/n)^n, n = infinity)

and this returned an answer of e. When I put this into my own Matlab, it gave me the same error, could anyone help? Is it possibly an error with my Matlab?


Solution

  • You've been looking at the wrong help. Such notation (and limit function) is used in MuPAD interface, not in the simple Matlab Command Window.
    To use limit() in Matlab environment, you have to use symbolic variables and this is the correct help page.

    In other words, to compute

    limit((1 + 1/n)^n, n = infinity)
    

    you have to declare a symbolic variable n

    syms n
    

    and then provide the correct syntax (ref. help)

    limit((1 + 1/n)^n, n, inf)
    

    and the result is (of course) exp(1), that is e.