I tried to calculate many years ago and gave up. Besides the bike, there is all the side stuff like helmet, lock, racks, any cycling specific parts, maintenance, and on and on and on that must be figured in to get a cost per mile.
By the way, this was back in the 80s so I've forgotten my preliminary numbers and it was way more than I thought it would be. All of those little bike parts and add-ons really add up. Don't tell your SO.