I have a multivariable function, z = f(x, y, w), represented by a surface plot in 3D (z versus xy) for each value of w. As w varies, the function z varies (goes up and down and changes shape) over a given rectangular xy region. As z varies with w, contour lines with given constant values of z form and change shape. Some of these contour lines are open while others are closed. However, as w increases the open path contours usually become closed paths (closed loops). I have two related problems: (1) I want to find the threshold value of w at which a certain contour, z = c where c is a given constant, turns from being open to closed (i.e. what is the minimum value of w at which the contour curve becomes closed loop). (2) I want to find the threshold value of w at which a certain curve with the condition, z ≥ c where c is constant, turns from being open to closed. Is there an analytical way for finding the threshold minimum values of w at which these two curves first become closed loops?