OKPEDIA MATLAB ANALISI MATEMATICA EN

How to calculate limits in Matlab and Octave

To calculate a limit of a function f(x) in Matlab and Octave use the function limit()

limit(x,x,xo,['right'/'left'])

The command parameters are

  • f is the function f(x)
  • x is the limit variable
  • x0 is an accumulation point or infinite (inf)
  • 'right'/'left' are optional parameters to calculate the right limit or the left limit.

Examples

Example 1

Define the variable x symbol

syms x

Calculate the limit of the function for x→∞

$$ \lim_{x \rightarrow \infty} \frac{1}{x} $$

Type the command

limit(1/x,x,inf)

The output result is the limit for x→∞

ans = (sym) 0

The limit of the function for x→∞ is 0

Example 2

Calculate the limit of the function for x→2

$$ \lim_{x \rightarrow 2} \frac{1}{x} $$

Type the command

limit(1/x,x,2)

The output result is the limit for x→2

ans = (sym) 1/2

The limit of the function for x→2 is 1/2

Example 3

Calculate the right limit of the function for x→0+

$$ \lim_{x \rightarrow 0^+} \frac{1}{x} $$

Type the command

limit(1/x,x,0,'right')

The output result is the limit for x→0+

ans = (sym) ∞

The limit of the function for x→0+ is +∞

Example 4

Calculate the left limit of the function for x→0-

$$ \lim_{x \rightarrow 0^-} \frac{1}{x} $$

Type the command

limit(1/x,x,0,'left')

The output result is the limit for x→0-

ans = (sym) -∞

The limit of the function for x→0- is -∞

https://how.okpedia.org/en/matlab/how-to-calculate-limits-in-matlab-and-octave


Report us an error or send a suggestion to improve this page


Calculus in Matlab/Octave


FacebookTwitterLinkedinLinkedin