show that function is not convex

I've never had to do this before, so I'm not really sure how to do it. These problems also don't even really relate to what the subject of the book is as well.

Given: $f(px+(1-p)y)\le pf(x)+(1-p)f(y)$

Consider the function

$f(x)\left\{ \begin{array}{cc} x & x\le1\\ 2-x & x>1\end{array}\right\}$

Show that $f(x)$ is convex on $-\infty < x \le 1$ and convex on $1 < x < \infty$ but not convex on $-\infty < x < \infty$

Another problem using the same convex definition:

Suppose $f(x)$ is defined on the interval I. If $x_{1}<x_{2}<x_{3}$ are in I and $f(x_{1})<f(x_{2})$ and $f(x_{3})<f(x_{2})$, then show that $f(x)$ is not convex on I.

Thanks

Edit: Im not sure how to use the definition. Thats kind of where i am stuck. I'm sure it's easy, but like i said i've never seen this before, the book has nothing to do with this, it's just randomly thrown in here. There are no examples for this either.

-
You just need to apply the definition, and for the second problem, your statement should read "If $x_1 < x_2 < x_3$ are in $I$ and $\ldots$" – user17762 Nov 25 '10 at 5:39

If you look at the definition geometrically (on $\mathbb{R}$) it states that a function is convex if each point of the graph $(x, f(x))$ is below any line that adjoins graph points $(a, f(a))$ and $(b, f(b))$ where $a<x<b$. In other words, for any ordered triple $a<x<b$ the point $(x,f(x))$ is below the lint through $(a,f(a))$ and $(b,f(b))$.

Now think about the graph of your function - look at $x<1$... look at $x>1$... look at $x=1$...

-

You just need to apply the definition for these two problems.

For the first problem,

Consider two points $x,y$ such that $x,y \leq 1$. Argue why the definition of convexity is true in this case.

Similarly, consider two points $x,y$ such that $x,y > 1$. Argue why the definition of convexity is true in this case.

Now consider $x < 1$ and $y > 1$ and argue why the definition is violated.

In the second problem, your statement should read "If $x_1 < x_2 < x_3$ are in $I$ and $\ldots$"

Use the same idea as before (argue from the definition)

Note that $x_2$ can be written as a weighted linear combination of $x_1$ and $x_3$.

-