Katherine
Katherine

Reputation: 143

Matlab function to determine if a function is continous or not?

I wish to write code for Riemann Stieltjes integrals using MATLAB's Symbolic Math toolbox. A necessary condition for the theorem to hold is that the function's derivative must be continuous. I am using the diff function to find the symbolic derivative. The domain of the function is a closed real interval containing infinitely many points, so I can't check at each and every point. I want to know if there are any built-in functions in MATLAB that determine if a function is continuous or not.

Is there any way I can check if the function obtained by differentiating my input function is continuous?

Upvotes: 4

Views: 3616

Answers (1)

horchler
horchler

Reputation: 18484

Yes, you can do this in a way via MuPAD's discont function, which lists the discontinuities of a function. MuPAD functions can be called from within Matlab. For example:

syms x;
f = 1/(x*(x-1));
feval(symengine,'discont',f,x)

returns [ 1, 0], the two poles of f. If you want to bound your search domain, one way to do so is via assumptions. Now:

syms x;
assume(x>=0);
assumeAlso(x<1/2);
f = 1/(x*(x-1));
feval(symengine,'discont',f,x)

just returns 0. Or, you can use MuPAD's string notation:

syms x;
f = 1/(x*(x-1));
feval(symengine,'discont',f,[char(x) '=0.5..2'])

which returns 1. Obviously if the list of discontinuities over a domain in not empty (see isempty), then the function is not continuous (i.e., discontinuous).

I recommend reading the documentation for discont. I have no idea how reliable it is or if it will have trouble with more complex functions.

Upvotes: 5

Related Questions