Items tagged with integerinteger Tagged Items Feed

Sorting with attributes

October 13 2005 by Maple

8

9

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.

Sorting a list with constraints

September 17 2005 by

0

1

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?

Octal Arithmetic

September 10 2005 by Maple

0

0

Similarly to Binary Arithmetic, Octal Arithmetic can be done using following module,

Binary Arithmetic

September 10 2005 by Maple

0

2

Silvexil announced in his blog a Binary Arithmetic package. Here is my version of it.

The Eratosthenes Sieve

September 08 2005 by Maple
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,

Finding the set of prime numbers ≤ n

September 08 2005 by Maple

1

1

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.

Binomial coefficients mod 2

August 28 2005 by Maple

2

0

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 Maple

0

9

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.

Overcoming the slowness of the map and...

August 19 2005 by Maple

0

4

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.

stack limit

August 05 2005 by Maple

0

5

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. "

Modify type/integer[a..b] so that a...

August 02 2005 by

1

4

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

Solve the Latest IBM "Ponder This" Challenge...

August 01 2005 by

2

7

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.

Changing background color of the help...

July 29 2005 by Maple

1

0

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.

Comparing different ways of building...

July 15 2005 by Maple

2

2

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