I am new to pipelines. I have a problem of providing expansion loops on a long pipeline.

If I have the following:

1) Material (Hence allowable stress, coefficient of thermal exp), diameter & thickness of the pipe.
2) Temperature of the pipe.
3) Insulation information (Type, density, thickness).
4) the applicable code (B31.4 or B31.8)
How can I get the anchor to anchor length (between which I have to give one loop)using above information? Is there any equation / procedure? Or is it only some rule of thumb (each 50m or so)? Can anybody help?
_________________________
Shahid Rafiq Piping Engineer