Maple 2015 Questions and Posts

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

Hello everyone! I was trying to draw a circle point by point using animate, but there's a catch: I'd like it to be created in front of the user, that is seeing every point being drawn in sequence.

Like this, but with the point leaving a trail behind him.

Can anyone help?

Hello everyone, we are doing some excercises on graphs. The commands PetersenGraph and GeneralisedPetersenGraph only draw an indirected one, and i was wondering, is there a way to draw a directed Petersen graph?

Hi, 

I represent 3 thin parallel slices of colors red, green and blue; all have the same transparency equal to 0.5
For the default orientation of the display, the blue slice is on the forefront, the red one in the background and the green one in beween. Then the blue slice is "bluer" than green and  the green one "greener" than red (FIG 1)
If you rotate manually the figure in order to place the red slice in the forefront and the blue one in the background, you expect to have the red slice "redder" than the green one and the green one "greener" than the blue one (FIG 2)
This is not the case.

The order in which the slices appear in the PLOT3D command defines the foreground and the background, but these latter are not dynamically recalculated when the figure is rotated.
To recover the correct colors one must revert the order of the slices in PLOT3D (FIG 3)

Are we comdamned to change to change manually the order of the slices in PLOT3D or does it exist an option whixh avoids doing so?

Don't pay too much attention to the plots above for the foreground is strangely correct on figure 2 ???

restart

with(plottools):

alpha := Pi/18.:
a := 2*cos(alpha):
b := 2*sin(alpha):
e := 0.02:
p := [[0,0,0],[a,b,0],[a,b,1],[0,0,1]],
     [[0,e,0],[a,b+e,0],[a,b+e,1],[0,e,1]],
     [[0,0,0],[0,e,0],[0,e,1],[0,0,1]],
     [[a,b,0],[a,b+e,0],[a,b+e,1],[a,b,1]],
     [[0,0,0],[a,b,0],[a,b+e,0],[0,e,0]],
     [[0,0,1],[a,b,1],[a,b+e,1],[0,e,1]]

[[0, 0, 0], [1.969615506, .3472963554, 0], [1.969615506, .3472963554, 1], [0, 0, 1]], [[0, 0.2e-1, 0], [1.969615506, .3672963554, 0], [1.969615506, .3672963554, 1], [0, 0.2e-1, 1]], [[0, 0, 0], [0, 0.2e-1, 0], [0, 0.2e-1, 1], [0, 0, 1]], [[1.969615506, .3472963554, 0], [1.969615506, .3672963554, 0], [1.969615506, .3672963554, 1], [1.969615506, .3472963554, 1]], [[0, 0, 0], [1.969615506, .3472963554, 0], [1.969615506, .3672963554, 0], [0, 0.2e-1, 0]], [[0, 0, 1], [1.969615506, .3472963554, 1], [1.969615506, .3672963554, 1], [0, 0.2e-1, 1]]

(1)

f   := k -> transform((x, y, z) -> [x, y+k, z]):
col := k-> COLOR(RGB, op(ListTools:-Rotate([1, 0, 0], -k))):
t   := TRANSPARENCY(0.5):
PLOT3D(POLYGONS(p, t, col(0)), f(1)(POLYGONS(p, t, col(1))), f(2)(POLYGONS(p, t, col(2))), AXESLABELS(2, 3, 1))

 

PLOT3D(POLYGONS(p, t, col(0)), f(1)(POLYGONS(p, t, col(1))), f(2)(POLYGONS(p, t, col(2))), AXESLABELS(2, 3, 1))

 

PLOT3D(f(2)(POLYGONS(p, t, col(2))), f(1)(POLYGONS(p, t, col(1))), POLYGONS(p, t, col(0)), AXESLABELS(2, 3, 1))

 

 


 

Download Background_Foreground.mw

Hello everyone.

I've took part in a math competition and we use Maple 15 as software to solve the various problems. We, apart from solving the problems, to correct and give a score to 4 other participants per problems. We have to download their solution and read it and then valuate it. However one of the files is .maple and not .mw. How can I open it? The tutors said to us that we just have to change extension and copy-paste the content into another document, but the the program doesn't let me copy the text (it's a mess) because "it's too big to be copied". I have obviously asked them how to solve this since what they said isn't working, but they didn't answer...

So, does anyone know how I could convert a file from .maple to .mw and still see the document as it was intended?

Hi everyone! I was writing this code for an interactive component, when I stumbled into a problem that I couldn't solve...

Here is the code.

use DocumentTools in 
if type(Do(%NIniziale), posint) then
    if Do(%NIterazioni)<=100 then
        if type(Do(%NIterazioni), posint) then
            Do(%E="Valid Values!");
Even:=Do(%Pari);
Odd:=Do(%Dispari);
     Iterazioni:=proc (N, i) 
         local m, n;
         n:=N;  
         for m from 1 to i do 
             if type(n, even) = true then
                 n := Even; 
                 else 
                     n := Odd; 
                     end if;
                     end do; 
                     return (SetCellFormula("Risultati", i, 1, eval(n)));
                     end proc;
ix:=Do(eval(%NIterazioni));
Nx:=Do(eval(%NIniziale));
seq(Iterazioni(Nx,y),y=1..eval(ix));
if Do(%NIterazioni)<100 then
seq(SetCellFormula("Risultati", x, 1, "//"), x=1+ix..100);
end if;
        else
            Do(%E="Inavalid Values");
            seq(SetCellFormula("Risultati", x, 1, "ERROR"), x=1..100);
            end if;
            else 
                Do(%E="Invalid Values");
                seq(SetCellFormula("Risultati", x, 1, "ERROR"), x=1..100);
            end if;
            else 
                Do(%E="Invalid Values");
                seq(SetCellFormula("Risultati", x, 1, "ERROR"), x=1..100);
            end if;
end use; 
 

Now this are what the names stands for:

%Pari is a math conainer in which there is a function of n that is to be used when n is even;

%Dispari is a math conainer in which there is a function of n that is to be used when n is odd;

"Risultati" is the name of a spreadsheet on which the results will be displayed;

%NIterazioni is a math conainer in which there is a posint that indicates how many times the procedure is to be iterated;

%NIniziale is a math conainer in which there is the starting number (another posint) to which on which the procedure will operate;

%E is a text area that will signal the validity of the input.

What I wanted to do was a procedure that reiterated two function on a given number a given amount of times and returned the result of every passage, however, when computing, it returns the function in n and not the final numbers. 

Here is what I mean! (Click for the link, hope Google Drive doesn't break the code when downloaded.).

I have opened the Spread package in the startup-code, and I really want to use the spreadsheet even though it is deprecated in newer versions. When you'll open, the function will be the ones of the Collatz Conjecture, however I want it to be able to iterate any function of n, which will be acquired via input, and will be to the user's choice.

I tried everything that came to my mind: using text area, assigning n outside of the preocedure, using evalf, eval, putting the return inside the if system, opening and closing a do inside "then" and one isndide "else" , changing names and everything... But I couldn't solve it. on the internet and on the MapleHelp I didn't find anything.

So can anyone tell me ( most importantly) why it doens't compute the formulas and just leaves them as input and (less important then the why, but still important and would appreciate) how can it be solved? Thanks to everyone even if you just read this, I know it is amybe a little too much.

I find some book teach motion planning in topology 

but do it need to formulate the equations for the environments such as a map with obstacle in 2d or 3D?  the environment is quite complex, how can these equations be formulated?

 

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

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]];

[a, b__c, t[1]]

(1)

k := 1:
for i in vars do
  ``||i := k;
  k := k+1:
end do:

vars;

[1, 2, 3]

(2)

 


 

Download Assignement.mw

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 ?

Thanks in advance

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)

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:

 

-0.26529838913395427314e88+0.10340147081332027605e89*I

(2)

numsol := dsolve({perturbation, epsilon(0)=0, D(epsilon)(0)=0}, numeric):

odeplot(numsol, [t, epsilon(t)], t=0..10, gridlines=true, color=red)

 

 


 

Download dsolve_vs_numeric_dsolve.mw

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

total-deaths-covid-19_NF.xls

Bayesian_Inference_ABC+MCMC_NF_2.mw


 

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." ?

Thanks in advance

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)

`Standard Worksheet Interface, Maple 2015.2, Mac OS X, December 21 2015 Build ID 1097895`

(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](%);

Si(3)+Si(1)-Si(3/5)-Si(1/5)

 

2.00705070023234

(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

 

2.007050700

(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

 

Int(Int(cos(x*y), x = -1. .. 3.), y = -1. .. -.2)

(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

 

Int(Int(cos(x*y), x = -1. .. 3.), y = -1. .. -.2)

(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);

HFloat(2.0076470771803545)

(6)

 


 

Download evalf_Int.mw

 

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?

Thank you so much in advance for your attention and help.

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

Download explore.mw

 

 

 

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

First 9 10 11 12 13 14 15 Last Page 11 of 72