It's surprisingly simple, honestly? Spoilered so that I don't give it away to anyone that doesn't want to be spoiled: You have to brew using the ingredients that the alchemy book in the Library says are used to make the original potion, without substituting anything; the consequences of this mistake result in Ending B.