Items tagged with integer


I have an Nx3 Matrix A and each row looks like [integer,integer,*]. Matrix A acts like a function of two variables in the sense that the ordered pairs that you get be selecting the first two entries of each row are all distinct.

I would like a slick way to convert A to a Matrix B for which B[i,j]=* where * is the third entry in the unique row of A that looks like [i,j,*]. We can insert 0 for "blanks."

For example, if


1 3 a
1 4 d
1 1 b




I have a problem in maple with conversion to the binary writing system.  I would like to convert integers into a binary string of fixed length.


So 7 should become [0,0,0,1,1,1] while 22 should become [0,1,0,1,1,0].

Is that possible? (it would save me quite some time).  I know there are methods to do binary conversion in maple but it's not really what I want.


Many thanks!

Is there a way to specify a user-supplied routine when using the define_external command?

Here is a simple Fortran program to show what I want.


This question comes from a math forum, somebody wanted to solve the following system with maple, but he didn't find a way for it:

eqs:={20<=a,a<=60, 20<=b,b<=60, 20<=c,c<=60, 20<=d,d<=60, a+b+c+d=160, 4*a+6*b+8*c+12*d=1200};

where a,b,c,d are integers.

A possible workaround to try each a,b,c,d, numbers in the given ranges to find the solutions, but it would be good from maple to solve it directly.

Can Maple solve these kinds of problems directly?

Hello everybody,


I have a list of 8 integers and I want to extract all the possible sublists of this list.

For example if the list is L:=[1,2,3,4,5,6,7,8] I want to extract





Is there a simple way to do that? Since there are 2^8=256 of such sublists, my idea was to

write a for i  from 1 to 256 and convert i to a binary number on each iteration, e.g, i =123

is the binary number 1111011, which would correspond to sub list


I'm currently doing some proof of concept implementation of what comes closest to be described as "network flow" problem inside Maple. The current applicability is limited to one source and one sink, flows are not interesting, meaning the edge-costs are all equally set to 1. The chosen vector-based representation for a simple network (adjacency matrix)


  S 1 2 E
S 0 1 1 0
1 0 0 0 1
2 0 0 0 1
E 0 0 0 0

is as follows:

MM := [[2], S, [[1, 2], [[], 1], [[], 2]], E]


I'd like to perform following operation as gracefully and computationally inexpensive as possible:

b := [[2, 3], 1, 2, 3, 4, 5]
c := b[2 .. nops(b)]
c[b[1, 1]] := c[b[1, 2]]
c := ListTools:-MakeUnique(c)
c[b[1, 1]] := max(c) + 1;

b[1] always contains a list of two consecutive indices which should be combined into one element of the list and having assigned the largest integer in the list. In the about example:

Somebody named Alec have gave me this programme after he modified my old programme.

Good Night all:

Anybody could tell me how can I obtain this integral with maple?

int(x^s*exp(-1/2*(x*(1+k)+exp(-x))), x = -infinity .. infinity)

Hello - I wonder if anyone can help.

I want to convert the square root of 2 into base 12 from decimal, to about 1000 digits. I've had a go at this with Maple using convert/base but this will only let me convert integers. Is there a way to display sqrt(2) in base 12, either by calculating sqrt(2) and then converting, or calculating and converting all in one go?

Thanks for any suggestions


I'm looking to display some results in my for loop but not others.  This is my code:

for j from 0 to 10 do
    fileName := sprintf(`destination%d.txt`, j):
    datalist := readdata(fileName, integer, 3):
    pointplot3d(datalist, style = line, linestyle = solid, thickness = 5);
end do;


Dear all,

I am using version 12. I would like to sort a list of lists of  integers in respect to some of the terms of the sublists.

For example, the list

[  [3,5], [2,10], [9,1], [4,2], [7,3]  ]

would be sorted as:

[  [9,1], [4,2], [7,3], [3,5], [2,10]  ]

in respect to the second variable.

Actually, I found that the sort command with  the 'lexorder'[n] option would exactly this, except that it

seems that it doesn't work with numbers, but only with letters.

Any ideas?


Hi everyone,

does anyone know how to use the LagrangianMultipliers function so that the solutions obtained will be the closest integer smaller than whatever the output is for each entry in the list.


LagrangeMultipliers(x1*x2*x3*x4*x5*x6*x7, [x1+x2+x3+x4+x5+x6+x7-32, x1^2+x2^2+x3^2+x4^2+x5^2+x6^2+x7^2-160],[x1,x2,x3,x4,x5,x6,x7]);

will give us entries which are not integers, and if i use other conditions I will sometimes not receive any integer solutions - which is to be expected.

Any help would be warmly received.



I don't even know where to start with this one:(

 Write a procedure PRIME_BRACKET that takes as input any positive real number (not just an integer) and finds the smallest prime number larger than or equal to the input.

5 6 7 8 9 10 11 Last Page 7 of 21