MHB How do I draw the contour line and gradient of a function at a specific point?

  • Thread starter Thread starter mathmari
  • Start date Start date
  • Tags Tags
    Gradient Line
Click For Summary
To draw the contour line of the function y=f(x1, x2)=-0.1x1^2-0.4x2^2 at y=-2.5, the equation simplifies to x1^2 + 4x2^2 = 25, representing an ellipse. The gradient of the function at the point (3,-2) is calculated as ∇f(3,-2) = (-0.6, 1.6), which is perpendicular to the contour lines. The discussion confirms that the contour line and gradient are correctly derived and emphasizes that the gradient vector should be drawn starting from the point (3,-2). Overall, the calculations and graphical representations discussed are validated as accurate.
mathmari
Gold Member
MHB
Messages
4,984
Reaction score
7
Hey! :o

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:
[desmos="-10,10,-10,10"]\sqrt{25-4x^2};-\sqrt{25-4x^2};[/desmos]

Is this correct? (Wondering) 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? (Wondering)
 
Physics news on Phys.org
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.
 
Last edited:
Rido12 said:
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? (Wondering) [desmos="-10,10,-10,10"]x=\sqrt{25-y^2};x=-\sqrt{25-y^2};\left(-0.6,\space1.6\right);[/desmos]
Rido12 said:
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? (Wondering)
 
mathmari said:
So, it must be as follows, or not? (Wondering)

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$.

mathmari said:
This point isn't on the contour line. Is this correct? (Wondering)

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.
 
Rido12 said:
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!

[desmos="-5,5,-5,5"]x=\sqrt{25-4y^2};x=-\sqrt{25-4y^2};\left(3,-2\right);\left(3-0.6t,\space-2+1.6t\right);[/desmos]Is this correct? (Wondering)
 
mathmari said:
Ah ok!

Is this correct? (Wondering)

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
[desmos="-8,8,-5.5,5.5"]4-2x;[/desmos]

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:
[desmos="-8,8,-5.5,5.5"]4-2x;\left(1-t,\space2-\frac{t}{2}\right);[/desmos]

Is this correct? (Wondering)
 
mathmari said:
Is this correct? (Wondering)

Perfect :)
 
Great! Thank you very much! (Happy)
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 34 ·
2
Replies
34
Views
2K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 7 ·
Replies
7
Views
1K
  • · Replies 15 ·
Replies
15
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 52 ·
2
Replies
52
Views
4K
  • · Replies 7 ·
Replies
7
Views
2K