Nick Pivetta was in the midst of a meltdown. After a terrific 11-game start to his second season in the big leagues, the Phillies' 25-year-old righthander stumbled through June and July, his earned run average soaring from 3.26 to 4.85. If manager Gabe Kapler had pulled the plug on Pivetta's turn in the rotation, no one, including the pitcher, could have questioned why.

Instead, the Phillies' manager dug into the numbers he so loves and found one he could not wait to share. Pivetta's ERA — the primary measuring stick for major-league pitchers for years and years — might have been an eyesore, but Kapler could not take his eyes off the pitcher's xFIP.

"I think there's a lot to get excited about there," Kapler said the day after Pivetta surrendered five runs on six hits in a loss at Cincinnati. "A lot to still be very optimistic about. I know that there is more external concern, but internally we are very, very confident in Nick Pivetta and his performance thus far."

There's no way to know if Kapler was telling the truth, the whole truth and nothing but the truth when he shared those thoughts in Cincinnati. Regardless, it was a bit of positive energy that has paid off for the manager and the Phillies. The xFIP acronym stands for Expected Fielding Independent Pitching. It is a stat that approximates pitchers' earned run averages based on what they can control: strikeouts, walks, hit by pitches, and fly balls allowed. The formula includes a calculation of the league's average home-run-per-fly-ball ratio.

"What that number attempts to do is compare the amount of fly balls that Nick is giving up vs. the amount of fly balls that the league is giving up and then subsequently the home runs that he's giving up vs. the home runs the league is giving up," Kapler said.

Looking at the definition and listening to the manager's explanation makes me feel like I'm back in an advanced mathematics class, and those things used to keep me up at night for fear of failure. You can use a cheat sheet and just go to FanGraphs.com, click on the xFIP statistic and see that Pivetta is among the best in baseball in that category. He was 14th when Kapler made his remarks late last month and he had improved to 10th heading into Tuesday night's start against the high-powered Boston Red Sox. His 3.19 xFIP before Tuesday was better than Cleveland's Corey Kluber, Houston's Justin Verlander and teammate Aaron Nola, all of whom are considered elite major-league pitchers.

There's no denying that Pivetta appears to be back on track and Tuesday night's performance in a 2-1 loss to the Red Sox should give him even more confidence going forward. He attacked the most dangerous offense in baseball with first-pitch strikes and held Boston to a single run on three hits through six innings. He left with the score tied at 1-1 after throwing 60 of his 84 pitches for strikes. In short, he matched former American League Cy Young Award winner Rick Porcello almost pitch for pitch while also admitting he had some help from his teammates on defense.

"Pivetta certainly matched [Porcello]," Kapler said. "His fastball had life through the zone. We saw some swings-and-misses up in the zone from some very, very good hitters and I thought he had command as well."

Pivetta was actually a little tougher on himself.

"I tried to stick to my strengths," he said. "Guys played phenomenally behind me. I hung a couple of breaking balls. [Maikel Franco] made some phenomenal plays, a couple of key groundball double plays. I tried to stick with Porcello as much as I could. He was throwing the ball really well and I knew I couldn't make a lot of errors or mistakes. I just tried to attack them the best that I could."

Although he did give up some hard-hit balls, Pivetta shut down Boston's most lethal offensive players, holding the first five hitters to a single hit. He did, however, surrender a solo home run to light-hitting catcher Sandy Leon in the top of the third inning. Rhys Hoskins evened the score for the Phillies with a home run in fifth, but Boston regained the lead on a solo shot by pinch-hitter Brock Holt off reliever Tommy Hunter in the eighth.

Still, the Phillies were pleased with Pivetta once again.

In his three starts since his manager brought up the xFIP factor, the right-hander has made three starts and allowed just three runs on 12 hits over 18 innings. He has struck out 19 and walked just two in that stretch. His performance might not have been good enough to get the Phillies a win against baseball's best team, but it does bode well for the stretch run.

Give Gabe Kapler some credit on this one. The manager has been criticized at times for being too positive after difficult-to-digest defeats, but in this case he has helped Pivetta believe in himself again.

Get insights on the Phillies delivered straight to your inbox with Extra Innings, our newsletter for Phillies fans by Matt Breen, Bob Brookover and Scott Lauber. Click here to sign up.