## 6117 Reputation

3 years, 327 days

## Algorithms...

Maple

There are no efficient algorithms for this.
How would you simplify by hand the expression

```512*b^9 + (2303*a + 2304)*b^8 + (4616*a^2 + 9216*a + 4608)*b^7 + (5348*a^3 + 16128*a^2 + 16128*a + 5376)*b^6
+ (4088*a^4 + 16128*a^3 + 24192*a^2 + 16128*a + 4032)*b^5 + (1946*a^5 + 10080*a^4 + 20160*a^3 + 20160*a^2
+ 10080*a + 2016)*b^4 + (728*a^6 + 4032*a^5 + 10080*a^4 + 13440*a^3 + 10080*a^2 + 4032*a + 672)*b^3
+ (116*a^7 + 1008*a^6 + 3024*a^5 + 5040*a^4 + 5040*a^3 + 3024*a^2 + 1008*a + 144)*b^2
+ (26*a^8 + 144*a^7 + 504*a^6 + 1008*a^5 + 1260*a^4 + 1008*a^3 + 504*a^2 + 144*a + 18)*b + 9*a^8
+ 36*a^7 + 84*a^6 + 126*a^5 + 126*a^4 + 84*a^3 + 36*a^2 + 9*a + 1```

to  (a+2*b+1)^9 - a*(a-b)^8   ?

## Putnam Mathematical Competition 2018...

Maple

Maple can solve the easiest two problems of the Putnam Mathematical Competition 2018.  link

Problem A1

Find all ordered pairs (a,b) of positive integers for which  1/a + 1/b = 3/2018

 > eq:= 1/a + 1/b = 3/2018;
 (1)
 > isolve(%);
 (2)
 > # Unfortunalely Maple fails to find all the solutions; eq must be simplified first!
 > (lhs-rhs)(eq);
 (3)
 > numer(%);
 (4)
 > s:=isolve(%);
 (5)
 > remove(u ->(eval(a,u)<=0 or eval(b,u)<=0),[s]);
 (6)
 > # Now it's OK.

Problem B1

Consider the set of  vectors  P = { < a, b> :  0 ≤ a ≤ 2, 0 ≤ b ≤ 100, a, b in Z}.
Find all v in P such that the set P \ {v} can be partitioned into two sets of equal size and equal sum.

 > n:=100: P:= [seq(seq([a,b],a=0..2), b=0..n)]:
 > for i to k do   v:=P[i]; sv:=s-v;   if irem(sv[1],2)=1 or irem(sv[2],2)=1 then next fi;   cond:=simplify(add( x[j]*~P[j],j=1..k))-sv/2;   try     sol:=[];     sol:=Optimization:-Minimize          (0, {x[i]=0, (cond=~0)[], add(x[i],i=1..k)=(k-1)/2 }, assume=binary);     catch:   end try:   if sol<>[] then numsols:=numsols+1;      print(v='P'[i], select(j -> (eval(x[j],sol[2])=1), {seq(1..k)})) fi; od: 'numsols'=numsols;
 (7)
 >

Edit.
Maple can be also very useful in solving the difficult problem B6; it can be reduced to compute the (huge) coefficient of x^1842 in the polynomial

g := (1 + x + x^2 + x^3 + x^4 + x^5 + x^9)^2018;

The computation is very fast:

coeff(g, x, 1842):   evalf(%);

0.8048091229e1147

## A useful exercise for Maple programmers...

Maple

The Maple help contains a nice example of a puzzle solver named alphametic,  see  ?Iterator,Permute.
The goal is to determine the distinct digits represented by letters which satisfy a given  equation. The provided solved example is:

"16540*781 = 12904836 + 12904"
i.e.  m=1, a=6, p=5 etc.

It's worth studying the program (written as a module) because it includes a few useful techniques.
I would suggest the following exercise for a Maple (young) programmer.

1.  When solving the "classical" puzzle  "FORTY+TEN+TEN=SIXTY", instead of the correct answer "29786+850+850=31486",   you will see
"2978Y+850+850=3148Y".
Try to find what's going on and correct the code.

2. The solutions given by alphametic include numbers beginning with a zero.
Execute e.g. .
Modify the code to produce only standard numbers.

## Great Hall Floor and Maple...

Maple

I have recently visited the Queen's House at Greenwich  (see wiki),  an  important building in British architectural history (17th century).
I was impressed by the Great Hall Floor, whose central geometric decoration seems to be generated by a Maple program :-)

Here is my code for this. I hope you will like it.

```restart;
with(plots): with(plottools):
n:=32: m:=3:#    n:=64: m:=7:

a[0], b[0] := exp(-Pi*I/n), exp(Pi*I/n):
c[0]:=b[0]+(a[0]-b[0])/sqrt(2)*exp(I*Pi/4):
for k to m+1 do
c[k]:=a[k-1]+b[k-1]-c[k-1];
b[k]:=c[k]*(1+exp(2*Pi*I/n))-b[k-1];
a[k]:=conjugate(b[k])  od:
b[-1]:=c[0]*(1+exp(2*Pi*I/n))-b[0]:
a[-1]:=conjugate(b[-1]):
c[-1]:=a[-1]+b[-1]-c[0]:
seq( map[inplace](evalf@[Re,Im], w), w=[a,b,c] ):
Q:=polygonplot([seq([a[k],c[k],b[k],c[k+1]],k=0..m-1), [c[m],a[m],b[m]], [a[-1],b[-1],c[0]]]):
display(seq(rotate(Q, 2*k*Pi/n, [0,0]),k=0..n-1), disk([0,0],c[m][1]/3), axes=none, size=[800,800], color=black);
```

## A limit from an undergraduate competitio...

Maple

At a recent undegraduate competition the students had to compute the following limit

 > Limit( n * Diff( (exp(x)-1)/x, x\$n), n=infinity ) assuming x<>0;
 (1)

Maple is able to compute the symbolic n-fold derivative and I hoped that the limit will be computed at once.

Unfortunately it is not so easy.
Maybe someone finds a more more straightforward way.

 > restart;
 > f := n * diff( (exp(x)-1)/x, x\$n );
 (2)
 > limit(%, n=infinity);
 (3)
 > simplify(%) assuming x>0;
 (4)

So, Maple cannot compute directly the limit.

 > convert(f, Int) assuming n::posint;
 (5)
 > J:=simplify(%)  assuming n::posint;
 (6)
 > L:=convert(J, Int) assuming n::posint;
 (7)
 > L:=subs(_k1=u, L);
 (8)

Now it should be easy, but Maple needs help.

 > with(IntegrationTools):
 > L1:=Change(L, u^n = t, t) assuming n::posint;
 (9)
 > limit(L1, n=infinity);  # OK
 (10)
 > ####################################################################

Note that the limit can also be computed using an integration by parts, but Maple refuses to finalize:

 > Parts(L, exp(u*x)) assuming n::posint;
 (11)
 > simplify(%);
 (12)
 > limit(%, n=infinity);
 (13)
 > value(%);  # we are almost back!
 (14)
 >
 1 2 3 4 Page 1 of 4
﻿