Showing If A Function Is Convex/Concave I have to show wither the two following functions are convex:
$f_1(x)=1+6x-7x^2$ and $f_2(x)=1+6x+7x^2$
Now I want to apply the condition that this is convex iff we have $f(y)\geq f(x)+\nabla^T f(x)(x-y)$
So for $f_1$ we have:
So I have that $\nabla^T f_1(x)=6-14x$  right?
So then if we choose $x=y=0$ then we have that
$1+6y-7y^2< 1+6x-7x^2+(6-14x)(x-y)$? and so this function is not convex.
On the other hand for $f_2$ we have that:
$\nabla ^Tf_2(x)=6+14x$ so we need to show that:
$1+6y+7y^2\geq 1+6x+7x^2+(6+14x)(x-y)$ right? But this doesn't seem to be true either so I am a bit confused?
Any help on where I may have gone wrong would be appreciated.
 A: If $f$ is a continuously differentiable function then, convexity is equivalently to the inequality (see here) $$f(y)-f(x)\ge f'(x)(y-x),\ \forall\ x,y.$$
Let $f(x)=a+bx+cx^2$. Note that $f'(x)=b+2cx$. In our case, $f$ is convex if and only if $$a+by+cy^2-a-bx-cx^2\ge (b+2cx)(y-x),$$
or equivalently $$b(y-x)+c(y^2-x^2)\ge b(y-x)+2cx(y-x),\ \forall\ x,y\in\mathbb{R}, $$
or equivalently $$c(y^2-x^2)\ge 2cxy-2cx^2,\ \forall\ x,y\in\mathbb{R},$$
or equivalently $$cy^2-2cxy+cx^2\ge 0,\ \forall\ x,y\in\mathbb{R}.$$
Therefore $$c(y-x)^2\geq 0,\ \forall\ x,y\in\mathbb{R}.$$
Can you conclude that this is true if and only if $c\ge 0$?
Remark 1: the problem with your solution is that you are verifying the wrong inequality, indeed, the right hand side of your inequality must be $y-x$ and not $x-y$.
A: It is much easier to look at the second derivatives. A function $f$ is concave if $f^{\prime\prime}(x)<0$ and convex if $f^{\prime\prime}>0$.
In your case this gives $f^{\prime\prime}_1(x)=-14$, so $f_1$ is concave (so you were right, it is not convex). Furthermore, $f^{\prime\prime}(x)=14$ and so $f_2$ is convex.
