Carl Love

Carl Love

28055 Reputation

25 Badges

12 years, 360 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@Carl Love I tried to do the (7,7) case on its own. It's too big. After it used about 11G of memory, I killed it.

I got a "kernel connection lost" error, which could be a memory error, when trying to do the full 7x7 matrix. Would you please attempt to do the (7,7) case separately, not as part of a matrix?

curry is trivial. Here's a brief explanation. Suppose you have a procedure/function f(x,y) and a particular value of x, X. If g:= curry(f, X), then g(y) = f(X,y) for all y. The benefit is that the y has been moved to the first argument position.

:: is fundamental, but not so trivial. X::t (outside of a procedure header) is the same as type(X,t) used in a position where a boolean value is required. It returns a true/false value that answers Does object X have property t? (I'm using property in its generic English meaning rather than its special Maple meaning. Maple-speak refers to t as a type. Maple properties are related, but nowhere near as important as types.) There are several ways that X::t can be used inside a procedure header, but they all essentially mean Return an error if an attempt is made to replace X with something that is not type t.

@Muhammad Usman So, you don't believe that evalm was causing the problem? Try replacing &* with . and putting evalm back in.

@Annonymouse The final two lines of the code snippet that you quoted, when displayed the "normal" way, are

nops~(M)
plots:-matrixplot(nops~(M), heights= histogram);

The first line of that pair needs to end with a semicolon. Without it, the 2D Input interprets it as a scalar product of a matrix of integers and a plot. Amazingly, this is not an outright error! It actually produces and displays a matrix of plots.

@tomleslie I've directly downloaded your attached worksheet "mine.mw" into both Maple 2016.2 and Maple 2018.1 and used the menu command Edit -> Execute -> Entire Worksheet. In both cases, I got no errors. I also suspect that this is some 2D Input issue.

@Muhammad Usman I still see two usages of evalm in your worksheet. There's no good reason to ever use evalm. The only reason that it's still in the Maple library is so that some very old code will still run.

@rhcp Thank you. No problem; I'm happy to help you. Let me know if you need any further assistance.

@Muhammad Usman Please post the new re-executed worksheet. I'm sure that evalm was part of the problem, but it may not be the whole problem.

@asa12 Sorry, I don't know physics at that level, and I can't offer you the least bit of help.

@rhcp I just finished this code anyway. Try this. Certainly it works for the case at hand plus some more-general cases. Do you need it more general? Do you need anything explained?

restart;
Nstates:= 3:
x:= Vector[row](Nstates, i-> i-1);
q:= Vector[row](Nstates, i-> i-1); 

u:= (x,q)-> p*min(x,q) - w*q;
#`add` works better than `sum` in this context (finite,
#definite, nonsymbolic addition):
U:= (x,q)-> add(u(x[i], q), i= 1..Nstates)/Nstates;

#z:= w/p;

Ineqs:= 
   [seq(
      eval[recurse](solve(U(x,q[i]) > U(x,q[i+1]), w)[], [p= 1, w= z*p]),
      i= 1..Nstates-1 
   )]
;
ReverseIneq:= (ineq::{`<`, `<=`})-> `if`(ineq::`<`, `>=`, `>`)(op(ineq)):
 
`q*`:= unapply(
   piecewise(
      Ineqs[1] and z <= 1, q[1],
      seq([Ineqs[i] and ReverseIneq(Ineqs[i-1]), q[i]][], i= 2..Nstates-1),
      0 <= z and ReverseIneq(Ineqs[Nstates-1]), q[Nstates]
   ),
   z
 );
'`q*`'(z) = `q*`(z);

 

 

@rhcp You wrote:

  • I thought there might be an intuitive way to rearrange the inequalities for w/p, then substitute this expression with z, and finally translate all inequalities into one piecewise representation.

It can be done, but I don't know how intuitive you'll find it. One roadblock is that these transformations are only valid for p > 0, right? Many Maple commands will accept an assuming clause; that is, one can append assuming p > 0 to the command and it will make use of that. But the solve command makes this difficult, although not impossible.

  • Is there then one command with which I could merge these intervals into one piecewise expression programmatically, or do i have to rely on the 'manual way' by simply writing it in text as I would do in LaTeX?

What you state are two extremes, and the truth is somewhere in between. On the one hand, it is never necessary to do it the manual way, and I generally recommend avoiding that at all costs. On the other hand, I don't think that it's possible with one command unless I write that command for you, which I'm trying to do.

The data structure piecewise is perhaps the most awkward to work with of all of Maple's standard data structures, and solve is perhaps the most awkward of all the standard commands. Nonetheless, I'm sure that I can put something together for you, probably in an hour or two. But it'll require some effort on your part to understand how it works.

 

 

@rhcp What terminology don't you know? I will explain.

I assume that the current problem is only a "toy" problem and that you want to set this up to handle larger and/or more-general problems. That is why I asked about the order.

It seems that without loss of generality, I can substitute z= w and p= 1. This is by far the easiest way to get z = w/p. Is that okay?

@asa12 I know nothing about ket and only a miniscule amount about the Physics package.

But I see that you've used i for the complex unit sqrt(-1). In Maple, this is usually capital I, but you can change it to another symbol.

@asa12 When a Maple response uses a variable of the form _Zn, which wasn't specified by the user, the assumption is that the variable is integer.

You've used LinearAlgebra for years, so why do you revert to linalg here? LinearAlgebra does have the MatrixExponential command.

First 320 321 322 323 324 325 326 Last Page 322 of 709