## Can old maple version saved .m files in window be ...

Can old maple version saved .m files in window be readable in maple 2015 Linux version?

## "Dynamic assignment" of variables : Is this a docu...

Hi
I inadvertently discovered that it was possible to create variables in a kind of dynamic way.
I wonder if the way i did  is something which is documented somewhere?

TIA

 > restart:
 > vars   := [a, b__c, t[1]];
 (1)
 > k := 1: for i in vars do   ``||i := k;   k := k+1: end do:
 > vars;
 (2)
 >

## Where does this difference between formal and nume...

Hi,

I have a 2nd order linear ODE that I solved firstly in a formal way.
The plot of the solution contains a "hole" which, in fact, corresponds to the range where the formal solution is not real.
This seemed strange to me as I expected a real solution.
So I solved this ODE numerically and this gave me a real solution.
Could you please explain that to me ?

PS : These results are obtained with Standard Worksheet Interface, Maple 2015.2, Mac OS X, December 21 2015 Build ID 1097895

 > restart:
 > with(plots):
 > perturbation := .9*(diff(epsilon(t), t, t)) = (-28.67085587*piecewise(0.2000000000e-1*t < 0.8e-1, 0., 0.2000000000e-1*t < .12, -0.8e-1+0.2000000000e-1*t, 0.2000000000e-1*t < .14, .16-0.2000000000e-1*t, 0.2e-1)-0.7645561571e-1*t-1.548363347)*(diff(epsilon(t), t))-0.7596363e-1*piecewise(0.2000000000e-1*t < 0.8e-1, 0., 0.2000000000e-1*t < .12, -0.8e-1+0.2000000000e-1*t, 0.2000000000e-1*t < .14, .16-0.2000000000e-1*t, 0.2e-1)-0.202569683e-3*t+0.26997403e-1-10.10*epsilon(t)
 (1)
 > Digits:=10: EPS := rhs( dsolve({evalf(perturbation), epsilon(0)=0, D(epsilon)(0)=0}, epsilon(t)) ): # a lengthy expression that involves Kummer's special functions
 > plot(EPS, t=0..10, gridlines=true); Digits:=20: evalf(eval(EPS, t=5)); Digits:=10:
 (2)
 > numsol := dsolve({perturbation, epsilon(0)=0, D(epsilon)(0)=0}, numeric): odeplot(numsol, [t, epsilon(t)], t=0..10, gridlines=true, color=red)
 >

## How high is your chance to die for CoViD19 once...

by: Maple 2015

Hi,

The present work is aimed to show how bayesian inference methods can be used to infer (= to assess) the probabilility that a person detected infected by the SARS-Cov2  has to die (remark I did not write "has to die if it" because one never be sure of the reason of the death).
A lot of details are avaliable in the attached pdf file (I tried to be pedagogic enough so that the people not familiar with bayesian inference can get a global understanding of the subject, many links are provided for quick access to the different notions).

In particular, I explain why simple mathematics cannot provide a reliable estimate of this probability of death (sometimes referred to as the "death rate") as long as the epidemic continues to spread.

Even if the approach presented here is rather original, this is not the purpose of this post.
Since a long time I had in mind to post here an application concerning bayesian methods. The CoVid19 outbreak has only provided me with the most high-profile topic to do so.
I will say no more about the inference procedure itself (all the material is given in the attached pdf file) and I will only concentrate on the MAPLE implementation of the solution algorithm.

Bayesian Inference uses generally simple algorithms such as MCMC (Markov Chain Monte Carlo) or ABC (Approximate Bayesian Computation) to mention a few, and their corresponding pseudo code writes generally upon a few tens of lines.
This is something I already done with other languages but I found the task comparatively more difficult with Maple. Probably I was to obsess not to code in Maple as you code in Matlab or R for instance.
At the very end the code I wrote is rather slow, this because of the allocated memory size it uses.
In a question I posed weeks ago (How can I prevent the creation of random variables...) Preben gave a solution to limit the burst of the memory: the trick works well but I'm still stuked with memory size problems (Acer also poposed a solution but I wasn't capable to make it works... maybe I was too lazzy to modify deeply my code).

Anyway, the code is there, in case anyone would like to take up the challenge to make it more efficient (in which case I'll take it).

Note 1: this code contains a small "Maplet" to help you choose any country in the data file on which you would like to run the inference.
Note 2: Be careful: doing statistics, even bayesian statistics, needs enough data: some countries have history records ranging over a few days , or no recorded death at all; infering something from so loos date will probably be disappointing

The attached files:

• The pdf file is the "companion document" where all or most of it is explained.It has been written a few days ago for another purpose and the results it presents were not ontained from the lattest data (march 21, 2020 coronavirus)
• xls files are data files, they were loaded yesterday (march 28, 2020) from here coronavirus
• the mw file... well, I guess you know what it is.

Bayesian_inference.pdf

total-cases-covid-19_NF.xls

## How can I prevent the creation of random variables...

Hi,

Suppose you have to do some sequence of operations on a random variable (RV), and that you need to repeat this for several RV of the same family (e.g. exponential RV), differing only in the values of their parameters.

Here are two examples do code this.
1/ probably the most natural way to proceed (?)
restart:
with(Statistics):
X := a -> RandomVariable(Exponential(a)):
for n from 1 to 100 do
S := X(n);
# here are some operations to do
end do:
anames(alluser);

The last instruction indicates that 103 user variables have been created (X, n, S and 100 random variables).
Note that adding one of the commands S := 'S'; or unassign('S') before the end of the loop just unassigns S but not remove the variables named _ProbabilityDistribution, ..., _ProbabilityDistribution98.

2/ To prevent this inflation of random variables I thought to use the procedure Specialize:
restart:
with(Statistics):
X := RandomVariable(Exponential(a)):
for n from 1 to 100 do
S := Specialize(X, [a=n]):

# here are some operations to do
end do:
anames(alluser);

This doesn't change the situation.

So my (multiple) question:

• How can I prevent the creation of the objects _ProbabilityDistribution, ..., _ProbabilityDistribution98 given only one of them is used for a given value of the loop counter (once the operations have been done I pass to another random variable) ?
• How can I unassign a random variable ?
Maybe it is not possible as suggested by the help page about "_": "Any symbol beginning with an underscore (_) is effectively reserved for use only by library code. It is not available to users." ?

## evalf(Int(...)) seems unable to assess numericall...

Hi,

Here is an example where evalf ( Int(....) ) fails to compute an in integral.
The function to integrate is very smooth and, except method=_Gquad, all the others seem to fail (even method=_MonteCarlo fails, which is probably the most surprising thing!)

Is it a weakness of evalf+Int or a misusse of my own ?

 > restart:
 > interface(version)
 (1)
 > plot3d(cos(x*y), x=-1..3, y=-1..-0.2)
 > int(cos(x*y), [x=-1..3, y=-1..-1/5]); evalf[15](%);
 (2)
 > CodeTools:-Usage( evalf[10](Int(cos(x*y), [x=-1..3, y=-1..-0.2], method=_Gquad)) );
 memory used=1.24KiB, alloc change=0 bytes, cpu time=0ns, real time=0ns, gc time=0ns
 (3)
 > CodeTools:-Usage( evalf[10](Int(cos(x*y), [x=-1..3, y=-1..-0.2], method=_CubaVegas)) );
 memory used=22.14KiB, alloc change=0 bytes, cpu time=16.99s, real time=17.01s, gc time=0ns
 (4)
 > CodeTools:-Usage( evalf[10](Int(cos(x*y), [x=-1..3, y=-1..-0.2], method=_MonteCarlo)) );
 memory used=12.79KiB, alloc change=0 bytes, cpu time=1000.00us, real time=0ns, gc time=0ns
 (5)
 > N := 10^6: X := Statistics:-Sample(Uniform(-1, 3), N): Y := Statistics:-Sample(Uniform(-1, -0.2), N): Z := cos~(X*~Y): add(Z) / N * (4*0.8);
 (6)
 >

## NonlinearFit Error...

Hi everybody, I’m Helena

I have a function with the following general characteristics:

y= const*M*[Int_def (from a to b) [f(x)*g(x, M)*p(x, t, M,K)]dx]

::::::::::::::::::::::::::::::::::::::::::::::::::

y= dependent variable

a= 1.76E-7

b= 1.76E-9

x= integration variable

M= unknown parameter

K= unknown parameter

t= independent variable

::::::::::::::::::::::::::::::::::::::::::::::::::

... and I'm trying to fit it to my experimental data (421 values), to determine the best values for M and K. In order to do that I’m using the package Statistic and the NonlinearFit command from maple, however, it seems that NonlinearFit cannot fit the model (y(t)) to the experimental data. It gives an error: “Error, (in Statistics:-NonlinearFit) integration range or variable must be specified in the second argument, got HFloat(1.0) = 0 .. 1” for which I could not find any explanation or solution on the internet. Could you please give me some advice or ideas about how can I solve this problem?

## Maybe a bug in MAPLE 2015's Explore ?...

Hi,

Here is the minimal situation that reveals which that could be a (little) bug in the MAPLE 2015 version of Explore.

In the attached file y is a list of numbers and val(r) a procedure that just print the value the rth element of y.
Changing the value of r is done with Explore (of course of no interest at all).
If I define the parameter r as a list ( r=[1..numelems(y)] ), only the value of y[1] is displayed: changing the value of r generates an error.
This doesn(t happen if r is defined as a slider ( r=1..numelems(r) ).

I discovered than the initial instance of Explore defines r as an integer while all the others (due to a change of r) define r as a string.
In the last command of the attached file you will see hjow I have circumvent this problem.

Is it a bug in Explore or does it exist some way to force the values of r to the implicit type they have in r=[\$1..numelems(y)] ?

TIA

## collocation method for integral equation ...

Hello,

I am looking help for solving this integral equation using the collocation method with 1.5<= x<=3.5 ?

I have used the successive approximation method and the solution seems to be increasing.

Thanks

## How can I get "allvalues" of a list of "rootof" ?...

Hi,

I have a list of integers (>1) and for all of them I define an alias (in the attached file I've tried two different names for them : a[n] or a||n) wich represents the nth roots of the unity.
When I apply the procedure allvalues to a specific alias it returns the algebraic values of the corresponding roots of the unity.
But when aplied to the list of aliases it gives me back only the name of the alias, not the algebraic values.

How can I fix this ?

TIA

 > restart:
 > interface(version)
 (1)
 > for n from 2 to 3 do   alias(a[n]=RootOf(z^n-1)): end do: alias();
 (2)
 > allvalues(a[2]); allvalues(a[3]); seq(allvalues(a[n]), n=2..3)
 (3)
 > for n from 2 to 3 do   alias(a||n=RootOf(z^n-1)): end do: alias(); allvalues(a2); allvalues(a3); seq(allvalues(a||n), n=2..3)
 (4)
 > A := [alias()]: map(allvalues, A);
 (5)
 >

## derivative of a function depending on a function a...

Hello,

I have the general function F(x,g(y)), and I don't understand the following notation of the derivative of  F w.r.t  y in Maple ?  What is D2(F) ?  Can we provide a concrete example ?

Thank you!

## Value of an expression at specific position ...

Dear Users!

Hope you would be fine with everything. I want to evaluate an expression (diff(u(y, t), y)+diff(diff(u(y, t), y), t)) for various values of b at y = 0, t=1. Please help me to evaluate it. Thanks in advance,

restart; with(plots); a := .7; L := 8; HAA := [0, 2, 5, 10];

for i to nops(HAA) do

b := op(i, HAA);

PDE1[i] := diff(u(y, t), t) = diff(u(y, t), y, y)+diff(diff(u(y, t), y, y), t)-b*u(y, t)+T(y, t);

PDE2[i] := diff(T(y, t), t) = (1+(1+(a-1)*T(y, t))^3)*(diff(T(y, t), y, y))+(a-1)*(1+(a-1)*T(y, t))^2*(diff(T(y, t), y))^2+T(y, t)*(diff(T(y, t), y, y))+(diff(T(y, t), y))^2;

ICandBC[i] := {T(L, t) = 0, T(y, 0) = 0, u(0, t) = t, u(L, t) = 0, u(y, 0) = 0, (D[1](T))(0, t) = -1};

PDE[i] := {PDE1[i], PDE2[i]}; pds[i] := pdsolve(PDE[i], ICandBC[i], numeric)

end do;

## how to find necessary condition for real solution ...

with(RegularChains):
with(ChainTools):
with(MatrixTools):
with(ConstructibleSetTools):
with(ParametricSystemTools):
with(SemiAlgebraicSetTools):
with(FastArithmeticTools):
R := PolynomialRing([x,y,z,a,b]):
sys := [x^2 + y^2 - x*y - 1 = 0, y^2 + z^2 - y*z - a^2 = 0, z^2 + x^2 - x*z - b^2 = 0,x > 0, y > 0, z > 0, a - 1 >= 0, b-a >= 0, a+1-b > 0]:

dec := RealTriangularize(sys,R): # very slow
Display(dec, R);

dec := LazyRealTriangularize(sys,R): # it is faster
dec2 := value(dec): # very slow
value(dec2);

find a , b to satisfy sys have real solution

expect  one of solution is below, but above function are very slow, load a very time still no result, where is wrong?

R1 = a^2+a+1-b^2;
R1 = a^2-1+b-b^2;

[R1 > 0, R2 > 0]

## How can I force Maple to rewrite expressions conta...

Hi,

Is it possible to force Maple to simplify these Sum(s) ?
SimplifySum.mw

 > s := Sum(a*X[n]+b, n=1..N); simplify(s); value(s);  # part of the job done  but... IWouldLikeToHave = a*Sum(X[n], n=1..N) + b*N; # or +N*b, it doesn't matter
 (1)
 > s := Sum(X[n]+Y[n], n=1..N); (expand@value)(s); IWouldLikeToHave = Sum(X[n], n=1..N) + Sum(Y[n], n=1..N);
 (2)
 >

## How can I define (and sample) a mixture of two ra...

Hi,

I can't find a unique way to define a mixture of two random variables that enables at the same time to compute its PDF and generate a sample.
In the attached file you will find two methods :

1. the first one is the most formal and only CAS are supposed to be able to allow its implementation:
it enables computing the PDF and the CDF (trivial) but fails to generate a sample.
(PS : in a first attempt I had defined only the PDF, which should have been enough for method=envelope does work... ... at my opinion)

2. the second method is the one one would use in non CAS languages (for instance Matlab, R, ...). It enables generating a sample (of course) but fails to compute the PDF (which is not very surprising).

So my question: does anyone here would have some suggestions to make one these two methods capable to compute both the PDF (eventually the CDF) and generate samples ?

PS: still have this kind of problems (tomleslie suggested months ago that using interface(rtablesize=10) could help but it's not the case here)
Maple Worksheet - Error
Failed to load the worksheet /maplenet/convert/Mixture_of_random_variables.mw .