Computer programs based on the exact calculations of the gravity and magnetic anomalies of polygonal prisms are faster in operation and more accurate than previous programs based on the numerical integration of polygonal laminas. The prism programs also are of more general application than existing computer programs that are based on the exact gravity and magnetic effects of rectangular prisms. There are no restrictions on the use of the exact formula for the gravitational attraction of a polygonal prism, but the formulas for the magnetic effect are restricted in that demagnetization is not considered, and a finite answer is not obtained in the unrealistic circumstance where an observation point coincides with an edge of the prism.Least-squares methods permit calculation of the gravity or magnetic effect of models without knowledge of the density or magnetization contrasts, respectively, by comparison of the observed anomalies with theoretical dimensionless values to determine contrasts as regression coefficients. The coefficient of correlation provides a goodness of fit estimate that helps model evaluation. After calculating a magnetic terrain correction for an outcrop of Quaternary dacite and andestite near Clear Lake, Calif., an improvement of the coefficient of correlation from 88 to the 92 percent level indicates that this volcanic unit probably extends at least 150 m beneath the surface. Application of a magnetic terrain correction to disconnected outcrops of Tertiary andesite, eliminates most of a prominent v-shaped magnetic anomaly south of the San Juan Mountains, Colo.