Message Boards Message Boards

0
|
2754 Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Finding x and y co'ordinates at a given time?

Posted 10 years ago
 Apologies if this question has been asked elsewhere / is a stupid question.
I'm fairly new to Mathematica syntax and doing a Mathematica-heavy project so any help will be much appreciated.


Basically I'm doing a simulation of scattering of particles. I have two equations regarding the x and y accelerations,
x''[t] == ( k x[t]/(x[t]^2 + y[t]^2)^(3/2) ), y''[t] == ( k y[t]/(x[t]^2 + y[t]^2)^(3/2) )
Using
path := NDSolve[ {x''[t] == (5.48147 x[t]/(x[t]^2 + y[t]^2)^(3/2)),
   y''[t] == (5.48147 y[t]/(x[t]^2 + y[t]^2)^(3/2)),
   x'[0] == 155000000, y'[0] == 0, x[0] == -10*10^-15,
   y[0] == 5*10^-16}, {x[t], y[t]}, {t, 0, 10^-22}]
and
ParametricPlot[Evaluate[{x[t], y[t]} /. path], {t, 0, 10^-22},
PlotPoints -> 1000]
I've managed to plot the correct graph. However, I need to find the x and y co'ordinates for a given value of t. I don't have any real idea of where to go on this and have been stuck on this for a while, I'd really appreciate it if anyone could help me on this.
POSTED BY: Michael B
2 Replies
Posted 10 years ago
Thank you! This is exactly what I needed. emoticon
POSTED BY: Michael B
Hi,
(* this returns x and y at t=1.E-23 *)
Flatten@Evaluate[{x[t], y[t]} /. path] /. t :>  10^(-23)
(* this creates a table of x and y vals. *)
ListPlot@Table[Flatten@Evaluate[{x[t], y[t]} /. path] /. t :>  i , {i, 0, 10^-22, 1/20 (* <- # of points *) 10^-22 }]

Also, EventLocator method for NDSolve[] might be of interest to you as well as documentation about ref/InterpolatingFunction

I.M.
POSTED BY: Ivan Morozov
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract