Robert Israel

6522 Reputation

21 Badges

18 years, 186 days
University of British Columbia
Associate Professor Emeritus
North York, Ontario, Canada

MaplePrimes Activity


These are replies submitted by Robert Israel

Just that solve usually doesn't find solutions for transcendental equations.  The fact that there happens to be a simple solution doesn't help if there's no reasonable way to find that solution.

 

Just that solve usually doesn't find solutions for transcendental equations.  The fact that there happens to be a simple solution doesn't help if there's no reasonable way to find that solution.

 

If you are using spacestep = 1/10000 with a range of 0 .. 1, that means you are calculating that for each time step you have at least 10000 values of u(x,t).  With timestep = 1/10000, calculating a value at, say, t = 1 would involve 10^8 values of
u(x,t).  This is likely to be rather time-consuming, and if those values are all saved it will consume a huge chunk of memory as well.  But this worked for me in Maple 13:


> g := piecewise(t <= 1/80, piecewise(x <= 2/3, k[1], 2/3 < x, k[2]),
 1/80 < t and t <= 2*(1/80), 0, 2*(1/80) < t and t < 3/80, 
 piecewise(x <= 2/3, k[1], 2/3 < x, k[2]), 3/80 < t and t < 4*(1/80),
 0, 4*(1/80) < t and t < 5*(1/80), piecewise(x <= 2/3, k[1], 
 2/3 < x, k[2]), 5*(1/80) < t and t < 6*(1/80), 0, 6*(1/80) < t 
 and t < 7/80, piecewise(x <= 2/3, k[1], 2/3 < x, k[2]), 7/80 < t 
 and t < 8*(1/80), 0, 8*(1/80) < t and t < 9/80, piecewise(x 
 <= 2/3, k[1], 2/3 < x, k[2]), 9/80 < t and t < 10*(1/80), 0, 
 10*(1/80) < t and t < 11/80, piecewise(x <= 2/3, k[1], 2/3 < x,
 k[2]), 11/80 < t and t < 12*(1/80), 0);
 k[1]:= 1; k[2]:= 2; a:= 1/100;
 PDE := diff(u(x, t), t) = g*(diff(u(x, t), x))+diff(u(x, t), x, x);
 IBC := {u(0, t) = 0, u(1, t) = 0, u(x, 0) = exp(-(x-2/3)^2/(2*a^2))/
  ((2*Pi)^(1/2)*a)};
 pds := pdsolve(PDE, IBC, numeric, time = t, range = 0 .. 1, 
   timestep = 1/10000, spacestep = 1/10000, optimize = true);
 R := pds:-value(output = listprocedure);
 uu:= subs(R,u(x,t));
 evalf(Int(uu(x,0.2),x=0..1,method=_Dexp));

0.1435771715

It took about 190 seconds of CPU time on my computer.

If you are using spacestep = 1/10000 with a range of 0 .. 1, that means you are calculating that for each time step you have at least 10000 values of u(x,t).  With timestep = 1/10000, calculating a value at, say, t = 1 would involve 10^8 values of
u(x,t).  This is likely to be rather time-consuming, and if those values are all saved it will consume a huge chunk of memory as well.  But this worked for me in Maple 13:


> g := piecewise(t <= 1/80, piecewise(x <= 2/3, k[1], 2/3 < x, k[2]),
 1/80 < t and t <= 2*(1/80), 0, 2*(1/80) < t and t < 3/80, 
 piecewise(x <= 2/3, k[1], 2/3 < x, k[2]), 3/80 < t and t < 4*(1/80),
 0, 4*(1/80) < t and t < 5*(1/80), piecewise(x <= 2/3, k[1], 
 2/3 < x, k[2]), 5*(1/80) < t and t < 6*(1/80), 0, 6*(1/80) < t 
 and t < 7/80, piecewise(x <= 2/3, k[1], 2/3 < x, k[2]), 7/80 < t 
 and t < 8*(1/80), 0, 8*(1/80) < t and t < 9/80, piecewise(x 
 <= 2/3, k[1], 2/3 < x, k[2]), 9/80 < t and t < 10*(1/80), 0, 
 10*(1/80) < t and t < 11/80, piecewise(x <= 2/3, k[1], 2/3 < x,
 k[2]), 11/80 < t and t < 12*(1/80), 0);
 k[1]:= 1; k[2]:= 2; a:= 1/100;
 PDE := diff(u(x, t), t) = g*(diff(u(x, t), x))+diff(u(x, t), x, x);
 IBC := {u(0, t) = 0, u(1, t) = 0, u(x, 0) = exp(-(x-2/3)^2/(2*a^2))/
  ((2*Pi)^(1/2)*a)};
 pds := pdsolve(PDE, IBC, numeric, time = t, range = 0 .. 1, 
   timestep = 1/10000, spacestep = 1/10000, optimize = true);
 R := pds:-value(output = listprocedure);
 uu:= subs(R,u(x,t));
 evalf(Int(uu(x,0.2),x=0..1,method=_Dexp));

0.1435771715

It took about 190 seconds of CPU time on my computer.

AFAIK, the closest thing to such an option is that you can set PlotBGColor in the maplexx.ini file, but this only affects plots to the "window" device in the Classic GUI.

AFAIK, the closest thing to such an option is that you can set PlotBGColor in the maplexx.ini file, but this only affects plots to the "window" device in the Classic GUI.

I don't know.  Maybe if you post your actual code, somebody could figure out what's causing that.

I don't know.  Maybe if you post your actual code, somebody could figure out what's causing that.

The simplest way is to display the plot together with a solid rectangle of the appropriate size.  Regions in a display are rendered "front to back", so make
the background rectangle the last item in the display (this will only matter, I think, if there are filled regions in your plot).  Thus:

> P1:= plot(whatever...): 
# say for this plot x goes from x1 to x2 and y from y1 to y2 
  Background:= plottools[rectangle]([x1,y1],[x2,y2],colour=cyan):
  plots:-display([P1, Background]);

 

 

The simplest way is to display the plot together with a solid rectangle of the appropriate size.  Regions in a display are rendered "front to back", so make
the background rectangle the last item in the display (this will only matter, I think, if there are filled regions in your plot).  Thus:

> P1:= plot(whatever...): 
# say for this plot x goes from x1 to x2 and y from y1 to y2 
  Background:= plottools[rectangle]([x1,y1],[x2,y2],colour=cyan):
  plots:-display([P1, Background]);

 

 

In other words, BesselJ(v,x) and BesselY(v,x) form a basis for the solutions of the Bessel equation.  One way of characterizing which of these solutions is BesselJ and which is BesselY is in terms of the asymptotics as x -> infinity:

BesselJ(v,x) ~ sqrt(2*Pi/x)*cos(x - Pi/4 - v*Pi/2) + O(x^(3/2))

BesselY(v,x) ~ sqrt(2*Pi/x)*sin(x - Pi/4 - v*Pi/2) + O(x^(-3/2))

In other words, BesselJ(v,x) and BesselY(v,x) form a basis for the solutions of the Bessel equation.  One way of characterizing which of these solutions is BesselJ and which is BesselY is in terms of the asymptotics as x -> infinity:

BesselJ(v,x) ~ sqrt(2*Pi/x)*cos(x - Pi/4 - v*Pi/2) + O(x^(3/2))

BesselY(v,x) ~ sqrt(2*Pi/x)*sin(x - Pi/4 - v*Pi/2) + O(x^(-3/2))

You might try something like this.

> costosin:= proc(expr)
    simplify(expr, map(t -> (t^2 = 1 - sin(op(t))^2),
                     indets(expr, specfunc(anything,cos))))
    end proc;

So for example:

> costosin(cos(x)^2*cos(y)^2 + sin(x)^2*sin(y)^2);

2*sin(x)^2*sin(y)^2-sin(x)^2+1-sin(y)^2

You might try something like this.

> costosin:= proc(expr)
    simplify(expr, map(t -> (t^2 = 1 - sin(op(t))^2),
                     indets(expr, specfunc(anything,cos))))
    end proc;

So for example:

> costosin(cos(x)^2*cos(y)^2 + sin(x)^2*sin(y)^2);

2*sin(x)^2*sin(y)^2-sin(x)^2+1-sin(y)^2

It should work.  Did you include the definitions of p1 and p2 from your previous message?  My guess is that you've left something out.  For convenience, here it is in one group.  I've cleaned it up a little by removing some unnecessary displays.

> S1:= unapply(u*FresnelS(u)+((1/Pi)*cos((1/2)*Pi*u^2))-(1/Pi),u): 
  C1:= unapply(u*FresnelC(u)-((1/Pi)*sin((1/2)*Pi*u^2)),u): 
  with(plottools): 
  with(plots):
  u0:= sqrt(0.25): 
  e1:= evalf(FresnelC(u0)+FresnelS(u0)*cot((3*Pi)/8)): 
  p1:= plot([FresnelC(u),FresnelS(u),u=0..u0]):
  p2:= plot(x-e1,x=0..1,y=0..1,colour=black):
  p3:= reflect(p1,[[e1,0],[FresnelC(u0),FresnelS(u0)]]):
  display(p1,p2,p3);
First 44 45 46 47 48 49 50 Last Page 46 of 187