# 3D plot of the spatial path of velocity/space stochastic differential equations

I define the following 6 dimensional stochastic (Ito) process- in velocity v/position x. I can plot x1 as a function of t- see script below which has been corrected by Daniel. My goal is however to plot the path [x1[t],x2[t],x3[t]] in 3D. Any help?

• There are syntax errors in your code, e.g. [DifferentialD] should be replaced by d and [Distributed] should be replaced by \[Distributed]. Nov 12 '21 at 7:34
• corrected below Nov 12 '21 at 18:04

You can change the Ito process to output the three x values, {x1[t],x2[t],x3[t]} instead of just x1[t]:

proc = ItoProcess[{\[DifferentialD]x1[t] ==
v1[t] \[DifferentialD]t, \[DifferentialD]x2[t] ==
v2[t] \[DifferentialD]t, \[DifferentialD]x3[t] ==
v3[t] \[DifferentialD]t, \[DifferentialD]v1[t] == -0.1*
v1[t] \[DifferentialD]t + \[DifferentialD]n1[
t], \[DifferentialD]v2[t] == -0.1*
v2[t] \[DifferentialD]t + \[DifferentialD]n2[
t], \[DifferentialD]v3[t] == -0.1*
v3[t] \[DifferentialD]t + \[DifferentialD]n3[t]},
{x1[t], x2[t],x3[t]},
{{x1, x2, x3, v1, v2, v3}, {0, 0, 0, 0, 0, 0}},
t, {n1 \[Distributed] WienerProcess[],
n2 \[Distributed] WienerProcess[],
n3 \[Distributed] WienerProcess[]}]


After solving this version of the Ito process, extract and plot the paths:

Graphics3D[Line[sol["ValueList"]]]


If you want to style each path, you can extract them individually from the solution, e.g, with sol["Values",p] for the {x1,x2,x3} values for path p.

• Thank Tad. That is starting to help. Is there a way to have each sample path in different color? I need these (or variations around the same problem) for an article I am preparing for The Astrophysical Journal. Nov 12 '21 at 19:33
• @NicolasBian For different colors Table[sol["Values", i], {i, 1, 50}] // ListPointPlot3D[#, AspectRatio -> 1] & Nov 12 '21 at 22:36

I corrected Differential and Distributed:

proc = ItoProcess[{\[DifferentialD]x1[t] ==
v1[t] \[DifferentialD]t, \[DifferentialD]x2[t] ==
v2[t] \[DifferentialD]t, \[DifferentialD]x3[t] ==
v3[t] \[DifferentialD]t, \[DifferentialD]v1[t] == -0.1*
v1[t] \[DifferentialD]t + \[DifferentialD]n1[
t], \[DifferentialD]v2[t] == -0.1*
v2[t] \[DifferentialD]t + \[DifferentialD]n2[
t], \[DifferentialD]v3[t] == -0.1*
v3[t] \[DifferentialD]t + \[DifferentialD]n3[t]},
x1[t], {{x1, x2, x3, v1, v2, v3}, {0, 0, 0, 0, 0, 0}},
t, {n1 \[Distributed] WienerProcess[],
n2 \[Distributed] WienerProcess[],
n3 \[Distributed] WienerProcess[]}]
sol = RandomFunction[proc, {0., 100, 0.1}, 50,
Method -> "StochasticRungeKutta"]; ListLinePlot[sol]


If you want to plot the 3 first data-path as 3D path you may do this by:

ListLinePlot3D[sol["Values", 1 ;; 3] // Transpose]


• Thank you Daniel. I would like to plot (x1,x2,x3) as a function of time in 3D? any clue? Nov 12 '21 at 17:57
• Think of ListPointPlot3D. Nov 12 '21 at 18:08
• Can you give me a script that would do? thanks Nov 12 '21 at 18:13
• I am not sure if I understand you correctly. I added a 3D path out of the first 3 paths from "sol" to my answer Nov 12 '21 at 20:31
• Thanks Daniel. I have 1 path of x1,x2,x3 as function of time. That's the meaning of 1;;3 I guess. 4;;6 would give the velocity path. So what is the meaning of transpose? what if I want 30 paths? Nov 13 '21 at 14:18