I was recently working on a math problem, which involved some horrifically messy calculations, but which resulted in a surprisingly clean, beautiful, and useful result, and I was wondering what a good expression would be to describe such a thing. My first thought was "diamond in the rough", but that doesn't really convey that it started out as something really ugly, and in any case, the expression reminds me of a song I don't like. Is there a better expression for this? The best I can think of is "ugly duckling", but that expression focuses mainly on the earlier (ugly) phase, rather than the fact that beauty came seemingly out of nowhere.
Perhaps gold is a good metaphor for your happy results: "I spun gold from a pile of straw" or "I panned gold nuggets from a pile of mud".
The butterfly emerged from its chrysalis See YouTube, Monarch Butterfly Emerging from Chrysalis
chrysalis, from Merriam-Webster:
the hardened outer protective layer of a pupa
and a pupa is, according to Merriam-Webster:
an intermediate usually quiescent stage of a metamorphic insect (such as a bee, moth, or beetle) that occurs between the larva and the imago, is usually enclosed in a cocoon or protective covering, and undergoes internal changes by which larval structures are replaced by those typical of the imago
and an imago is, from Merriam-Webster:
an insect in its final, adult, sexually mature, and typically winged state
In this case, the imago is the butterfly.
You made a silk purse out of a sows ear, that's what you did!!