Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How to make a surface plot involving an infinite series

  1. Mar 23, 2013 #1
    How to make a surface plot involving an infinite series in Matlab

    Solving Laplace's equation for electric potential for a 2D surface yields:

    V(x,y) = 4 Vo/pi * Ʃ (n=1,3,5,...) (1/n e^(-npi*x/a) sin(n*pi*y/a)

    ,where a is and Vo are constants

    ...it's convoluted, but basically, I need to plat the value V over the x,y plane and V is defined by an infinite series
    Last edited: Mar 23, 2013
  2. jcsd
  3. Mar 23, 2013 #2
    Infinite series, when they converge, are calculated from their partial sums. What you would do is first choose the margin of error you are comfortable with, then find the value of n that you need to get sums below that margin of error. You can find bounds for your error by using various comparisons.
    For example, the value of sine is between -1 and 1, so the magnitude of each term of the sum is bounded by 1/(ne^(npix/a)) independently of the value of y. The ratio test on this comparison series shows that this series is guaranteed to converge only when x/a is positive, so the original series does as well. Borrowing from the integral test, since this series is monotone decreasing, we know its partial sum up to n = m is bounded by
    [tex]4 \frac{V_0}{\pi e^{\pi \frac{x}{a}}} + \int_1^m \frac{dt}{t e^{t \pi \frac{x}{a}}}[/tex]
    The error of the partial sum is then bounded by the partial sum of absolute values minus this term, since the true value of the series lies between. You will, of course, want a computer to do these calculations. You may also have better ideas for tighter comparisons.
    Once you have the value of n you need to sum up to for your chosen range of x values to get your chosen degree of error, you would then put the partial sum into a computer algebra system or write a program to get the function's approximate values and plot them. If you have Mathematica, for example, here is an example of plotting a 1-dimensional series.
  4. Mar 23, 2013 #3
    If you can use the symbolic tools in Matlab you might find the following:

    (note: the following is using Mathematica notation so you will have to translate it)

    In[1]:= Simplify[4Vo/Pi Sum[1/(2n+1)E^-((2n+1)Pi x/a)Sin[(2n+1)Pi y/a],{n,0,Infinity}]]

    Out[1]= ((2*I)*Vo*(-ArcTanh[E^(-((Pi*(x - I*y))/a))] + ArcTanh[E^(-((Pi*(x + I*y))/a))]))/Pi

    If you choose constant values for Vo and a and discard the very tiny complex component left over after doing that calculation for particular x and y and handle the places where this goes to infinity then you should be able to get yourself a plot.

    Test all this carefully before you depend on it.
  5. Mar 23, 2013 #4
    I didn't know Mathematica was that powerful of a symbolic simplifier. Very nice! =D Although you must still check for possible errors: there is an entire newsgroup that constantly comes up with oddball bugs in Mathematica's algorithms.
  6. Mar 23, 2013 #5
    I thought it would be as simple as:

    >> syms V0 n x y a
    >> for i=1:2:inf;

    but this returns nothing; no error nothing.

    This is more for personal enrichment, rather than a class... unless someone else comes by and posts some suggestions, I'll give an update when I figure this out over the next few days.
    Last edited: Mar 24, 2013
  7. Mar 25, 2013 #6
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook