1. Hey!!

I want to draw the contour line of the function $\displaystyle{y=f(x_1, x_2)=-0,1x_1^2-0,4x_2^2}$ at $y=-2,5$ and at the point $(3,-2)$ I want to draw the gradient.

We have the following: \begin{equation*} y=-2,5 \Rightarrow -0,1x_1^2-0,4x_2^2=-2,5 \Rightarrow -10\cdot \left (-0,1x_1^2-0,4x_2^2\right )=-10\cdot \left (-2,5\right )\Rightarrow x_1^2+4x_2^2=25 \Rightarrow x_1^2=25-4x_2^2 \\ \Rightarrow x_1=\pm \sqrt{25-4x_2^2} \end{equation*}

So that the root is well-defined it must be \begin{align*}25-4x_2^2\geq 0 &\Rightarrow 5^2-(2x_2)^2\geq 0 \\ &\Rightarrow (5-2x_2)(5+2x_2)\geq 0 \\ &\Rightarrow \left (5-2x_2>0 \text{ and } 5+2x_2 >0 \right )\ \ \text{ or } \ \ \left (5-2x_2<0 \text{ and } 5+2x_2< 0 \right ) \\ &\Rightarrow \left (x_2<\frac{5}{2} \text{ and } x_2 >-\frac{5}{2}\right ) \ \ \text{ or } \ \ \left (x_2>\frac{5}{2} \text{ and } x_2<-\frac{5}{2}\right )\end{align*}
Since it cannot be that $\left (x_2>\frac{5}{2} \text{ and } x_2<-\frac{5}{2}\right )$ it must be $\left (x_2<\frac{5}{2} \text{ and } x_2 >-\frac{5}{2}\right )$.

We get the following table:

$\begin{matrix} x_2 & -2 & -1 & 0 & 1 & 2\\ x_1 & \pm 3 & \pm \sqrt{21} & \pm 5 & \pm \sqrt{21} & \pm 3 \end{matrix}$

So, the contour line is the following:

Is this correct?

We have that $f_{x_1}=-0,2x_1$ and $f_{x_2}=-0,8x_2$. So, the gradient is $\nabla f=\begin{pmatrix}-0,2x_1\\ -0,8x_2\end{pmatrix}$.

At the point $(3,-2)$ it is $\nabla f(3,-2)=\begin{pmatrix}-0,6\\ 1,6\end{pmatrix}$.

How can we draw it at the graph above?

2. Hi mathmari,

Your work looks correct to me, assuming $x_1$ is the vertical axis and $x_2$ is the horizontal axis. Alternatively, you could have recognized that $x_1^2+4x_2^2=25$ is an ellipses with major and minor axis of 5 and 2.5, respectively, to graph it directly.

To draw $(-0.6, 1.6)$, recall that the gradient of a function at a point is perpendicular to the contour lines at that point.

Originally Posted by Rido12
Your work looks correct to me, assuming $x_1$ is the vertical axis and $x_2$ is the horizontal axis. Alternatively, you could have recognized that $x_1^2+4x_2^2=25$ is an ellipses with major and minor axis of 5 and 2.5, respectively, to graph it directly.
So, it must be as follows, or not?

Originally Posted by Rido12
To draw $(-0.6, 1.6)$, recall that the gradient of a function at a point is perpendicular to the contour lines at that point.
This point isn't on the contour line. Is this correct?

4. Originally Posted by mathmari
So, it must be as follows, or not?
Yup, I agree with your answer. Your first plot was correct also -- it doesn't matter which axis you set as $x_1$ or $x_2$.

Originally Posted by mathmari
This point isn't on the contour line. Is this correct?
Well, the gradient is a vector. Since we are finding the gradient at a point, namely, $(3,-2)$, we would draw the vector starting from that point, rather than the origin.

Originally Posted by Rido12
Well, the gradient is a vector. Since we are finding the gradient at a point, namely, $(3,-2)$, we would draw the vector starting from that point, rather than the origin.
Ah ok!!

Is this correct?

6. Originally Posted by mathmari
Ah ok!!

Is this correct?
Good job!

For the function $\displaystyle{y=f(x_1, x_2)=4-x_1-\frac{1}{2}x_2}$ we want to draw the contour line $y=2$.

We have that \begin{equation*} y=2 \Rightarrow 4-x_1-\frac{1}{2}x_2=2 \Rightarrow \frac{1}{2}x_2=4-x_1-2 \Rightarrow \frac{1}{2}x_2=2-x_1 \Rightarrow x_2=4-2x_1\end{equation*}

So, the contour line is

We have that \begin{equation*}f_{x_1}(x_1, x_2)=\frac{\partial{f(x_1, x_2)}}{\partial{x_1}}=-1\end{equation*}
and \begin{equation*}f_{x_2}(x_1, x_2)=\frac{\partial{f(x_1, x_2)}}{\partial{x_2}}=-\frac{1}{2}\end{equation*}

Therefore, \begin{equation*}\nabla f=\begin{pmatrix}f_{x_1}\\ f_{x_2}\end{pmatrix}=\begin{pmatrix}-1\\ -\frac{1}{2}\end{pmatrix}\end{equation*}
and at the point $(1,2)$ we have that \begin{equation*}\nabla f(1,2)=\begin{pmatrix}f_{x_1}(1,2)\\ f_{x_2}(1,2)\end{pmatrix}=\begin{pmatrix}-1\ -\frac{1}{2}\end{pmatrix}\end{equation*}

The gradient at the graph is:

Is this correct?

8. Originally Posted by mathmari

Is this correct?
Perfect