Nuclear submarines are among the most complex machines ever built, capable of staying hidden beneath the ocean for months.