When you include the high price of extract, liquid yeast and hops if you use a lot of them, $40 is about average - it's not high if you are starting from a recipe and not buying a kit. You can get down cheaper with a kit, but I think you'll find the kit will probably have less in it than the recipe and you'll learn more from using a recipe vs a kit. It's nothing against kits, the beer will probably taste as good as the recipe. This is especially true if you are buying at a local homebrew store, where they are including their shipping costs in the prices.
That said, there are some ways you can save money. The main thing I've found is LME is significantly more in local stores. A 3.3 lb container of Briess LME at the LHBS is around $13-14 in my neighborhood, whereas it's about $9 online, but then you're paying shipping. But even with shipping, you may still save money buying LME online. Some stores have free shipping deals if you buy a certain amount. For example morebeer.com has free shipping over $59. If you buy a LME online in bulk you will definitely save there. It has a shelf life, but if you keep it in the fridge it should last a few months.
I prefer to have my grains milled as close to the day I'm going to use them as possible, and I don't own a grain main, so I try to buy them at the LHBS. Yeast needs to be kept cold, especially liquid yeast so it's tricky to buy online without it being expensive since you need ice packs and fast shipping.
I think it's commonly acknowledged that if you want to save the most money in the long run, all grain is cheaper than extract brewing. I still do extract, but I'm planning to start doing stove top all grain soon with a cheap setup like this:
http://www.homebrewtalk.com/f39/easy-stovetop-all-grain-brewing-pics-90132/