iPhone turns off, thinking it has run out of battery
From time to time (every second or third day) my iPhone turns off thinking it has run out of battery. This is despite the battery % stating it still has a significant amount of power remaining. I have seen it turn off at 17%, 25% and today 38%. When I try to turn it back on by holding down the on/off butting, the screen displays the out of battery screen, telling me to plug it into a charger. When I plug it into a charger, the phone comes back on, and already has the same amount of charge as it did before it turned off. So in today's case when I plugged it back it, and it powered up, the phone had 38% of battery immediately.
What can I do to fix this so the phone uses all its battery life?
Thanks
iPhone 5, iOS 6.1.4