Maple 2020 Questions and Posts

These are Posts and Questions associated with the product, Maple 2020

The original question (crossed through below) was too vague, so I tried to clarified it:

I have the following expression
Q(h);
 1 /  2                    1                 2    / 3\   1     
 - |- - f(x) - D(f)(x) h + - @@(D, 2)(f)(x) h  + O\h / + - f(x)
 h \  3                    2                             2     

      1                                        2    / 3\\
    + - f(x) + 2 D(f)(x) h + 2 @@(D, 2)(f)(x) h  + O\h /|
      6                                                 /


It doesn't expand this following way...
expand(Q(h));
      /                   1                 2    / 3\\       
    2 |f(x) - D(f)(x) h + - @@(D, 2)(f)(x) h  + O\h /|       
      \                   2                          /   f(x)
  - -------------------------------------------------- + ----
                           3 h                           2 h

                                              2    / 3\
       f(x) + 2 D(f)(x) h + 2 @@(D, 2)(f)(x) h  + O\h /
     + ------------------------------------------------
                             6 h                       


But it does expand when I add the multiplication symbols manually:
expand(2*(f(x) - D(f)(x)*h + 1/2*(D@@2)(f)(x)*h^2 + O(h^3))/(3*h) + f(x)/(2*h) + (f(x) + 2*D(f)(x)*h + 2*(D@@2)(f)(x)*h^2 + O(h^3))/(6*h));
                                                    / 3\
       4 f(x)   1           2                    5 O\h /
       ------ - - D(f)(x) + - h @@(D, 2)(f)(x) + -------
        3 h     3           3                      6 h  

How can I expand my output without having to add the multiplication symbols?


------------------------------------old question below, please disregard----------------------






This happens each time I run a long loop.  (2,500 iterations, which takes about 3 hrs to complete)

Maple always hangs (it does not time out on odetest() ). But my question is not about this (as this is something I have to deal with for long time now and mentioned it before many times. May be one day Maplesoft will fix this). 

But I noticed this also.  When Maple hangs, (and it always hangs at least once during this loop), I then click on the button "interrupt the current operation". This does stop the hangs.

Next I do a restart and starts the loop from the loop counter where it hanged in order to continue.  

But It still hangs at that same iteration. I repeate this again, and it still hangs.

Now I close Maple altogether, start Maple again, open same worksheet, and repeat from the same iteration again from where it was at before, now it does not hang.

This tells me that restart and "interrupt the current operation" do not clean everything as expected. Else why only restarting Maple makes it work?

It means mserver.exe (separate process from the frontend) still is caching something related, and that is why it hangs at that iteration.

I can reproduce this each time I run the whole loop from the start.

I can't make a minimal example, since I have no idea where it hangs and why. And it is related to running a long loop.

I just know it hangs when doing odetest() with timeout which never timeout, and it seems random at what iteration it decides to hang.

But my question is really basic here: Does mserver.exe keep any information about the earlier user session/worksheet even after restart ? help says that restarts clear internal memory of the kernel.

Isn't mserver.exe  the Maple kernel? If so, then what could explain that only restarting Maple clears the hang? I am just looking for ideas that could explain this.

This type of problem is the most annoying thing about Maple for me. 

Maple 2020.1 on windows 10.

 

Anyone maybe helps me with writing the maple code mentioned in the following pdf.

I want to know about the potential flow around 3D domain.

 

Doc1.pdf

 

Dear everyone,

I want to execute a simple example by using Grid:-Send and Grid:-Receive commands. I have two questions:
1) Why does the Grid:-GetLastResult(0) command not return anything?

2) I tried to send the value of a, namely 2, from node 0 to node 1. It seems the execution is not stopped by Grid:-Send(1,a) and a_1:=Grid:-Receive(0) while CPU is not working.
Would anyone guide me?

The answer to the second question is more important to me.

Best wishes

 

 

restart;

Grid:-Run(0,"a:=2;");

Grid:-GetLastResult(0);

Grid:-Get(0,a);

Grid:-Send(1,a);

a_1:=Grid:-Receive(0);

Maple can return multiple values as expression sequence. The problem with this is that if one of the values is NULL, then one gets an error on the receiving end.

For example, suppose a proc foo() is meant to return 3 separate values. When doing 

  a,b,c := foo() 

This will fail if one of the values was NULL. For example, if b  was NULL, then Maple returns a,c only. The NULL value is discarded.

foo:=proc()
 local a,b,c;
  a:=1; b:=NULL; c:=3;
  return a,b,c;
end proc;

a,b,c := foo()

Error, mismatched multiple assignment of 3 variables on the left side and 2 values on the right side

I'd like to use NULL to indicate that this variable has no value (may be it could be something that could not be computed inside foo, or some solution that could not be found, and for any other reason.)

So currently I use {} instead of NULL everywhere to indicate no value for that variable and that works

foo:=proc()
 local a,b,c;
  a:=1; b:={}; c:=3;
  return a,b,c;
end proc;

a,b,c := foo()

And now I check using if b={} instead of if b=NULL and that works OK for what I want.

It would be nice if one could do this

  [a,b,c] := foo() 

And even if b was NULL, it will still keep that slot. But Maple will also replace [a,b,c]  with [a,c]  if b was NULL

So what is NULL used for in Maple exactly? (help says it is used to initialize an expression sequence). Since one can't return NULL as value.

In Mathematica, NULL can be returned as an actual value. For example

foo[] := Module[{a, b, c},
  a = 1; b = Null; c = 3;
  {a, b, c}
 ];

{a, b, c} = foo[]

gives

    {1, Null, 3}

My question: is using {} in place of NULL a common practice  in Maple to indicate no value for a variable being returned? Or is there a better way than this?

 

I have been using Maple 2017 but recently upgraded to MacOS Catalina. It doesn't work anymore. I would upgrade to Maple 2020, but worried will I have to upgrade again when the new MacOS 11 comes out? does anyone have any experiece dealing with similar situation on previous MacOS upgrade?

What is a good way to determine, at run time, a free symbol to use inside a proce, so it does not appear the same as one being passed in from outside?

Here is the problem. Inside a proc, user calls it with an ODE. The independent variable is passed in as the argument called x

Inside this proc, it does change of variables to do something else.  If the proc uses say as the new variabe, this could be the same as the passed in argument in the way it appears when being printed out to file.  

I know the local symbol is not the same as the passed in symbol, even if that happend to be also. As one is local and the other is not. So the math will still work, but the display will look very confusing to the user.

But since I am printing these out, these will show the same. 

So I need a way to make symbol inside proc, which looks different from the one being passed in.

An example will show the problem. 

foo:=proc(ode::`=`,y,x)
local t; #hoping this will not be the same looking as actual x
return PDEtools:-dchange({x=t^2},ode,t)  
end proc;

Now it is called as

ode:=diff(y(x),x)=sin(x);
foo(ode,y,x)

Which gives

The above worked, because the independent variable being passed in happend to be x

But if the proc was next called using global as the independent variable

ode:=diff(y(t),t)=sin(t);
foo(ode,y,t)

The output will be the same. Which looks confusing.

I want the out in this case to be using different letter than t, say z

The point is, the proc needs to use different looking symbol. Since it does not know which symbol the user is using, currently I use Z  since this is not likely to be used as independent variable by a user. most odes use x or t or z as independent variables

Again, this is all for display purposes, as I am printing these out, and want to avoid using the same looking symbol.

What is a good way to come up with symbol that does not look like the one being passed in?   The option of the user passing in the extra variable to use for this is not possible at all, as this is done deep inside and asking the user to pass in the spare symbol to use is not possible.

 

 

Hello

Although I have read the help file on how to use try-catch commands, I am not sure how they work exactly.  Here is an example of how I used them. (It is just a pseudocode).

myrout:=proc(arg1,arg2,arg3,args4,arg5)
try 
   .....
   timelimit(...)
   if condition then 
      ....
   else 
      timelimit(...)
      .....
   end if:
catch "time expired":
    return([a,b,c,d]):
finally
    .......
end try:
return([res1,res2]):
end proc:

Questions:

1) Does catch catch "time expired" from both calls of timelimit?  

2) Will the set of sequences under finally be executed when a "time expired" is caught? Somehow reading the help file i had the impression that it will.  If that is the case, how can it be avoided?  

 

Many thanks

Ed

Even though I was using the thoughtful answer provided by a poster in a previous MaplePrimes question, I was unable to successfully place labels on a column graph.  I have reduced the problem to adding a plots:-setoptions call, of any type, before calling ColumnGraph:
 

restart

with(Statistics)

T := [StringTools[CharacterFrequencies]("antidisestablishmentarianism")]

["a" = 4, "b" = 1, "d" = 1, "e" = 2, "h" = 1, "i" = 5, "l" = 1, "m" = 2, "n" = 3, "r" = 1, "s" = 4, "t" = 3]

(1)

ColumnGraph(T)

 

plots:-setoptions(size = [300, 250])

ColumnGraph(T)

Error, (in Statistics:-ColumnGraph) expecting plot structure but received: ROOT(BOUNDS_X(0), BOUNDS_Y(0), BOUNDS_WIDTH(300), BOUNDS_HEIGHT(250))

 

 


 

Download ColumnGraph_Problem.mw

 

The challenge for me is that for my work, several default plot parameters require changing including the default plot size which is too large. Hence my Maple initialization file includes calls to plots:-setoptions. Is this a bug in the ColumnGraph command and is there a work around that does not include removing the plots:-setoptions from my initialization file? Note: this problem occurs both in Maple 2019 and 2020. 

Hello,

I have noticed a small decrease in real time running 4 cpus versus 1 cpu. I am not sure if implemented the multi-threads  feature correctly or efficiently. Could you please show me some alternative coding methods with even more improvements? Thanks in advance.  

 

# Generative Model

n_trials := 16:
n_sample := 1:

subscribers := Vector[row](n_draw):
gen_model := proc(ib,ie)
        global n_trials, n_sample, prior_rate;
        local i, Y;
        for i from ib to ie do
          Y := RandomVariable(Binomial(n_trials, prior_rate(i)));
          subscribers(i) := apply(Sample(Y, n_sample), 1):
        end do:
        return subscribers:
end proc:

# Multi-threads, use 4 cpus
gm1 := Create(gen_model(1, n_draw/4), out1):
gm2 := Create(gen_model(n_draw/4 + 1, n_draw/2), out2):
gm3 := Create(gen_model(n_draw/2 + 1, 3*n_draw/4), out3):
gm4 := Create(gen_model(3*n_draw/4 + 1, n_draw), out4):


Usage(Wait(gm1, gm2, gm3, gm4));
memory used=1.97GiB, alloc change=0.52GiB, cpu time=83.56s, real time=45.52s, gc time=6.20s

 

ApproxBayesComp_Threads_2.mw

Hi,

I'm just trying Maple 2020.

In Maple 2016, a package may be loaded at restart by creating the file: 

c:\Program Files\Maple 2016\Users\maple.ini

and writing in it:

libname:= "F:\\Maple\\Trilinears", libname: 
currentdir("F:\\Maple\\Trilinears"):
libname:= "F:\\Maple\\mysql", libname:

 

But this does not work in Maple 2020.

What is the workaround for loading these packages when restart is executed?

Thanks in advance,

César Lozada

 

 

 

ApproxBayesComp_for_loop.mw

The observed data were 6 out 16 people signed up. Priors were defined by a uniform distribution. A Generative Model utilized a binomial distribution. A distribution of subscribers were generated, see plot below. By filtering the subscribers distribution for the value is equal 6, the posterior distribution was obtained. Why is the frequency the highest for subscribers = 16? Where did I go wrong in coding this problem?

Hi

This Carl Code evaluates fine

MySumP:= (j::integer)->
    seq(combinat:-numbcomb((j+10),(i+10))*p^(j+i)*(1-p)^(j+i), i= 0..0);
:[MySumP(10)]


[184756*p^10*(1 - p)^10]

But what I would like is whats inside the numbcomb argument to be displayed.

i tried

MySumP:= (j::integer)->
    seq(combinat:-numbcomb(``(j+10),``(i+10))*p^(j+i)*(1-p)^(j+i), i= 0..0)
:

[MySumP(10)]

What i would like displayed: numbbomb(20,10)*p^10*(1-p)^10 or (better) C(20,10)*p^10*(1-p)^10

For last 4 hrs, I've been chasing this problem.

Inside a module, there is a proc with a name say foo().

It is local to the module. When creating an .mla file that contains this module which was read from .mpl file, and running a test against it, Maple does not see this specific proc foo() as a proc, but only sees it as a symbol.

So the call to foo() never happens (error is generated).

I have a print statement inside foo() also which never prints. In the debugger, when I try to step into foo(), it fails also. Maple simply does not see it as a proc.

I also added my_module:-foo() in call, but this made no difference, even though it is not needed to prefix the module name, since foo is a local proc.

Now, instead of making an .mla, I now just read the .mpl file directly which make up the module. And now run the same test, and now maple see foo() as proc and the test runs with no error.

No change in the code at all. Nothing changed, exacept the test is called one time when package is inside the .mla vs. just using plain .mpl files.  The module has option package on it.

It seems something goes wrong with symbol table when inside mla file.

When I do 

libname := currentdir(), libname;
LibraryTools:-Browse()

And browse the content inside my mla file, I see no problems, it lists all 24 procs inside the package, and I can see foo listed there as type PROC.

But in the code, what printing whattype(foo)  it says it is symbol when using mla file, but it says it is a procedure when not using mla, but just by reading the .mpl file which went into the .mla

I will try to make an example to reproduce this if I can. But has any one seen something like this before? What could cause this?  I've restarted Maple ofcourse, and this made no difference.

The way I build the mla is

FileTools:-Remove(cat(currentdir(),"/my.mla"));
LibraryTools:-Create(cat(currentdir(),"/my.mla"));

read cat(currentdir(),"/my_module.mpl");
LibraryTools:-Save('my_module',"my.mla");

For now, I will stop using .mla and just read the .mpl file each time to use the code, as this seems safer and this always worked and never gave any problems.

The code is large. I also use database. So I am not sure I can make a small example but will try.  

I am using 2020.1 on windows 10.

I am not able to use Maple's map() to do the following. Given 2 lists of things (of equal length), map a function that take 2 arguments, from these 2 lists, in order.  Here is an example to illustrate. In Mathematica

a = {1, 2, 3}; b = {7, 8, 9};
MapThread[f, {a, b}]

           {f[1, 7], f[2, 8], f[3, 9]}

In Maple, I tried map and map2, map[n] etc.. not able to get the result I want. I want to use map, and not ~

A:=[1,2,3];
B:=[7,8,9];
map((x,y)->f(x,y),A,B)

          [f(1, [7, 8, 9]), f(2, [7, 8, 9]), f(3, [7, 8, 9])]

 

map[2]((x,y)->f(x,y),A,B)

           [f([1, 2, 3], 7), f([1, 2, 3], 8), f([1, 2, 3], 9)]

and other things.

How to get same result as MapThread, using map?

First 39 40 41 42 43 44 45 Last Page 41 of 55