The demagnetizing field of a non-uniform rectangular prism