Preheat the oven to 375°F. Butter a 9x13 inch ceramic baking dish thoroughly, right into the corners.
Peel 3 pounds Yukon Gold potatoes and slice them into rounds about 1/8 inch thick on a mandoline. Drop the slices into a large glass bowl of cold water as you go, so they do not brown.
Drain the potato slices in a colander and pat them dry with a clean kitchen towel; wet slices thin the sauce.
In a cream Dutch oven, melt 3 tablespoons butter over medium heat. Add 5 cloves minced garlic and cook, stirring, for 1 minute, until fragrant but not browned.
Pour in 2 cups heavy cream and 1 cup whole milk. Stir in 1 teaspoon salt, 1/2 teaspoon pepper, 1/4 teaspoon nutmeg, and 1 teaspoon thyme leaves. Bring to a gentle simmer and cook, stirring occasionally, for 4 minutes, until the sauce coats the back of a spoon.
In a mixing bowl, toss 2 cups grated gruyere with 1 1/2 cups grated sharp cheddar.
Arrange a third of the potato slices in the prepared baking dish, overlapping them slightly like shingles. Season with a pinch of salt and pepper and scatter a third of the cheese mixture over the top. Repeat with two more layers of potatoes, salt, pepper and cheese, ending with the last of the cheese on top.
Pour the warm garlic cream evenly over the layered potatoes, tilting the dish so it reaches every corner and settles between the layers.
Cover the dish tightly with foil and bake for 45 minutes.
Remove the foil and bake for 25 to 35 minutes more, until the top is deep golden and a paring knife slides through the center layers with no resistance.
Let the gratin rest, uncovered, for 15 minutes before serving; this gives the sauce time to set so each portion holds its layers instead of pooling onto the plate.
Cut into squares or scoop with a large spoon and serve warm.
Good to Know
Set the mandoline to a true eighth of an inch and do not pull the dish early: the center, not the edges, tells you when it is done.