Preben Alsholm

13663 Reputation

22 Badges

19 years, 319 days

MaplePrimes Activity


These are replies submitted by Preben Alsholm

Yes, that bug is old. I told Maple about it a long time ago, on October 10 2007.

The answer I got was:

"We have entered this issue into our internal bug-tracker. Thank you for bringing this to our attention."

The Maple version then must have been Maple 11. But nothing changed in Maple 12 or 13.

I still (!) don't have Maple 14.

The remedy I use, and which I also suggested at the time, is to replace the occurrences of subs with eval.

I have used the following redefinition with success and seemingly with no bad side effects:

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

Preben Alsholm

Sum(ln(1+1/n)/n,n=1..N) = Sum(ln(n)/n/(n-1),n=2..N+1)+ln(N+1)/(N+1);

so the two infinite series have the same sum. Convergence follows by comparison to Sum(ln(n)/n^2,n=2..infinity), which is seen to be convergent by using e.g. the integral test.

 

Preben Alsholm

I guess it is related to the fact that `evalf/Sum` (in Maple 13) cannot handle this simpler one either:

Sum(ln(n)/n^2,n=2..infinity);

In this case though, sum can find an expression for the sum,  -Zeta(1, 2) , and that is known to evalf.

Also evalf(Sum(ln(n)/n^3,n=2..infinity)) fails, but evalf(Sum(ln(n)/n^4,n=2..infinity)) is OK.

Preben Alsholm

 

Just to keep you updated:

Maple 14 has not yet arrived. I guess Denmark is far away, at least on the priority list. The company handling the distribution is called Adept Scientific. Maybe they should consider changing their name to, .. well, you guessed it.

Preben Alsholm

You may try these two approaches.

restart;
eq:=diff(q(t), t) =piecewise(t<T,3-3*q(t)/10^4, -3*q(t)/10^4);
#Version 1
p1:=dsolve({eq, q(0)=0}, numeric, parameters=[T],range=0..2*T):
p1(parameters=[4380]):
plots[odeplot](p1,0..16000,refine=1);

#Version 2

EQ:=unapply(eq,T);
DEtools[DEplot](EQ(4380),q(t),t=0..16000,[q(0)=0],linecolor=blue,color=gray);

#Animations. The second first.
plots[animate](DEtools[DEplot],[EQ(T),q(t),t=0..16000,q=0..10000,[q(0)=0],linecolor=blue,color=gray,stepsize=50],T=2000..8000);

#Now the first version.
#Make a small procedure, so that the parameter can be set.
PP:=proc(T1) p1(parameters=[T1]); plots[odeplot](p1,0..16000,refine=1) end proc;
plots[animate](PP,[T1],T1=2000..8000);

As far as sliders etc, you may look into Components in the panel to the left in Standard Maple.

Preben Alsholm

You may try these two approaches.

restart;
eq:=diff(q(t), t) =piecewise(t<T,3-3*q(t)/10^4, -3*q(t)/10^4);
#Version 1
p1:=dsolve({eq, q(0)=0}, numeric, parameters=[T],range=0..2*T):
p1(parameters=[4380]):
plots[odeplot](p1,0..16000,refine=1);

#Version 2

EQ:=unapply(eq,T);
DEtools[DEplot](EQ(4380),q(t),t=0..16000,[q(0)=0],linecolor=blue,color=gray);

#Animations. The second first.
plots[animate](DEtools[DEplot],[EQ(T),q(t),t=0..16000,q=0..10000,[q(0)=0],linecolor=blue,color=gray,stepsize=50],T=2000..8000);

#Now the first version.
#Make a small procedure, so that the parameter can be set.
PP:=proc(T1) p1(parameters=[T1]); plots[odeplot](p1,0..16000,refine=1) end proc;
plots[animate](PP,[T1],T1=2000..8000);

As far as sliders etc, you may look into Components in the panel to the left in Standard Maple.

Preben Alsholm

The tilde is superfluous as it is designed for elementwise operations on containers, i.e. sets, lists Vectors, Matrices, Arrays, and tables, and has no effect on other types, in this case `+`.

Preben Alsholm

 

The tilde is superfluous as it is designed for elementwise operations on containers, i.e. sets, lists Vectors, Matrices, Arrays, and tables, and has no effect on other types, in this case `+`.

Preben Alsholm

 

Well, it seems to be correct in Maple 13.02.

Preben Alsholm

Since you don't have a more recent version of Maple (I guessed you use Maple 5.1 from your worksheet), allow me to reproduce from the help pages in Maple 13:

'range'= numeric...numeric
Values that specify the range of the independent variable over which solution values are desired.
For IVPs and DAEs this option is used only by the non-stiff and stiff default methods (rkf45, rosenbrock, rkf45_dae, rosenbrock_dae) and the taylorseries method. It has two purposes for procedure-type output. If 'range' is used, then the call to dsolve computes the solution over the desired range before returning, storing that solution for later calls to the returned procedure, which then compute the return values through interpolation.
 

and about maxfun (cut short)

The option maxfun=n in the call to dsolve,numeric gives an upper limit on the total number of function evaluations.
For the rkf45 and rosenbrock methods, the default setting is maxfun=30000, while for the classical methods, the default setting is maxfun=50000.
A setting of maxfun=0 disables the option.

Preben Alsholm

Since you don't have a more recent version of Maple (I guessed you use Maple 5.1 from your worksheet), allow me to reproduce from the help pages in Maple 13:

'range'= numeric...numeric
Values that specify the range of the independent variable over which solution values are desired.
For IVPs and DAEs this option is used only by the non-stiff and stiff default methods (rkf45, rosenbrock, rkf45_dae, rosenbrock_dae) and the taylorseries method. It has two purposes for procedure-type output. If 'range' is used, then the call to dsolve computes the solution over the desired range before returning, storing that solution for later calls to the returned procedure, which then compute the return values through interpolation.
 

and about maxfun (cut short)

The option maxfun=n in the call to dsolve,numeric gives an upper limit on the total number of function evaluations.
For the rkf45 and rosenbrock methods, the default setting is maxfun=30000, while for the classical methods, the default setting is maxfun=50000.
A setting of maxfun=0 disables the option.

Preben Alsholm

After receiving your answer I thought that a fairly big customer like my university would receive Maple 14 more or less right away.

Instead the response from your UK representative (Adeptscience) was that if she could find time maybe we would get Maple 14 in 1 or 2 weeks.

However, we still have not received anything, and I'm not talking about tangibles like DVDs or manuals.

Preben Alsholm

Since plot and plot3d are not disturbed by undefined results there is no need for defining k for all values in the square [-1,1]x[-1,1].

With a definition of zero for points below the x-axis the plot is different and maybe not as intended.

Another minor comment. The two if- statements can be made into one by the use of 'elif' :

k := proc (x, y) if -1 <= x and x <= 0 and -1 <= y and y <= 0 then x^2+y^2 elif 0 <= x and x <= 1 and 0 <= y and y <= 1 then 3*x*y  end if end proc;
plot3d(k,  -1 .. 1,  -1 .. 1,axes=boxed);

And finally the answer to the original question: What is wrong with plot3d( k, x= -1..1,y=-1..1) is the same that is wrong with plot(sin, x = 0..2*Pi);

k and sin are procedures. So you have the choice between the variable free version plot(sin, 0..2*Pi) and the version plot(sin(x),x=0..2*Pi)

In your case you need unevaluation quotes around k(x,y), since your procedure doesn't handle symbolic input:

plot3d('k(x,y)', x= -1 .. 1, y= -1 .. 1,axes=boxed);
 

Preben Alsholm

Since plot and plot3d are not disturbed by undefined results there is no need for defining k for all values in the square [-1,1]x[-1,1].

With a definition of zero for points below the x-axis the plot is different and maybe not as intended.

Another minor comment. The two if- statements can be made into one by the use of 'elif' :

k := proc (x, y) if -1 <= x and x <= 0 and -1 <= y and y <= 0 then x^2+y^2 elif 0 <= x and x <= 1 and 0 <= y and y <= 1 then 3*x*y  end if end proc;
plot3d(k,  -1 .. 1,  -1 .. 1,axes=boxed);

And finally the answer to the original question: What is wrong with plot3d( k, x= -1..1,y=-1..1) is the same that is wrong with plot(sin, x = 0..2*Pi);

k and sin are procedures. So you have the choice between the variable free version plot(sin, 0..2*Pi) and the version plot(sin(x),x=0..2*Pi)

In your case you need unevaluation quotes around k(x,y), since your procedure doesn't handle symbolic input:

plot3d('k(x,y)', x= -1 .. 1, y= -1 .. 1,axes=boxed);
 

Preben Alsholm

There is nothing wrong with using (e.g.) s[1] and t together. The problem is with t[1] and t, i.e. the same letter 't' used in both names.

If you like the indexed name to resemble 't', you could use T[1] or tt[1], or whatever you like, just not t[1].

Preben Alsholm

First 221 222 223 224 225 226 227 Page 223 of 229