Apple has overtaken Nvidia as the world most valuable company, reaching 5.03 trillion dollars as investors rotate away from heavy artificial intelligence spending.