Phase Plane Plot using pst-odeHow to expand TeX's “main memory size”? (pgfplots memory...
Practical reasons to have both a large police force and bounty hunting network?
Should I use HTTPS on a domain that will only be used for redirection?
Is there a way to find out the age of climbing ropes?
Does running dd if=/dev/zero often can damage the drive?
How did the Luna spacecraft collect samples of the moon and containerize them for return to Earth?
The past tense for the quoting particle って
Why are special aircraft used for the carriers in the United States Navy?
What is the purpose of a disclaimer like "this is not legal advice"?
Can inspiration allow the Rogue to make a Sneak Attack?
Was it really inappropriate to write a pull request for the company I interviewed with?
What is the oldest European royal house?
First time traveler, what plane ticket?
Why would /etc/passwd be used every time someone executes `ls -l` command?
3.5% Interest Student Loan or use all of my savings on Tuition?
Is it a Cyclops number? "Nobody" knows!
Did Amazon pay $0 in taxes last year?
How can I be pwned if I'm not registered on the compromised site?
Is divide-by-zero a security vulnerability?
Why can't we use freedom of speech and expression to incite people to rebel against government in India?
Is "cogitate" an appropriate word for this?
How to write a chaotic neutral protagonist and prevent my readers from thinking they are evil?
How did Haman know Moshe Rabeinu's Yahrzeit but not his Birthday?
An Undercover Army
What's the best tool for cutting holes into duct work?
Phase Plane Plot using pst-ode
How to expand TeX's “main memory size”? (pgfplots memory overload)Differential Equation direction plot with pgfplotsHow to do mathematical programming in LaTeX?Phase plane diagrams in latexWrong x-axis with pst-plotRedefining axes label in pst-plotpst-plot: x-y-data from different filesHow do I ignore lines to points with y=0 using pst-plot and a logarithmic y-scale?A little problem with pst-plotpst-plot graph offset on page when graph has non-zero originpst-plot and psgraph environment to smallpst-plot: overfull hbox when using psaxespst-ode, magnetic induction lineCalculating data inside pst-plot/postscript and conditionally coloring the plot
I am trying to incorporate the solution to the nonlinear differential equations
x' = x + y + x^2 + y^2
y' = x - y - x^2 + y^2
The solution to these nonlinear differential equations were found with a saddle point at (0,0) and an equilibrium point at (-1, -1). The equation was solved using Matlab and produced this result:
I have been trying to plot some of the lines and simplified the plot to produce these points with
x0=[-2.5,-1.5,-1, -0.5]; and
y0=-2.5.
This is the result:
I am trying to elegantly plot this and came across pst-ode
. I attempted to get a plot to match but so far have failed miserably! I followed the code given here: Differential Equation direction plot with pgfplots but still no luck. Can you help me get the correct plot to match the original plot showing the lines.
I'm uncertain how to incorporate the second differential equation to come up with the correct plot. Thanks for your help!
Here is my attempt this far:
documentclass[border=10pt]{standalone}
usepackage{pst-plot,pst-ode}
begin{document}
psset{unit=3}
begin{pspicture}(-1.2,-1.2)(1.1,1.1)
psaxes[ticksize=0 4pt,axesstyle=frame,tickstyle=inner,subticks=20,
Ox=-2.5,Oy=-2.5](-1,-1)(1,1)
psset{arrows=->,algebraic}
psVectorfield[linecolor=black!60](-0.9,-0.9)(0.9,0.9){ x + y + x^2 + y^2 }
%y0_a=-2.5
pstODEsolve[algebraicOutputFormat]{y0_a}{t | x[0]}{-1}{1}{100}{-2.5}{t + x[0] + t^2 + x[0]^2}
%y0_b=-1.5
pstODEsolve[algebraicOutputFormat]{y0_b}{t | x[0]}{-1}{1}{100}{-1.5}{t + x[0] + t^2 + x[0]^2}
%y0_c=-1
pstODEsolve[algebraicOutputFormat]{y0_c}{t | x[0]}{-1}{1}{100}{-1}{t + x[0] + t^2 + x[0]^2}
%y0_c=-0.5
pstODEsolve[algebraicOutputFormat]{y0_d}{t | x[0]}{-1}{1}{100}{-0.5}{t + x[0] + t^2 + x[0]^2}
psset{arrows=-,linewidth=1pt}%
listplot[linecolor=red ]{y0_a}
listplot[linecolor=green]{y0_b}
listplot[linecolor=blue ]{y0_c}
listplot[linecolor=blue ]{y0_d}
end{pspicture}
end{document}
pgfplots pstricks pst-plot
add a comment |
I am trying to incorporate the solution to the nonlinear differential equations
x' = x + y + x^2 + y^2
y' = x - y - x^2 + y^2
The solution to these nonlinear differential equations were found with a saddle point at (0,0) and an equilibrium point at (-1, -1). The equation was solved using Matlab and produced this result:
I have been trying to plot some of the lines and simplified the plot to produce these points with
x0=[-2.5,-1.5,-1, -0.5]; and
y0=-2.5.
This is the result:
I am trying to elegantly plot this and came across pst-ode
. I attempted to get a plot to match but so far have failed miserably! I followed the code given here: Differential Equation direction plot with pgfplots but still no luck. Can you help me get the correct plot to match the original plot showing the lines.
I'm uncertain how to incorporate the second differential equation to come up with the correct plot. Thanks for your help!
Here is my attempt this far:
documentclass[border=10pt]{standalone}
usepackage{pst-plot,pst-ode}
begin{document}
psset{unit=3}
begin{pspicture}(-1.2,-1.2)(1.1,1.1)
psaxes[ticksize=0 4pt,axesstyle=frame,tickstyle=inner,subticks=20,
Ox=-2.5,Oy=-2.5](-1,-1)(1,1)
psset{arrows=->,algebraic}
psVectorfield[linecolor=black!60](-0.9,-0.9)(0.9,0.9){ x + y + x^2 + y^2 }
%y0_a=-2.5
pstODEsolve[algebraicOutputFormat]{y0_a}{t | x[0]}{-1}{1}{100}{-2.5}{t + x[0] + t^2 + x[0]^2}
%y0_b=-1.5
pstODEsolve[algebraicOutputFormat]{y0_b}{t | x[0]}{-1}{1}{100}{-1.5}{t + x[0] + t^2 + x[0]^2}
%y0_c=-1
pstODEsolve[algebraicOutputFormat]{y0_c}{t | x[0]}{-1}{1}{100}{-1}{t + x[0] + t^2 + x[0]^2}
%y0_c=-0.5
pstODEsolve[algebraicOutputFormat]{y0_d}{t | x[0]}{-1}{1}{100}{-0.5}{t + x[0] + t^2 + x[0]^2}
psset{arrows=-,linewidth=1pt}%
listplot[linecolor=red ]{y0_a}
listplot[linecolor=green]{y0_b}
listplot[linecolor=blue ]{y0_c}
listplot[linecolor=blue ]{y0_d}
end{pspicture}
end{document}
pgfplots pstricks pst-plot
You mean you triedquiver
from pgfplots? Can you show us a/the failing code?
– Symbol 1
Jun 8 '17 at 2:48
I did not tryquiver
. I made my first attempt here withpst-ode
. Am I going down the wrong path?
– Joe
Jun 8 '17 at 2:53
Probably the right path. PS can do more computations than PGF. But I am not familiar with the magical PStricks family.
– Symbol 1
Jun 8 '17 at 3:00
add a comment |
I am trying to incorporate the solution to the nonlinear differential equations
x' = x + y + x^2 + y^2
y' = x - y - x^2 + y^2
The solution to these nonlinear differential equations were found with a saddle point at (0,0) and an equilibrium point at (-1, -1). The equation was solved using Matlab and produced this result:
I have been trying to plot some of the lines and simplified the plot to produce these points with
x0=[-2.5,-1.5,-1, -0.5]; and
y0=-2.5.
This is the result:
I am trying to elegantly plot this and came across pst-ode
. I attempted to get a plot to match but so far have failed miserably! I followed the code given here: Differential Equation direction plot with pgfplots but still no luck. Can you help me get the correct plot to match the original plot showing the lines.
I'm uncertain how to incorporate the second differential equation to come up with the correct plot. Thanks for your help!
Here is my attempt this far:
documentclass[border=10pt]{standalone}
usepackage{pst-plot,pst-ode}
begin{document}
psset{unit=3}
begin{pspicture}(-1.2,-1.2)(1.1,1.1)
psaxes[ticksize=0 4pt,axesstyle=frame,tickstyle=inner,subticks=20,
Ox=-2.5,Oy=-2.5](-1,-1)(1,1)
psset{arrows=->,algebraic}
psVectorfield[linecolor=black!60](-0.9,-0.9)(0.9,0.9){ x + y + x^2 + y^2 }
%y0_a=-2.5
pstODEsolve[algebraicOutputFormat]{y0_a}{t | x[0]}{-1}{1}{100}{-2.5}{t + x[0] + t^2 + x[0]^2}
%y0_b=-1.5
pstODEsolve[algebraicOutputFormat]{y0_b}{t | x[0]}{-1}{1}{100}{-1.5}{t + x[0] + t^2 + x[0]^2}
%y0_c=-1
pstODEsolve[algebraicOutputFormat]{y0_c}{t | x[0]}{-1}{1}{100}{-1}{t + x[0] + t^2 + x[0]^2}
%y0_c=-0.5
pstODEsolve[algebraicOutputFormat]{y0_d}{t | x[0]}{-1}{1}{100}{-0.5}{t + x[0] + t^2 + x[0]^2}
psset{arrows=-,linewidth=1pt}%
listplot[linecolor=red ]{y0_a}
listplot[linecolor=green]{y0_b}
listplot[linecolor=blue ]{y0_c}
listplot[linecolor=blue ]{y0_d}
end{pspicture}
end{document}
pgfplots pstricks pst-plot
I am trying to incorporate the solution to the nonlinear differential equations
x' = x + y + x^2 + y^2
y' = x - y - x^2 + y^2
The solution to these nonlinear differential equations were found with a saddle point at (0,0) and an equilibrium point at (-1, -1). The equation was solved using Matlab and produced this result:
I have been trying to plot some of the lines and simplified the plot to produce these points with
x0=[-2.5,-1.5,-1, -0.5]; and
y0=-2.5.
This is the result:
I am trying to elegantly plot this and came across pst-ode
. I attempted to get a plot to match but so far have failed miserably! I followed the code given here: Differential Equation direction plot with pgfplots but still no luck. Can you help me get the correct plot to match the original plot showing the lines.
I'm uncertain how to incorporate the second differential equation to come up with the correct plot. Thanks for your help!
Here is my attempt this far:
documentclass[border=10pt]{standalone}
usepackage{pst-plot,pst-ode}
begin{document}
psset{unit=3}
begin{pspicture}(-1.2,-1.2)(1.1,1.1)
psaxes[ticksize=0 4pt,axesstyle=frame,tickstyle=inner,subticks=20,
Ox=-2.5,Oy=-2.5](-1,-1)(1,1)
psset{arrows=->,algebraic}
psVectorfield[linecolor=black!60](-0.9,-0.9)(0.9,0.9){ x + y + x^2 + y^2 }
%y0_a=-2.5
pstODEsolve[algebraicOutputFormat]{y0_a}{t | x[0]}{-1}{1}{100}{-2.5}{t + x[0] + t^2 + x[0]^2}
%y0_b=-1.5
pstODEsolve[algebraicOutputFormat]{y0_b}{t | x[0]}{-1}{1}{100}{-1.5}{t + x[0] + t^2 + x[0]^2}
%y0_c=-1
pstODEsolve[algebraicOutputFormat]{y0_c}{t | x[0]}{-1}{1}{100}{-1}{t + x[0] + t^2 + x[0]^2}
%y0_c=-0.5
pstODEsolve[algebraicOutputFormat]{y0_d}{t | x[0]}{-1}{1}{100}{-0.5}{t + x[0] + t^2 + x[0]^2}
psset{arrows=-,linewidth=1pt}%
listplot[linecolor=red ]{y0_a}
listplot[linecolor=green]{y0_b}
listplot[linecolor=blue ]{y0_c}
listplot[linecolor=blue ]{y0_d}
end{pspicture}
end{document}
pgfplots pstricks pst-plot
pgfplots pstricks pst-plot
asked Jun 8 '17 at 2:30
JoeJoe
3,61632049
3,61632049
You mean you triedquiver
from pgfplots? Can you show us a/the failing code?
– Symbol 1
Jun 8 '17 at 2:48
I did not tryquiver
. I made my first attempt here withpst-ode
. Am I going down the wrong path?
– Joe
Jun 8 '17 at 2:53
Probably the right path. PS can do more computations than PGF. But I am not familiar with the magical PStricks family.
– Symbol 1
Jun 8 '17 at 3:00
add a comment |
You mean you triedquiver
from pgfplots? Can you show us a/the failing code?
– Symbol 1
Jun 8 '17 at 2:48
I did not tryquiver
. I made my first attempt here withpst-ode
. Am I going down the wrong path?
– Joe
Jun 8 '17 at 2:53
Probably the right path. PS can do more computations than PGF. But I am not familiar with the magical PStricks family.
– Symbol 1
Jun 8 '17 at 3:00
You mean you tried
quiver
from pgfplots? Can you show us a/the failing code?– Symbol 1
Jun 8 '17 at 2:48
You mean you tried
quiver
from pgfplots? Can you show us a/the failing code?– Symbol 1
Jun 8 '17 at 2:48
I did not try
quiver
. I made my first attempt here with pst-ode
. Am I going down the wrong path?– Joe
Jun 8 '17 at 2:53
I did not try
quiver
. I made my first attempt here with pst-ode
. Am I going down the wrong path?– Joe
Jun 8 '17 at 2:53
Probably the right path. PS can do more computations than PGF. But I am not familiar with the magical PStricks family.
– Symbol 1
Jun 8 '17 at 3:00
Probably the right path. PS can do more computations than PGF. But I am not familiar with the magical PStricks family.
– Symbol 1
Jun 8 '17 at 3:00
add a comment |
1 Answer
1
active
oldest
votes
The right-hand side of the given system of ODEs
dx/dt = x + y + x^2 + y^2
dy/dt = x − y − x^2 + y^2
translates into algebraic
notation, used by pstODEsolve
as its last argument, as
defodeRHS{
x[0] + x[1] + x[0]^2 + x[1]^2
|
x[0] − x[1] − x[0]^2 + x[1]^2
}
Here, in the given case, the RHS does not depend on t, the independent integration parameter.
We solve the set of ODEs many times with varying initial conditions, that is, starting points x0 and y0 in the x-y plane. Those starting points are aligned on a 0.1 by 0.1 raster which is shifted by 0.05 in x and y to avoid the saddle point as starting point. (This would not do any harm, but produce a coloured dot at (0,0).) The starting points are specified in algebraic notation as the last-but-one argument of pstODEsolve
.
The example needs pst-ode
v0.8 [2017/06/12]
in order to compile.
The code is quite demanding in terms of TeX memory due to the nested loops. The TeX memory ↗can be enlarged for the latex
engine, but it may be easier to just use lualatex
instead:
lualatex phasePlane
dvips phasePlane
ps2pdf phasePlane.ps
The code:
ifdefinedoutputmodeoutputmode=0fi %enforce DVI output
documentclass{article}
usepackage[tightpage,active]{preview}
usepackage{pst-plot,pst-ode,multido}
%right hand side in algebraic notation
defodeRHS{
x[0] + x[1] + x[0]^2 + x[1]^2
|
x[0] - x[1] - x[0]^2 + x[1]^2
}
deftEnd{10} % end of integration interval; in- or de-crease to have longer/shorter lines
defoutputSteps{500} %increase for smoother lines (and larger PDF file)
definecolor[ps]{random}{rgb}{Rand Rand Rand} %define random colour
begin{document}
begin{preview}
% Solve ODE for initial conditions (starting points) on a 0.1 by 0.1 raster
multido{ii=0+1,rx=-2.55+0.1}{42}{
multido{ij=0+1,ry=-2.55+0.1}{42}{
pstODEsolve[algebraicAll]{line_ii_ij}{x[0] | x[1]}{0}{tEnd}{outputSteps}{rx | ry}{odeRHS}
}
}
psset{unit=3}
begin{pspicture}(-2.95,-2.8)(1.6,1.6)
psaxes[ticksize=0 4pt,axesstyle=frame,tickstyle=inner,
dx=0.5,dy=0.5,Dx=0.5,Dy=0.5,Ox=-2.5,Oy=-2.5,subticks=5
](-2.5,-2.5)(1.5,1.5)
rput(-0.5,-2.75){$x$}
rput(-2.9,-0.5){$y$}
psclip{psframe[linestyle=none](-2.5,-2.5)(1.5,1.5)}%
%plot the lines previously computed
multido{ii=0+1}{42}{
multido{ij=0+1}{42}{
listplot[linecolor=random]{line_ii_ij}
}
}
endpsclip
end{pspicture}
end{preview}
end{document}
1
I may need to revise thepst-ode
code in order catch the numerical underflow error, preventing the code from chrashing but just stopping the integration instead.
– AlexG
Jun 8 '17 at 18:04
1
See my edit (the blue line).
– AlexG
Jun 10 '17 at 9:55
1
Ok, pst-ode has been updated (v0.8, [2017/06/12]). This should answer most of your questions.
– AlexG
Jun 13 '17 at 14:26
1
Sincerest Thanks for providing this elegant solution!
– Joe
Jun 14 '17 at 5:05
1
I was looking for a way to randomly set the line colours. Now we get a result which is close to the Matlab output. I updatedpst-ode
once more (v 0.9), but the code should happily compile with v 0.8. Occasionally, the alogrithm entered an infinite loop. Thanks for the interesting topic which helped me to improve the pkg.
– AlexG
Jun 15 '17 at 8:28
|
show 9 more comments
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f373866%2fphase-plane-plot-using-pst-ode%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The right-hand side of the given system of ODEs
dx/dt = x + y + x^2 + y^2
dy/dt = x − y − x^2 + y^2
translates into algebraic
notation, used by pstODEsolve
as its last argument, as
defodeRHS{
x[0] + x[1] + x[0]^2 + x[1]^2
|
x[0] − x[1] − x[0]^2 + x[1]^2
}
Here, in the given case, the RHS does not depend on t, the independent integration parameter.
We solve the set of ODEs many times with varying initial conditions, that is, starting points x0 and y0 in the x-y plane. Those starting points are aligned on a 0.1 by 0.1 raster which is shifted by 0.05 in x and y to avoid the saddle point as starting point. (This would not do any harm, but produce a coloured dot at (0,0).) The starting points are specified in algebraic notation as the last-but-one argument of pstODEsolve
.
The example needs pst-ode
v0.8 [2017/06/12]
in order to compile.
The code is quite demanding in terms of TeX memory due to the nested loops. The TeX memory ↗can be enlarged for the latex
engine, but it may be easier to just use lualatex
instead:
lualatex phasePlane
dvips phasePlane
ps2pdf phasePlane.ps
The code:
ifdefinedoutputmodeoutputmode=0fi %enforce DVI output
documentclass{article}
usepackage[tightpage,active]{preview}
usepackage{pst-plot,pst-ode,multido}
%right hand side in algebraic notation
defodeRHS{
x[0] + x[1] + x[0]^2 + x[1]^2
|
x[0] - x[1] - x[0]^2 + x[1]^2
}
deftEnd{10} % end of integration interval; in- or de-crease to have longer/shorter lines
defoutputSteps{500} %increase for smoother lines (and larger PDF file)
definecolor[ps]{random}{rgb}{Rand Rand Rand} %define random colour
begin{document}
begin{preview}
% Solve ODE for initial conditions (starting points) on a 0.1 by 0.1 raster
multido{ii=0+1,rx=-2.55+0.1}{42}{
multido{ij=0+1,ry=-2.55+0.1}{42}{
pstODEsolve[algebraicAll]{line_ii_ij}{x[0] | x[1]}{0}{tEnd}{outputSteps}{rx | ry}{odeRHS}
}
}
psset{unit=3}
begin{pspicture}(-2.95,-2.8)(1.6,1.6)
psaxes[ticksize=0 4pt,axesstyle=frame,tickstyle=inner,
dx=0.5,dy=0.5,Dx=0.5,Dy=0.5,Ox=-2.5,Oy=-2.5,subticks=5
](-2.5,-2.5)(1.5,1.5)
rput(-0.5,-2.75){$x$}
rput(-2.9,-0.5){$y$}
psclip{psframe[linestyle=none](-2.5,-2.5)(1.5,1.5)}%
%plot the lines previously computed
multido{ii=0+1}{42}{
multido{ij=0+1}{42}{
listplot[linecolor=random]{line_ii_ij}
}
}
endpsclip
end{pspicture}
end{preview}
end{document}
1
I may need to revise thepst-ode
code in order catch the numerical underflow error, preventing the code from chrashing but just stopping the integration instead.
– AlexG
Jun 8 '17 at 18:04
1
See my edit (the blue line).
– AlexG
Jun 10 '17 at 9:55
1
Ok, pst-ode has been updated (v0.8, [2017/06/12]). This should answer most of your questions.
– AlexG
Jun 13 '17 at 14:26
1
Sincerest Thanks for providing this elegant solution!
– Joe
Jun 14 '17 at 5:05
1
I was looking for a way to randomly set the line colours. Now we get a result which is close to the Matlab output. I updatedpst-ode
once more (v 0.9), but the code should happily compile with v 0.8. Occasionally, the alogrithm entered an infinite loop. Thanks for the interesting topic which helped me to improve the pkg.
– AlexG
Jun 15 '17 at 8:28
|
show 9 more comments
The right-hand side of the given system of ODEs
dx/dt = x + y + x^2 + y^2
dy/dt = x − y − x^2 + y^2
translates into algebraic
notation, used by pstODEsolve
as its last argument, as
defodeRHS{
x[0] + x[1] + x[0]^2 + x[1]^2
|
x[0] − x[1] − x[0]^2 + x[1]^2
}
Here, in the given case, the RHS does not depend on t, the independent integration parameter.
We solve the set of ODEs many times with varying initial conditions, that is, starting points x0 and y0 in the x-y plane. Those starting points are aligned on a 0.1 by 0.1 raster which is shifted by 0.05 in x and y to avoid the saddle point as starting point. (This would not do any harm, but produce a coloured dot at (0,0).) The starting points are specified in algebraic notation as the last-but-one argument of pstODEsolve
.
The example needs pst-ode
v0.8 [2017/06/12]
in order to compile.
The code is quite demanding in terms of TeX memory due to the nested loops. The TeX memory ↗can be enlarged for the latex
engine, but it may be easier to just use lualatex
instead:
lualatex phasePlane
dvips phasePlane
ps2pdf phasePlane.ps
The code:
ifdefinedoutputmodeoutputmode=0fi %enforce DVI output
documentclass{article}
usepackage[tightpage,active]{preview}
usepackage{pst-plot,pst-ode,multido}
%right hand side in algebraic notation
defodeRHS{
x[0] + x[1] + x[0]^2 + x[1]^2
|
x[0] - x[1] - x[0]^2 + x[1]^2
}
deftEnd{10} % end of integration interval; in- or de-crease to have longer/shorter lines
defoutputSteps{500} %increase for smoother lines (and larger PDF file)
definecolor[ps]{random}{rgb}{Rand Rand Rand} %define random colour
begin{document}
begin{preview}
% Solve ODE for initial conditions (starting points) on a 0.1 by 0.1 raster
multido{ii=0+1,rx=-2.55+0.1}{42}{
multido{ij=0+1,ry=-2.55+0.1}{42}{
pstODEsolve[algebraicAll]{line_ii_ij}{x[0] | x[1]}{0}{tEnd}{outputSteps}{rx | ry}{odeRHS}
}
}
psset{unit=3}
begin{pspicture}(-2.95,-2.8)(1.6,1.6)
psaxes[ticksize=0 4pt,axesstyle=frame,tickstyle=inner,
dx=0.5,dy=0.5,Dx=0.5,Dy=0.5,Ox=-2.5,Oy=-2.5,subticks=5
](-2.5,-2.5)(1.5,1.5)
rput(-0.5,-2.75){$x$}
rput(-2.9,-0.5){$y$}
psclip{psframe[linestyle=none](-2.5,-2.5)(1.5,1.5)}%
%plot the lines previously computed
multido{ii=0+1}{42}{
multido{ij=0+1}{42}{
listplot[linecolor=random]{line_ii_ij}
}
}
endpsclip
end{pspicture}
end{preview}
end{document}
1
I may need to revise thepst-ode
code in order catch the numerical underflow error, preventing the code from chrashing but just stopping the integration instead.
– AlexG
Jun 8 '17 at 18:04
1
See my edit (the blue line).
– AlexG
Jun 10 '17 at 9:55
1
Ok, pst-ode has been updated (v0.8, [2017/06/12]). This should answer most of your questions.
– AlexG
Jun 13 '17 at 14:26
1
Sincerest Thanks for providing this elegant solution!
– Joe
Jun 14 '17 at 5:05
1
I was looking for a way to randomly set the line colours. Now we get a result which is close to the Matlab output. I updatedpst-ode
once more (v 0.9), but the code should happily compile with v 0.8. Occasionally, the alogrithm entered an infinite loop. Thanks for the interesting topic which helped me to improve the pkg.
– AlexG
Jun 15 '17 at 8:28
|
show 9 more comments
The right-hand side of the given system of ODEs
dx/dt = x + y + x^2 + y^2
dy/dt = x − y − x^2 + y^2
translates into algebraic
notation, used by pstODEsolve
as its last argument, as
defodeRHS{
x[0] + x[1] + x[0]^2 + x[1]^2
|
x[0] − x[1] − x[0]^2 + x[1]^2
}
Here, in the given case, the RHS does not depend on t, the independent integration parameter.
We solve the set of ODEs many times with varying initial conditions, that is, starting points x0 and y0 in the x-y plane. Those starting points are aligned on a 0.1 by 0.1 raster which is shifted by 0.05 in x and y to avoid the saddle point as starting point. (This would not do any harm, but produce a coloured dot at (0,0).) The starting points are specified in algebraic notation as the last-but-one argument of pstODEsolve
.
The example needs pst-ode
v0.8 [2017/06/12]
in order to compile.
The code is quite demanding in terms of TeX memory due to the nested loops. The TeX memory ↗can be enlarged for the latex
engine, but it may be easier to just use lualatex
instead:
lualatex phasePlane
dvips phasePlane
ps2pdf phasePlane.ps
The code:
ifdefinedoutputmodeoutputmode=0fi %enforce DVI output
documentclass{article}
usepackage[tightpage,active]{preview}
usepackage{pst-plot,pst-ode,multido}
%right hand side in algebraic notation
defodeRHS{
x[0] + x[1] + x[0]^2 + x[1]^2
|
x[0] - x[1] - x[0]^2 + x[1]^2
}
deftEnd{10} % end of integration interval; in- or de-crease to have longer/shorter lines
defoutputSteps{500} %increase for smoother lines (and larger PDF file)
definecolor[ps]{random}{rgb}{Rand Rand Rand} %define random colour
begin{document}
begin{preview}
% Solve ODE for initial conditions (starting points) on a 0.1 by 0.1 raster
multido{ii=0+1,rx=-2.55+0.1}{42}{
multido{ij=0+1,ry=-2.55+0.1}{42}{
pstODEsolve[algebraicAll]{line_ii_ij}{x[0] | x[1]}{0}{tEnd}{outputSteps}{rx | ry}{odeRHS}
}
}
psset{unit=3}
begin{pspicture}(-2.95,-2.8)(1.6,1.6)
psaxes[ticksize=0 4pt,axesstyle=frame,tickstyle=inner,
dx=0.5,dy=0.5,Dx=0.5,Dy=0.5,Ox=-2.5,Oy=-2.5,subticks=5
](-2.5,-2.5)(1.5,1.5)
rput(-0.5,-2.75){$x$}
rput(-2.9,-0.5){$y$}
psclip{psframe[linestyle=none](-2.5,-2.5)(1.5,1.5)}%
%plot the lines previously computed
multido{ii=0+1}{42}{
multido{ij=0+1}{42}{
listplot[linecolor=random]{line_ii_ij}
}
}
endpsclip
end{pspicture}
end{preview}
end{document}
The right-hand side of the given system of ODEs
dx/dt = x + y + x^2 + y^2
dy/dt = x − y − x^2 + y^2
translates into algebraic
notation, used by pstODEsolve
as its last argument, as
defodeRHS{
x[0] + x[1] + x[0]^2 + x[1]^2
|
x[0] − x[1] − x[0]^2 + x[1]^2
}
Here, in the given case, the RHS does not depend on t, the independent integration parameter.
We solve the set of ODEs many times with varying initial conditions, that is, starting points x0 and y0 in the x-y plane. Those starting points are aligned on a 0.1 by 0.1 raster which is shifted by 0.05 in x and y to avoid the saddle point as starting point. (This would not do any harm, but produce a coloured dot at (0,0).) The starting points are specified in algebraic notation as the last-but-one argument of pstODEsolve
.
The example needs pst-ode
v0.8 [2017/06/12]
in order to compile.
The code is quite demanding in terms of TeX memory due to the nested loops. The TeX memory ↗can be enlarged for the latex
engine, but it may be easier to just use lualatex
instead:
lualatex phasePlane
dvips phasePlane
ps2pdf phasePlane.ps
The code:
ifdefinedoutputmodeoutputmode=0fi %enforce DVI output
documentclass{article}
usepackage[tightpage,active]{preview}
usepackage{pst-plot,pst-ode,multido}
%right hand side in algebraic notation
defodeRHS{
x[0] + x[1] + x[0]^2 + x[1]^2
|
x[0] - x[1] - x[0]^2 + x[1]^2
}
deftEnd{10} % end of integration interval; in- or de-crease to have longer/shorter lines
defoutputSteps{500} %increase for smoother lines (and larger PDF file)
definecolor[ps]{random}{rgb}{Rand Rand Rand} %define random colour
begin{document}
begin{preview}
% Solve ODE for initial conditions (starting points) on a 0.1 by 0.1 raster
multido{ii=0+1,rx=-2.55+0.1}{42}{
multido{ij=0+1,ry=-2.55+0.1}{42}{
pstODEsolve[algebraicAll]{line_ii_ij}{x[0] | x[1]}{0}{tEnd}{outputSteps}{rx | ry}{odeRHS}
}
}
psset{unit=3}
begin{pspicture}(-2.95,-2.8)(1.6,1.6)
psaxes[ticksize=0 4pt,axesstyle=frame,tickstyle=inner,
dx=0.5,dy=0.5,Dx=0.5,Dy=0.5,Ox=-2.5,Oy=-2.5,subticks=5
](-2.5,-2.5)(1.5,1.5)
rput(-0.5,-2.75){$x$}
rput(-2.9,-0.5){$y$}
psclip{psframe[linestyle=none](-2.5,-2.5)(1.5,1.5)}%
%plot the lines previously computed
multido{ii=0+1}{42}{
multido{ij=0+1}{42}{
listplot[linecolor=random]{line_ii_ij}
}
}
endpsclip
end{pspicture}
end{preview}
end{document}
edited 5 mins ago
answered Jun 8 '17 at 15:13
AlexGAlexG
33.9k480149
33.9k480149
1
I may need to revise thepst-ode
code in order catch the numerical underflow error, preventing the code from chrashing but just stopping the integration instead.
– AlexG
Jun 8 '17 at 18:04
1
See my edit (the blue line).
– AlexG
Jun 10 '17 at 9:55
1
Ok, pst-ode has been updated (v0.8, [2017/06/12]). This should answer most of your questions.
– AlexG
Jun 13 '17 at 14:26
1
Sincerest Thanks for providing this elegant solution!
– Joe
Jun 14 '17 at 5:05
1
I was looking for a way to randomly set the line colours. Now we get a result which is close to the Matlab output. I updatedpst-ode
once more (v 0.9), but the code should happily compile with v 0.8. Occasionally, the alogrithm entered an infinite loop. Thanks for the interesting topic which helped me to improve the pkg.
– AlexG
Jun 15 '17 at 8:28
|
show 9 more comments
1
I may need to revise thepst-ode
code in order catch the numerical underflow error, preventing the code from chrashing but just stopping the integration instead.
– AlexG
Jun 8 '17 at 18:04
1
See my edit (the blue line).
– AlexG
Jun 10 '17 at 9:55
1
Ok, pst-ode has been updated (v0.8, [2017/06/12]). This should answer most of your questions.
– AlexG
Jun 13 '17 at 14:26
1
Sincerest Thanks for providing this elegant solution!
– Joe
Jun 14 '17 at 5:05
1
I was looking for a way to randomly set the line colours. Now we get a result which is close to the Matlab output. I updatedpst-ode
once more (v 0.9), but the code should happily compile with v 0.8. Occasionally, the alogrithm entered an infinite loop. Thanks for the interesting topic which helped me to improve the pkg.
– AlexG
Jun 15 '17 at 8:28
1
1
I may need to revise the
pst-ode
code in order catch the numerical underflow error, preventing the code from chrashing but just stopping the integration instead.– AlexG
Jun 8 '17 at 18:04
I may need to revise the
pst-ode
code in order catch the numerical underflow error, preventing the code from chrashing but just stopping the integration instead.– AlexG
Jun 8 '17 at 18:04
1
1
See my edit (the blue line).
– AlexG
Jun 10 '17 at 9:55
See my edit (the blue line).
– AlexG
Jun 10 '17 at 9:55
1
1
Ok, pst-ode has been updated (v0.8, [2017/06/12]). This should answer most of your questions.
– AlexG
Jun 13 '17 at 14:26
Ok, pst-ode has been updated (v0.8, [2017/06/12]). This should answer most of your questions.
– AlexG
Jun 13 '17 at 14:26
1
1
Sincerest Thanks for providing this elegant solution!
– Joe
Jun 14 '17 at 5:05
Sincerest Thanks for providing this elegant solution!
– Joe
Jun 14 '17 at 5:05
1
1
I was looking for a way to randomly set the line colours. Now we get a result which is close to the Matlab output. I updated
pst-ode
once more (v 0.9), but the code should happily compile with v 0.8. Occasionally, the alogrithm entered an infinite loop. Thanks for the interesting topic which helped me to improve the pkg.– AlexG
Jun 15 '17 at 8:28
I was looking for a way to randomly set the line colours. Now we get a result which is close to the Matlab output. I updated
pst-ode
once more (v 0.9), but the code should happily compile with v 0.8. Occasionally, the alogrithm entered an infinite loop. Thanks for the interesting topic which helped me to improve the pkg.– AlexG
Jun 15 '17 at 8:28
|
show 9 more comments
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f373866%2fphase-plane-plot-using-pst-ode%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You mean you tried
quiver
from pgfplots? Can you show us a/the failing code?– Symbol 1
Jun 8 '17 at 2:48
I did not try
quiver
. I made my first attempt here withpst-ode
. Am I going down the wrong path?– Joe
Jun 8 '17 at 2:53
Probably the right path. PS can do more computations than PGF. But I am not familiar with the magical PStricks family.
– Symbol 1
Jun 8 '17 at 3:00