I like the way magic functions in Harry Potter. One can criticize Rowling for many things however magic is where she did rather creatively in her series (at least initially), often referred back to moments written prior to expand on them indirectly. I'd like to compare this to 2 other fantasy series; Lord of the Rings and Young Wizards.
First the LOTR-verse: It has magic but more passive, acting rarely as a semi-divine ability. It makes the Elves, Dwarves and Wizards live MUCH longer and have abilities and talents (physical included) unavailable to mortal men. It also allows for minor spells (light, fire etc.) and is more atmospheric and internal. It is very weak compared to most magic in other media. This is a low-magic fantasy approach and is fine for a work like LOTR but it also takes away the sheer wonderment of a fantasy setting. In layman's terms LOTR magic is largely spiritual, and grants minor 'stat boosts' to objects and people of magical descent
The second mentioned here >>5963
Young Wizards, written by Diane Duane, has plenty of power/creativity in the magic (and variety dependent on species and situations) however the approach is so clinical it becomes a bit bland, using calculations into the territory of Physics. In other words, stops being magic, becoming a "magic is unknown science" meme. Magic has its rhyme and reason, but the point is that it ISN'T science, but mystics that work with the metaphysical with low-medium reality-warping.
An example from the Second Book Deep Wizardry, SPOILERS: "...characters appeared. "Okay, print four eight zero times twenty... Good, print nine six zero zero divided by three... Great. Cubic meters... uhh... Oh, crap. Kit, what's the volume of a cylinder again?"
"V equals pi times r squared times the height."
"That's it. Now how did I do this before?" Nita chewed her lip a little, thinking...
The excessive calculations needed for the magic makes it lose its mystery and the sheer complexity makes it hard to write and thus spells are rarely detailed (the excerpt above an exception). Other times the magic follows NO such complexity or logic; later on in the same book the binding magic needed is from an operatic theatre (though this can be explained with the fact that this magic is done by whale wizards
In Harry Potter Magic works primarily through intent and belief. One feels the magic, working in the flow, leading to how well it turns out. For example Potioneering; rather than scientific chemical reactions it is a reaction based on mythological properties and their internal "stories" imbued with magical energy and how they interact.
An interesting description comes from, a well written Xover fanfic called Umino Iruka and the Will of Fire by Leicontis; recently finished and a delightful read for fans of Harry Potter and Naruto, but I digress. On Chapter 38 we get the following from Professor McGonagall,
"The Study of Ancient Runes is, in earlier years, primarily a language course. Students learn to decipher various runic languages, and to scribe and engrave runes themselves. In its later years the class begins to cover the usage of runes in magic, a topic not entirely dissimilar to the 'seals' you are all familiar with. Runes are primarily used in the creation and anchoring of long-term and permanent magical effects upon objects and locations. A thorough grounding in Runes is therefore essential for any profession involving the creation of such effects, such as warders and enchanters, or the dismantling of existing effects by cursebreakers and the like."
"Arithmancy begins with basic numerology, the study of the magical properties of numbers and how they interact with each other and with magic and the world. At more advanced levels, the course covers the calculations involved in understanding magical effects. These calculations are essential in the crafting of new spells and potions, and in analyzing existing magics. Aspiring warders, enchanters, and cursebreakers again will find this field essential, but so will spellcrafters, Potions masters, and others that seek to research magic and its many mysteries."
"Care of Magical Creatures is essentially a counterpart to Herbology. In it, students learn about many forms of magical fauna, though some creatures are discussed more in Defense Against the Dark Arts. Obviously, anyone who might wish to work with magical beasts of any sort would be well-advised to take this class. This not only includes the more apparent careers, such as dragon-handling or magizoology, but also wandmaking and others that utilize parts or products from magical creatures. A Potions master would thus benefit from such knowledge, as would a master Herbologist."
The excerpt beautifully summarizes the sheer potential of magical creativity created by Rowling, which she ironically only scratched the surface of, but fans and fanworks have eagerly delved in. Later in the fic during the Horcrux Hunt
the methods in breaking down Voldemort's defenses and his response to the shinobi's abilities
allow for a creative demo of fan-made and canon spells and their use in quick succession. Another example of this is shown in the fanfic Divided and Entwined by Starfox5, where a good example is a lengthy arc dedicated to deciphering mysterious Houngan Necromancy.
Unfortunately, the whole Chosen One story in the Canon Harry Potter books began to escalate, the magical side of things became side-material and thus ground to a halt in terms of new things introduced or prior mentions being expanded. This is the problem the Young Wizards series also faces. Each book has a specific set of antagonists and protagonists and a certain goal that must be reached. Magical items mythical and original are found and new spells used in situations, but magic itself is rarely explored or given understanding. Due to the physics-like nature of the 'Book-magic' one would assume it is limited by physics and calculation and thus cannot be used inventively without careful longterm study (like runes/arithmancy) and lacks others like Charms, Jinxes, Curses, Hexes, and Transfiguration. Mythical creatures are either aliens or deities in mortal animal disguise, potions are nigh non-existent etc. Then there is the magic of the whales which is done with singing/opera which comes from the heart
and thus requires writing similar to a Musical play, which is hard enough as it is. It is both too specific and too vague and thus cannot be expanded on by fans without, essentially creating almost an original work entirely. It essentially tries the "alchemy" shtick of Full Metal Alchemist, without actually showing enough to have a real grasp of it, and because it's deconstructed scientifically you cannot wonder/let your mind run-wild, as you hit certain blocks.
LOTR lacks this issue because magic was never big in its story in the first place, the quest(s) being told were what's important, but when looking for prominent magical ability in a story you can't have this either.
TL;DR: Harry Potter's magic system is defined, yet fluid enough that creative license can be used freely without fearing contradiction of in-universe rules. This allows for the most important part of a fantasy's world-building; the imagination of the audience to take hold and develop it further, past the main story and characters, without everything being scientific or weak or vague.
>Inb4 HP has a weak Magical system
Debatable and irrelevant as Magical function and system aren't the same. A large point of magic being MAGIC. Magic has changed in modern view. In the past that which couldn't be rationally explained was 'magic' or 'divine' however this was also embellished with legend/myth, so that real science behind it has long been expanded into a new realm. Today it has evolved further to embody, first and foremost, the power of imagination and willpower put into direct ability; magic.