1. A method for obtaining an optimal reflectivity value for a complex multilayer stacks implemented as a lithography simulation program executed on a computer, comprising: (a) generating a model of a simulated multilayer stack prior to production of the multilayer stack and parameterizing each layer by providing parameters, the parameters including a thickness and an index of refraction; (b) receiving from a user input values for the parameters, including a designation of an unrestricted number of the parameters as independent variables; (c) calculating an extrema for a cost function of reflectivity R using the input parameter values; (d) calculating sensitivity values S for the extrema; (e) obtaining the optimal reflectivity value for the simulated multilayer stack by calculating a cost function R+α·S using the independent variables at once, wherein α is a weighted parameter for the sensitivity values in the cost function; and (f) using the optimal reflectivity value to one of minimize and maximize reflectivity of at least one layer boundary in the multilayer stack to reduce resist critical dimension (CD) variation and improve accuracy of a lithography process.