Preben Alsholm

13728 Reputation

22 Badges

20 years, 240 days

MaplePrimes Activity


These are answers submitted by Preben Alsholm

If both the following redefinitions are made to `plots/animate` then animate works:

`plots/animate`:=subs(subs=((x,y)->eval(y,x)),eval(`plots/animate`)):
`plots/animate`:=subs(evalf=(()->args),eval(`plots/animate`)):

animate(PointPlot, [L[t]], t=1..5,frames=5,digits=13);
animate(PointPlot, [L[round(t)]], t=1..5,paraminfo=false);

While the first change is safe and works fine (in my opinion - I have used it a lot since 2007), the last one surely is not, but it points to the problem.

In this case the last change makes the title weird looking. I have set digits=13 just to call attention to the title problem That issue is, however, easily fixed.

Preben Alsholm

restart;
A:=Matrix(3,5,symbol=a);
<seq(LinearAlgebra:-Row(A,i),i=combinat:-randperm(3))>;

Preben Alsholm

How about putting all of your procedures into a module:

M:=module() export a,b,c,..,d; local A,B,C, ..., D; global g1, g2, ..., gn;
a:=proc(x,y) ....end proc;
b:=proc(x,y,z) ... end proc;
....
end module;

Preben Alsholm
 

If you use piecewise, life is easier.

restart;
eq:=diff(q(t), t) =piecewise(t<8760,3-3*q(t)/10^4, -3*q(t)/10^4);
#First version:
p1:=dsolve({eq, q(0)=0}, type=numeric, range=0..16000):
plots[odeplot](p1,refine=1);
#Second version:
DEtools[DEplot](eq,q(t),t=0..16000,[q(0)=0],linecolor=blue,color=gray);

 

Preben Alsholm
 

Doug Meade's version may be written somewhat shorter this way:

XY := proc(T,H)
  global integ;
  if not ( T::numeric and H::numeric ) then return ['procname'(args)[1],'procname'(args)[2]] end if;
  integ(parameters=[H]);
  eval( [x(t),y(t)], integ(T) );
end proc:
XY(2,1);
                 [2.08917117586676548, 1.35878133507557242]
XY(u,8);
                         [XY(u, 8)[1], XY(u, 8)[2]]

plot3d( XY(t,H), t=0..3, H=-1..5, color=[red,blue], transparency=0.5, axes=boxed );

It should be noticed that when XY returns 'unevaluated', it returns a list, just as in the case of numeric input. (This means that strictly speaking, it doesn't return unevaluated).

Otherwise the plot3d won't work.

Simple tests (see below) seems to indicate that the XY- version takes about half the time compared to the separate X, Y - version.
Not really surprising.

Preben Alsholm


t0:=time():
for k to 100 do
   for j to 100 do
    XY(j*.1,k*.1)
   end do
end do:
time()-t0;
t0:=time():
for k to 100 do
   for j to 100 do
    [X(j*.1,k*.1),Y(j*.1,k*.1)]
   end do
end do:
time()-t0;

 

If you are using 2D-math, then the following assignment

f(t):= t^2

is considered ambiguous by Standard Maple.

If you intend to define a function, then the proper definition is

f:= t -> t^2;

If you use Maple Notation for your input (which I always do, and ask my students to do), then the assignment

f(t):= t^2;

is writing to the remember table for the function f. This means that f now knows what to do if it literally receives the letter t. It won't know what to do about anything else, unless of course you have already defined f as a function (= procedure), as in

restart;

f:= t -> t^2;

f(t):=411;

Now try

f(t);

f(6),

f(x);

Besides asking my students to use Maple input, I ask them to use Worksheet interface.

These setting can be changed by going to  Tools/Options/Display  and Tools/Options/Interface.

 

Preben Alsholm

If you use the long form of polarplot, plots:-polarplot (or plots[polarplot]) the plot is fine:

Explore(plots:-polarplot(1+a*cos(theta), theta = 0 .. 2*Pi)) ;

 

Preben Alsholm

I'm not sure what you want to do, but is this anywhere close?

for k to 10 do fnormal(10^(-k),7) end do;
 

Preben Alsholm

Another (obvious) solution is to place with(plots): outside the loops.

Preben Alsholm


 

I have changed the syntax for the initial and boundary conditions and used Pi instead of pi (in this case not important as you will notice, since I replace it by evalf(Pi)).

Also all u's have been made u[0]'s.

eq_u_0 := diff(u[0](x,t),`$`(x,4))+a*u[0](x,t)+diff(u[0](x,t),`$`(t,2))=0;
bc_u0 :=u[0](0,t) = 0, u[0](Pi,t) = 0, D[1,1](u[0])(0,t) = 0, D[1,1](u[0])(Pi,t) = 0, u[0](x,0) =a*sin(x), D[2](u[0])(x,0) = 0;
#Exact solution, no conditions:
pdsolve(eq_u_0);
#Numerical solution (for a = 1):
M:=pdsolve(op(eval([eq_u_0,{bc_u0}],{a=1,Pi=evalf(Pi)})),numeric);
M:-plot(x=0..Pi,t=1);
M:-animate(x=0..Pi,t=0..10,frames=100);
 

Preben Alsholm

I added two options (in Maple 13.02):

ff:=dsolve(syst union CI,{x(t),y(t)},type=numeric,output=listprocedure,maxfun=0,range=0..0.1);

fx := subs(ff,x(t)): fy := subs(ff,y(t)):
fx(0), fy(0);
fx(.01);
plot(fx,0..0.1);
plot(fy,0..0.1);
 

The plots are rather wild.

Preben Alsholm

In Maple 13 you can do

solve(cos(2*theta)=1/2,theta,AllSolutions);

I don't think you can do that in Maple 10, but you can do this (also in Maple 13) (notice the underscore):

_EnvAllSolutions:=true:
solve(cos(2*theta)=1/2,theta);

Here B1 can be 0 or 1 and Z1 represents an (arbitrary) integer.

Preben Alsholm
 

 

Your equation 12 should have ( ) instead of [ ].

Preben Alsholm

 

I don't know exactly what you mean by saying "it is for x = 0", since in fact you plot for x = 0..10.

However, your functions drops in magnitude really fast, so plotting in the interval x = 0..0.001 makes it possible to actually see waves.

restart;
u:=A*exp(-sqrt(w/(2*a^(2)))*x)*cos(-sqrt(w/(2*a^(2)))*x+w*t);
w:=10;
A:=4;
a:= 4*10^(-3);
plot3d(u, x = 0..0.001, t = 0 .. 2,axes=boxed);

Preben Alsholm
 

You may do something like this: Start orbits in directions of eigenvectors of the jacobian at the saddle point and close to it (epsilon below).

with(LinearAlgebra):
G:=(k,c)->c*(alpha*k^(alpha-1)-delta-rho-theta*g)/theta;
F:=(k,c)->k^alpha-c-(n+g+delta)*k;
J:=unapply(VectorCalculus:-Jacobian([F(k,c),G(k,c)],[k,c]),k,c):
J(25,3.5);
Lambda,V:=op(simplify([Eigenvectors(%)]));
#Using simplify to remove 0.*I
eps:=.01:
ivp:=[[k(0) = kss+Column(V,1)[1]*eps, c(0) = css+Column(V,1)[2]*eps],[k(0) = kss-Column(V,1)[1]*eps, c(0) = css-Column(V,1)[2]*eps],[k(0) = kss+Column(V,2)[1]*eps, c(0) = css+Column(V,2)[2]*eps],[k(0) = kss-Column(V,2)[1]*eps, c(0) = css-Column(V,2)[2]*eps]];
phase := DEplot(RAMSEY, [k(t), c(t)], t = -200 .. 100, k = 0 .. 100, c = 0 .. 10, ivp,arrows = small, title = `Ramseyho model`, color = magnitude,linecolor=red,stepsize=.1);
display({nulc, nulk, phase});
 

Preben Alsholm

First 153 154 155 156 157 158 159 Page 155 of 160