I am trying to run the function to perform a plot but instead, I am getting the error:
Message[With::lvset, {dt = 0.01, tfinal = 100., \[Gamma] = 1, k = 1,
Subscript[\[Sigma], 1] = 1, Subscript[\[Sigma], 2] = 2},
Subscript[\[Sigma], 1] = 1, Subscript[\[Sigma], 1]]
The function, which is a for loop that stores the values in a list and plots them is :
With[{dt = 0.01, tfinal = 100.0, \[Gamma] = 1, k = 1,
Subscript[\[Sigma], 1] = 1, Subscript[\[Sigma], 2] = 2},
x = {0, 0};
a = 0.0;
alist = {};
dtsqrt = Sqrt[dt];
M = ( {
{1 + 1, -1},
{-1, 1 + 1}
} );
\[Sigma] = ( {
{1, 0},
{0, 2}
} );
Do[
dx = -M.x*dt +
dtsqrt*\[Sigma]. RandomVariate[NormalDistribution[], 2];
a += x[[1]] dx[[2]] - x[[2]] dx[[1]] ;
x += dx;
AppendTo[alist, {t, a}], {t, dt, tfinal, dt}];
p1 = ListPlot[alist, Joined -> True];
Show[p1]
]
Could you tell me where the error emerges from or perhaps how to stop it from occurring?
Subscript[\[Sigma], 1] = 1
orSubscript[\[Sigma], 2] = 2
as part of the specification ofWith
. Subscripts don't always behave how you might expect them to, so it's better to avoid them until you learn more about when they work and when they don't. There are some good posts on this site about possible workarounds if you really need to have a subscript. If you don't absolutely require a subscript, I would use\[Sigma]1 = 1
and\[Sigma]2 = 2
. $\endgroup$Format[σ1] = Subscript[σ, 1]
to haveσ1
display as aSubscript
in output. $\endgroup$