Assign variables automatically to a function To some who might find that answer useful I would recommend to use {var = ToString /@ Sort@DeleteDuplicates@Cases[fn, _Symbol, Infinity]} instead of {var = ToString /@ Sort@Variables@fn} so it works with every functions (& not only polynomials).