Your $40k price is the high end and only in some markets, and has a whole lot more to do with regional labor costs than anything else. The same system would probably be $15k installed in another market. And that's before the enormous subsidies that are on offer in many states.
Or if you're at all handy and willing to educate yourself, you can DIY it for a fraction of the cost. That's obviously not for everyone, but you don't need any professional skills. You could hire an electrician if you want to be grid-tied.