If you are interested in trend removal, please have a look in the following chapter. Christin Bald, Julia Kreisel, and Gerhard Schmidt put some ideas by means of written words and Matlab code into this chapter. Beside conventional methods such as highpass filtering, robust and "cheap" nonlinear / time-invariant schemes are discussed.
Robust (recursive) vector norm computation can be found here. If you one had problems that vectors norms became negative after a while when computed recursively, have a look in this chapter written by Katharina Rebbe, Gerhard Schmidt, and Owe Wisch.