8975 Reputation

18 Badges

5 years, 203 days

MaplePrimes Activity

These are Posts that have been published by vv

Maple strings contain extended ASCII characters (codes 1..255). 
The international characters such as  î, ș, Å, Ø ,Ă, Æ, Ç are multi-byte encoded. They are ignored by the Maple engine but are known to the user interface which uses the UTF-8 encoding.
The package StringTools does not support this encoding. However it is not difficult to manage these characters using Python commands (included in the Maple distribution now).
Here are the UTF-8 versions of the Maple procedures length and substring.
You may want to improve these procedures, or to add new ones (my knowledge of Python is very limited).

LEN:=proc(s::string) Python:-EvalFunction("len",s) end proc:

SS:=proc(s::string, mn::{integer, range(({integer,identical()}))})
  local m,n;
  if type(mn,integer) then m,n := mn$2 else m:=lhs(mn); n:=rhs(mn) fi; 
  if m=NULL then m:=1 fi; if n=NULL then n:=-1 fi;
  if n=-1 then n:=LEN(s) elif n<0 then n:=n+1 fi;
  if m=-1 then m:=LEN(s) elif m<0 then m:=m+1 fi;
  Python:-EvalString(cat("\"",  s, "\"", "[", m-1, ":", n, "]"  ));
end proc:

LEN("Canada"), length("Canada");
                              6, 6

LEN(s), length(s);
                              7, 8

SS(s, 1..), SS(s, 1..-3), SS(s, 1..1), SS(s, -7..2), SS(s,1), SS(s,-1); 
            "România", "Român", "R", "Ro", "R", "a"

diff(abs(z), z)  returns abs(1, z)  and the latter, for a numeric z, is defined only for a nonzero real z.
However,  functions such as abs(I+sin(t)) are (real) differentiable for a real t and diff should work. It usually does, but not always.

f:= t -> abs(GAMMA(2*t+I)):  # We want D(f)(1)
evalf(%);  # Error, (in simpl/abs) abs is not differentiable at non-real arguments
D(f)(1); simplify(%); 
evalf(%);   # 0.3808979508 + 1.161104935*I,  wrong

The same wrong results are obtained with diff instead of D

diff(f(t),t):   # or  diff(f(t),t) assuming t::real; 
simplify(%); evalf(%);   # wrong, should be real

To obtain the correct result, we could use the definition of the derivative:

limit((f(t)-f(1))/(t-1), t=1); evalf(%); # OK 
fdiff(f(t), t=1);    # numeric, OK



Note that abs(1, GAMMA(2 + I)); returns 1; this is also wrong, it should produce an error because  GAMMA(2+I) is not real;

Let's redefine now `diff/abs`  and redo the computations.

`diff/abs` := proc(u, z)   # implements d/dx |f(x+i*y|) when f is analytic and f(...)<>0
local u1:=diff(u,z);
1/abs(u)*( Re(u)*Re(u1) + Im(u)*Im(u1) )
f:= t -> abs(GAMMA(2*t+I));
D(f)(1); evalf(%);   # OK now



Now diff works too.

simplify(%); evalf(%);   # it works

This is a probably a very old bug which may make diff(u,x)  fail for expressions having subespressions abs(...) depending on x.

However it works  using assuming x::real, but only if evalc simplifies u.
The problem is actually more serious because diff/ for Re, Im, conjugate should be revized too. Plus some other related things. 

The Putnam 2020 Competition (the 81st) was postponed to February 20, 2021 due to the COVID-19 pandemic, and held in an unofficial mode with no prizes or official results.

Four of the problems have surprisingly short Maple solutions.
Here they are.

A1.  How many positive integers N satisfy all of the following three conditions?
(i) N is divisible by 2020.
(ii) N has at most 2020 decimal digits.
(iii) The decimal digits of N are a string of consecutive ones followed by a string of consecutive zeros.

add(add(`if`( (10&^m-1)*10&^(n-m) mod 2020 = 0, 1, 0), 
n=m+1..2020), m=1..2020);



A2.  Let k be a nonnegative integer.  Evaluate  

sum(2^(k-j)*binomial(k+j,j), j=0..k);



A3.  Let a(0) = π/2, and let a(n) = sin(a(n-1)) for n ≥ 1. 
Determine whether the series   converges.

asympt('rsolve'({a(n) = sin(a(n-1)),a(0)=Pi/2}, a(n)), n, 4);


a(n) ^2 being equivalent to 3/n,  the series diverges.


B1.  For a positive integer n, define d(n) to be the sum of the digits of n when written in binary
 (for example, d(13) = 1+1+0+1 = 3). 

Let   S =  
Determine S modulo 2020.

d := n -> add(convert(n, base,2)):
add( (-1)^d(k) * k^3, k=1..2020 ) mod 2020; 



Here is a very nice (but not easy) elementary problem.
The equality
ceil(2/(2^(1/n)-1)) = floor(2*n/ln(2));


is not an identity, it does not hold for each positive integer n.
How to find such a number?

[This is a re-post, because the original vanished when trying a conversion Question-->Post]

The problem appears in the recent book:
Richard P. Stanley - Conversational Problem Solving. AMS, 2020. 

The problem is related to a n-dimensional tic-tac-toe game. The first counterexample (2000) was wrong due to a multiprecision arithmetic error.
The  author of the book writes 
"To my knowledge, only eight values of n are known for which the equation fails,
and it is not known whether there are infinitely many such values",

but using Maple it will be easy to find more.

A brute-force solution is problematic because the smallest counterexample is > 7*10^14.

a := 2/(2^(1/n)-1): b := 2*n/ln(2):
asympt(b-a, n);


It results:  b - a → 1 (for n →oo);
So, to have a counterexample, b must be close to an integer
m ≈ 2*n/ln(2)  ==> n/m ≈ ln(2)/2

The candidates for n/m will be obviously the convergents of the continued fraction of the irrational number ln(2)/2.

convert(ln(2)/2, confrac, 200, 'L'):
for n in numer~(L[3..]) do
  if not evalf(ceil(a)=floor(b)) then printf("n=%d\n", n) fi;



So, we have obtained 16 counterexamples. The question whether there are an infinity of such n's remains open.


This year, the International Mathematics Competition for University Students  (IMC) took place online (due to Coronavirus), https://www.imc-math.org.uk/?year=2020

One of the sponsors was Maplesoft.

Here is a Maple solution for one of the most difficult problems.


Problem 4, Day 1.

A polynomial p with real coeffcients satisfies the equation

p(x+1)-p(x) = x^100, for all real x.

Prove that p(x) <= p(1-x) for   0 <= x and x <= 1/2.


A Maple solution.

Obviously, the degree of the polynomial must be 101.

We shall find effectively p(x).






p:= x -> add(a[k]*x^k, k=0..n+1):

collect(expand( p(x+1) - p(x) - x^n ), x):


f:=unapply(expand(eval(p(1-x)-p(x), S)), x);

proc (x) options operator, arrow; (94598037819122125295227433069493721872702841533066936133385696204311395415197247711/16665)*x-37349543370098022593228114650521983084038207650677468129990678687496120882031450*x^3-1185090416633200*x^87+5974737180020*x^89-(86465082200/3)*x^91+133396340*x^93-597520*x^95+2695*x^97-(50/3)*x^99+x^100-(2/101)*x^101+(16293234618989521508515025064456465992824384487957638029599182473343901462949018943/221)*x^5-69298763242215246970576715450882718421982355083931952097853888722419955069286800*x^7+(113991896447569512043394769396957538374962221763587431560580742819193991151970540/3)*x^9-(450021969146981792096716260960657763583495746057337083106755737535521294639081800/33)*x^11+3451079104335626303615205945922095523722898887765464179344409464422173275181060*x^13-648776866983969889704838151840901241863730925272452260127881376737469460326640*x^15+(1224135636503373678241493336115166408006020118605202014423201964267584789018590/13)*x^17-(32609269812588448517851078111423700053874956628293000710950261666057691492700/3)*x^19+(17369174852688147212979009419766100341356836811271344020859968314555332168046/17)*x^21-79714896335448291043424751268405443765709493999285019374276097663327217200*x^23+(26225149723490747954239730131127580683873943002539194987613420614551124468/5)*x^25-294965074792241210541282428184641838437329968596736990461830398732050600*x^27+(186430797065926226062569133543332579493666384095775768758650822594552980/13)*x^29-608766986011732859031810279841713016991034114339196337222615083429200*x^31+22758671683254934243234770245768111655371809025564559292966948184145*x^33-755022138514287934394628273773230341731572817528392747252537299270*x^35+(380420681562789081339436627697748498619486609696130138245054547645/17)*x^37-596110444235534895977389751553577405150617862905657345084592800*x^39+(186546013247587274869312959605954587283787420112828231587660264/13)*x^41-313678397368440441190125909536848768199325715147747522784400*x^43+6254306446857003025144445909566034709396500424382183891144*x^45-114204496639521606716779723226539643746613722246036949600*x^47+1916927215404111401325904884511116319416726263341690260*x^49-29677354167404548158728688629916697559643435320275800*x^51+(93950257927474972838978328999588595121346462082404180/221)*x^53-5650787690628744633775927032927548604440367748960*x^55+69888520126633344286255800412032531913013033640*x^57-806279422358340503473340514496960223283853200*x^59+8696895011389170857678332370276446830499368*x^61-87900576836101226420991143179656778525600*x^63+(10844299000116828980379757772973769420469/13)*x^65-7447304814595165455238549781183862150*x^67+(1065245686771269279784908613651828005/17)*x^69-497741911503981694520541768814800*x^71+3738596479537236832468307626580*x^73-26593490941061853727808593704*x^75+179403449737703736809514420*x^77-1149393958953185579079600*x^79+(21007540356807993839074/3)*x^81-(121855249152521399900/3)*x^83+(3818021878637120462/17)*x^85 end proc


plot(f, 0..1); # Visual check: f(x)>0 for 0<x<1/2


f(0), f(1/4), f(1/2);

0, 2903528346661097497054603834764435875077553006646158945080492319146997643370625023889353447129967354174648294748510553528692457632980625125/3213876088517980551083924184682325205044405987565585670602752, 0


sturm(f(x), x, 0, 1/2);



So, the polynomial f has a unique zero in the interval (0, 1/2]. Since f(1/2) = 0  and f(1/4) > 0, it results that  f > 0 in the interval  (0, 1/2). Q.E.D.


Download imc2020-1-4.mw

1 2 3 4 5 6 Page 1 of 6