You might like The Laundry Files books by Charles Stross. Exactly that plays out in one book where elves invade Earth.
The premise is that magic is real, and can be summoned/controlled by the appropriate application of mathematics. If you discover this truth, you’re irrevocably attached to The Laundry, basically MI6 for supernatural affairs, and you can never leave.
The protagonist is an IT nerd in England. He almost flattened Wolverhampton with a new algorithm he discoved but they caught him in time. His wife is a protagonist in a few books, and she’s a delight. One of my favorites is where a bunch of high-end accountants accidentally make themselves vampires.
Why the hell can’t you spell colour?!