dharr

Dr. David Harrington

8235 Reputation

22 Badges

20 years, 342 days
University of Victoria
Professor or university staff
Victoria, British Columbia, Canada

Social Networks and Content at Maplesoft.com

Maple Application Center
I am a retired professor of chemistry at the University of Victoria, BC, Canada. My research areas are electrochemistry and surface science. I have been a user of Maple since about 1990.

MaplePrimes Activity


These are answers submitted by dharr

Typing ?while will bring up the help for the Repetition statement, or search for while in the search box under help/Maple help.

 

As @vv says, there a probably too many solutions, but Groebner gives a way of systematically finding them. You would first want to make all the coefficients rational. As a toy example that finds four real solutions for two equations see below. If you eliminate ones that are unphysical as you go (perhaps negative solutions?), you might be able to find your solution relatively efficiently.

Groebner.mw

(I'm having a problem pasting the contents of the worksheet)

 

 

 

 

At t=0, you have x(0)=0 and D(x))(0) = 500. Substituting these into eqn gives 0 = 2*500^2, which can't be true. So the equation and the initial conditions are inconsistent at the initial point.

for example, for

f:=(x,y)->x^2;

op(1,eval(f));
gives the sequence of parameters x,y and nops can then be used to count them:

nops([op(1,eval(f))]);

gives 2

sprintf("%.4f",0.0141); gives "0.0141"

The format parameters give finer control about width, precision etc see ?sprintf

If you right-click on the first definition of f, and use 2-D math/convert/convert to 1-D math input you will see:

f:=k->;sum(k*x(n), n = 2 .. 3);f(1);

There is an unwanted something (appears as a semicolon here, but that's prob not what you entered) after the arrow and before the sum, i.e., this line is corrupted somehow.

A parametric plot is an alternative to Kitonum's implicit plot, and is general for switching axes:

plot([-4.918231636*z^3+2.486861786*z^2+.8573483099*z+2.341623514,z,z=-0.5..0.8]);

and use the view option to define the plot area.

Assuming that your x should be t, then

restart;

EQ:=(3*t)*diff(y(t),t,t)+y(t)=0;
gfun:-diffeqtorec(EQ, y(t), c(n));

{c(n)+(3*n^2+3*n)*c(n+1), c(0) = 0, c(1) = _t[2]}

 


 

Download powerseries.mw

 

There is a problem having the page breaks in the file "The Lattice Package Users Guide.mw" - if you remove them then you can load it into a workbook.

I figured this out by assembling the workbook by hand, and it might be instructive to do this. I would install a package from the cloud ("Orbitals" would be my choice but I'm biased) and look at the workbook structure to figure things out.

To make it a package in the cloud just save the workbook to the cloud from the file menu. Then you can install it from the cloud.

The help page ?worksheet,cloud,creatingPackages is quite good on the details of the process

ode:=diff(y(x),x$2)+lambda*y(x)=0;
bc:=y(0)=0;
sol:=rhs(dsolve({ode,bc},y(x)));
solve(eval(sol,x=L),lambda,allsolutions);

gives  Pi^2*_Z1~^2/L^2 and then about(_Z1) tells you it is an integer.

(Edit: Didn't see Carl's solution until after I submitted this.)

There are n*(n-1) = 64 {0,1} adjacency matrices with zeroes on the main diagonal (loopless graphs), so for this case, an indexing function for generating the matrices can help:
 

restart;with(GraphTheory):with(ListTools):

perm:='perm':
n:=3;
bits:=n*(n-1);
indexfn:=proc(i,j) local m;
         m:=(i-1)*n+(j-1);
         if i=j then 0 else perm[m-iquo(m,n+1)] end if;
         end proc:
Matrix(n,n,indexfn);
mlist:=table():
for i from 0 to 2^bits-1 do
   perm:=Bits:-Split(i,'bits'=bits);
   mlist[i]:=Matrix(n,n,indexfn);
end do:
mlist:=convert(mlist,list):

 

n := 3

 

bits := 6

 

Matrix([[0, perm[1], perm[2]], [perm[3], 0, perm[4]], [perm[5], perm[6], 0]])

(1)

cats:=[ListTools:-Categorize((i,j)->IsIsomorphic(Digraph(i),Digraph(j)),mlist)];

cats := [[Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 0, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0})], [Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 0, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 1, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 0, (2, 1) = 1, (2, 2) = 0, (2, 3) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 0, (2, 1) = 0, (2, 2) = 0, (2, 3) = 1, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 0, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (3, 1) = 1, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 0, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (3, 1) = 0, (3, 2) = 1, (3, 3) = 0})], [Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 1, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 0, (2, 1) = 1, (2, 2) = 0, (2, 3) = 1, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 0, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (3, 1) = 1, (3, 2) = 1, (3, 3) = 0})], [Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 0, (2, 1) = 1, (2, 2) = 0, (2, 3) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 1, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (3, 1) = 1, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 0, (2, 1) = 0, (2, 2) = 0, (2, 3) = 1, (3, 1) = 0, (3, 2) = 1, (3, 3) = 0})], [Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 1, (2, 1) = 1, (2, 2) = 0, (2, 3) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 0, (2, 1) = 0, (2, 2) = 0, (2, 3) = 1, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 0, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (3, 1) = 1, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 0, (2, 1) = 0, (2, 2) = 0, (2, 3) = 1, (3, 1) = 1, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 1, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (3, 1) = 0, (3, 2) = 1, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 0, (2, 1) = 1, (2, 2) = 0, (2, 3) = 0, (3, 1) = 0, (3, 2) = 1, (3, 3) = 0})], [Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 1, (2, 1) = 1, (2, 2) = 0, (2, 3) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 0, (2, 1) = 1, (2, 2) = 0, (2, 3) = 1, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 1, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (3, 1) = 1, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 0, (2, 1) = 1, (2, 2) = 0, (2, 3) = 1, (3, 1) = 0, (3, 2) = 1, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 1, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (3, 1) = 1, (3, 2) = 1, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 0, (2, 1) = 0, (2, 2) = 0, (2, 3) = 1, (3, 1) = 1, (3, 2) = 1, (3, 3) = 0})], [Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 1, (2, 1) = 0, (2, 2) = 0, (2, 3) = 1, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 0, (2, 1) = 1, (2, 2) = 0, (2, 3) = 0, (3, 1) = 1, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 0, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (3, 1) = 0, (3, 2) = 1, (3, 3) = 0})], [Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 1, (2, 1) = 0, (2, 2) = 0, (2, 3) = 1, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 1, (2, 1) = 1, (2, 2) = 0, (2, 3) = 1, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 0, (2, 1) = 1, (2, 2) = 0, (2, 3) = 1, (3, 1) = 1, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 1, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (3, 1) = 0, (3, 2) = 1, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 0, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (3, 1) = 1, (3, 2) = 1, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 0, (2, 1) = 1, (2, 2) = 0, (2, 3) = 0, (3, 1) = 1, (3, 2) = 1, (3, 3) = 0})], [Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 1, (2, 1) = 1, (2, 2) = 0, (2, 3) = 1, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 1, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (3, 1) = 1, (3, 2) = 1, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 0, (2, 1) = 1, (2, 2) = 0, (2, 3) = 1, (3, 1) = 1, (3, 2) = 1, (3, 3) = 0})], [Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 0, (2, 1) = 1, (2, 2) = 0, (2, 3) = 0, (3, 1) = 1, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 1, (2, 1) = 1, (2, 2) = 0, (2, 3) = 0, (3, 1) = 1, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 1, (2, 1) = 0, (2, 2) = 0, (2, 3) = 1, (3, 1) = 1, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 0, (2, 1) = 1, (2, 2) = 0, (2, 3) = 0, (3, 1) = 0, (3, 2) = 1, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 0, (2, 1) = 0, (2, 2) = 0, (2, 3) = 1, (3, 1) = 0, (3, 2) = 1, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 1, (2, 1) = 0, (2, 2) = 0, (2, 3) = 1, (3, 1) = 0, (3, 2) = 1, (3, 3) = 0})], [Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 1, (2, 1) = 1, (2, 2) = 0, (2, 3) = 0, (3, 1) = 1, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 0, (2, 1) = 1, (2, 2) = 0, (2, 3) = 1, (3, 1) = 0, (3, 2) = 1, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 1, (2, 1) = 0, (2, 2) = 0, (2, 3) = 1, (3, 1) = 1, (3, 2) = 1, (3, 3) = 0})], [Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 0, (2, 1) = 0, (2, 2) = 0, (2, 3) = 1, (3, 1) = 1, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 1, (2, 1) = 1, (2, 2) = 0, (2, 3) = 0, (3, 1) = 0, (3, 2) = 1, (3, 3) = 0})], [Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 1, (2, 1) = 0, (2, 2) = 0, (2, 3) = 1, (3, 1) = 1, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 0, (2, 1) = 1, (2, 2) = 0, (2, 3) = 1, (3, 1) = 1, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 1, (2, 1) = 1, (2, 2) = 0, (2, 3) = 0, (3, 1) = 0, (3, 2) = 1, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 1, (2, 1) = 1, (2, 2) = 0, (2, 3) = 1, (3, 1) = 0, (3, 2) = 1, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 1, (2, 1) = 1, (2, 2) = 0, (2, 3) = 0, (3, 1) = 1, (3, 2) = 1, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 0, (2, 1) = 0, (2, 2) = 0, (2, 3) = 1, (3, 1) = 1, (3, 2) = 1, (3, 3) = 0})], [Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 1, (2, 1) = 1, (2, 2) = 0, (2, 3) = 1, (3, 1) = 1, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 1, (2, 1) = 0, (2, 2) = 0, (2, 3) = 1, (3, 1) = 0, (3, 2) = 1, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 0, (2, 1) = 1, (2, 2) = 0, (2, 3) = 0, (3, 1) = 1, (3, 2) = 1, (3, 3) = 0})], [Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 1, (2, 1) = 1, (2, 2) = 0, (2, 3) = 1, (3, 1) = 1, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 1, (2, 1) = 1, (2, 2) = 0, (2, 3) = 1, (3, 1) = 0, (3, 2) = 1, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 1, (2, 1) = 1, (2, 2) = 0, (2, 3) = 0, (3, 1) = 1, (3, 2) = 1, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 1, (2, 1) = 0, (2, 2) = 0, (2, 3) = 1, (3, 1) = 1, (3, 2) = 1, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 0, (2, 1) = 1, (2, 2) = 0, (2, 3) = 1, (3, 1) = 1, (3, 2) = 1, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 1, (2, 1) = 1, (2, 2) = 0, (2, 3) = 1, (3, 1) = 1, (3, 2) = 1, (3, 3) = 0})], [Matrix(3, 3, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 1, (2, 1) = 1, (2, 2) = 0, (2, 3) = 1, (3, 1) = 1, (3, 2) = 1, (3, 3) = 0})]]

(2)

nops(cats);

16

(3)

nops(Flatten(cats));

64

(4)

 

 

Download graphs.mw

If the bugs go away, and you generate a list of the digraphs, then you can categorize into the groups (equivalence classes) that are isomorphic using

[ListTools:-Categorize(IsIsomorphic,graphlist)]

I would do the generation of the matrices and graphs like this (for the 2x2 case)

n:=2;
bits:=n^2;
mlist:=table():
for i from 0 to 2^bits-1 do
   mlist[i]:=Matrix(n,n,Bits:-Split(i,'bits'=bits));
end do:
mlist:=convert(mlist,list);

n := 2

 

bits := 4

 

mlist := [Matrix(2, 2, {(1, 1) = 0, (1, 2) = 0, (2, 1) = 0, (2, 2) = 0}), Matrix(2, 2, {(1, 1) = 1, (1, 2) = 0, (2, 1) = 0, (2, 2) = 0}), Matrix(2, 2, {(1, 1) = 0, (1, 2) = 1, (2, 1) = 0, (2, 2) = 0}), Matrix(2, 2, {(1, 1) = 1, (1, 2) = 1, (2, 1) = 0, (2, 2) = 0}), Matrix(2, 2, {(1, 1) = 0, (1, 2) = 0, (2, 1) = 1, (2, 2) = 0}), Matrix(2, 2, {(1, 1) = 1, (1, 2) = 0, (2, 1) = 1, (2, 2) = 0}), Matrix(2, 2, {(1, 1) = 0, (1, 2) = 1, (2, 1) = 1, (2, 2) = 0}), Matrix(2, 2, {(1, 1) = 1, (1, 2) = 1, (2, 1) = 1, (2, 2) = 0}), Matrix(2, 2, {(1, 1) = 0, (1, 2) = 0, (2, 1) = 0, (2, 2) = 1}), Matrix(2, 2, {(1, 1) = 1, (1, 2) = 0, (2, 1) = 0, (2, 2) = 1}), Matrix(2, 2, {(1, 1) = 0, (1, 2) = 1, (2, 1) = 0, (2, 2) = 1}), Matrix(2, 2, {(1, 1) = 1, (1, 2) = 1, (2, 1) = 0, (2, 2) = 1}), Matrix(2, 2, {(1, 1) = 0, (1, 2) = 0, (2, 1) = 1, (2, 2) = 1}), Matrix(2, 2, {(1, 1) = 1, (1, 2) = 0, (2, 1) = 1, (2, 2) = 1}), Matrix(2, 2, {(1, 1) = 0, (1, 2) = 1, (2, 1) = 1, (2, 2) = 1}), Matrix(2, 2, {(1, 1) = 1, (1, 2) = 1, (2, 1) = 1, (2, 2) = 1})]

(1)

graphs:=map(GraphTheory:-Digraph,mlist):

 


 

Download graphs.mw

You can set up indices with procedures, but you stll need parentheses to show it is a procedure.

q := proc () local inds; if not type(procname, 'indexed') then return 'procname(args)' end if; inds := op(procname); inds end proc;

proc () local inds; if not type(procname, 'indexed') then return 'procname(args)' end if; inds := op(procname); inds end proc

(1)

q(y)

q(y)

(2)

q[4, 5]()

4, 5

(3)

q[4, 5]

q[4, 5]

(4)

``

 

If r=0 then you correctly change i. But then you test r agoinst N+1, which fails, and then the else clause sets i back to r, which is zero.

First 68 69 70 71 72 73 74 Last Page 70 of 81