Jean-Claude Arbaut

Mr. Jean-Claude Arbaut

72 Reputation

One Badge

3 years, 314 days
I used briefly Maple in the late 90s during my undergraduate studies. Back then it was Maple V r4 if I remember correctly, and a few years later Maple 6. I use again Maple since around 2018.

MaplePrimes Activity


These are answers submitted by Jean-Claude Arbaut

That does not really solve your problem, but:

assume(x::real):
is(ceil(x)=-floor(-x));

                              true

simplify(floor(-x)+ceil(x));
                      floor(-x) + ceil(x)

is(%=0);
                              true

 

 

If you are working with very large sets of combinations, it's usually a better idea to iterate through them one at a time, to keep memory usage low.

Maple can do that with combinat:-nextcomb, Iterator:-Combination or combstruct:-iterstructs.

You may also devise your own functions to achieve this. You can find algorithms for instance in Knuth's TAOCP volume 4A.

 

Here is an example with the three approaches:

 

with(combinat):
s:=firstcomb(5,2):
do
  print(s);
  s:=nextcomb(s,5)
until s=FAIL:

 

with(Iterator):
for a in Combination(5,2) do print(a) od:

 

with(combstruct):
it:=iterstructs('Combination'(5),size=2):
while not finished(it) do print(nextstruct(it)) od:

Try:

applyrule(exp(k::algebraic*a)=p^k,exp(-a));

First, you can do infolevel[IntegrationTools]:=3 to check what is printed by int. You will at least see that Maple needs the sign of n+1, which should not be a surprise.

To get an answer with or without assumptions:

int(x^n*exp(-x),x=0..infinity,method=MeijerG);

GAMMA(n+1)

And of course, int works with an assumption:

assume(n::nonnegint):
int(x^n*exp(-x),x=0..infinity);

factorial(n)

 

I see at least two problems:

* gamma is not assigned (you only had gamma = 0.1; not gamma := 0.1;). But you can't assign gamma as it's protected, unless you do first local gamma;.

* In the expression for Eq, you seem to be using square brackets as if they meant parentheses. They do not. To modify the order of evaluation, use parentheses only. Not square brackets, not curly brackets.

Try this:

with(plots):
display(arrow([0,0],[4,4.1],
color=red,shape=double_arrow,width=0.03,border=false,head_width=0.15,head_length=0.2),
arrow([4,4.1],[1,7.9],difference=true,
color=blue,shape=double_arrow,width=0.03,border=false,head_width=0.15,head_length=0.2),

arrow([0,0],[1,7.9],
color=green,shape=double_arrow,width=0.03,border=false,head_width=0.15,head_length=0.2));

 

Note that the output does not match your definition:

a:=proc(n) option remember;
if n<2 then n else n-2+add(a(k),k=1..n-1) fi end proc:
['a(n)'$n=0..20];

 [0, 1, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 
   8191, 16383, 32767, 65535, 131071, 262143, 524287]

However, it's easy to get the same output. Note that n-2 is replaced by n-1 in the formula for a(n):

a:=proc(n) option remember;
if n<2 then n else n-1+add(a(k),k=1..n-1) fi end proc:
['a(n)'$n=0..20];

 [0, 1, 2, 5, 11, 23, 47, 95, 191, 383, 767, 1535, 3071, 6143, 
   12287, 24575, 49151, 98303, 196607, 393215, 786431]

However, even now, 1535 does not match your 1536.

Page 1 of 1