As I stated, you can't feed the input of a voltage regulator from a resistor divider like that, it's resistance will be in series with the regulator's input which limits current destroying the ability of he regulator to regulate. You could try tacking on a zener regulator beforehand to help get the max voltage in line but dropping from 40 to 5 volts is an incredible waste of power, you're going to wasting almost 90% of the power being used as pure heat.
If your 5V circuit draws 1 amp that will be 35watts of power lost as heat in the regulator.