BATTLE OF THE EXES: Carmelo Anthony and Mike D’Antoni couldn’t get on the same page in New York. Photo: Paul J. Bereswil

Mike D’Antoni and Carmelo Anthony are back together at the Garden for the first time tonight, their public divorce last March working out magnificently for the player and not so wonderfully for the former Knicks coach.

As D’Antoni’s purple-and-gold Lakers invade the Garden, Anthony is coming off a 45-point explosion in Brooklyn amidst an MVP-caliber season.

Anthony’s Knicks are soaring like an eagle above the Eastern Conference at 16-5. The Lakers — and the knee-impaired D’Antoni — are limping along in the West. D’Antoni owns a 4-8 clip in L.A. following Tuesday’s loss in Cleveland after which he flipped out at a Los Angeles Times columnist questioning his preparation.

When asked what kind of reception D’Antoni will get tonight, Anthony said, “We shall see. I don’t know.”

Heartwarming stuff. Maybe Anthony will even wave his bandaged middle finger at D’Antoni after he scores.

D’Antoni resigned from the Knicks on March 14 last season, feeling he no longer could coach Anthony. D’Antoni realized owner James Dolan was committed to Anthony and not running the offense through Jeremy Lin. The morning of D’Antoni’s resignation, The Post reported Anthony was so unhappy he preferred a trade unless he had assurances D’Antoni wouldn’t be back next season.

Mike Woodson, D’Antoni’s assistant, took over the reins and has posted the best record in Knicks coaching history after 45 games (34-11). Woodson got Anthony playing ferocious defense and installed him as the focal point. Anthony never felt comfortable in D’Antoni’s speedball system, especially when Lin ran the show and got the credit.

“At the end, it didn’t work out the way it should’ve,’’ D’Antoni said. “But I do think the franchise is now on a great path. They’re good. Tyson Chandler is huge for that team. We just struggled because to get Tyson, we had to give up our point guard [Chauncey Billups]. We couldn’t figure that out until Linsanity. Then Linsanity became another problem, but also a great thing.

“I wouldn’t change it. I’d change to be more successful.’’

Kobe Bryant spoke to Anthony during the Olympics and claims Anthony still respects D’Antoni’s offense.

“You know what, if you talk to Carmelo and you ask him about Mike D’Antoni’s offense, he’ll tell you he’s an offensive genius for sure,’’ Bryant said. “Whether it didn’t work down there because of the personnel, I really don’t know. But I know he feels firsthand that way about him.’’

Bryant said Anthony is the “most difficult” player for him to guard, harder than LeBron James. “Melo does it all,” Bryant said on ESPN yesterday. “He’s as strong as a bull.”

So far, it’s not working out for the Lakers, though point guard Steve Nash (broken fibula) has yet to play a game for D’Antoni. The Lakers are committing a lot of turnovers and not playing defense — exactly the opposite of the Knicks — and Lakers fans are frustrated the team didn’t hire Phil Jackson.

The pressure got to D’Antoni in Cleveland when he was asked if there wasn’t enough defensive preparation during the morning shootaround’s film session.

“I didn’t see you at the film session. We worked a half-hour on it,’’ D’Antoni barked. “Now you’re starting to [tick] me off. Now you’re starting to [tick] me off when you’re saying something that’s not factually correct.’’

As miserable as he may be, D’Antoni is never far from dropping a wisecrack. When asked if the Knicks shouted “championship’’ when breaking a huddle like with the Lakers, D’Antoni quipped, “We didn’t quite get there in New York. I think we said, ‘Let’s win one.’ ”

Touché. It wasn’t a prosperous stint (121-167 in nearly four seasons) but D’Antoni’s losing record also wasn’t entirely his fault. He acknowledged the first two seasons were designed to lose big to get under the salary cap for James. Instead, the Knicks signed Amar’e Stoudemire and traded the farm for Carmelo Anthony. It took until now to restock the roster.

“We were going to destroy everything for two years, so we built guys’ stats up so we can trade them,’’ D’Antoni said. “I thought it was successful because we made a good run at the free agents. But it didn’t work out.’’

D’Antoni’s downfall was the overhaul of the roster, climaxed by the Anthony blockbuster. D’Antoni had more than 50 players in New York. “I coached half the league in the last couple of years,’’ he said.

D’Antoni said the Anthony trade made it hard to win immediately because of all they gave up.

“In the third year we signed Amar’e, which is cool,’’ D’Antoni said. “He did a hell of a job. We have a nice young team and we make the playoffs. We were sixth. In the middle of that run, we trade everybody for Melo. Good trade for the [future of the] organization. That’s what they should’ve done. But when the expectations were out the roof, here we go.’’