Multiphase fluid flows have applications in natural, scientific, and engineering systems. In today's scenario, it is very important to have an analysis of multiphase fluid flows for which Lattice Boltzmann law is used. For this, the second-order D2Q9 LBM model is used. Also for accurate analysis, the higher-order LBM models are used. During the analysis of multiphase fluids, a piecewise linear equation of state is adopted for nonideal fluids in which two equations are used for defining the mechanical and chemical equilibrium. Both the equation possesses two roots usually referred to as spinodal points. In the present work for getting these spinodal points, the two equations have been simultaneously solved with the help of a nonlinear programming method called Sequential Quadratic Programming (SQP). The code has been developed in MATLAB. The spinodal points for few cases available in the literature have been obtained with higher accuracy using the above optimization method. A parameter that tunes mechanical stability conditions for multiphase fluid flow has been estimated using the second-order regression analysis.