Continuity of a function in a interval
48 views (last 30 days)
Show older comments
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
Answers (1)
John D'Errico
on 11 Apr 2021
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.
2^64
What is 1e19? Lets see. There are 30 million seconds in a year. If you can perform a billion such tests per second,
2^64/3e7/1e9
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])
they look the same, yet they are not.
diff(ftest)
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]))
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!