Robert Israel

6522 Reputation

21 Badges

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

MaplePrimes Activity


These are replies submitted by Robert Israel

Hmm, now you have an end condition as well as initial conditions.  pdsolve(..., numeric) is unable to handle those.  There may not be
any way to do this in Maple, unless you want to program your own numerical method for solving this.

Indeed.  On my system (Core 2 Duo P8400 at 2.26 GHz with Classic GUI under Windows Vista, 32-bit), I got times 15.397 and 6.145 in Maple 13.02,
0.592 and 0.968 in Maple 14 for these examples.

The "complex value" error is misleading, I think.  Here's a simpler example:

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

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

A little debugging reveals that F is called once, with argument 0., returning Int(3*x^2,x = 0 .. 1).  Then in line 16 of Optimization:-NLPSolve the error message is put out, after checking that this is of type complex (well, yes, but it is also of type realcons).

Anyway, it's easy to figure out how to prevent the error: F should have been a procedure that returns a number.  Thus

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

[-.500000000000000000,[-1.]]]

 

The "complex value" error is misleading, I think.  Here's a simpler example:

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

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

A little debugging reveals that F is called once, with argument 0., returning Int(3*x^2,x = 0 .. 1).  Then in line 16 of Optimization:-NLPSolve the error message is put out, after checking that this is of type complex (well, yes, but it is also of type realcons).

Anyway, it's easy to figure out how to prevent the error: F should have been a procedure that returns a number.  Thus

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

[-.500000000000000000,[-1.]]]

 

I take that back: it does happen when NLPSolve is called with an expression involving an int that can't be done in closed form.  For example,

> NLPSolve(int(exp(sin(c*x)),x=0..1));

Error, (in Optimization:-NLPSolve) integration range or variable must be specified in the second argument, 
got 1. = 0 .. 1

This is a bug in NLPSolve.  I have submitted an SCR.

I take that back: it does happen when NLPSolve is called with an expression involving an int that can't be done in closed form.  For example,

> NLPSolve(int(exp(sin(c*x)),x=0..1));

Error, (in Optimization:-NLPSolve) integration range or variable must be specified in the second argument, 
got 1. = 0 .. 1

This is a bug in NLPSolve.  I have submitted an SCR.

If you have one equation first order in time, and another second order in time, you need 1+2=3 initial conditions.  You just have two:
a(0,y) = 0 and D[1](a)(0,y) = 1.  So Maple's error message is correct.

If you have one equation first order in time, and another second order in time, you need 1+2=3 initial conditions.  You just have two:
a(0,y) = 0 and D[1](a)(0,y) = 1.  So Maple's error message is correct.

OK, then instead of one outcome there should be two, one where player 2 is using pass and one where player 2 is using play.

F:= proc(pp)
      uses Statistics;
      local c,a,b, C, S, T0, T1, i;
      S:= Sample(Bernoulli(pp),1000);  # player 1's moves on heads
      C:= Sample(Bernoulli(1/2),1000); # coin tosses
      T0:= 0; T1:= 0;
      for i from 1 to 1000 do
        if (C[i] = 0) and (S[i]=1) then T0:= T0-1; T1:= T1-1; # player 1 passes on tails with prob pp
        else T0:= T0 + 4*C[i]-2;    # both play
             T1:= T1 + 1;           # player 2 passes
        end if
     end do;
     [pp,T0/1000],[pp,T1/1000]
 end proc; 
 M:= [seq(F(p),p=0 .. 1, 0.01)];
 plot(M, style-point);

 

OK, then instead of one outcome there should be two, one where player 2 is using pass and one where player 2 is using play.

F:= proc(pp)
      uses Statistics;
      local c,a,b, C, S, T0, T1, i;
      S:= Sample(Bernoulli(pp),1000);  # player 1's moves on heads
      C:= Sample(Bernoulli(1/2),1000); # coin tosses
      T0:= 0; T1:= 0;
      for i from 1 to 1000 do
        if (C[i] = 0) and (S[i]=1) then T0:= T0-1; T1:= T1-1; # player 1 passes on tails with prob pp
        else T0:= T0 + 4*C[i]-2;    # both play
             T1:= T1 + 1;           # player 2 passes
        end if
     end do;
     [pp,T0/1000],[pp,T1/1000]
 end proc; 
 M:= [seq(F(p),p=0 .. 1, 0.01)];
 plot(M, style-point);

 

It should be D[1](a)(t,0) = 1, not (diff(a(t, y), t))(t, 0) = 1

 

It should be D[1](a)(t,0) = 1, not (diff(a(t, y), t))(t, 0) = 1

 

The two are different, and they should be different.  a/(b/c) is not the same as (a/b)/c.  If the "right answer" is the top one but you "need to evaluate" the bottom one, there is something very wrong going on. 

The two are different, and they should be different.  a/(b/c) is not the same as (a/b)/c.  If the "right answer" is the top one but you "need to evaluate" the bottom one, there is something very wrong going on. 

It's not a bug.  Basically, the question is this.  Consider four points, say P1 = [1,1,2.5], P2 = [1,2,2.5], P3 = [2,1,2.5], P4 = [2,2,5].  You want to draw a 3-dimensional polygon with these as vertices.  There are two reasonable choices:
(1) triangles P1, P2, P3 and P2,P3,P4.

(2) triangles P1,P2,P4 and P1,P2,P3.

,

In other words, the projection of this figure on the xy plane is a square.  You can split it into two triangles with a line going southwest to northeast or with a line going northwest to southeast.  Each way produces a different choice.  In matrixplot, Maple is splitting each square northwest to southeast, which makes two of your corners look like (1) and two look like (2).

 

First 33 34 35 36 37 38 39 Last Page 35 of 187