# 3D plot of electrical potential

1. Aug 20, 2011

### jplcarpio

Hi all, I apologize in advance if this isn't the right forum to put my question.

1. The problem statement, all variables and given/known data
In our electromagnetism course, we were asked to give the 3D plots of the electric potential V(x/y) for the examples on our book. (We're currently using Introduction to Electrodynamics (3rd Ed.) by Griffiths.) Unfortunately, I have no background in programming though our professor assumes that all of us do. :(

2. Relevant equations
There were three examples:

[PLAIN]http://img820.imageshack.us/img820/9798/tograph1.jpg [Broken]
[PLAIN]http://img688.imageshack.us/img688/2117/tograph2.jpg [Broken]
[PLAIN]http://img694.imageshack.us/img694/1479/tograph3.jpg [Broken]

3. The attempt at a solution
I've gotten a copy of Microsoft Mathematics, Scilab and Python. When I tried it on Mathematics, the program stated that the equation was too complex. As for Scilab and Python, I'm still trying to cram how-to's.

Are there other programs I can use? Or are there newbie-friendly how-to's for Scilab and Python that cover 3D plots for the three equations?

I'm already a bit desperate, I'm a few steps short of just having a friend plot it for me. :(

Last edited by a moderator: May 5, 2017
2. Aug 20, 2011

### wukunlin

hmmm, I'm not sure how to do those with the summation to infinity, but if there were non of those summations, then it would be really easy with matlab (I assume scilab is a free alternative of matlab so they should function similarly)

in matlab, for example, the first term of your first example, plotting the potential I would do the following:

n = 1;
V0 = 1; a = 1; % or whatever your V0 or a are supposed to be
x = -1:0.01:1; %this specifies x from -1 to +1 in 0.01 step size
y = -1:0.01:1; %this specifies y from -1 to +1 in 0.01 step size
[xx, yy] = meshgrid(x,y);
V = 4*V0/pi*1/n*exp(-n*pi*xx/a).*sin(n*pi*yy/a);
surf(x,y,V)

that will plot the case for n=1, as for n=3, n=5 etc, I'm not sure how that will work. You can do them each manually, obtaining V1, V3, V5 for n=1, n=3, n=5 respectively and add them all up, but since the summation continues until n = +inf, this probably isn't the approach...

3. Aug 20, 2011

### jplcarpio

One of my friends suggested something like this, however I need n= +inf. :( I tried plotting the first equation in MS Math, and it just gave me a horizontal plane which I doubt is the answer.

I'll still try out your suggestion, perhaps I can improvise a way. (But if someone out there has the magical solution, I'm wide open for suggestions. :D ) Thanks! :)