I was wondering if there was a possible way to animate electric and magnetic field lines using Mathematica?

I'm currently doing a physics major and taking an upper level electromagnetism course. I'm having a difficult time creating a mental image of everything, and it seems my professors are pretty adamant I should learn how to use this software to help me in my future endeavours. I've had some practice using Mathematica in my quantum mechanics class, but I was hoping to utilize the graphics provided by this software to aid in my learning.

Let's say I have a particle moving in 3 dimensional space for example, and it's spinning in a circle. As it's spinning, it is also travelling upward in a z direction, so it makes kind of a spring shape. I would have a function where

x = rcos(wt)

y = rsin(wt)

z = vt

is there a way to animate a particle with this behaviour from time of 0 to infinity using this program? The particle can travel in any shape of course, and if you're willing to help me, feel free to make up any of your own functions so it doesn't look like you're helping me to do an assignment or something. I just wanted a code I can use as a reference to help me out in the future. I'm still quite new to using this program, and though I can plot, and use the calculation functions pretty well, animation is something I've not been able to understand using Mathematica

Thanks for any help you can give in my understanding of this program!


1 Answer 1


Mathematica is great for Physics and simulation. One way is to use Manipulate which makes things very easy

enter image description here

 ParametricPlot3D[{r Cos[w t], r Sin[w t], v t}, {t, 0, maxTime},
  PlotRange -> {{-10, 10}, {-10, 10}, {0, 100}}, 
  PerformanceGoal -> "Quality", PlotStyle -> Red],
 {{r, 6, "r?"}, 0.01, 10, 0.01, Appearance -> "Labeled", ImageSize -> Small},
 {{w, 7, "w?"}, 0.01, 10, 0.01, Appearance -> "Labeled", ImageSize -> Small},
 {{v, 6, "v?"}, 0.01, 10, 0.01, Appearance -> "Labeled", ImageSize -> Small},
 {{maxTime, 20, "time"}, 0.001, 20, 0.01, Appearance -> "Labeled", ImageSize -> Small},
 TrackedSymbols :> {r, w, v, maxTime}
  • $\begingroup$ This is perfect! just another quick question. I'm not sure if you are familiar with electromagnetism, but if I wanted to animate the particle's magnetic and electric field, how would I go about it? basically, I want to see how the magnetic field and electric field changes once I change the trajectory or direction of the particle. If it requires a lot of effort or it's something that cannot be easily done, I don't mind if you're unable to answer it. this is already tremendous help! Thanks! $\endgroup$ Dec 9, 2019 at 5:50
  • 1
    $\begingroup$ @AidenDuggan there are lots of demos on this subject at https://demonstrations.wolfram.com You can use the search box. If something you do not find or have trouble doing, you can ask new question and someone can help. $\endgroup$
    – Nasser
    Dec 9, 2019 at 6:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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