The S&P 500 index tracks 500 large U.S. companies that collectively represent about 80% of the entire domestic stock market and more than 50% of the global stock market in terms of market capitalization. The index has rocketed 18% higher year to date (as of Nov. 17), as signs of economic resilience have lifted investor sentiment.

During that time, accelerated-computing company Nvidia (NVDA 6.18%) saw its share price soar 237%, making it the best-performing stock in the index. Meanwhile, solar-energy company SolarEdge Technologies (SEDG 2.81%) saw its share price plunge 72%, making it the worst-performing stock in the index.

I happen to be a shareholder of both. Here's what I plan to do.

Nvidia: 237% year-to-date gain

Nvidia has reported phenomenal financial results throughout the year due to strong demand for data center computing products, especially those related to artificial intelligence (AI). Second-quarter revenue soared 101% to $13.5 billion, gross profit margin expanded 26 points to 70.1%, and non-GAAP net income increased more than fivefold to $6.7 billion.

What's truly incredible is that management actually expects that momentum to accelerate. Third-quarter guidance calls for revenue to grow 171% to $16 billion. It also calls for non-GAAP operating expenses to increase just 12%, and the discrepancy between that figure and the revenue growth figure implies tremendous net-income growth. Of course, results like that are unsustainable over long periods of time, but investors still have reason to expect solid growth for many years to come.

Nvidia's graphic processing units (GPUs) are the gold standard in accelerating complex data center workloads. The company holds more than 95% market share in workstation graphics and machine learning processors, and its GPUs are synonymous with AI infrastructure. But Nvidia is truly formidable because its portfolio also includes high-performance networking solutions, subscription software, and cloud services that support AI workflows.

Indeed, Nvidia recently launched three cloud services for building generative AI applications: NeMo for language applications, Picasso for visual applications, and BioNeMo for biological applications. Those products came on the heels of its latest AI Enterprise software, which helps businesses build and deploy AI applications that address use cases across virtually every industry, from retail and logistics to healthcare and financial services.

In short, Nvidia offers a relatively comprehensive computing platform geared toward graphics and AI, and that puts the company in a good position. Grand View Research says the AI market will expand at 37% annually through 2030, and Morningstar analyst Brian Colello expects Nvidia to grow revenue at 22% annually over the next decade.

The only problem here is valuation. Shares trade at 37.6 times sales, a substantial premium to the three-year average of 23.5 times sales. Alternatively, shares trade at 22.4 times forward sales, which is still a premium to the three-year average of 17.6 times forward sales.

I have no plans to add to my position at the current valuation, nor do I plan to sell. But if I didn't have a stake in the company already, I would probably buy a small position today.

SolarEdge Technologies: 72% year-to-date loss

In October, SolarEdge saw its share price fall 30% following a press-release warning that its third-quarter financial results would miss expectations by a wide margin. That drawdown was particularly painful because the stock had already fallen precipitously on weaker-than-expected third-quarter guidance.

Unfortunately, the report was every bit as bad as management warned. Third-quarter revenue declined 13% to $725 million, and the company reported a non-GAAP loss of $31 million, down from a profit of $54 million in the prior year. The primary reason was unexpectedly weak demand due to high interest rates, but that was compounded by an inventory buildup meant to address unexpectedly strong demand earlier this year.

Management says the inventory correction will persist through the first half of next year, but the investment thesis remains unchanged. The world is gravitating toward renewable energy, and SolarEdge has a strong presence in the solar-systems market. Its core products include inverters, power optimizers, and energy management software for residential and commercial customers. The company has also branched into the adjacent markets of battery storage and electric-vehicle chargers.

What sets SolarEdge apart is brand authority and scale. It revolutionized the solar industry with the invention of the power optimizer, a device that optimizes solar-panel production by mitigating problems like partial shading, and it currently ranks as the second-largest manufacturer of solar inverters worldwide (and the largest outside of China). That means the company is well-positioned to benefit as solar power becomes more prevalent.

On that note, Straits Research projects 6% annual growth in the solar-inverter market through 2030, and 16% annual growth in the solar-battery market during the same period. SolarEdge's sales growth should land somewhere in the middle of those figures, given its leadership position in the inverter market and its nascent storage business.

Indeed, Morgan Stanley expects SolarEdge to grow revenue at 9% annually through 2035. That forecast makes its current valuation of 1.3x sales look like a bargain, especially when the three-year average is 7.1x sales.

At that price, I'm very tempted to add to my current position and not at all inclined to sell. I think patient investors with a five-year time horizon can buy this stock with confidence.