Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168728
Image: ubuntu2004

This notebook compares the exact electric field of a dipole with the approximations developed in Section 14.6 of Chabay and Sherwood's Matter and Interactions textbook.

import numpy
k=9.0e9 #=1/(4*pi*e0) in N m^2/C^2

Define functions for the exact and approximate fields

def ExactField(r,s,q): return k*2.0*q*s*r/(r-s/2.0)^2/(r+s/2.0)^2
def ApproxField(r,s,q): return k*2.0*q*s/r^3

Define some constants and indicate that r is a variable

s=0.1e-9 #Separation in m q=1.60217646e-19 #charge in Coulombs r=var('r')

Plot the results

pexact=plot(ExactField(r,s,q),0.2e-9,0.5e-9,rgbcolor=hue(0.8)) #Plotted Function lexact=text('Exact',(4e-10,4e10),rgbcolor=hue(0.8)) #Legend Label papprox=plot(ApproxField(r,s,q),0.2e-9,0.5e-9,rgbcolor=hue(0.6))#Plotted Function lapprox=text('Approximate',(4e-10,3.5e10),rgbcolor=hue(0.6),axes_labels=['r (m)','|E| (N/C)']) #Legend Label show(pexact+papprox+lexact+lapprox) #display the figure

Why not make a similar plot for the fields along a perpendicular axis, since the textbook discusses this case as well?

def ExactFieldPerp(r,s,q): return k*q*s/((s/2.0)^2+r^2)^(3/2)
def ApproxFieldPerp(r,s,q): return k*q*s/r^3
pexactp=plot(ExactFieldPerp(r,s,q),0.1e-9,0.4e-9,rgbcolor=hue(0.8)) #Plotted Function lexactp=text('Exact',(3e-10,8e10),rgbcolor=hue(0.8)) #Legend Label papproxp=plot(ApproxFieldPerp(r,s,q),0.1e-9,0.4e-9,rgbcolor=hue(0.6),axes_labels=['r (m)','|E| (N/C)'])#Plotted Function lapproxp=text('Approximate',(3e-10,1e11),rgbcolor=hue(0.6)) #Legend Label show(pexactp+papproxp+lexactp+lapproxp) #display the figure