The assignment is as follows: $$f(x_1,x_2) = (x_1^2 −x_2^2)(x_1^2 −1) + 4(x_1^2 + x_2^2 −2x_1)^2$$ With sublevel $X = f(x) \le 8$
I want to know whether the function f is convex or not. I want to extract the eigenvalues, and if they both are positive, then $f$ is convex. However, I don´t know what to put in at the last line of the code eig(ddf$(x_1,x_2)$), and how do I know what $x_1$ and $x_2$ to put in to the code?

In order to be convex, the eigenvalues of the Hessian must be nonnegative for all $(x_1,x_2)$. However, to disprove convexity, you only need to find one $(x_1,x_2)$ at which the Hessian eigenvalues are not all nonnegative.
Your function $f(x_1,x_2)$ is not convex. Nor is it concave.
At $(0,0)$, the Hessian eigenvalues are $30$ and $2$, so $f$ is convex at that point. However, at $(1,0)$, the Hessian eigenvalues are $-6$ and $-16$, so $f$ is concave at that point. Therefore, $f$ is neither convex nor concave.