To plot a phase portrait in Maple, define your planar system as a list of right-hand sides, then call DEtools[phaseportrait] with an initial-condition list and a time range—for example, phaseportrait([diff(x(t),t)=y(t), diff(y(t),t)=-sin(x(t))], [x,y], t=-10..10, [[x(0)=1,y(0)=0]], stepsize=0.05, arrows=line). That single call produces solution trajectories through your chosen starting points; adding dirfield=[a,b] overlays a slope field. Everything else—nullclines, equilibria, window framing, export—is either an argument to that command or a short supporting calculation.
Maple's numerical engine does the integration, so the picture is only as trustworthy as your time span, step size, and starting points. The workflow below takes you from a blank worksheet to a labeled, exportable figure, using the built-in procedures rather than hand-rolled loops.
What phaseportrait actually plots, and what it doesn't
A phase portrait for a two-dimensional autonomous system x' = f(x, y), y' = g(x, y) is a picture in the xy-plane, not a plot of x and y against time. Each curve is one solution trajectory; the direction of travel is usually shown with arrows. Equilibrium points, where f and g both vanish, organize the whole picture.
Maple's phaseportrait (part of the DEtools package) works in three modes:
Trajectories only from initial conditions you supply. Direction field only, when you give dirfield=[xrange, yrange] and no initial conditions. Both, when you supply initial conditions and dirfield.
What it does not do is find equilibria for you or guess good initial conditions. Those steps are on you, and they matter more than any option: a portrait seeded with three arbitrary points can hide a saddle or a stable spiral entirely.
One naming caution: current Maple releases still document the command as phaseportrait. Older tutorials sometimes show DEplot or dfieldplot; DEplot is the general ODE plotting command and remains valid for systems, but the rest of this article uses phaseportrait because it's the purpose-built tool.
Set up the worksheet before your first command
Three prerequisites keep the first attempt from failing:
1: Load DEtools. Run with(DEtools): (colon suppresses the long output list). Without it, phaseportrait is an unknown command. 2: Use explicit dependent variables. Write x(t) and y(t), not bare x and y, inside diff. The command needs to know what's being differentiated. 3: Check your Maple version. Interface details below match Maple 2024–2025 conventions; the phaseportrait calling sequence has been stable for many releases, but confirm option names in the help page (?phaseportrait) for your installed version before relying on newer keywords.
If you prefer not to load the whole package, the fully qualified call DEtoolsphaseportrait works identically.
Build the system and choose a viewing window
Write the system as a list of two equations. A pendulum with damping, linearized for small angles, is a clean test case:
sys := [diff(x(t),t) = y(t), diff(y(t),t) = -sin(x(t)) - 0.2*y(t)];
Here x is angle and y is angular velocity. The undamped version (-sin(x(t)) alone) is the classic pendulum; the damping term tilts the portrait toward spirals.
The viewing window is the x = a..b, y = c..d range you pass to dirfield. Pick it so the interesting structure fits: for the pendulum, x=-2Pi..2Pi, y=-4..4 captures the two saddle-like equilibria at (±π, 0) and the centers at (0,0) and (±2π, 0) for the undamped case. A window that's too wide makes trajectories look like straight lines; too narrow and you crop the separatrices that define the portrait's character.
You can also set the window through the xrange and yrange options on the plot itself; when both dirfield and the plot ranges are given, keep them consistent or the arrows will crowd oddly.
Seed trajectories with initial conditions
Initial conditions go in a list of lists, each inner list assigning values at t = 0 (or at your chosen start time):
ics := [[x(0)=1, y(0)=0], [x(0)=0, y(0)=2], [x(0)=-1, y(0)=0.5], [x(0)=3, y(0)=-2]];
Choosing them is the craft. Three habits pay off:
Seed near each equilibrium you expect, from several directions, so you see whether nearby solutions close in (stable node/spiral), veer away (unstable), or approach then depart (saddle). Seed on both sides of a separatrix. For the pendulum, a trajectory starting just below the energy needed to swing over the top will librate; just above, it rotates. Watching where those two families diverge is the whole point. Include one or two far-field points to show the global flow.
If you want both forward and backward time from the same seeds, pass scene=[x,y] with a time range that includes negative t, or run two calls and combine the plots with display.
Run your first working command
Putting it together:
The time range t=-15..15 integrates each seed both backward and forward, which is why the picture looks fuller than a forward-only run. stepsize=0.05 is the integrator's step; smaller values cost time and gain accuracy.
What to expect: a window with a light grid of direction arrows and four trajectories, each with small arrowheads showing direction. Damped pendulum seeds should spiral into (0,0) or a nearby offset equilibrium depending on your parameters.
How to check success: the plot renders without an error, trajectories start at the specified points (zooming in confirms this), and the arrowheads on each curve point along the flow. If a trajectory terminates early, the integrator hit a singularity or left the window—usually cured by extending the range slightly or reducing the step size.
Make the portrait readable: arrows, colors, ranges
Defaults are serviceable but rarely publishable. The options worth knowing:
arrows = line draws directional arrowheads along the curve; arrows = small places them more discreetly, and arrows = none is useful when you want solution curves only. linecolor = [...] takes a list matching your initial conditions in order, so keep the two lists the same length. stepsize controls resolution; numpoints (inherited from plotting) can smooth the drawn curve, but it doesn't improve the integration, only the rendering. axes = boxed and labels = ["x","y"] handle the framing; title accepts a string. scene = [x,y] selects which variables appear on the axes—necessary when your formulation carries a third variable such as time, and harmless in a two-variable system.
A common frustration is trajectories that exit the plotted window and stop. That's correct behavior, not a bug: the solution left the box. Widen dirfield or shorten the time range.
Overlay nullclines and equilibria by hand
phaseportrait won't draw equilibrium markers or nullclines. Add them yourself and combine with display (from the plots package):
1: Solve for equilibria. solve({rhs(sys)=0, rhs(sys)=0}, {x,y}) on the right-hand sides—use rhs to strip the derivatives—returns the candidate points. Exclude non-real results. 2: Draw markers. Build a list of small circles or points with plotspointplot. 3: Draw nullclines if you want them: implicitplot on f = 0 and g = 0, each in its own color, across your window. 4: Combine. Assign the phaseportrait call to p1 (ending with a colon, not semicolon, to suppress output), the marker plot to p2, then plotsdisplay.
This layering is standard practice in Maple differential-equations courses: the command gives you the flow, manual geometry gives you the skeleton.
Validate the picture before you trust it
A phase portrait is a numerical object, and plausible-looking wrong pictures are easy to produce. Three checks catch most problems:
Compare against linearization. At each equilibrium, evaluate the Jacobian and its eigenvalues. A stable spiral must actually spiral in your plot; a saddle must show incoming and outgoing directions. If they disagree, your integration window or step size is the suspect. Halve the step size and re-run. If trajectories shift visibly, the original was under-resolved. If they're stable, the picture is likely sound. Sanity-check conserved quantities. For the undamped pendulum, energy 0.5*y² − cos(x) should be constant along each trajectory; compute it at a couple of points to confirm the numerics aren't drifting.
Stop and reconsider your model setup—not just the plot—if trajectories cross each other. In a genuine autonomous planar system they cannot, so crossings mean a typo in the equations or a stray non-autonomous term. If the system comes from a real engineering or physical model and the portrait looks qualitatively impossible, that's the point to bring in a colleague or your instructor rather than tuning options until it looks right.
Export the figure into a report or assignment
Right-click the plot and choose Export, or use plotsetup to write directly to a file:
plotsetup(png, plotoutput="pendulum.png", plotoptions="width=800,height=600");
Then call phaseportrait again; the next plot goes to the file. Reset with plotsetup(default) afterward, or you'll wonder why nothing appears in the worksheet. For LaTeX documents, exporting EPS or PDF preserves the vector arrows better than raster formats. Keep the generating command in the worksheet next to the figure—reviewers and graders ask, and reproducing the picture takes one line.
Beyond the basics: parameters, 3D, and Maple's alternatives
A few extensions cover most follow-on needs:
Parameter sliders. Maple's Explore command wraps a phaseportrait call and gives you interactive sliders for parameters like the damping coefficient; the portrait redraws as you drag. This is the fastest way to see a Hopf bifurcation appear as damping changes sign. Non-autonomous systems. Time-dependent systems don't have true phase portraits in the plane, but DEplot with scene=[x,y] will still trace the projected motion—useful, with the caveat that trajectories may cross. Three-dimensional systems. DEplot3d with scene=[x,y,z] handles 3D flows; phaseportrait itself is planar. Direction fields alone. Drop the initial-condition list and pass only dirfield to phaseportrait, or use DEtools[dfieldplot], when you want the vector field without solution curves.
For coursework, the usual deliverable is one figure per system: direction field, four to six well-chosen trajectories, equilibria marked, axes labeled, and a caption naming the parameter values. Everything in this article fits in roughly fifteen lines of Maple, most of which you'll reuse by editing the system and the seed list.