NotebookDirectory[]

SetDirectory[NotebookDirectory[]]

Must know vector fields

“Exploding” vector field

VectorPlot[{x,y},
             {x, -6,  6}, {y, -6, 6}, 
VectorPoints->30,
	 Axes->True, Frame->True,
	PlotRange->{{-5,5},{-5,5}}]

Below is a modified version in which we specify a predefined scaling of vectors in a vector field.

VectorPlot[{x,y},
             {x, -6,  6}, {y, -6, 6}, 
	VectorPoints -> 35,
 VectorScale-> Medium, Axes->True, 
	PlotRange->{{-5,5},{-5,5}}]

VectorPlot[{-x,-y},
             {x, -6,  6}, {y, -6, 6}, 
	VectorPoints -> 25,
 VectorScale-> Medium, Axes->True, Frame->True,
		PlotRange->{{-5,5},{-5,5}}]

VectorPlot[{(x/(Sqrt[(x^2)+(y^2)])),(y/(Sqrt[(x^2)+(y^2)]))},
             {x, -6,  6}, {y, -6, 6}, 
	VectorPoints -> 30,
 VectorScale-> Small, Axes->True, Frame->True,
	PlotRange->{{-5,5},{-5,5}}]

VectorPlot[-{(x/(Sqrt[(x^2)+(y^2)])),(y/(Sqrt[(x^2)+(y^2)]))},
             {x, -6,  6}, {y, -6, 6}, 
	VectorPoints -> 30,
 VectorScale-> Small, Axes->True, Frame->True,
	PlotRange->{{-5,5},{-5,5}}]

VectorPlot[{(x/((x^2)+(y^2))),(y/((x^2)+(y^2)))},
             {x, -4,4}, {y, -4, 4}, 
	VectorPoints -> 40,
 VectorScale->Small, Axes->True, Frame->True,
	PlotRange->{{-3,3},{-3,3}}]

Sometimes it is quite challenging to get a vector field to show nicely. In the above plot the vectors close to the origin are very large in magnitude, much larger than how the apper. In the plot below I wanted to get a more realistic picture. However, the realistic picture you can produce only in your imagination.

VectorPlot[{(x/((x^2)+(y^2))),(y/((x^2)+(y^2)))},
             {x, -1,1}, {y, -1, 1}, 
	VectorPoints -> 40,
 VectorScale->{0.3,0.1,Automatic}, Axes->True, Frame->True,
	PlotRange->{{-1,1},{-1,1}}]

One component constant

VectorPlot[{x,0},
             {x, -6,  6}, {y, -6, 6}, 
	VectorPoints -> 20,
 VectorScale-> Small, Axes-> True, Frame->True,
	PlotRange->{{-5,5},{-5,5}}]

VectorPlot[{0,x},
             {x, -6,  6}, {y, -6, 6}, 
	VectorPoints -> 20,
 VectorScale-> Small, Axes-> True, Frame->True,
	PlotRange->{{-5,5},{-5,5}}]

VectorPlot[{0,y},
             {x, -6,  6}, {y, -6, 6}, 
	VectorPoints -> 20,
 VectorScale-> Small, Axes-> True, Frame->True,
	PlotRange->{{-5,5},{-5,5}}]

VectorPlot[{y,0},
             {x, -6,  6}, {y, -6, 6}, 
	VectorPoints -> 20,
 VectorScale-> Small, Axes-> True, Frame->True,
	PlotRange->{{-5,5},{-5,5}}]

VectorPlot[{x,1},
             {x, -6,  6}, {y, -6, 6}, 
	VectorPoints -> 20,
 VectorScale-> Medium, Axes-> True, Frame->True,
	PlotRange->{{-5,5},{-5,5}}]

VectorPlot[{1,x},
             {x, -6,  6}, {y, -6, 6}, 
	VectorPoints -> 20,
 VectorScale-> Medium, Axes-> True, Frame->True,
	PlotRange->{{-5,5},{-5,5}}]

Rotational vector field

VectorPlot[{-y,x},
             {x, -6,  6}, {y, -6, 6}, 
	VectorPoints -> 30,
 VectorScale-> Medium, Axes->True, Frame->True,
	PlotRange->{{-5,5},{-5,5}}]

VectorPlot[{((-y)/(Sqrt[x^2+y^2])),(x/(Sqrt[x^2+y^2]))},
             {x, -6,  6}, {y, -6, 6}, 
	VectorPoints -> 32,
 VectorScale-> Small, Axes->True, Frame->True,
	PlotRange->{{-5,5},{-5,5}}]

VectorPlot[{y,-x},
             {x, -6,  6}, {y, -6, 6}, 
	VectorPoints -> 30,
 VectorScale-> Medium, Axes->True, Frame->True,
	PlotRange->{{-5,5},{-5,5}}]

Hyperbolic vector field

VectorPlot[{y,x},
             {x, -6,  6}, {y, -6, 6}, 
	VectorPoints -> 30,
 VectorScale-> Medium, Axes->True, Frame->True,
	PlotRange->{{-5,5},{-5,5}}]

Hyperbolic vector field 2

VectorPlot[{x,-y},
             {x, -6,  6}, {y, -6, 6}, 
	VectorPoints -> 30,
 VectorScale-> Medium, Axes->True, Frame->True,
	PlotRange->{{-5,5},{-5,5}}]

More vector fields

VectorPlot[{Sin[y],Sin[x]},
             {x, -2π, 2 π}, {y, -2π, 2π}, 
	VectorPoints -> 42,
 VectorScale-> Small, Axes->True, Frame->True,
	PlotRange->{{-5,5},{-5,5}}]

VectorPlot[{x +y,x-y},
             {x, -2, 2 }, {y, -2, 2}, 
	VectorPoints -> 32,
 VectorScale-> Medium, Axes-> True, Frame->True,
	PlotRange-> {{-2,2},{-2,2}}]

Must know vector fields with flow lines

Exploding vector field

VectorPlot[{x,y},
             {x, -6,  6}, {y, -6, 6}, 
	VectorPoints -> 35,VectorScale-> Medium,
StreamPoints-> 30,StreamStyle->Red,
  Axes->True, PlotRange->{{-5,5},{-5,5}}]

To find the exact formulas for flow lines we need to solve two differential equations

DSolve[{x'[t]==x[t],y'[t]==y[t],x[0]==x0,y[0]==y0},{x[t],y[t]},t][[1]]

VectorPlot[{-x,-y},
             {x, -6,  6}, {y, -6, 6}, 
	VectorPoints -> 25,
 VectorScale-> Medium, 
StreamPoints->30,StreamStyle->Orange,
Axes->True, Frame->True,
		PlotRange->{{-5,5},{-5,5}}]

To find the exact formulas for flow lines we need to solve two differential equations

DSolve[{x'[t]==-x[t],y'[t]==-y[t],x[0]==x0,y[0]==y0},{x[t],y[t]},t][[1]]

{x[t],y[t]}/.DSolve[{x'[t]==-x[t],y'[t]==-y[t],x[0]==x0,y[0]==y0},{x[t],y[t]},t][[1]]

VectorPlot[{(x/(Sqrt[(x^2)+(y^2)])),(y/(Sqrt[(x^2)+(y^2)]))},
             {x, -6,  6}, {y, -6, 6}, 
	VectorPoints -> 30,
 VectorScale-> Small, 
StreamPoints->35,StreamStyle->Orange,
Axes->True, Frame->True,
	PlotRange->{{-5,5},{-5,5}}]

To find the exact formulas for flow lines we need to solve a system of two differential equations

FullSimplify[DSolve[{x'[t]==((x[t])/(Sqrt[((x[t])^2)+((y[t])^2)])),y'[t]==((y[t])/(Sqrt[((x[t])^2)+((y[t])^2)])),x[0]==x0,y[0]==y0},{x[t],y[t]},t][[1]]]

In fact this solution is wrong.  We can see that this solution is wrong by substituting x0 = 1, y0 =1

{y[t]->y0-((t y0)/(x0 (Sqrt[1+((y0^2)/(x0^2))]))),x[t]->x0-(t/(Sqrt[1+((y0^2)/(x0^2))]))}/.{x0-> 1,y0-> 1}

For t = 0 we get the point (1,1), but with increasing t the point moves towards the origin not away from the origin.

Interestingly, based on Mathematica solution we can guess the correct solution. It is

{y[t]->y0(1+(t/(Sqrt[(x0^2)+(y0^2)]))),x[t]->x0(1+(t/(Sqrt[(x0^2)+(y0^2)])))}

and this solution is valid for all  t>-(Sqrt[(x0^2)+(y0^2)]).  To prove that this is the correct solution, I take the derivative

D[x0(1+(t/(Sqrt[(x0^2)+(y0^2)]))),t]

FullSimplify[((x0(1+(t/(Sqrt[(x0^2)+(y0^2)]))))/(Sqrt[(((x0(1+(t/(Sqrt[(x0^2)+(y0^2)])))))^2)+(((y0(1+(t/(Sqrt[(x0^2)+(y0^2)])))))^2)]))]

Mathematica does not simplify this fully. Notice that (t^2)+(x0^2)+(y0^2)+2 t (Sqrt[(x0^2)+(y0^2)])= (((t+(Sqrt[(x0^2)+(y0^2)])))^2) and thus (Sqrt[(t^2)+(x0^2)+(y0^2)+2 t (Sqrt[(x0^2)+(y0^2)])]) =t+(Sqrt[(x0^2)+(y0^2)]) , since t+(Sqrt[(x0^2)+(y0^2)]) > 0.

This proves that x[t] satisfies the given differential equation. Similarly y[t] satisfies the given differential equation.

VectorPlot[{(x/((x^2)+(y^2))),(y/((x^2)+(y^2)))},
             {x, -6,  6}, {y, -6, 6}, 
	VectorPoints -> 30, VectorScale-> Small, 
StreamPoints->35,StreamStyle->Orange,
Axes->True, Frame->True,
	PlotRange->{{-5,5},{-5,5}}]

FullSimplify[DSolve[{x'[t]==((x[t])/(((x[t])^2)+((y[t])^2))),y'[t]==((y[t])/(((x[t])^2)+((y[t])^2))),x[0]==x0,y[0]==y0},{x[t],y[t]},t][[1]]]

Again, this is wrong.

FullSimplify[{y[t]->-((y0 (Sqrt[2 t+(x0^2)+(y0^2)]))/(x0 (Sqrt[1+((y0^2)/(x0^2))]))),x[t]->-((Sqrt[2 t+(x0^2)+(y0^2)])/(Sqrt[1+((y0^2)/(x0^2))]))}/.{x0->1,y0->1}]

This is wrong since with increasing t the point moves towards the origin, not away from it. As before, we can guess the correct solution

{y[t]->((y0 (Sqrt[2 t+(x0^2)+(y0^2)]))/(Sqrt[(x0^2)+(y0^2)])),x[t]->((x0(Sqrt[2 t+(x0^2)+(y0^2)]))/(Sqrt[(x0^2)+(y0^2)]))}

which is defined for t>((x0^2)+(y0^2))/2.  Now prove it:

FullSimplify[D[((x0 (Sqrt[2 t+(x0^2)+(y0^2)]))/(Sqrt[(x0^2)+(y0^2)])),t]]

FullSimplify[((x0((Sqrt[2 t+(x0^2)+(y0^2)])/(Sqrt[(x0^2)+(y0^2)])))/((((x0((Sqrt[2 t+(x0^2)+(y0^2)])/(Sqrt[(x0^2)+(y0^2)]))))^2)+(((y0((Sqrt[2 t+(x0^2)+(y0^2)])/(Sqrt[(x0^2)+(y0^2)]))))^2)))]

Since the last two expressions are identical, we have the solution.

One component constant

VectorPlot[{x,0},
             {x, -6,  6}, {y, -6, 6}, 
	VectorPoints -> 20,
 VectorScale-> Small, 
StreamPoints-> 25,StreamStyle->Orange,
Axes-> True, Frame->True,
	PlotRange->{{-5,5},{-5,5}}]

To find the exact formulas for flow lines we need to solve the differential equations (this is easily done by hand as well)

DSolve[{x'[t]==x[t],y'[t]==0,x[0]==x0,y[0]==y0},{x[t],y[t]},t][[1]]

VectorPlot[{0,x},
             {x, -6,  6}, {y, -6, 6}, 
	VectorPoints -> 20,
 VectorScale-> Small,
StreamPoints-> 25,StreamStyle->Orange,
 Axes-> True, Frame->True,
	PlotRange->{{-5,5},{-5,5}}]

DSolve[{x'[t]==0,y'[t]==x[t],x[0]==x0,y[0]==y0},{x[t],y[t]},t][[1]]

VectorPlot[{0,y},
             {x, -6,  6}, {y, -6, 6}, 
	VectorPoints -> 20,
 VectorScale-> Small, 
StreamPoints-> 25,StreamStyle->Orange,
Axes-> True, Frame->True,
	PlotRange->{{-5,5},{-5,5}}]

DSolve[{x'[t]==0,y'[t]==y[t],x[0]==x0,y[0]==y0},{x[t],y[t]},t][[1]]

VectorPlot[{y,0},
             {x, -6,  6}, {y, -6, 6}, 
	VectorPoints -> 20,
 VectorScale-> Small, 
StreamPoints-> 25,StreamStyle->Orange,
Axes-> True, Frame->True,
	PlotRange->{{-5,5},{-5,5}}]

{x[t],y[t]}/.DSolve[{x'[t]==y[t],y'[t]==0,x[0]==x0,y[0]==y0},{x[t],y[t]},t][[1]]

VectorPlot[{x,1},
             {x, -6,  6}, {y, -6, 6}, 
	VectorPoints -> 20,
 VectorScale-> Medium,
StreamPoints-> 25,StreamStyle->Orange,
 Axes-> True, Frame->True,
	PlotRange->{{-5,5},{-5,5}}]

DSolve[{x'[t]==x[t],y'[t]==1,x[0]==x0,y[0]==y0},{x[t],y[t]},t][[1]]

VectorPlot[{1,x},
             {x, -6,  6}, {y, -6, 6}, 
	VectorPoints -> 20,
 VectorScale-> Small,
StreamPoints-> 25,StreamStyle->Orange,
 Axes-> True, Frame->True,
	PlotRange->{{-5,5},{-5,5}}]

DSolve[{x'[t]==1,y'[t]==x[t],x[0]==x0,y[0]==y0},{x[t],y[t]},t][[1]]

Rotational vector field

VectorPlot[{-y,x},
             {x, -6,  6}, {y, -6, 6}, 
	VectorPoints -> 30,
 VectorScale-> Medium,
StreamPoints-> 25,StreamStyle->Orange,
 Axes->True, Frame->True,
	PlotRange->{{-5,5},{-5,5}}]

DSolve[{x'[t]==-y[t],y'[t]==x[t],x[0]==x0,y[0]==y0},{x[t],y[t]},t][[1]]

DSolve[{x'[t]==-y[t],y'[t]==x[t],x[0]==1,y[0]==0},{x[t],y[t]},t][[1]]

DSolve[{x'[t]==-y[t],y'[t]==x[t],x[0]==0,y[0]==1},{x[t],y[t]},t][[1]]

VectorPlot[{((-y)/(Sqrt[x^2+y^2])),(x/(Sqrt[x^2+y^2]))},
             {x, -6,  6}, {y, -6, 6}, 
	VectorPoints -> 32,
 VectorScale-> Small,
StreamPoints-> 25,StreamStyle->{Orange,Thickness[0.007]},
 Axes->True, Frame->True,
	PlotRange->{{-5,5},{-5,5}}]

FullSimplify[DSolve[{x'[t]==-((y[t])/(Sqrt[((x[t])^2)+((y[t])^2)])),y'[t]==((x[t])/(Sqrt[((x[t])^2)+((y[t])^2)])),x[0]==x0,y[0]==y0},{x[t],y[t]},t][[1]]]

Testing

FullSimplify[{y[t]->(Sqrt[((x0^2)+(y0^2)) ((Cos[(t/(Sqrt[(x0^2)+(y0^2)]))+ArcTan[(x0/y0)]])^2)]),x[t]->(((Sqrt[(x0^2)+(y0^2)]) Tan[(t/(Sqrt[(x0^2)+(y0^2)]))+ArcTan[(x0/y0)]])/(Sqrt[((Sec[(t/(Sqrt[(x0^2)+(y0^2)]))+ArcTan[(x0/y0)]])^2)]))}/.{x0->0,y0->1}]

Clearly these formulas have problems. However they are valid for  t∈[0,π/2). Can you guess the formulas for the correct solution?

VectorPlot[{y,-x},
             {x, -6,  6}, {y, -6, 6}, 
	VectorPoints -> 30,
 VectorScale-> Medium,
StreamPoints-> 25,StreamStyle->Orange,
 Axes->True, Frame->True,
	PlotRange->{{-5,5},{-5,5}}]

FullSimplify[DSolve[{x'[t]==y[t],y'[t]==-x[t],x[0]==x0,y[0]==y0},{x[t],y[t]},t][[1]]]

FullSimplify[DSolve[{x'[t]==y[t],y'[t]==-x[t],x[0]==1,y[0]==0},{x[t],y[t]},t][[1]]]

Hyperbolic vector field

VectorPlot[{y,x},
             {x, -6,  6}, {y, -6, 6}, 
	VectorPoints -> 30,
 VectorScale-> Medium, 
StreamPoints-> 25,StreamStyle->Orange,
Axes->True, Frame->True,
	PlotRange->{{-5,5},{-5,5}}]

FullSimplify[DSolve[{x'[t]==y[t],y'[t]==x[t],x[0]==x0,y[0]==y0},{x[t],y[t]},t][[1]]]

FullSimplify[DSolve[{x'[t]==y[t],y'[t]==x[t],x[0]==1,y[0]==0},{x[t],y[t]},t][[1]]]

FullSimplify[DSolve[{x'[t]==cc,y'[t]==x[t],x[0]==x0,y[0]==y0},{x[t],y[t]},t][[1]]]

FullSimplify[DSolve[{x'[t]==cc,y'[t]==y[t],x[0]==x0,y[0]==y0},{x[t],y[t]},t][[1]]]

FullSimplify[DSolve[{x'[t]==x[t],y'[t]==cc,x[0]==x0,y[0]==y0},{x[t],y[t]},t][[1]]]

FullSimplify[DSolve[{x'[t]==x[t],y'[t]==cc,x[0]==x0,y[0]==y0},{x[t],y[t]},t][[1]]]

FullSimplify[DSolve[{x'[t]==y[t],y'[t]==cc,x[0]==x0,y[0]==y0},{x[t],y[t]},t][[1]]]

?VectorScale