sand15

615 Reputation

11 Badges

8 years, 311 days

MaplePrimes Activity


These are questions asked by sand15

Hi,

Here is a set of simple instructions to illustrate the first problem :

restart:
fichier := TheNameOfSomeFile:
writeto(fichier):
printf("Hello\n"):
writeto(termional):

When executed from Maple 2015 or Maple 2016, the content of TheNameOfSomeFile is

Hello

When executed from Maple 2018 it becomes

> printf("Hello\n"):
Hello
> writeto(terminal):

 

Using interface(echo=0) changes nothing to the result obtained with Maple 2018.

Has anyone ever encountered this problem?
How can I fix it?


Thanks in advance

Hi everybody,

Why f generates the error "... orthopoly is not a module or member"

f := proc(n)
   uses orthopoly;
   H(n,z);
end proc;

as g works correctly ?

g := proc(n)
   orthopoly:-H(n,z);
end proc;


Thanks in advance

Hi everybody,

I want to compare the performances of a set of codes that realize the same operation.
The worksheet I use is organized this way

restart:
Code1 := proc(...) ... end proc:
CodeTools[Usage](Code1(...))

restart:
Code2 := proc(...) ... end proc:
CodeTools[Usage](Code2(...))

and so on.

It appears that the execution of the whole worksheet doesn't always return the same values for the different indicators, which means that the ranking of the codes can be affected

To obtain more precise indicators I thought do do some statistics.
I then replace each bloc by :

restart:
CodeX := proc(...) ... end proc:  # here X stands for 1, 2, ...
N := "some positive integer"
for n from 1 to N do
   CodeTools[Usage](CodeX(...))
   "catch the values of the indicators"
end do:
"compute some statistics on the samples ot these indicator"

The problem is that Usage doesn't return any values but only does a printf.
I investigated two ways to circumvent this problem:

  1. - redirect the printings to file MyFile by using writeto(MyFile)
    - read MyFile
    - extract the numerical values of the indicators
    - compute the desired statistics
      It works well but it is far from being elegant
     
  2. - insert with(CodeTools) after the restart (within a separate block)
    - copy-paste the output of showstat(Usage) to define a new function, let's say MyUsage
    - insert at the correct place some lines like
             Tcpu := CodeTools:-FormatTime(result:-cputime)  (if my time of interest is the cpu time)
                          (this for all the indicators)
    - insert the line  [..., Tcpu, ...]; before the 'end proc' declaration;
      More elegant but it doesn't work
      I get the error   error (in T) DoUsage is not a command of the CodeTools package


Do you have some idea (beyond the first method above) of the way to catch the performance indicators that Usage computes ?

Thanks in advance


 

Hi,

 

I'm working on coding questions and I want to realize a particular addition (sometimes called "Nim addition")
Here is an example in base 3

Let A=11 and B=21 two numbers written inbase 10.
I want to realize the operation "A plus B" defined this way

  1. write A and B in base 3 : A -> a=102  and B -> b=210
  2. do c=a+b just as if a and b were numbers in base 10 : c=312
  3. compute all digits modulo 3 : 312 -> 012 = 12
  4. write this number in base 10 : 12 -> 5

Then 11 plus 21 = 5


In Maple"s syntax :

A := 11:
B := 21:
a := convert(A, base, 3):   # returns [1, 0, 2]
b := convert(B, base, 3):   # returns [0, 1, 2]


# the simplest thing I found to implement operation 2 and 3 above is :
# 1/ convert each list into polynomials (let's say pa and pb)
# 2/ set pc = pa+pb mod 3
# 3/ convert pc into a list
#
# Instead of coding something like pa := add(a[k]*x^(k-1), k=1..numelems(a)),
# I found more astute to use the gfun package

sa := gfun[listtoseries](a, x, 'ogf'):  # returns x^2+2+O(x^3)
sb := gfun[listtoseries](b, x, 'ogf'):  # returns 2*x^2+x+O(x^3)
pc := convert(sa, polynom)+convert(sb, polynom) mod 3; # returns x+2


Unfortunately I can't use now gfun[seriestolist](pc, 'revogf') for pc is obviously not a serie !
Reciprocally sc := sa+sb mod 3 doesn't return x+2+O(x^3)

Then I'm trapped here and I don't know how to go further
(of course I know how to proceed if I build directly the polynoms associated to a and b ... but it is far less elegant)

Does anyone have some idea ?

This problems raise the following question: how can we add tho series ?
For instance sa+sb returns (x^2+2+O(x^3))+(2*x^2+x+O(x^3)) without, apparently, no way to simplify this into  x+2+O(x^3)


Thanks in advance

Hi everybody,

I'm working with orthogonal or Bernstein polynomials and I would like to keep my results expressed in terms of such polynomials.
Here is a notional example.
 

with(orthopoly):
#  first example : the result of diff is of the desired form  (p*q)' =  p' * q + p * q'
p := H(2, x):
q := H(3,x):
pq;
    (4*x^2-2)*(8*x^3-12*x)
dpq := diff(pq, x);
    8*x*(8*x^3-12*x)+ (4*x^2-2)*(24*x^2-12)   
  
#  second example : the result of diff is not exactly of the desired form (p*q)' =  p' * q + p * q'
# for  p' * q has been expanded

p := H(1,x)
q := H(3,x):
pq := p*q;
    2*x*(8*x^3-12*x)
diff(pq, x);
    16*x^3-24*x+ 2*x*(24*x^2-12)  
    
#  third example : here the result has been fully expanded
p := H(1,x)
q := H(2,x):
pq := p*q;
    2*x*(4*x^2-2)
diff(pq, x);
    24*x^2-4
   

First question : How could Iforce Maple to  preserve the form  p' * q + p * q' in all the situations ?

______________________________________________________________________


In the first test case the value of dpq (   8*x*(8*x^3-12*x)+ (4*x^2-2)*(24*x^2-12)    ) is not expressed in terms of Hermite polynomials.
I would like it to be, so I tried this ...

r := degree(dpq, x):
A := add(a__||k*H(k,x), k=0..r):
C := coeffs(expand(dpq-A), x)
S := solve(C, {seq(a__|-k, k=0..r)});
      {a0=48, a1=0, a2=72, a3=0, a4=10}
Hdpq := subs(S, A)
    160*x^4-192*z^2+24

...but  I had hope to obtain   Hdpq := 48*H(0,z)+72*H(2,z)+10*H(4,z), so here 
   48 + 72 * (4*z^2 - 2) + 10 * (16*z^4 - 48*z^2 + 12)
 

Second question : How could I prevent Maple to simplify the result os subs(S, A) ?




Thanks in advance

First 8 9 10 11 12 13 14 Last Page 10 of 20