We present two algorithms for computing the gravitational and magnetic anomalies due to an n-sided polygon in a two-dimensional space. Both algorithms have been implemented as subroutines coded in Fortran-77, and listings are provided. Because references to trigonometric functions have been almost completely eliminated, these codes run substantially faster than most codes now in existence. Furthermore, anomalies can be computed at any point outside, on, or inside the polygon. Unlike other codes, these algorithms can be used to model subsurface observations.