Preben Alsholm

MaplePrimes Activity


These are replies submitted by 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

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

In Maple 13.02:

F:= c -> evalf(Int(3*c*x^2 + c^2*x, x = 0 .. 1)):
  Optimization:-NLPSolve(F);

Error, (in Optimization:-NLPSolve) complex value encountered
 

Preben Alsholm

In Maple 13.02:

F:= c -> evalf(Int(3*c*x^2 + c^2*x, x = 0 .. 1)):
  Optimization:-NLPSolve(F);

Error, (in Optimization:-NLPSolve) complex value encountered
 

Preben Alsholm

Yes, the straightforward solve gave the warning (Maple 13.02).

Preben Alsholm

 

 

Yes, the straightforward solve gave the warning (Maple 13.02).

Preben Alsholm

 

 

Is "Extended Maintenance Program" equivalent in this regard to  "Elite Maintenance Plan"?

My university has received the following message from 
Adeptscience in the UK:
"We are working with MapleSoft to make sure that Elite Maintenance Plan customers, like yourselves are sent the new version by the end of May. This will be provided as a download link with new purchase codes unless you have a Site licence, in which case you will also receive physical product. This will take longer to arrive."       Preben Alsholm 

 

Thank you, indeed it does seem to be more efficient.

I tried in the previous simple example to compute the solution at t = 1 for 10000 values of (A, x0). The ratio between the times spent was roughly 3/1.
The actual test is below.

Preben Alsholm

restart;
ode := diff(x(t),t)=x(t)*(A-x(t)):
ic := x(0)=x0:
ivp:=unapply({ode,ic},A,x0):
sol := (A,x0)->dsolve( ivp(A,x0), numeric):
t0:=time():
for k from 1 to 100 do
  for j from 1 to 100 do
    sol(k,j)(1)
  end do
end do:
time()-t0;
                                   30.389
restart;
ode := diff(x(t),t)=x(t)*(A-x(t)):
ic := x(0)=x0:
sol := dsolve( {ode,ic}, numeric,parameters=[A,x0]):
t0:=time():
for k from 1 to 100 do
  for j from 1 to 100 do
    sol(parameters=[A=k,x0=j]);
    sol(1)
  end do
end do:
time()-t0;
                                    8.783
 

I still haven't seen any need for using the parameters version of dsolve/numeric.

What is wrong with the following?

restart;
ode := diff(x(t),t)=x(t)*(A-x(t)):
ic := x(0)=x0:
ivp:=unapply({ode,ic},A,x0);
sol := (A,x0)->dsolve( ivp(A,x0), numeric):
sol(2,1);
 

Preben Alsholm

When using sum, test[1,j] is evaluated at the indices [1,j] with j being the symbol j, therefore the error message.

You are better off using add, but if you do use sum, then put apostrophes around test[1,j] to ensure that the evaluation taking place before sum just consists in removing the apostrophes.

test:=Matrix([[1,2,3],[4,5,6],[9,8,7]]);
sum('test[1,j]',j=1..3);
add(test[1,j],j=1..3);
 

Preben Alsholm

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