# Test if a function is continuous or has at least one discontinuous vertical asymptote between an interval

Imagine evaluating a function with little intervals incrementally across a graph and testing by using the end points of the each interval (and maybe a midpoint), whether the function is continuous for this interval or possibility contains at least one vertical asymptotes (could contain hundreds, doesn't matter precisely how many), just a Boolean will do indicating that there's at least one break in this interval somewhere, so that a different algorithm can do further evaluations on that interval and skip the extra evaluations on continuous segments of a function.

• I don't want this to be solved symbolically using CAS, but instead by regular computational evaluations or methods
• I'm not really concerned about single discontinuous points such as the point $$x = 0$$ for the function $$\frac{sin(x)}{x}$$, it doesn't matter if it goes undetected and is treated as continuous
• or piecewise-defined functions that could confuse the algorithm
• I'm more interested in detecting vertical asymptotes as opposed to any other kind of discontinuities

Desmos demo used for all examples in this post

Change the function $$f(x)$$ in the Desmos demo to change the example

Testing

I'm not sure what the exact conditional statement would be for testing, but I suspect that there maybe consistent patterns that comes about when evaluating the function at each end point and possibly the midpoint of the interval maybe, using any of the following information gained from the evaluations of

• the parity of the function (odd or even)
• the function $$f(x)$$
• its inverse $$f(x)^{-1}$$
• its derivative $$d(x)$$
• inverse derivative $$d(x)^{-1}$$
• maybe 2nd derivative
• maybe subtracting values from each other
• or anything else that's simple to calculate

Some other ideas of testing might be where they intersect (possibly rounding off those values and checking if both points are equal in value) or whether they're opposite signs from each other or testing their inequalities or ratios or if certain points are undefined(NaN).

Example

Using $$f(x)=\frac{1}{x}$$ between $$[-3,-1]$$ the function is continuous between that interval, but between $$[-1,1]$$ there exists a vertical asymptote indicated by $$f(x)^{-1}$$ going from negative to positive as does $$f(x)$$, but unlike $$f(x)$$ also intersects the x-axis and the inverse derivative $$d(x)^{-1}$$ intersecting $$f(x)^{-1}$$

image of the above example $$f(x)=\frac{1}{x}$$

Usually for odd functions like this one, the inverse $$f(x)^{-1}$$ will cross the x-axis while the inverse derivative $$d(x)^{-1}$$ will be a extrama intersecting with the inverse at $$0$$ and the derivative will be undefined at that intersection. At that point there's always a vertical asymptote. For even functions where there's an asymptote, the inverse will instead be an extrama at the x-axis while the inverse derivative will cross the x-axis changing signs from positive to negative or vica versa.

Rounding off the inverse and inverse derivative also seems to help with the evaluation at the midpoint checking when the two intersect at 0

image of rounded off inverse and inverse derivative for $$f(x)=\frac{1}{x}$$

Interval Step Size Problem

Continuing with the function $$f(x)=\frac{1}{x}$$, if you have two sequential intervals of [-1,0] followed by [0,1] each having a step size of 1, both would confirm the existence of an asymptote. If the inverse and inverse derivative are rounded off and the step size is even smaller, it would confirm the existence of an asymptote multiple times defeating the purpose of the algorithm which is to avoid further evaluations.

image of small step size for $$f(x)=\frac{1}{x}$$ with rounding

As for functions like $$x\left ( \frac{x-1-10^{-3}}{x-1} \right )$$

image of the above example $$x\left ( \frac{x-1-10^{-3}}{x-1} \right )$$

the vertical asymptote may go undetected depending on the step size, which is ok as I don't expect the algorithm to pick up every tiny asymptote on a function. Although, the 2nd derivative (in the image above colored purple) does seem to widen the gap for detection and also passing the nth root $$\sqrt[n]{x}$$ into the other functions like the inverse $$f(\sqrt[n]{x})^{-1}$$ and inverse derivative $$d(\sqrt[n]{x})^{-1}$$, where $$n$$ is odd or even number depending of the parity of the function - this can help accentuate and widen them further for detection but may be computationally expensive. However, this approach with the nth root arguments doesn't work for functions like $$tan(x)$$.

The Main Question to this Problem

What would be the conditional statements for this algorithm be to work robustly to detect as best as possible whether an interval between $$[xmin,xmax]$$ is just continuous and contains at least one vertical asymptote somewhere in that interval

Alternative Methods

I'm open to any other alternative approaches to this problem as long as they're not very computationally expensive. Or any help or advice to improve detection rate and robustness would be appreciated

• If you knew the roots of the derivative (solve f’(x) = 0), then you could make each of these ‘x’ points the endpoints of your intervals and be guaranteed that so long as f(x) is defined and finite at those points then there must have only been a continuous deformation between them. I can’t really think of any other way to verify continuity only from the endpoints without using more CAS-like tools. Even solving f’(x) = 0 might be too much for what you’re looking for, in which case I’m not sure if this really can precisely be done. – Jack Crawford May 20 at 2:45
• Yeah, I'm probably asking for too much using very little information. As for your suggestion, the intervals would be small that incrementally scan the function left to right, I could check where $f'(x)$ passes the x-axis when the signs turn opposite and use the closest values to 0 (possibly the midpoint, could also apply 1st iteration of newtons method to get a little closer) and use it as a potential root. Once I've collected a pair of roots, I can evaluate for the conditions you've stated at the midpoint between the roots. – C9C May 20 at 18:08
• Considering the values will be approximations it won't come back as perfectly undefined near an asymptote but instead huge value that could be treated as undefined using a threshold. This approach will only tell if the function is continuous between the roots and if the overall interval starts a bit outside of the roots, that section will go unaccounted for. Thanks anyway – C9C May 20 at 18:08