How to make a surface plot involving an infinite series

AI Thread Summary
The discussion focuses on creating a surface plot in MATLAB for the electric potential V(x,y) derived from Laplace's equation, expressed as an infinite series. The series converges, and the approach involves determining a suitable value of n to achieve a desired margin of error. This is done by calculating partial sums and bounding the error using comparisons, such as the sine function's limits and the ratio test for convergence. Participants suggest using MATLAB's symbolic toolbox to compute the series and plot the results. An example of a MATLAB command is provided, demonstrating how to sum the series up to a specified n value and visualize it with the `ezsurf` function. There are mentions of potential complexities and errors in calculations, particularly when not using symbolic tools. The conversation emphasizes the importance of testing and validating results, especially when relying on software for symbolic computations.
pr0me7heu2
Messages
13
Reaction score
2
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:
Physics news on Phys.org
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
4 \frac{V_0}{\pi e^{\pi \frac{x}{a}}} + \int_1^m \frac{dt}{t e^{t \pi \frac{x}{a}}}
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.
 
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.
 
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.
 
I thought it would be as simple as:

>> syms V0 n x y a
>> for i=1:2:inf;
i=n;
s=1/n*exp(-n*pi*x/a)*sin(n*pi*y/a);
end
f=4*V0/pi*s;
ezsurf(f)

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:
The easiest way to do it is:

syms x y n
v=4/pi*symsum(1/(2*n+1)*exp(-(2*n+1)*pi*x)*sin((2*n+1)*pi*y),n,0,100);
ezsurf(v)

https://docs.google.com/file/d/0B56mzK7jKc5ebE9nYlNVMUhuWVk/edit?usp=sharing



...still trying to work out complex errors if I try to do this without symbolic toolbox.
 

Similar threads

Replies
7
Views
2K
Replies
3
Views
2K
Replies
3
Views
2K
Replies
1
Views
1K
Replies
2
Views
2K
Replies
5
Views
4K
Back
Top