acer

32632 Reputation

29 Badges

20 years, 46 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@Dragonsoul02 The problem seems to lie with the IC of a(0)=0.

How do you interpret the first system, with that setting?

Specifying a(0) just a small amount above 0.0 seems to do better.

@Dragonsoul02 The problem seems to lie with the IC of a(0)=0.

How do you interpret the first system, with that setting?

Specifying a(0) just a small amount above 0.0 seems to do better.

Maple 15 showed the double attractor nicely for your correction of the code, eg. with just a few more options to DEplot3d such as,

stepsize = .01, thickness=1, orientation=[90,70,135]

acer

Maple 15 showed the double attractor nicely for your correction of the code, eg. with just a few more options to DEplot3d such as,

stepsize = .01, thickness=1, orientation=[90,70,135]

acer

That doesn't look right. You've used  rhs(func(1)[2])*z(t) which is hard-coded to evaluate func at the point 1.

sol1:=dsolve({x(0)=.1,diff(x(t),t)=x(t)},numeric,output=listprocedure);
func := eval(x(t),sol1);
func(2);
sol:=dsolve({z(0)=.1,diff(z(t),t)=func(t)*z(t)}, numeric,known=[func]);
plots:-odeplot(sol,0..4);

Using output=listprocedure makes it a bit easier to understand (I think) than the following, which is more like the original form posed,

restart:
sol1 := dsolve({diff(x(t), t) = x(t), x(0) = 0.1}, numeric):
func := proc(q)
   if not type(q,numeric) then 'procname'(q);
   else rhs( op(2, sol1(q)) ); end if;
end proc:
sol:=dsolve({diff(z(t), t) = func(t) * z(t), z(0) = 0.1},numeric,known=func):
func(2);
plots:-odeplot(sol,0..4);

Perhaps the submitter might also like to know that it is not always necessary to dsolve for a procedural solution to x(t) separately from solving for z(t). For the example given, Maple can solve them together as a coupled system.

restart:
sol:=dsolve({diff(x(t),t)=x(t), x(0)=.1}
            union
            {diff(z(t),t)=x(t)*z(t), z(0)=0.1},
            numeric):
sol(2);
plots:-odeplot(sol,[t,z(t)],0..4);

acer

That doesn't look right. You've used  rhs(func(1)[2])*z(t) which is hard-coded to evaluate func at the point 1.

sol1:=dsolve({x(0)=.1,diff(x(t),t)=x(t)},numeric,output=listprocedure);
func := eval(x(t),sol1);
func(2);
sol:=dsolve({z(0)=.1,diff(z(t),t)=func(t)*z(t)}, numeric,known=[func]);
plots:-odeplot(sol,0..4);

Using output=listprocedure makes it a bit easier to understand (I think) than the following, which is more like the original form posed,

restart:
sol1 := dsolve({diff(x(t), t) = x(t), x(0) = 0.1}, numeric):
func := proc(q)
   if not type(q,numeric) then 'procname'(q);
   else rhs( op(2, sol1(q)) ); end if;
end proc:
sol:=dsolve({diff(z(t), t) = func(t) * z(t), z(0) = 0.1},numeric,known=func):
func(2);
plots:-odeplot(sol,0..4);

Perhaps the submitter might also like to know that it is not always necessary to dsolve for a procedural solution to x(t) separately from solving for z(t). For the example given, Maple can solve them together as a coupled system.

restart:
sol:=dsolve({diff(x(t),t)=x(t), x(0)=.1}
            union
            {diff(z(t),t)=x(t)*z(t), z(0)=0.1},
            numeric):
sol(2);
plots:-odeplot(sol,[t,z(t)],0..4);

acer

@OxidisedLizard Ah, you are using Maple 12.

Better to let us know this detail earlier. I will change the top-post to reflect this.

@OxidisedLizard Ah, you are using Maple 12.

Better to let us know this detail earlier. I will change the top-post to reflect this.

@jeffb Yes, of course that doesn't work.

It doesn't work for those two Matrices with your original code, either.

You cannot multiply a 2x3 Matrix by a 2x3 Matrix, in the usual way. Look at my question to you above, about checking whether the number of columns of A should match the number of rows of B.

@jeffb Yes, of course that doesn't work.

It doesn't work for those two Matrices with your original code, either.

You cannot multiply a 2x3 Matrix by a 2x3 Matrix, in the usual way. Look at my question to you above, about checking whether the number of columns of A should match the number of rows of B.

@Hyperian ...with the op command.

@Hyperian ...with the op command.

@jeffb No, the code I wrote has that op() fragment as it ought to be. op(1,A) should return two values, the row and column dimension of Matrix A.

The code I posted above works for me when I paste it -- as is -- into either Document or Worksheet of the Standard GUI of Maple versions 11.02, 12.02, 13.02, 14.01, 15.01, and 16.00 on MS-Windows.

What version and platform are you using? Can you save your worksheet, once you get the error, and upload it in a Comment here (using the green up-arrow in the Mapleprimes editing menubar)?

@jeffb No, the code I wrote has that op() fragment as it ought to be. op(1,A) should return two values, the row and column dimension of Matrix A.

The code I posted above works for me when I paste it -- as is -- into either Document or Worksheet of the Standard GUI of Maple versions 11.02, 12.02, 13.02, 14.01, 15.01, and 16.00 on MS-Windows.

What version and platform are you using? Can you save your worksheet, once you get the error, and upload it in a Comment here (using the green up-arrow in the Mapleprimes editing menubar)?

@jeffb You haven't shown your revised code, so we cannot tell the source of the error message.

mymatrix:=proc(A::Matrix,B::Matrix)
local i,j,q,C,numrowsA,numcolsA,numcolsB;
   numrowsA,numcolsA:=op(1,A);
   numcolsB:=op([1,2],B);
   C:=Matrix(numrowsA,numcolsB);
   for i from 1 to numrowsA do
      for j from 1 to numcolsB do
         for q from 1 to numcolsA do
            C[i,j]:=C[i,j] + A[i,q]*B[q,j];
         od;
      od;
   od;
   return C;
end proc:

x:=Matrix(3,2,symbol=X):
y:=Matrix(2,4,symbol=Y):

mymatrix(x,y) - x . y;

                                [0  0  0  0]
                                [          ]
                                [0  0  0  0]
                                [          ]
                                [0  0  0  0]

Should you add a check that the number of columns of A equals the number of rows of B?

If you've been instructed to not use any "built-in" routines then the spirit of that instruction is presumably to prevent you from simply using `.` or MatrixMatrixMultiply or something similar. You'll still have to use something to pick off the dimensions of A and B or else you'd have to pass those in as additional arguments in order to have the code get them right. I would guess that you probably are allowed to use LinearAlgebra:-Dimensions(), but if not then you might be allowed to use op() as above.

Don't blindly trust that code above: check it, via understanding.

First 412 413 414 415 416 417 418 Last Page 414 of 597