Dr. David Harrington

4776 Reputation

21 Badges

19 years, 29 days
University of Victoria
Professor or university staff
Victoria, British Columbia, Canada

Social Networks and Content at Maplesoft.com

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

MaplePrimes Activity

These are replies submitted by dharr

@Ahmed111 Well, Maple is often a bit inscrutable about the way it does things. Here's my guess. The first time, Maple always found the lambdas together, e.g., (lambda__1-conjugate(lambda__2)) and so kept them together. But the second time, you have things like phi2 or conjugate(psi2), which now have polynomials in lambda__2 or its conjugate. Now I might look at phi2 and conjugate(psi2) and try to combine them (they are very similar after all, but not conjugates), which might give a shorter expression if split into real and imaginary parts.

If you don't want Maple to combine them, just call them something like lambda__1 and clambda__1 until the end of the calculation and then substitute back.

But at some point, you have to decide what is acceptably simple, and Maple might not agree (or at least without contortions).

@arashghgood You needed list1[i][2] instead of just list1[i], and numeric rather than numerical.


@arashghgood I'm confused about what you want. You talked about residues - do you want to do a contour integration? if so of what function - Q, deq? - which contour? upper half plane? That can probably be done.

How exactly was the plot in c made? I think by numerical solution of the same differential equation? if you want to exactly replicate that then it would be helpful to know the method, stepsize, hardware precision, exact initial conditions.

Perhaps a step back to tell us where is problem came from and what you want out of it would be helpful.

@arashghgood You can try stiff methods other than the default resenbrock one, e.g. lsode. You could put Digits higher for more accuracy, but it will get very slow. In combination with the transformation method to add a small imaginary part you may get closer to what you want. I don't really understand what you are expecting - near a sigularity inaccuracy seems inevitable.

@arashghgood Stiff method seems to work here, without transformation. (just plotting real and imm parts of Q)

Download ODE.mw

Edit: at least for the second case. For the first, it varies depending on the exact values of the ic.

@arashghgood  The dchange can be done more simply by 


and still using Q. Result is the same. Hard to understand any discrepancy.

@arashghgood Perhaps you can reformulate, e.g., K=x+a with x real (including changing the derivatives appropriately). PDEtools:-dchange can do a change of variables - see attached. But ignoring singularities seems risky.

Download ODE.mw

@Thomas Dean Here's my interpretation. The wikipedia page you cited makes clear  is the notation for a ring, modulo n. So for the additive group modulo n, the order is n, but for the multiplicative group, 0 is excluded and the order is n-1. So your ord=12, mod 13, is Z/13Z.

This is how you used it in your original post.

@Thomas Dean Your original table didn't have 0 in the multiplicative case, so I emulated that without thinking too much about it. The Wikipedia page talks about integers 0..n-1 mod n. So that may be part of it. But notice that you are doing ord=12, which is mod 13, which is prime. If you change ord to 11, so mod 12, you get an error message, since the default is to check that it is a group. Try other values, some work and some don't.

@Thomas Dean 



Matrix has to have the entries coded as 1..4

v := [1, -1, I, -I]; M := Matrix(4, 4, proc (i, j) options operator, arrow; eval(v[i]*v[j], `~`[`=`](v, [`$`(1 .. 4)])) end proc)

v := [1, -1, I, -I]

Matrix(%id = 36893490351220485524)

G := CayleyTableGroup(M)



Array(%id = 36893490351220474092)

lbl := proc (i) options operator, arrow; v[i] end proc

proc (i) options operator, arrow; v[i] end proc

DrawCayleyTable(G, labels = lbl)


Download Group.mw

I tried to find this out a while ago, but concluded it wasn't possible. You can use FileTools:-ListDirectory to find a list of all *.mw files in the interface(worksheetdir) directory, but there seems not to be a simple way to find which one is running. I suppose there must be some system-dependent system calls to figure out which programs are running.

@mmcdara Much, much simpler than mine!

@gharouce So, to be clear, you never want the actual numbers out, but just to evaluate some special algebra in which e^2=1, e^3=e etc for one specific variable e in an expression? That is easy to do if your expression is a polynomial in e, but requires more work if you want it to work for, say, e/sin(e^2). Here's the polynomial case:


  local p,sum,power,term,terms;
  if not type(p,polynom(anything,var)) then error "%1 not polynomial in %2",expr,var end if;
  if nops(p)=1 then terms:=[p] else terms:=[op(p)] end if;
  for term in terms do
  end do;
end proc:

q := X^3*Y+X^2*Z+X; q2 := (e+1)^3



evalpm(q2, e)


evalpm(q, X)



Download Xn.mw

For the more general case

        local p,pwr;
            proc(pwr) local res; 
              if op(1,pwr)=var then
                if op(2,pwr)::even then
                elif op(2,pwr)::odd then
                end if
              end if;
             end proc
   end proc:


@gharouce You can only set X to one value at a time. But you can do something like this:

s:=X^3*Y + X^2*Z + X;

or you can do something like this:

solve({s=X^3*Y + X^2*Z + X,X^2=1},{s,X});

which gives the two possibilities

First 8 9 10 11 12 13 14 Last Page 10 of 45