I'm trying to post a question but keep getting the error

Your post appears to contain code that is not properly formatted as code. Please indent all code by 4 spaces using the code toolbar button or the CTRL+K keyboard shortcut. For more editing help, click the [?] toolbar icon.

Reducing my question to just the opening sentence, I still get the same message.

Consider the anisotropic harmonic potential in two dimensions $(q_1,q_2)$ given by $$ V(q_1,q_2) = \frac{m}{2} \, q_1^2 + \frac{k}{2} \, q_2^2. $$

Could anybody explain what the problem is? Here is the full question:

Consider the anisotropic harmonic potential in two dimensions $(q_1,q_2)$ given by

$$ V(q_1,q_2) = \frac{m}{2} \, q_1^2 + \frac{k}{2} \, q_2^2, $$

or `V = m/2 q1^2 + k/2 q2^2;` in Mathematica.

The Newtonian e.o.m.s of a particle moving through this potential are

$$ \ddot{q}_1 = -q_1, \qquad \ddot{q}_2 = -\omega^2 \, q_2, $$

where $\omega = \sqrt{k/m}$ is the angular frequency of oscillations in the $q_2$-direction. Given the initial conditions $q_i(0) = q_{i,0}$ and $p_i(0) = p_{i,0}$, the e.o.m.s are solved by

$$ \begin{aligned} q_1(t) &= q_{1,i} \cos(t) + \frac{p_{1,i}}{m} \, \sin(t),\\ q_2(t) &= q_{2,i} \cos(\omega t) + \frac{p_{2,i}}{m \omega} \, \sin(\omega t),  \end{aligned} \qquad \text{with $p_i = m \dot{q}_i$.} $$

In Mathematica:

    DSolve[{q1''[t] == -q1[t], q2''[t] == -\[Omega]^2 q2[t], q1[0] == q10,
    q1'[0] == p10/m, q2[0] == q20, q2'[0] == p20/m}, {q1[t], q2[t]}, t]

    {{q1[t] -> q10 Cos[t] + (p10 Sin[t])/m, q2[t] -> q20 Cos[t \[Omega]] + (p20 Sin[t \[Omega]])/(m \[Omega])}}

I generated a 3d plot of the potential.

    Plot3D[V /. {m -> 1, k -> 3}, {q1, -5, 5}, {q2, -5, 5},RegionFunction -> Function[{q1, q2}, m/2 q1^2 + k/2 q2^2 <= 12 /. {m -> 1, k -> 3}]]

[![enter image description here][2]][2]

What I would like to do now is draw the particle as a ball moving through this potential with a fixed energy, i.e. it always reaches the same height before rolling back down again and up the other side, thereby creating oscillatory motion. The frequency $\omega(\phi)$ is dependent on which direction the particle is moving. In theory all that would need to be done is to somehow add a ball to the plot whose position is given by the solution to the e.o.m.s above. I tried using the `Manipulate[]` command but couldn't get it to work. Any help would be much appreciated.

  [2]: https://i.stack.imgur.com/8NtyI.png
  • Please show your post. Put the markdown in a code block in this question. Is it all LaTeX and no code?
    – Szabolcs
    Dec 18, 2016 at 17:59
  • @Szabolcs No, there is also some code.
    – Casimir
    Dec 18, 2016 at 20:30

1 Answer 1


I cannot reproduce the problem you mention. Here's your question re-posted exactly as you wrote it, from a new user's account.


enter image description here

The warning you mention was indeed enabled a few weeks ago. But it is not triggered by this text, at least when posting from an unregistered account.

First-time posts with unformatted code should be automatically caught

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .