Algorithm to generate this alignment pattern locations table for QR codes
I don't think such algorithm exists, because I looked quite hard and couldn't find it. It seems you have to follow the given table. Your formula approximates it pretty well. Too bad about the magic branch, but this shouldn't be a major concern anyway:
it's a small table that you only need to calculate once and can reuse later,
so any performance issues should be negligible in practice.

Coding style

The coding style can be improved.
Follow PEP8, the official coding style guide of Python,
for example, put 2 blank lines in front of top-level method definitions

Unnecessary parentheses

The parentheses around the multiplication are unnecessary here:


w = 21 + ((ver - 1) * 4)       # Width



It would be better to use more meaningful variable names, 
for example no need to shorten version as ver.

Unnecessary parentheses here:


if (w == 145):



The augmented assignment operator +=

Instead of:


    intervals = intervals + (intervals % 2)



This is better:

    intervals += intervals % 2


Use one statement per line

Break the line after :, for example instead of:


for m in (n-1) * [intervals]: xs.append(xs[-1] - m)



Write like this:

for m in (n-1) * [intervals]: 
    xs.append(xs[-1] - m)


Avoid code in the global namespace

Move code out of the global namespace into methods, so instead of this:


for n in range(2, 41):
    print("Version {:2d}: {}".format(n, pattern(n)))



Do it this way:

def main():
    for n in range(2, 41):
        print("Version {:2d}: {}".format(n, pattern(n)))

if __name__ == '__main__':
    main()