banner



how to draw a vector field

Vector field plots are linked to differential equations. When we solve a differential equation, we don't get a particular (unique) solution, we get a full general solution, which is basically a family unit of particular solutions.

For an easier understanding let'south jump straight to an example. Suppose nosotros take the differential equation:

\[\frac{dy}{dx}=x\]

This is aseparable get-go order differential equation, because we can write it with all the y's on one side of the equal sign, and all the x's on the other side, similar this:

\[dy=x \cdot dx\]

With other words, we have separated the y's from the x's. We solve it by integrating both sides of the equation:

\[\int dy = \int ten \cdot dx\]

The solution is straightforward:

\[y = \frac{ten^2}{2}+C\]

where C is a constant.

Discover that the solution in not unique (detail) just full general, because the constant C can take whatsoever value (real number). This ways that our differential equation can have as many solutions equally possible values of the constant C.

Using vector field plots we can see the representation of all the solutions of a linear differential equation between fixed boundaries.

Vector field plot for the differential equation dy/dx = y + x

Image: Vector field plot for the differential equation dy/dx = y + x

In the image above we tin run into the vector field plot for the differential equation:

\[\frac{dy}{dx}=y+x\]

The small-scale blue arrows (vectors) indicate the tendency (shape) of the solutions of the differential equation between the boundaries of the plot. The red line represents a detail solution of the differential equation.

By cartoon the vector field plot nosotros will know, before solving the differential equation, how the solution will look like in terms of the shape of the curve.

The question is: how practise we describe the vector field plot having only the differential equation?

Nosotros will utilise the same differential equation, which we solved previously, as instance:

\[\frac{dy}{dx}=x\]

First we need to think that nosotros tin define the equation of a line y = f(ten) having 1 point (x0 , y0 ) and the slope m:

\[y-y_0 = 1000 \cdot (x – x_0)\]

For small-scale values of ten, the slope yard is the derivative of the function:

\[m=\frac{dy}{dx}\]

Past replacing the equation of the slope in the line equation, we get:

\[y-y_0 =\frac{dy}{dx} \cdot (x – x_0)\]

All the vectors in the field plot are small lines divers by the equation in a higher place for different values of the start point (x0 , y0 ) and slope dy/dx .

In the table below nosotros are going to calculate the points which define the vectors.

Pace 1. Choose the value of ten0 .

Step two. Choose the value of y0 .

Step three. The value of the slope is equal with the value of the differential equation. In our case, the differential equation is equal toten, so the value of the gradient is the same equally the value of the point x0 .

\[m = \frac{dy}{dx} = 10 = x_0\]

Step 4. We choose the point x1  equal to the betoken x0 plus an offset (0.iii).

\[x_1 = x_0 + 0.3\]

Step 5. Summate the value of the point y1 using the equation of the line:

\[y_1 = g(x_1-x_0)+y_0\]

Step 6. Draw line between (ten0 , y0 ) and (10i , yone )

All the higher up steps are summarized in the table below.

Step 1 2 3 4 v half-dozen
Vector x0 y0 thousand 10i yone Draw line
1 -v 2 -five -four.seven 0.6
2 -4 2 -4 -three.7 0.8
3 -3 2 -iii -2.7 i.ane
4 -ii 2 -2 -1.7 1.4
five -1 2 -ane -0.7 one.7
6 0 2 0 0.3 two
7 1 ii 1 i.3 2.3
8 2 2 2 2.3 two.6
nine 3 2 3 3.three 2.nine
10 iv 2 four 4.three 3.2
eleven 5 2 5 5.3 3.five

After we calculate all the finish points (xane , y1 ), we tin draw each vector line:

Vector field plot - manual drawing

Image: Vector field plot – manual cartoon

The process can be repeated for different values of y.

In social club to brand the calculations faster we can apply the Scilab script below:

// Articulate Scilab console and all variables clc clear  // Define differential function deff('f=dydx(x,y)','f=10');  // Define variable range xmin = -five; xmax = 5; x=xmin:xmax; ymin = -five; ymax = five; y=ymin:ymax;  // Graphic window setup figure(0); hf=gcf(); hf.axes_size = [480,480]; hf.background = 8; ha=gca(); ha.grid=[33,33];  // Vector field plot for i=i:length(x)    for j=1:length(y)       grand = dydx(10(i),y(j));       get-go=0.3;       xl = x(i)+beginning;        yl = thou*(xl-x(i))+y(j);       plot([x(i) forty],[y(j) yl]);    end end  // Rescale the axes of the figure ha.data_bounds = [xmin-1 ymin-1;xmax+1 ymax+i];

The differential equation is divers as a function, using the embedded Scilab part deff(). After running the script, we get the vector field plot for the specified x and y boundaries.

Vector field plot for the differential equation dy/dx = x

Image: Vector field plot for the differential equation dy/dx = x

To check our statement, that the vector field plot of a differential equation is the family of all particular solutions within specified boundaries, nosotros are going to plot on the same figure the line plot of the general solution y(x) for C = -2, -1, 0, 1, 2.

\[y(x) = \frac{x^2}{2}+C\]

Vector field plot for the differential equation dy/dx = x and particular solutions (C = -2, -1, 0, 1, 2)

Image: Vector field plot for the differential equation dy/dx = x and detail solutions (C = -ii, -ane, 0, i, 2)

As you tin meet, each of the curves for the particular solutions follow the direction of the vector field.

In order to cheque if our Scilab script is generating the correct vector field plot, we are going to utilize it for two more differential equations, which have a divers vector field plot.

\[\frac{dy}{dx}=y+x\]

The vector field plot of this differential equation can be institute here.

Change the function definition in the Scilab script:

deff('f=dydx(ten,y)','f=y+ten');

and run the script.

On the left image is the vector field plot specified at the source in a higher place, on the right side, we have the vector field plot generated by the Scilab script.

Vector field plot for the differential equation dy/dx = y + x

Image: Vector field plot for the differential equation dy/dx = y + x

Vector field plot for the differential equation dy/dx = y + x

Image: Scilab vector field plot for the differential equation dy/dx = y + 10

As you can see, the direction of the vector field are the same in both plots.

Repeat the steps above for the office:

\[\frac{dy}{dx}=y-x\]

The vector field plot of this differential equation can be institute here.

Vector field plot for the differential equation dy/dx = y - x

Paradigm: Vector field plot for the differential equation dy/dx = y – ten

Vector field plot for the differential equation dy/dx = y - x

Image: Scilab vector field plot for the differential equation dy/dx = y – x

Again, the Scilab script is generation the aforementioned vector field plot.

Use the script to generate vector field plots for different differential equations. Then solve the equations and meet if the line plot for a detail solution is matching the direction of the vector field.

For whatever questions, observations and queries regarding Scilab variables use the comment grade beneath.

Don't forget to Similar, Share and Subscribe!

Source: https://x-engineer.org/plot-vector-field/

Posted by: whitethetting.blogspot.com

0 Response to "how to draw a vector field"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel