How to Create a 3D Plot of Electric Potential for Electromagnetism Homework?

Click For Summary
SUMMARY

This discussion focuses on creating 3D plots of electric potential V(x/y) for electromagnetism homework using various software tools. The user has attempted Microsoft Mathematics, Scilab, and Python but faced challenges, particularly with complex equations and the summation to infinity. MATLAB is mentioned as a preferred tool for plotting, with specific code provided for visualizing the potential for n=1. The user seeks additional resources or beginner-friendly guides for Scilab and Python to effectively plot the required equations.

PREREQUISITES
  • Understanding of electromagnetism concepts, specifically electric potential.
  • Familiarity with programming basics in Python and Scilab.
  • Knowledge of MATLAB syntax for 3D plotting.
  • Ability to interpret mathematical equations and summations.
NEXT STEPS
  • Learn how to use Python's Matplotlib library for 3D plotting.
  • Explore Scilab's plotting functions for visualizing complex equations.
  • Study MATLAB's handling of infinite summations in 3D plots.
  • Review Griffiths' "Introduction to Electrodynamics" for additional context on electric potential equations.
USEFUL FOR

This discussion is beneficial for students in electromagnetism courses, particularly those struggling with programming and visualization of electric potential equations. It is also useful for educators and tutors assisting students with similar challenges.

jplcarpio
Messages
7
Reaction score
0
Hi all, I apologize in advance if this isn't the right forum to put my question.


Homework Statement


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. :(


Homework Equations


There were three examples:

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


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:
Physics news on Phys.org
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...
 
wukunlin said:
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...


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! :)
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 26 ·
Replies
26
Views
6K
Replies
8
Views
2K
Replies
4
Views
2K
Replies
4
Views
2K
Replies
1
Views
6K
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
34K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 9 ·
Replies
9
Views
3K