  A generic algorithm is developed to reduce the problem of obtaining linear
and nonlinear entanglement witnesses of a given quantum system, to convex
optimization problem. This approach is completely general and can be applied
for the entanglement detection of any N-partite quantum system. For this
purpose, a map from convex space of separable density matrices to a convex
region called feasible region is defined, where by using exact convex
optimization method, the linear entanglement witnesses can be obtained from
polygonal shape feasible regions, while for curved shape feasible regions,
envelope of the family of linear entanglement witnesses can be considered as
nonlinear entanglement witnesses. This method proposes a new methodological
framework within which most of previous EWs can be studied. To conclude and in
order to demonstrate the capability of the proposed approach, besides providing
some nonlinear witnesses for entanglement detection of density matrices in
unextendible product bases, W-states, and GHZ with W-states, some further
examples of three qubits systems and their classification and entanglement
detection are included. Also it is explained how one can manipulate most of the
non-decomposable linear and nonlinear three qubits entanglement witnesses
appearing in some of the papers published by us and other authors, by the
method proposed in this paper. Keywords: non-linear and linear entanglement
witnesses, convex optimization. PACS number(s): 03.67.Mn, 03.65.Ud
