There is no magic formula to taking notes when reading.You have to find out what works best for you. (Source: Iran's English Coursebooks)
Yes, "to" is functioning as a preposition there; "taking notes when reading" is a gerund phrase that is functioning as the object of the preposition "to." However, "to" is not the idiomatic preposition to use in this context. Native speakers tend to use "for":
- There is no magic formula for taking notes when reading.
In the somewhat rare cases when "to" is used after "magic formula," it is as the stem of an infinitive: "There is no magic formula to take notes when reading." There "to" is NOT a preposition. In your sentence, the idiomatic choice is "for" followed by the gerund. Perhaps you can notify Iran's textbook committee.