MATLAB Answers

Continuity of a function in a interval

30 views (last 30 days)
Dani Amposta Navarro
Dani Amposta Navarro on 11 Apr 2021 at 21:05
Commented: Dani Amposta Navarro on 11 Apr 2021 at 22:49
Is there any function or any other compact and simple form to know if a function is continuos in a interval?
In other math programs you can do it with a siple iscont[function, x=(interval)] and is very very usefull, I don't know why MATLAB can't do this basic and usefull thing.
  1 Comment
Matt J
Matt J on 11 Apr 2021 at 21:20
It seems like a very hard thing to do, even for the Symbolic Math Toolbox.

Sign in to comment.

Answers (1)

John D'Errico
John D'Errico on 11 Apr 2021 at 21:48
It may seem basic to you. However, that just means you need to understand computing and floating point arithmetic.
Nope. In fact, no (non-constant) function when evaluated in double precision can possibly be continuous. This is easy to show, since you cannot evaluate the function at two points that are infinitely close together. You can evaluate the function only at discrete points in terms of the 64 bits of information stuffed into a double.
Essentially, as long as you can do no more than evaluate the function at any point, as a black box, then you can NEVER know if a function is continuous. The idea is I can always create some simple function that is EVERY where continuous, but then insert some infinitessimal discontinuity at a specific location known only to the programmer (me). I'm not telling where. So you will need to test EVERY location in that space, thus 2^64 possible locations along the real line. At every point, you will then need to decide if the function is continuous, perhaps by testing the immediate neighbors along that line.
ans = 1.8447e+19
What is 1e19? Lets see. There are 30 million seconds in a year. If you can perform a billion such tests per second,
ans = 614.8915
The test would still require something like 614 years to perform.
So as much as the test itself will be painful, requiring 2^64 tests, how will you know if the function is continuous? For example, we can try this out:
x = 1;
dx = eps;
fun = @(x) sin(x.^2);
ftest = fun(x + [-dx,0,dx])
ftest = 1×3
0.8415 0.8415 0.8415
they look the same, yet they are not.
ans = 1×2
1.0e+-15 * 0.2220 0.2220
Since this is a nonlinear function, how are you to know if I did something very tricky in that black box of a function? You cannot do so. You cannot evaluate the function at closer points than that. And if you look at the function at a sequence of such points, any nonlinear function will in fact look quite bumpy.
diff(fun(x + dx*[-5:5]))
ans = 1×10
1.0e+-15 * 0.2220 0.3331 0.2220 0.2220 0.2220 0.2220 0.2220 0.3331 0.2220 0.2220
  1 Comment
Dani Amposta Navarro
Dani Amposta Navarro on 11 Apr 2021 at 22:49
Okey, thank you for answering.
I'm considering about doing a plot arround my interval and check by myself then.
And about my message, I'm not saying that proving the continuity of a function with computer is a simple thing to do. As basic, I'm saying that is a thing that is used a lot in numeric calculous, defined integration, to prove that Bolzano theorem holds...

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by