Catch discontinuities in functions
I have a function which is something like

`f(a, b, s) = arctan(cos(a + b) * csc(a - b) * cot(s))`

I know that it's discontinuous in some places, and that it's possible to "cure" the discontinuities by shifting the function. In this case I know where these discontinuities are, and it's kinda easy to treat them properly. Basically it's just


    s_discontinuities = [s_0, s_1, s_2]

    for i in s_discontinuities:
        jump = round(f(a, b, s_discontinuities(i) + Ds) - f(a, b, s_discontinuities(i) - Ds))
        offset(i) = jump
    
    def new_f(a, b, s):
        exit = 0
        for i in s_discontinuities:
            if s > s_discontinuities(i):
                exit += offset(i)
        return f(a, b, s) + exit

and then the same with `a` and `b`. The first question is: are there way to make the algorithm more efficient, and are there any algorithm out there which can work in the case I don't know where the discontinuities are?
Catch discontinuities in functions
===

I have a function which is something like

`f(a, b, s) = arctan(cos(a + b) * csc(a - b) * cot(s))`

I know that it's discontinuous in some places, and that it's possible to "cure" the discontinuities by shifting the function. In this case I know where these discontinuities are, and it's kinda easy to treat them properly. Basically it's just


    s_discontinuities = [s_0, s_1, s_2]

    for i in s_discontinuities:
        jump = round(f(a, b, s_discontinuities(i) + Ds) - f(a, b, s_discontinuities(i) - Ds))
        offset(i) = jump
    
    def new_f(a, b, s):
        exit = 0
        for i in s_discontinuities:
            if s > s_discontinuities(i):
                exit += offset(i)
        return f(a, b, s) + exit

and then the same with `a` and `b`. The first question is: are there way to make the algorithm more efficient, and are there any algorithm out there which can work in the case I don't know where the discontinuities are?