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

In summary, we discussed how to draw the contour line and gradient for a function with two variables. The contour line is the set of points that satisfy the equation $y=f(x_1,x_2)$, and the gradient is the vector of partial derivatives of the function at a given point. We also saw how to graph the gradient at a given point on the contour line.
  • #1
mathmari
Gold Member
MHB
5,049
7
Hey! :eek:

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
  • #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.
 
Last edited:
  • #3
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)
 
  • #4
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.
 
  • #5
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)
 
  • #6
mathmari said:
Ah ok!

Is this correct? (Wondering)

Good job! :)
 
  • #7
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)
 
  • #8
mathmari said:
Is this correct? (Wondering)

Perfect :)
 
  • #9
Great! Thank you very much! (Happy)
 

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

What is a contour line?

A contour line is a line on a map or chart that connects points of equal elevation. It represents a horizontal cross-section of the terrain or surface being mapped.

How are contour lines used in topographic maps?

Contour lines are used in topographic maps to show the shape and elevation of the land. By analyzing the spacing and shape of the contour lines, one can determine the steepness of the terrain, the presence of valleys and ridges, and the overall topography of the area.

What is the significance of contour intervals?

Contour intervals are the vertical distance between each contour line on a map. They are used to show the change in elevation between each line. The smaller the contour interval, the steeper the terrain, while a larger interval indicates a more gradual slope.

How is gradient calculated using contour lines?

Gradient, also known as slope, is calculated by dividing the change in elevation between two points by the horizontal distance between those points. This can be determined by using two contour lines and their corresponding elevations.

Can contour lines be used to determine the direction of water flow?

Yes, contour lines can be used to determine the direction of water flow on a map. Water will always flow perpendicular to contour lines, meaning it will flow from higher elevations to lower elevations. By analyzing the shape and direction of the contour lines, one can determine the direction of water flow in a particular area.

Similar threads

Replies
2
Views
1K
Replies
34
Views
2K
Replies
2
Views
1K
Replies
2
Views
874
Replies
7
Views
1K
Replies
15
Views
1K
Replies
3
Views
2K
Replies
52
Views
3K
Replies
7
Views
2K
Back
Top