Items tagged with integer integer Tagged Items Feed

Consider the task of sorting a list of complex floating-point numbers by magnitude. First Attempt The usual method to do this in Maple is with the sort procedure. By passing a boolean-valued function that computes then compares the magnitudes of two complex numbers, we can sort the list. The following procedure shows how this is accomplished.
sort1 := proc(L)
    return sort(L, proc(z1,z2) abs(z1) <= abs(z2) end proc);
end proc:
A disadvantage of this approach is that the absolute-value procedure is called twice every time a pair of numbers is compared. For a long list, the time spent in the absolute value routine dominates the computation time.
i have a list in the form of [[x,y,z]] where x,y,z are integers, i want to find all the elements of the form [0,y,z]. how do i do that?
Similarly to Binary Arithmetic, Octal Arithmetic can be done using following module,
Silvexil announced in his blog a Binary Arithmetic package. Here is my version of it.
Here is the simplest program for obtaining the set of prime numbers less than or equal to n,
f:=n->select(isprime,{$1..n}):
It is not Eratosthenes Sieve though. The program ES below implements the Eratosthenes Sieve,

In this post, daniel asks about how to compute the list of primes less or equal to some integer n. This is often called the Sieve of Eratosthenes problem, but the term "Sieve of Eratosthenes" actually refers to a specific algorithm for solving this problem, not to the problem itself.

Recently I was asked in a private email about the fastest way of calculating of binomial coefficients mod 2 in Maple. It shouldn't be a problem for anybody reading my assembly dll creation manual. Anyway, here is the assembly code,

Mktime

August 27 2005 by Alec Mihailovs 4015 Maple
With Maple being able to access dll functions, it is easy to produce a function giving the epoch from the date and time. I give an example here for doing that with Open Watcom compiler included in Maple's distribution for Windows.
It is quite frustrating how slow map or zip acts over rtables (examples below). I find it quite useful to write a separate procedure and use the new compiler abilities in Maple 10.

Chi^2 calculations above some "size" or "complexity", using Maple 9.5 and Global Optimization Toolbox (GOT), may produce after some time of calculation error messages like:

"Execution stopped: stack limit reached.
The kernel has been shut down. Further computation cannot be performed."

Seeking workarounds, I have looked for information at ?kernelopts for kernelopts(stacklimit), but it was not very useful:

"Limits may be raised or lowered. Maple limits may not be raised above any system defined hard limits. "

It would be convenient if the subscripted version of type/integer could handle infinity and -infinity. Then, to specify an integer greater than, say, 1, we could do type(i, integer[2..infinity]). Currently I handle this as type(i, And(integer,Range(1,infinity))) which is not as nice, particularly because it isn't clear that 1 is excluded. The drawback of doing this is that it implies that infinity is allowed. However, because infinity is not an integer, it seems reasonable that it would return fals
The IBM Research August 2005 Ponder This challenge is out. The attached 11 line Maple procedure solves it in just under 2.5 seconds. Don't look at my solution if you want to do this yourself.
Previously I described how to change the default zoom setting for the Maple gui by modifying the appropriate initialization file. Another useful setting to change is the default background color of the help browser. This is done by modifying, in the initialization file, the line HelpBGColor=. I set it to HelpBGColor=240 240 240, that gives a light gray background that is less harsh on my eyes. The three fields should be integers from 0 to 255; they correspond to the red, green, and blue components of the color.
A while ago, I was trying to determine the fastest way, using Maple, to compute a list of a particular sequence of integers defined by a recurrence relation. This isn't a new idea of course, but I think the exercise is a useful introduction into the various ways of coding algorithms in Maple, and why some may be better than others.

My original example was a bit esoteric, so for simplicity I've redone it using the standard example of a recurrence relation, the Fibonacci sequence. We'll fix N, the number of Fibonacci numbers to compute, at 40000.

First 19 20 21 Page 21 of 21