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: Going from cylindrical to cartesian coordinates

  1. Oct 19, 2012 #1
    1. The problem statement, all variables and given/known data

    The expression for the magnetic field from an infinite wire is
    \boldsymbol B(r) = \frac{\mu_0I}{2\pi}\frac{1}{r} \hat\phi
    which points along [itex]\phi[/itex]. I am trying to convert this into cartesian coordinates, and what I get is
    \boldsymbol B(x, y) = \frac{\mu_0I}{2\pi}\frac{1}{\sqrt{x^2+y^2}} \hat\phi
    \hat\phi = -\sin\phi \hat x + \cos\phi \hat y
    I am trying to make a phase plot of this expression, so what I have done is to say that [itex]\phi = \arctan(y/x)[/itex], so [itex]\hat\phi = -\sin(\arctan(y/x))\hat x + \cos(\arctan(y/x))\hat y[/itex]. However I don't get the desired result. Have I missed something in my approach?
  2. jcsd
  3. Oct 19, 2012 #2
    sin (arctan a) and cos (arctan a) can be simplified. Let z = arctan a, that means tan z = a, and tan z = sin z/cos z = a, so you can express sin z and cos z in terms of a.
  4. Oct 19, 2012 #3
    Thanks, so I know that
    \frac{y}{x} = \frac{\sin(\phi)}{\cos(\phi)}
    I can't see how this enables me to rewrite e.g. [itex]\sin(\arctan(y/x))[/itex].
  5. Oct 19, 2012 #4
    ## \sin (\arctan a) = \sin z ##. Since ##\tan z = \sin z/\cos z = a##, ##\sin^2 z = a^2 \cos^2 z = a^2(1 - \sin^2 z)##. So you can find ##\sin z## as a function of ##a##; ditto for ##\cos z##. Then substitute ## a = y/x ##.
  6. Oct 19, 2012 #5
    Ah, I see. So I get
    \sin z = \frac{a}{\sqrt{1+a^2}} \\
    \cos z = \frac{1}{\sqrt{1+a^2}}
    But I still have my original problem: That when I plot B using these for negative x, then I don't see the correct magnetic field. I thought that I was perhaps missing a term [itex]\pi/2[/itex], but that didn't solve it either.
  7. Oct 19, 2012 #6
    What do you get and what is your expectation?
  8. Oct 19, 2012 #7
    I have attached a plot of what I see (the axes are (x, y), the current 1A and the units on the axis in meters), it is called "negative_x". If I only plot for positive x-values I get "positive_x", and there I see what I expect (as shown here, on the top: http://www.netdenizen.com/emagnet/solenoids/frommaxwellonly.htm).

    My code in Mathematica for plotting is:

    VectorPlot[(mu0/2 pi)*
    current*(1/(x^2 + y^2)^(1/2))*{-(y/x)/(1 + y^2/x^2)^(1/2),
    1/(1 + y^2/x^2)^(1/2)}, {x, -0.01, 0.01}, {y, -0.01, 0.01}]

    Attached Files:

  9. Oct 19, 2012 #8
    You should be able to simply the formula very significantly. Note that ## \frac 1 {\sqrt {1 + y^2/x^2}} = \frac x {\sqrt {x^2 + y^2}} ##, and the radical in the denominator nicely couples with that in the common factor. But even then your formula is not wrong, I am not sure why Mathematica does not plot it correctly.
  10. Oct 19, 2012 #9
    I don't know either. Strange, but nice to know that I have the correct exprssion. Thanks!
  11. Oct 19, 2012 #10
    OK, I just plotted it in MatLAB, and it *isn't* correct. For x<0 the y-coordinates all have to change sign. So the expression is not correct.

    EDIT: I have attached the plot.

    Attached Files:

    Last edited: Oct 19, 2012
  12. Oct 19, 2012 #11
    Have you tried the simplified formula as I suggested?
  13. Oct 19, 2012 #12
    Yes, it didn't change anything. It shouldn't either, since it is just a different way of expressing it.
  14. Oct 20, 2012 #13
    Your formula is ## (\mu_0/2 \pi)
    I \frac 1 {(x^2 + y^2)^{1/2}} \left(\frac {-y/x } {(1 + y^2/x^2)^{1/2}},
    \frac 1 {(1 + y^2/x^2)^{1/2}} \right)##

    Observe that the y-component is always positive, which is incorrect. If you transform it the way I suggested, you will get ## (\mu_0/2 \pi) I \frac 1 {x^2 + y^2} \left(-y, x\right)##, which restores the correct sign.
  15. Oct 21, 2012 #14
    thanks! I must have made an error somewhere then when I tried
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook