First, there is no way to get the focal length from the aperture.
Your camera's max aperture is f/3.1 at 6.3mm and f/5.9 at 18.9mm - but there isn't anything that say the camera must use the max aperture, it's completely possible to use f/5.9 at 6.3mm - so there no relationship what so ever between the aperture used and the focal length.
Even if you force the camera to use the max aperture the relationship between the max aperture and the focal length is depended on the internal design of that camera's lens and there is not general formula that can help you.
And, just to make things even more impossible camera manufacturers don't publish the max aperture - focal length relationship because usually it just makes them look bad (the max aperture gets smaller faster than you would think).
Second, "in the real world" it's usually very easy to get the focal length, every digital camera I've ever owned from entry level point ans shoots all the way to may current DSLR always records the focal length in the EXIF data.