How to make a surface plot involving an infinite series

Click For Summary

Discussion Overview

The discussion revolves around creating a surface plot in Matlab that involves an infinite series derived from solving Laplace's equation for electric potential on a 2D surface. Participants explore methods for calculating and visualizing the series, addressing both theoretical and practical aspects of implementation.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Exploratory
  • Homework-related

Main Points Raised

  • One participant presents the infinite series for electric potential, indicating the need to plot this over the x,y plane.
  • Another participant explains how to calculate the convergence of the series using partial sums and suggests methods for determining the necessary number of terms to achieve a desired margin of error.
  • A different participant shares a symbolic simplification approach using Mathematica, noting the need to translate it for Matlab use.
  • Concerns are raised about the reliability of Mathematica's symbolic simplification capabilities, with a reminder to check for potential errors.
  • One participant attempts a straightforward implementation in Matlab but encounters issues with the code returning no output, expressing a desire for personal enrichment rather than academic requirements.
  • Another participant suggests an alternative method using the symbolic sum function in Matlab, while also mentioning ongoing challenges with complex errors when not using the symbolic toolbox.

Areas of Agreement / Disagreement

Participants express various methods for approaching the problem, but there is no consensus on a single solution or approach. Several competing views and techniques are presented, indicating that the discussion remains unresolved.

Contextual Notes

Participants highlight limitations related to the convergence of the series, the need for careful testing of symbolic computations, and potential issues with complex components in the calculations.

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 ·
Replies
7
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K
Replies
7
Views
4K
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K