1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Magnetic Pendulum Mathematica Simulation

  1. Feb 28, 2012 #1
    1. The problem statement, all variables and given/known data
    This is for a lab, which I'm working on at home. There are two parts: using Mathematica to simulate a magnetic pendulum with 3 magnets by plotting the path of the bob and then extend my code to determine where the bob endpoint for all starting positions and draw the fractal basin boundaries.

    2. Relevant equations
    x''[t] == -R x'[t] + ((
    X[1] - x[t])/(Sqrt[(X[1] - x[t])^2 + (Y[1] - y[t])^2 + d^2])^3 + (
    X[2] - x[t])/(Sqrt[(X[2] - x[t])^2 + (Y[2] - y[t])^2 + d^2])^3 + (
    X[3] - x[t])/(Sqrt[(X[3] - x[t])^2 + (Y[3] - y[t])^2 + d^2])^3) -
    c x[t]

    and likewise for y''[t] (copy-pasted from Mathematica)
    where R is the damping constant of the air, and c is the "spring" constant of the pendulum, since we approximate this using Hooke's Law. X, Y are the x and y positions of the magnets.

    3. The attempt at a solution
    The first part, simulating the pendulum's path was very easy. The equation(s) above was basically given to me; I just had to fine-tune the constants R and c. My problem is now getting the fractal basin boundary.

    I'm trying to get a Do loop to output a Table of data points that includes the initial and final positions, and from there plot these points in different colours based on where the final position is. I know there must be some way to do this, but I have no idea how.

    For reference, I've attached my .nb's. pendulum fbb.nb is what I've got so far for the second part, but it doesn't really do anything right now. Any help I could get with this would be awesome!

    Attached Files:

  2. jcsd
  3. Mar 7, 2012 #2
    Any help? Short of running 400+ calculations to find the y value of the pendulum for each set of x0 and y0 from -2 to 2 in 0.1 steps, I'm lost.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook