moremath

15 Reputation

One Badge

8 years, 273 days

MaplePrimes Activity


These are questions asked by moremath

I would like to plot a function u(r,theta,z) where r, theta, and z are standard cylindrical coordinates.  I would like u to be illustrate on the domain (say the unit cylinder) by a color scheme, say blue = minimum and red = maximum value of u.

Does anyone have any ideas how I could do this?

Heather

I am trying to solve the wave equation in polar coordinates.  The initial condition on u is given by f(r,theta) and the initial condition on u_t is zero.  The weight function is w(r).  I am not sure why it will not evaluate this as I know the solution remains finite on the domain (the unit disk).  Here is the code: 
 

Wave Equation in Polar Coordinates

restart; with(plots); addcoords(u_cylindrical, [u, r, theta], [r*cos(theta), r*sin(theta), u])

Example:

rho := 1; 1; c := 1; 1; w := proc (r) options operator, arrow; r end proc

1

 

1

 

proc (r) options operator, arrow; r end proc

(1)

f := proc (r, theta) options operator, arrow; 2.5*(1-r^2)*r*sin(theta) end proc

proc (r, theta) options operator, arrow; 2.5*(1-r^2)*r*sin(theta) end proc

(2)

assume('n', integer); 1; assume('m', integer)

lambda := proc (n, m) options operator, arrow; BesselJZeros(n, m)^2/rho^2 end proc;

proc (n, m) options operator, arrow; BesselJZeros(n, m)^2/rho^2 end proc

(3)

c0 := proc (m) options operator, arrow; (int(int(f(r, theta)*BesselJ(0, sqrt(lambda(0, m))*r)*w(r), theta = -Pi .. Pi), r = 0 .. rho))/(int(int(BesselJ(0, sqrt(lambda(0, m))*r)^2*w(r), theta = -Pi .. Pi), r = 0 .. rho)) end proc; 1; a := proc (n, m) options operator, arrow; (int(int(f(r, theta)*BesselJ(n, sqrt(lambda(n, m))*r)*cos(n*theta)*w(r), theta = -Pi .. Pi), r = 0 .. rho))/(int(int(BesselJ(n, sqrt(lambda(n, m))*r)^2*cos(n*theta)^2*w(r), theta = -Pi .. Pi), r = 0 .. rho)) end proc; 1; b := proc (n, m) options operator, arrow; (int(int(f(r, theta)*BesselJ(n, sqrt(lambda(n, m))*r)*sin(n*theta)*w(r), theta = -Pi .. Pi), r = 0 .. rho))/(int(int(BesselJ(n, sqrt(lambda(n, m))*r)^2*sin(n*theta)^2*w(r), theta = -Pi .. Pi), r = 0 .. rho)) end proc

proc (m) options operator, arrow; (int(int(f(r, theta)*BesselJ(0, sqrt(lambda(0, m))*r)*w(r), theta = -Pi .. Pi), r = 0 .. rho))/(int(int(BesselJ(0, sqrt(lambda(0, m))*r)^2*w(r), theta = -Pi .. Pi), r = 0 .. rho)) end proc

 

proc (n, m) options operator, arrow; (int(int(f(r, theta)*BesselJ(n, sqrt(lambda(n, m))*r)*cos(n*theta)*w(r), theta = -Pi .. Pi), r = 0 .. rho))/(int(int(BesselJ(n, sqrt(lambda(n, m))*r)^2*cos(n*theta)^2*w(r), theta = -Pi .. Pi), r = 0 .. rho)) end proc

 

proc (n, m) options operator, arrow; (int(int(f(r, theta)*BesselJ(n, sqrt(lambda(n, m))*r)*sin(n*theta)*w(r), theta = -Pi .. Pi), r = 0 .. rho))/(int(int(BesselJ(n, sqrt(lambda(n, m))*r)^2*sin(n*theta)^2*w(r), theta = -Pi .. Pi), r = 0 .. rho)) end proc

(4)

u := proc (n, m, r, theta, t) options operator, arrow; sum(BesselJ(0, sqrt(lambda(0, j))*r)*c0(j)*cos(sqrt(lambda(0, j))*c*t), j = 1 .. m)+sum(sum(BesselJ(i, sqrt(lambda(i, j))*r)*(a(i, j)*cos(i*theta)+b(i, j)*sin(i*theta))*cos(sqrt(lambda(i, j))*c*t), j = 1 .. m), i = 1 .. n) end proc

proc (n, m, r, theta, t) options operator, arrow; sum(BesselJ(0, sqrt(lambda(0, j))*r)*c0(j)*cos(sqrt(lambda(0, j))*c*t), j = 1 .. m)+sum(sum(BesselJ(i, sqrt(lambda(i, j))*r)*(a(i, j)*cos(i*theta)+b(i, j)*sin(i*theta))*cos(sqrt(lambda(i, j))*c*t), j = 1 .. m), i = 1 .. n) end proc

(5)

soln := evalf(u(3, 3, r, theta, t));

(Float(infinity)+Float(infinity)*I)*BesselJ(1., 3.831705970*r)*sin(theta)*cos(3.831705970*t)+(Float(infinity)+Float(infinity)*I)*BesselJ(1., 7.015586670*r)*sin(theta)*cos(7.015586670*t)+(Float(infinity)+Float(infinity)*I)*BesselJ(1., 10.17346814*r)*sin(theta)*cos(10.17346814*t)-0.3676566232e-9*BesselJ(2., 5.135622302*r)*sin(2.*theta)*cos(5.135622302*t)-0.1879633956e-10*BesselJ(2., 8.417244140*r)*sin(2.*theta)*cos(8.417244140*t)-0.5146823927e-10*BesselJ(2., 11.61984117*r)*sin(2.*theta)*cos(11.61984117*t)+(Float(infinity)+Float(infinity)*I)*BesselJ(3., 6.380161896*r)*sin(3.*theta)*cos(6.380161896*t)+(Float(infinity)+Float(infinity)*I)*BesselJ(3., 9.761023130*r)*sin(3.*theta)*cos(9.761023130*t)+(Float(infinity)+Float(infinity)*I)*BesselJ(3., 13.01520072*r)*sin(3.*theta)*cos(13.01520072*t)

(6)

plot3d(soln, r = 0 .. 1, theta = 0 .. 2*Pi, coords = u_cylindrical, axes = boxed)

NULL

NULL


 

Download Section_6.3.mw

Any assistance would be greatly appreciated. 

I have computed the eigenfunction expansion for f(x)=x on 0<x<1 in terms of the eigenfunctions exp(-x/2)*sin(n*Pi*x).

I wish to calculate the weighted L2 error in this expansion (the weight function is w(x)=exp(x)).

Specifically, I want to determine how many terms in the eigenfunction expansion are necessary for the error to be less than say 0.3.

Here is the code:

f := x -> x
w := x -> exp(x)
assume('n', integer);
y :=  (n, x) -> exp(-x/2) sin(n Pi x)       
c := n-> (int(f(x)*y(n, x)*w(x), x = 0 .. 1))/(int(y(n, x)^2*w(x), x = 0 .. 1))
Fourierf := (n, x) -> sum(c(j)*y(j, x), j = 1 .. n)

fsolve(Lerror(n) = 0.3, n);

This seems to run forever without giving a value of n.  I know this is a large computation, but it seems that Maple should be able to handle it.  Does anyone have any suggestions?

Heather

 

Page 1 of 1