16.12.2012 Views

Computer Algebra Recipes

Computer Algebra Recipes

Computer Algebra Recipes

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

5.1. CHECKING SOLUTIONS 221<br />

> L:=f->simplify(Laplacian(f,'cartesian'[x,y])):<br />

Applying L to u and to v yields zero, con¯rming that these functions satisfy<br />

Laplace's equation and can be regarded as real potentials.<br />

> L(u); L(v);<br />

0 0<br />

To con¯ne our attention to the region outside the cylinder, two piecewise functions,<br />

pw1 and pw2 , are formed which are equal to zero for x2 + y2 < 1andu<br />

and v, respectively, outside this circular region.<br />

> pw1:=piecewise(x^2+y^2=1,u);<br />

( 2 2 0 x + y < 1<br />

pw1 := x<br />

x + 1 · x2 + y2 x 2 + y 2<br />

> pw2:=piecewise(x^2+y^2=1,v):<br />

A contour plot operator CP is formed to plot the equipotentials for a given<br />

potential function f. The color C must also be speci¯ed. The contours are<br />

drawn for potentials equal to 0:2 n, withn ranging from ¡11 to +11. The grid<br />

spacing is taken to be 90 £ 90, and constrained scaling is imposed.<br />

> CP:=(f,C)->contourplot(f,x=-2..2,y=-2..2,contours=<br />

[seq(0.2*n,n=-11..11)],grid=[90,90],color=C,<br />

scaling=constrained,thickness=2):<br />

The curves corresponding to constant u are colored red, those corresponding<br />

to constant v colored blue. The two sets of curves are superimposed. A blackand-white<br />

version of the plot is shown in Figure 5.4.<br />

> display(fCP(pw1,red),CP(pw2,blue)g);<br />

2<br />

y<br />

–2 x 2<br />

–2<br />

Figure 5.4: Equipotentials and electric ¯eld lines outside a conducting cylinder.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!