I am a beginner at mathematica, so I have made huge blunders in my code which gave too many errors so I did not think it would be relevant to post it. I will try and explain my target as well as possible.

I am trying to trace the motion of a particle in a varying electric field. I have the initial position and initial velocity of the particle. The equations are as follows:

$$ r(t)=r(0)+ \int_0^t v(\tau)d\tau $$ $$ v(t)=v(0)+ \int_0^t A.E(r) d\tau $$ $$ E(r)= (B).\frac{p}{pdist^3} + C.z^\frac{1}{3} $$

where $A$, $B$ and $C$ are constants, $p$ is the position vector from the point {2, 3, 4} and $pdist$ is the distance from that point.

$r(t),\,v(t)$ and $E(t)$ are in vector forms. vector $r$ is in the form $\{x,y,z\}$ (that is the $z$ which is in equation 3).

I have to simultaneously solve these equations of motion to determine the motion of the particle and make a parametric plot of its trajectory. I have to account for the motion for $t=15$ minutes.

I made a noob attempt which did not work at all. I tried solving all three using DSolve which gave lots of errors. I am also not familiar with how to work with trajectory vectors in mathematica.

Can you please guide me in the direction towards the path which I need to take while solving something like this?


closed as off-topic by bbgodfrey, m_goldberg, LCarvalho, bobthechemist, gwr Nov 20 '17 at 12:17

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – bbgodfrey, m_goldberg, LCarvalho, bobthechemist, gwr
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Some questions: 1.- by using the Fundamental Theorem of Calculus, you can reduce these equations to just three second-order differential equations, i.e., in terms of $d^2r(t)/dt^2$, 2.- is $C$ a constant vector? $\endgroup$ – José Antonio Díaz Navas Nov 12 '17 at 12:03
  • $\begingroup$ C is a constant scalar .... the equation given will give the absolute value of the vector E(r) and the direction will be same as that of p.... And I do not understand if the first one is a question or a suggestion. $\endgroup$ – Shivam Kaushik Nov 12 '17 at 15:15
  • $\begingroup$ Look up NDSolve in the documentation. It will likely have examples of solving this type of problem. $\endgroup$ – Daniel Lichtblau Nov 12 '17 at 15:26
  • $\begingroup$ Since I am dealing with vectors, I could not find any example similar to this one. $\endgroup$ – Shivam Kaushik Nov 12 '17 at 16:09
  • $\begingroup$ @ShivamKaushik, if in $E(r)$ the first term is a vector you cannot add an scalar ($C z^{1/3})$ to it. By the way, what you mean with "absolute value of a vector"? Your problem can be solved, but I need a precise definition of $E(r)$. Oh, my first point before was a suggestion... $\endgroup$ – José Antonio Díaz Navas Nov 12 '17 at 16:20

This is a first approach. I am not sure that the equation for $\vec{E}(r)$ is correct. This is the acceleration vector. Anyway, we should know the values for all the constant, including the values for the vectors at $t=0$, and thus, I assume $\vec{r}(0)=\{2,3,4\}$ and $\vec{v}(0)=\{0\}$. The resulting system of equations cannot be solved with DSolve.

I am also assuming from the comments that if the direction of $E(r)$ is that of $p$ the can be expressed then as

$\vec{E}(r)=\left(\frac{B}{\left[\sqrt{(x(t)-2)^2+(y(t)-3)^2+(z(t)-4)^2}\right]^3}+ C z(t)^{1/3}\right)\cdot\{x(t),y(t),z(t)\}$

Therefore, the system is:

$\frac{d^2\vec{r}(t)}{dt^2}=\frac{d\vec{v}(t)}{dt}=\left(\frac{AB}{\left[\sqrt{(x(t)-2)^2+(y(t)-3)^2+(z(t)-4)^2}\right]^3}+A C z(t)^{1/3}\right)\cdot\{x(t),y(t),z(t)\}$

Then, the system of equations can be solved by NDSolve;

eqns = {x''[t] == (2 A B x[t])/((-2 + x[t])^2 + (-2 + y[t])^2 + (-2 + z[t])^2)^(3/2) + 2 A C z[t]^(1/3) x[t], 
y''[t] == (3 A B y[t])/((-2 + x[t])^2 + (-2 + y[t])^2 + (-2 + z[t])^2)^(3/2) + 3 A C z[t]^(1/3) y[t],
z''[t] == (4 A B z[t])/((-2 + x[t])^2 + (-2 + y[t])^2 + (-2 + z[t])^2)^(3/2) + 4 A C z[t]^(4/3), 
x[0] == 2, 
y[0] == 3, 
z[0] == 4, 
x'[0] == 0, 
y'[0] == 0,
z'[0] == 0};
sol = NDSolve[eqns /. {A -> 1, B -> 1, C -> 1}, {x, y, z}, {t, 0, 15}];
{rx, ry, rz} = {x, y, z} /. sol[[1]];
ParametricPlot3D[{rx[t], ry[t], rz[t]} /. sol[[1]], {t, 0, 15}, 
AxesLabel -> (Style[#, 24, Bold,FontFamily -> "Times New Roman"] & /@ {"x", "y", "z"})]

enter image description here

I do not trust on the problem statement, so its solution. However, this answer intends to illustrate how to solve it with MMA. Hope this helps.

  • $\begingroup$ I understand your approach on converting each expression in the terms of the position vectors (if i am reading it correctly) .... that I think is exactly what I needed. The code although have many errors when i copy and paste the whole thing in mathematica. But it did help me get a direction, thank you :) $\endgroup$ – Shivam Kaushik Nov 12 '17 at 18:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.