Schivnorr

526 Reputation

7 Badges

16 years, 81 days

MaplePrimes Activity


These are replies submitted by Schivnorr

My apologies, Doug.  I had meant no two positive integers adjacent to.  For example when n=k=2, the initial list is [1,2,0,0] and all the permutations are:

[[1, 2, 0, 0], [1, 0, 2, 0], [1, 0, 0, 2], [2, 1, 0, 0], [2, 0, 1, 0], [2, 0, 0, 1], [0, 1, 2, 0], [0, 1, 0, 2], [0, 2, 1, 0], [0, 2, 0, 1], [0, 0, 1, 2], [0, 0, 2, 1]]

Of these results, only [1,0,2,0], [1,0,0,2], and [0,1,0,2] are desired. 

 

Yes, I've been playing with procedures to place k 0's into a list of the first n positive integers.  I was going to say how this seemed a daunting task, but while I was writing this post inspiration struck:

 

myp2 := proc(n,k)
local L,i;

L:=[ListTools:-Join([i$i=1..n],0)];
for i from k-(n-1) to 1 by -1 do
  L := ListTools:-MakeUnique( [seq( seq(op([L[j][1..m]),0,op(L[j][m+1..-1])],m=0..nops(L[j]) ),j=1..nops(L) )] );
od:

return L;
end proc:

 

Thank you for pointing out the ListTools:-Sorted command.  That inspired me to look in the ListTools package for an "insert" command, when I found Join.  Since I couldn't in 30 seconds a command to insert an element into a list, I created that sequence command above to simply produce all results from inserting a 0 into any position in the list.  (e.g.  [1,2]  ->  [[0,1,2], [1,0,2], [1,2,0]]).  Though there is a lot of waste in this command, it tackles the case where n=6 and k=8 in about 0.094 seconds.  This is much better than the several minutes I was able to pare this time down to last night before ultimately going to bed. 

When you issue a restart command, the seed value for Maple's random number generator is reset as well. If you wish to be more "consistently random," you can issue a randomize() command to set the seed value based on your computer's clock. You can also create an init file so that a randomize(): command is always run after you restart.
Since you're on a Mac, I assume that you're using Maple's standard interface. While such a great increase in CPU usage is unusual (for me), the Java interface of Maple's standard interface does cause my CPU to put in more work. Have you found that any other applications that make use of Java have a similar effect?
Be very, VERY careful when using the Worksheet and XMLTools packages together. See point #2 in this post for slightly more details.
Don't forget the older student package. ?student,trapezoid
Don't forget the older student package. ?student,trapezoid
The determinant of a product of (square) matricies is equal to the product of the determinants of the (square) matricies. det(AB) = det(A)det(B) (for appropriate A,B)
The determinant of a product of (square) matricies is equal to the product of the determinants of the (square) matricies. det(AB) = det(A)det(B) (for appropriate A,B)
Again, the easiest way to do it would probably be to type it in as you would write it out, using Maple's function notation. For example, see what happens below:
[> diff( f(x(t)), t );
                                    /d      \
                         D(f)(x(t)) |-- x(t)|
                                    \dt     /

Maple sees f(x(t)) as a function, f evaluated at x(t), which itself is a function, x, evaluated at t. In the output, the D is Maple's notation for differentiating a function. D(f)(x(t)) means "the derivative of the function f evaluated at x(t)," or equivalently:
     /d      \|
     |-- f(m)||
     \dm     /|
              |
              | m = x(t)
For more information, see ?diff and ?D. Hopefully this is what you're looking for. --Schivnorr
Again, the easiest way to do it would probably be to type it in as you would write it out, using Maple's function notation. For example, see what happens below:
[> diff( f(x(t)), t );
                                    /d      \
                         D(f)(x(t)) |-- x(t)|
                                    \dt     /

Maple sees f(x(t)) as a function, f evaluated at x(t), which itself is a function, x, evaluated at t. In the output, the D is Maple's notation for differentiating a function. D(f)(x(t)) means "the derivative of the function f evaluated at x(t)," or equivalently:
     /d      \|
     |-- f(m)||
     \dm     /|
              |
              | m = x(t)
For more information, see ?diff and ?D. Hopefully this is what you're looking for. --Schivnorr
The problem is not that there is a warning displayed; the problem is inconsistency. When a user attempts to plot a procedure and uses the syntax name=range for the range, an error is thrown. When a user attempts to plot both a procedure and an expression, no error message is produced and an incorrect plot is shown. Finally, when a user attempts to plot an expression and uses the syntax range for the range, no error is thrown and a most likely incorrect plot is shown. This really shouldn't be the case. Since we (apparently) cannot trap warnings, and since Maple fusses about the proper plotting of procedures, Maple should fuss about these other issues as well.
Yeah, that's what I was afraid of :(
The only functionality I see over ToInert & FromInert is readability. Then again, dismantle is quite readable.
These levels of error I would have expected to see, because I know that subs() and eval() can produce slightly different values thanks to the extra simplification that eval() does. What you see in the worksheet I uploaded is much, much, much greater errors for low-digit evalf()'s. Apparently, the large errors in my worksheet are "not surprising," according to Robert Israel. I guess I just need more experience with floating point arithmetic and error analysis. x_x
Actually, specifying "range(realcons)" is a type check, and it may be buried somewhere in the type help page(s); however, I didn't know that I could do it until I tried one day and it worked. Experimentation will never be outdated.
1 2 3 4 5 6 7 Page 2 of 9