This is an appeal from a summary judgment entered in favor of the Secretary of the United States Department of Health, Education and Welfare (HEW)1 by the United States District Court, Eastern District of Arkansas,2 in which the court upheld the validity of certain regulations promulgated by the Secretary in connection with the Medicaid program. On appeal plaintiffs essentially argue that the regulations are not authorized by the statute they purport to implement, or, alternatively, that the regulations are unconstitutional as a violation of due process and equal protection under the fifth amendment. Finding these allegations without merit, we affirm.
Under Title XIX of the Social Security Act, 42 U.S.C. § 1396 et seq., Congress established a cooperative federal-state program to provide assistance to certain needy individuals whose income and resources are *869“insufficient to meet the costs of necessary medical services.” 42 U.S.C. § 1396. This program, commonly referred to as Medicaid, offers federal matching funds to help states reimburse providers of medical services to the poor. To qualify for these federal matching funds, the Act requires the states to submit to the Secretary of HEW plans for administering the medical assistance program. If the Secretary finds that a given state plan comports with federal statutory requirements, the state becomes eligible for grants of federal funds which the state, in turn, can channel through appropriate state agencies to the various providers of medical services.
Although the states are given broad latitude in formulating these medical assistance plans, the Act prescribes certain requirements with which all states must comply. See 42 U.S.C. §§ 602(a), 1202(a) and 1352(a). Furthermore, under the Act the states cannot reimburse those who provide medical services in excess of “reasonable charges consistent with efficiency, economy, and quality of care.” 42 U.S.C. § 1396a(a)(30). To implement this language, the Secretary promulgated regulations 3 limiting in some instances the level of reimbursement to be paid to providers. With regard to prescription drugs, payment for which a state may make under its Medicaid program, 42 U.S.C. § 1396d(a)(12), the Secretary ruled that the state Medicaid agency “may not pay more . . . than the lower of ingredient cost plus a dispensing fee or the provider’s usual and customary charge to the general public.” 42 C.F.R. § 447.331(a).4
As indicated, the Arkansas Pharmacists Association and two individual practicing pharmacists challenge, on both statutory and constitutional grounds, the validity of these federal regulations limiting reimbursement for drugs provided to Medicaid customers.
Plaintiffs first contend that the Secretary’s regulations specifying that the state agency may not pay more than the lower of either (1) the ingredient cost plus dispensing fee or (2) the pharmacists’ customary charge to the public, 42 C.F.R. § 447.331-34, are invalid because the regulations are not authorized by the statute they purport to implement. Although the plaintiffs concede that the Secretary has authority under the Act to prohibit a state agency from reimbursing a pharmacist who charges more to Medicaid customers than his “customary charge to the public,” plaintiffs argue that the Secretary is not authorized to prevent a state agency in certain circumstances from fully reimbursing a pharmacist who charges more than the ingredient cost plus a dispensing fee. Plaintiffs claim that the Congress explicitly limited the Secretary’s authority under the Act to assuring that payments “are not in excess of reasonable charges,” 42 U.S.C. § 1396a(a)(30), and indicated that the Secretary should not promulgate regulations which involve price fixing, 1967 U.S.Code Cong. & Admin. News, 90th Cong., 1st Session, pp. 2834,3213, create unnecessary bureaucratic complexity, 42 U.S.C. § 1396a(a)(19), or result in a confiscatory level of reimbursement, cf. 42 U.S.C. § 1395x(v)(l)(A). Plaintiffs allege that by implementing the cost plus dispensing fee prong of the challenged formula, the Secretary will clearly engage in price fixing as well as employ a methodology *870which will create an unnecessary bureaucracy.
Plaintiffs also urge that the cost plus dispensing fee limitation will lead to a confiscatory level of reimbursement. In this regard plaintiffs cite the affidavit of Dr. D. C. Huffman where he states:
[Assume] an average mark-up of $3.50 is necessary for a pharmacist to pay his cost of operation and make a modest profit, the pharmacist might add only $1.00 to a drug costing $1.00 for a total of $2.00, which is not sufficient to cover the $3.50 average mark-up needed. The average mark-up needed would be obtained by marking a $34.00 item up to $40.00.
Plaintiffs observe that it is only by averaging the high priced items with the low priced items that the pharmacist obtains his average price figure. Plaintiffs argue that the challenged regulations hinder the pharmacist who serves Medicaid customers in obtaining this average price figure because they only allow a $1.00 mark-up on the low priced item, and an average mark-up (which, according to plaintiffs, approximates the ingredient cost plus dispensing fee) on high priced items. Plaintiffs allege that this level of reimbursement not only is confiscatory but also that it is inconsistent with the “reasonable charge” language of 42 U.S.C. § 1396a(a)(30) and contravenes the policy of a companion statute by shifting losses on higher priced items to non-Medicaid customers. 42 U.S.C. § 1395x (v)(l)(A). .
We find plaintiffs’ arguments unpersuasive.
We note initially that in reviewing the adoption of regulations by an agency under its informal rulemaking procedures a court is limited to considering whether the administrative action was “arbitrary, capricious, an abuse of discretion, or otherwise not in accordance with the law.” 5 U.S.C. § 706(2)(A). While the courts will not hesitate to strike down regulations that are unauthorized or illegally promulgated, they will not attempt to substitute their judgment for that of the administrative agency. Citizens to Preserve Overton Park, Inc. v. Volpe, 401 U.S. 402, 416, 91 S.Ct. 814, 823, 28 L.Ed.2d 136 (1971). If the regulations are “reasonably related to the purpose of the enabling legislation,” this court ordinarily will not set them aside. Thorpe v. Housing Authority, 393 U.S. 268, 280-81, 89 S.Ct. 518, 525, 21 L.Ed.2d 474 (1969); see also Mourning v. Family Publications Service, Inc., 411 U.S. 356, 369, 93 S.Ct. 1652, 1660, 36 L.Ed.2d 318 (1973); Leimbach v. Califano, 596 F.2d 300, 304 (8th Cir. 1979); Johnson’s Professional Nursing Home v. Weinberger, 490 F.2d 841, 844 (5th Cir. 1974).
Although plaintiffs’ arguments may cast some doubt on the wisdom of the challenged regulations, we find in these arguments no sufficient basis upon which to invalidate the regulations. The use of cost data as a determinant of “reasonable charge” has been endorsed by the courts for drug reimbursement, American Medical Ass’n v. Mathews, 429 F.Supp. 1179 (N.D.Ill.1977); Ohio State Pharmaceutical Ass’n v. Rhodes, Civ. No. C-2-76—707 (S.D.Ohio Oct. 28, 1977), as well as other areas, see, e. g., Johnson’s Professional Nursing Home v. Weinberger, supra, and nothing in the statutory scheme or legislative history suggests that Congress intended to preclude the use of a reasonable cost standard as a component in the measure of “reasonable charge.” Moreover, we are firmly convinced that requiring the state agency to pay pharmacists the ingredient cost plus dispensing fees when this amount is lower than the pharmacist’s customary charge is reasonably related to the apparent legislative purpose of providing necessary medical services to the poor without undue expense to the taxpayer. See 1967 U.S.Code Cong. & Admin. News, 90th Cong., 1st Session, pp. 2884, 3213; 1965 U.S.Code Cong. & Admin.News, 89th Cong., 1st Session, p. 1964.
As to plaintiffs’ contention that the regulations involve price fixing, we note that the regulations neither fix prices nor compel the pharmacist to sell his drugs at a specified price. Rather, the regulations are calculated to protect the government from the vagaries of the marketplace by setting *871a reasonable limit on the amount the government will pay when it provides reimbursement for drugs furnished under the Medicaid program.
Similarly, the regulations can only be termed “confiscatory” in the sense that they place a limit upon the sums the government will pay in connection with the Medicaid program. It is clear that under the regulations the pharmacists are not required to sell at a loss or give up anything other than the collection of a charge which the Secretary may consider excessive.
Moreover, the regulations do not, as the plaintiffs apparently claim, necessarily result in an alleged inadequate level of reimbursement by requiring the agency to determine the dispensing fee of high priced drugs based on the average price of dispensing all drugs. We note that the regulations provide that the agency may look to a number of factors in setting the dispensing fee, 42 C.F.R. § 447.333, and may vary the dispensing fee when, for example, a drug is a prescription rather than a nonprescription drug, or is furnished to an institution instead of an individual. 42 C.F.R. §§ 447.-333(b)(3) and (c). In such circumstances, we believe that the regulations cannot be successfully attacked as confiscatory.5
There are, of course, other reimbursement methods which could protect the government from unreasonable charges. For instance, plaintiffs seem to suggest that the Secretary adopt a regulation providing that a pharmacist who exceeds the general prevailing price in the area not be reimbursed for the excess. However, as indicated, the Secretary’s reimbursement formula reasonably comports with the general purposes of the Medicaid legislation,6 and we are unwilling to substitute our judgment for that of the Secretary.
In addition to their statutory arguments, plaintiffs also contest the validity of the regulations on constitutional grounds. In this regard, plaintiffs contend that the regulations result in a confiscatory taking of property without due process in violation of the fifth amendment. Plaintiffs also argue that the regulations deny them their rights of equal protection by subjecting the pharmacists to one standard of reimbursement while subjecting others similarly situated, such as doctors and dentists, to another standard of reimbursement.
In light of our finding that the regulations do not have a confiscatory effect, we need add but little concerning plaintiffs’ claim of a taking in violation of the fifth amendment.
It is established that in reviewing economic and social welfare regulations, a court must uphold the regulations if they bear a rational relation to a legitimate congressional purpose. See, e. g., Exxon Corp. v. Governor of Maryland, 437 U.S. 117, 98 5. Ct. 2207, 57 L.Ed.2d 91 (1978); Cleland v. National College of Business, 435 U.S. 213, 98 S.Ct. 1024, 55 L.Ed.2d 225 (1978). After careful evaluation of the Act and the challenged regulations, we have no hesitancy in concluding that the regulations do in fact bear a rational relation to the legitimate purpose of the statute.
As to plaintiffs’ equal protection argument, we note that in the context of social welfare legislation a classification is not necessarily constitutionally infirm simply because “it is not made with mathematical nicety or because in practice it results in some inequality.” Dandridge v. Williams, 397 U.S. 471, 485, 90 S.Ct. 1153, 1161, 25 L.Ed.2d 491 (1970). See also Mathews v. *872Lucas, 427 U.S. 495, 509, 96 S.Ct. 2755, 2764, 49 L.Ed.2d 651 (1976). So long as the classification is rational, it will not be found violative of equal protection. Jefferson v. Hackney, 406 U.S. 535, 546, 92 S.Ct. 1724, 1731, 32 L.Ed.2d 285 (1972).
Here, plaintiffs have made no substantial arguments showing that the pharmacists should not be classified differently than doctors and dentists for the purposes of setting charges. In such circumstances, we will not invalidate a classification which seems reasonably related to a legitimate statutory purpose.
The judgment of the district court is, in all things, affirmed.
. This suit was originally brought against Joseph Califano as Secretary of HEW. Subsequently, HEW was divided into the United States Department of Health and Human Services and the United States Department of Education, 5 U.S.C. § 101, as amended. Pursuant to Fed.R.App.P. 43(c), this court ordered the substitution of the present Secretary of the United States Department of Health and Human Services, Patricia R. Harris, as party defendant. In this opinion, however, we will refer to the agency by its name at the time this suit was filed.
. The Honorable Bruce M. Van Sickle, United States District Judge for the District of North Dakota, sitting by designation.
. Under the authority of 42 U.S.C. § 1302, “. [t]he Secretary of Health, Education, and Welfare, . . . shall make and publish such rules and regulations, not inconsistent with this chapter, as may be necessary to the efficient administration of the functions with which [he] is charged under this chapter."
. In general, the regulations provide that the “ingredient cost” for multi-source drugs (drugs marketed or sold by two or more manufacturers or labeiers) is the lower of the maximum allowable cost (MAC) and the estimated acquisition cost (EAC), while the cost for all other drugs is the EAC. 42 C.F.R. § 447.332. The MAC is basically the lowest price at which a drug is widely and consistently available. The EAC is the agency’s best estimate of what providers are generally paying for a drug. 42 C.F.R. § 447.332.
The regulations provide that the “dispensing fee” is determined on the basis of periodic surveys of pharmacy operations, including data on operations, professional services, overhead, and profits. 42 C.F.R. § 447.333.
. We also find unconvincing plaintiffs’ argument that the alleged confiscatory nature of the regulations contravenes a policy set forth in the Medicare legislation — namely, that the cost of the Medicare program should not be borne by persons not covered by Medicare. 42 U.S.C. § 1395x(v)(l)(A). We find no comparable standard in the Medicaid legislation nor any showing that Congress intended to include such a standard.
. In this connection we also observe that there is no showing that the Secretary’s reimbursement method will require any more bureaucratic complexity than the formulas suggested by plaintiffs, and we reject plaintiffs’ arguments that the regulations violate the statutory prohibition against unnecessary bureaucracy.