Here are a few websites in which the combination "formula to + gerund" has been used.

The only link I am able to follow is the first, and it leads to an example that I find unidiomatic. If you continue to search for examples of "formula to + gerund," you will find some, and you can safely assume that I will find all of them unidiomatic; so there is no need for you to present them here or to give links to the examples.

Should you continue your search, I recommend that you compare the relative frequency of "formula for + gerund," using the same gerund. You will thus be able to compile some statistics showing you that the overwhelming preference is for "for."

*The Oxford English Dictionary (OED)*, in its definitions of "formula," does not contain a single example of "formula to + gerund." It does, however, contain an example of "formula for + gerund": "1850 C. G. B. Daubeny (ed. 2) v. 156 A general **formula for calculating** the specific heat of each class of compounds."

On COCA (The Corpus of Contemporary American English), there are **319** examples of "formula to," and **only 2** of them are instances of "formula to + gerund." I find both of the sentences to be unidiomatic, and would have revised "to" to "for" if I had been able to edit the sentences:

- "Joe Linta may have come up with a two-question
**formula to evaluating it**." - "You might think that you had discerned the secret
**formula to becoming one of our favorite ski areas**."

COCA displays 1225 results for "formula for," and I do not have time to go through all of them for you, but you're welcome to join the corpus yourself and have a look. Suffice it to say that the results for "formula for + gerund" dwarf the pitiful two results for "formula to + gerund." Here are a handful of examples:

- "Some post the
**formula** **for** calculating pay." - "In an era of constant disruption, clinging to purpose and recruiting for resilience is the
__formula__ __for__ building the workforce of the future." - "it did suggest a sharp departure from the usual post-1989
__formula__ __for__ exercising global leadership." - "the use of total population is supported by the Constitution's
__formula__ __for__ allocating seats in the House of Representatives among the States." - "He must have a magic
__formula__ __for__ reaching the Final Four, which his teams have done seven times."

I don't have time to keep providing you with more and more evidence right now.