IME measuring with tape and formulas is a waste of time. The quick and correct way to do it is to use the heel-on-pedal method. Measure with your leg. With your heel on the pedal and your knee completely locked out, your heel should barely touch the pedal or perhaps have up to a 4mm gap between heel and pedal. An important caveat is not to tilt your pelvis, reaching down for the pedal. A good method is to go out on a level road with your allen wrench in your pocket. Get moving, then unclip one foot and pedal very slowly while coasting with the heel of the unclipped foot on the pedal. That knee should completely lock out while barely or not quite touching the pedal. Repeat with the other foot.
This is a good approximation, but might still be a few mm off of what is perfect for you. Make final very small adjustments while feeling for that perfect knee bend which gives you good pulling-back power at the bottom of the pedal stroke.
Your hamstrings may ache because they're not used to the proper saddle height. Pulling back at the bottom uses some ham strength.
Fore-and-aft saddle adjustment is by feel. You want your hands to feel light on the bars and in fact be able to remove them briefly from the bars without sliding forward on the saddle. The further back the saddle, the less weight on the hands. So first measure your current saddle height. I measure from the center of the pedal axle right along the seat tube to the saddle top. Adjust the saddle fore-and-aft until it feels right. Then reset saddle height.
__________________
Results matter