In a span of a few years, China has outstripped the U.S. in scientific publications, spending and patents.