Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Instead of getting a pop message telling me I have been cut off from the maple kernel can I please know how to recieve that error in the output of my worksheet instead?

Why does it insist I have to close and reopen the worksheet?

I was just thinking that if it were in my worksheets output I could have the current procedure in a try catch statement and write the occurance of the loss of server connection to a text file that is being checked by a script that will then send the necessary keystrokes to maple to save the worksheet close it then reopen it

Maple2020 was installed in windows 10 home. When installing maplesim 2019, it was looking for maple2019. Do I have to install maple 2019 before maplesim 2019? 

with(plots);
P1 := plot([-sin(t), t, t = 0 .. 2*Pi], coords = polar, color = red);
P2 := plot([cos(t), t, t = 0 .. 2*Pi], coords = polar, color = blue);
display(P1, P2, scaling = constrained);
 

I have two polar equation in the same graph but how do i shade the region between those two polar curve?

s1 := RootOf(D1*D2*D6*_Z^2+(-D1*D4*D6-D2*D6*S-D4)*_Z+D4*D6*S)

s2 := -(D1*RootOf(D1*D2*D6*_Z^2+(-D1*D4*D6-D2*D6*S-D4)*_Z+D4*D6*S)*D6-S*D6+RootOf(D1*D2*D6*_Z^2+(-D1*D4*D6-D2*D6*S-D4)*_Z+D4*D6*S))/(D2*D6*RootOf(D1*D2*D6*_Z^2+(-D1*D4*D6-D2*D6*S-D4)*_Z+D4*D6*S))
algsubs(s = RootOf(D1*D2*D6*_Z^2+(-D1*D4*D6-D2*D6*S-D4)*_Z+D4*D6*S), s2)

I try to use s1 to represent s2, and I get the following result:

-(D1*__SELECTION(RootOf(D1*D2*D6*_Z^2+(-D1*D4*D6-D2*D6*S-D4)*_Z+D4*D6*S))*D6-S*D6+RootOf(D1*D2*D6*_Z^2+(-D1*D4*D6-D2*D6*S-D4)*_Z+D4*D6*S))/(D2*D6*RootOf(D1*D2*D6*_Z^2+(-D1*D4*D6-D2*D6*S-D4)*_Z+D4*D6*S))
what is mean of __SELECTION, If algsubs cannot work well, what should I do?

Hi,

Two weeks ago, I started loading data on the CoVid19 outbreak in order to understand, out of any official communication from any country, what is really going on.

From february 29 to march 9 these data come from https://bnonews.com/index.php/2020/02/the-latest-coronavirus-cases/ and from 10 march until now from https://www.worldometers.info/coronavirus/#repro.In all cases the loading is done manually (copy-paste onto a LibreOffice spreadsheet plus correction and save into a xls file) for I wasn't capable to find csv data (csv data do exist here https://github.com/CSSEGISandData/COVID-19, by they end febreuary 15th).
So I copied-pasted the results from the two sources above into a LibreOffice spreadsheet, adjusted the names of some countries for they appeared differently (for instance "United States" instead of "USA"), removed the unnessary commas and saved the result in a xls file.

I also used data from https://www.worldometers.info/world-population/population-by-country/ to get the populations of more than 260 countries around the world and, finally, csv data from https://ourworldindata.org/coronavirus#covid-19-tests to get synthetic histories of confirmed and death cases (I have discovered this site only yesterday evening and I think it could replace all the data I initially loaded).

The two worksheet here are aimed to exploratory and visualization only.
An other one is in progress whose goal is to infer the true death rate (also known as CFR, Case Fatality Rate).

No analysis is presented, if for no other reason than that the available data (except the numbers of deaths) are extremely dependent on the testing policies in place. But some features can be drawn from the data used here.
For instance, if you select country = "China" in file Covid19_Evolution_bis.mw, you will observe very well known behaviour which is that the "Apparent Death Rate", I defined as the ratio of the cumulated number of death at time t by the cumulatibe number of confirmed cases at the same time, is always an underestimation of the death rate one can only known once the outbreak has ended. With this in mind, changing the country in this worksheet from China to Italy seems to lead to frightening  scary interpolations... But here again, without knowing the test policy no solid conclusion can be drawn: maybe Italy tests mainly elder people with accute symptoms, thus the huge "Apparent Death Rate" Italy seems to have?


The work has been done with Maple 2015 and some graphics can be improved if a newer version is used (for instance, as Maple 2015 doesn't allow to change the direction of tickmarks, I overcome this limitation by assigning the date to the vertical axis on some plots).
The second Explore plot could probably be improved by using newer versions or Maplets or Embeded components.

Explore data from https://bnonews.com/index.php/2020/02/the-latest-coronavirus-cases/ and https://www.worldometers.info/coronavirus/#repro
Files to use
Covid19_Evolution.mw
Covid19_Data.m.zip
Population.xls

Explore data from  https://ourworldindata.org/coronavirus#covid-19-tests
Files to use
Covid19_Evolution_bis.mw
daily-deaths-covid-19-who.xls
total-cases-covid-19-who.xls
Population.xls


I would be interested by any open collaboration with people interested by this post (it's not in my intention to write papers on the subject, my only motivation is scientific curiosity).

 

If I execute a program like:

restart;
pathname := "C:\\Users\\Gregory McColm\\Desktop\\Scratch2";
filename := "WhatGives6.txt";
stream := cat(pathname, "\\", filename);
Y := seq(rand(1..10)(), j = 1..10);
writeto(stream);
for i from 1 to 10 do
 printf("X[ %d ]:= %d;\n", i, Y[i]);
end do;
writeto(terminal);
printf("DONE\n");

 

Maple will print exactly what I told it to print.  But when I enter

restart;
pathname := "C:\\Users\\Gregory McColm\\Desktop\\Scratch2";
filename := "WhatGives44.txt";
stream := cat(pathname, "\\", filename);
writeto(stream);
for i from 1 to 10 do
 Y := rand(1..10)();
 printf("X[ %d ]:= %d;\n", i, Y);
end do;
writeto(terminal);
printf("DONE\n");

 

Maple prints:

             YAssign7, [Typesetting:-mprintslash([Y := 7], [7])]

X[ 1 ]:= 7;
           YAssign10, [Typesetting:-mprintslash([Y := 10], [10])]

X[ 2 ]:= 10;
             YAssign6, [Typesetting:-mprintslash([Y := 6], [6])]

X[ 3 ]:= 6;
             YAssign2, [Typesetting:-mprintslash([Y := 2], [2])]

X[ 4 ]:= 2;
             YAssign4, [Typesetting:-mprintslash([Y := 4], [4])]

X[ 5 ]:= 4;
             YAssign6, [Typesetting:-mprintslash([Y := 6], [6])]

X[ 6 ]:= 6;
             YAssign5, [Typesetting:-mprintslash([Y := 5], [5])]

X[ 7 ]:= 5;
             YAssign1, [Typesetting:-mprintslash([Y := 1], [1])]

X[ 8 ]:= 1;
             YAssign8, [Typesetting:-mprintslash([Y := 8], [8])]

X[ 9 ]:= 8;
             YAssign5, [Typesetting:-mprintslash([Y := 5], [5])]

X[ 10 ]:= 5;
 

This must be more than a matter of calling rand when I am writing to terminal, for if I enter:

restart;
pathname := "C:\\Users\\Gregory McColm\\Desktop\\Scratch2";
filename := "WhatGives8.txt";
stream := cat(pathname, "\\", filename);
writeto(stream);
X := rand(0..1)():
printf("Mary had a little lamb\n");
writeto(terminal);
printf("DONE\n");

 

then all Maple prints is "Mary is a little lamb".  I have tried this on Maple 2018 and Maple 2019, with the same results.

 

Any ideas or suggestions?

Hi,

I'm having trouble converting a static plot to animated plot:

Also I've been considering using functional operators instead of expressions so that there's no reuse of variable s when drawing different curves, though I'm not sure if this will be harder to differentiate since diff(expr, s) does not work on a functional operator meaning I'd have to do unapply(diff(f(s),s),s) which seems a long route and I'm not sure if it's what I'm looking for (in terms of simplification).

 

Thanks guys

agentpath.mw

 Hello everyone!

 I want to find all solutions of  following equations :

I used Maple 2019: 

solutions:=solve([abs(1+1/3*lambda+1/18*lambda^2-1/324*lambda^3+1/1944*lambda^4)-1=0],[lambda]);
evalf(solutions)

The output is:

So we have two solutions. But when I use Matlab 2018, 
four solutions are returned.

syms lambda
eqn =abs(1+1/3*lambda+1/18*lambda^2-1/324*lambda^3+1/1944*lambda^4)-1==0;
solx1=solve(eqn, lambda) 
%%
solx1 =
 root (z1 ^ 4-6 * z1 ^ 3 + 108 * z1 ^ 2 + 648 * z1, z1, 1)
 root (z1 ^ 4-6 * z1 ^ 3 + 108 * z1 ^ 2 + 648 * z1, z1, 2)
 roots (z1 ^ 4-6 * z1 ^ 3 + 108 * z1 ^ 2 + 648 * z1, z1, 3)
 roots (z1 ^ 4-6 * z1 ^ 3 + 108 * z1 ^ 2 + 648 * z1, z1, 4)


 

solx3=solve(eqn, lambda,   'MaxDegree', 4)
double(solx3)
%%The solution is:
 -4.2681 + 0.0000i
 0.0000 + 0.0000i
 5.1340 -11.2012i
5.1340
+ 11.2012i

It is easy to check that  first two in Maple and Matlab are  same.

Who is right? Does Maple miss complex solutions?

 

 

 

 

 

 

 

 

Dear,

I need to attach CPU time to my iterations/Computations, please how do I obtain that in Maple. I tried 

a:=time () 

Iterations code

cputime:=time() -a; 

 

But the issue is that once I rerun the code, It produces different cpu time, kindly help me out here. 

 

Thank you.

First make sure that  and  are unassigned variables and then enter the Maple command

 

 

This tells Maple that  is a postive real number.  (You will see more on using "assume" later.)

 

Next, calculate the improper definite integral of

 

(8sin(x)+11cos(x))e^(−52cx)

 

for  from 0 to ∞ and assign this to the variable .  (Notice that Maple displays  as  to indicate it that an assumption has been made about .)

 

Finally calculate the limit of  times  as  tends to infinity and enter the limit in the box below.  (Enter your answer exactly using Maple syntax, not as a decimal.)

 

Can someone please help me in this? I cant really understand this.

 

An expression sequence is the underlying data structure for lists, sets, and function call arguments in Maple. Conceptually, a list is just a sequence enclosed in "[" and "]", a set is a sequence (with no duplicate elements) enclosed in "{" and "}", and a function call is a sequence enclosed in "(" and ")". A sequence can also be used as a data structure itself:

> Q := x, 42, "string", 42;
                           Q := x, 42, "string", 42

> L := [ Q ];
                          L := [x, 42, "string", 42]

> S := { Q };
                            S := {42, "string", x}

> F := f( Q );
                          F := f(x, 42, "string", 42)

A sequence, like most data structures in Maple, is immutable. Once created, it cannot be changed. This means the same sequence can be shared by multiple data structures. In the example above, the list assigned to and the function call assigned to both share the same instance of the sequence assigned to . The set assigned to refers to a different sequence, one with the duplicate 42 removed, and sorted into a canonical order.

Appending an element to a sequence creates a new sequence. The original remains unaltered, and still referenced by the list and function call:

> Q := Q, a+b;
                        Q := x, 42, "string", 42, a + b

> L;
                             [x, 42, "string", 42]

> S;
                               {42, "string", x}

> F;
                            f(x, 42, "string", 42)

Because appending to a sequence creates a new sequence, building a long sequence by appending one element at a time is very inefficient in both time and space. Building a sequence of length this way creates sequences of lengths 1, 2, ..., -1, . The extra space used will eventually be reclaimed by Maple's garbage collector, but this takes time.

This leads to the subject of this article, which is how to create long sequences efficiently. For the remainder of this article, the sequence we will use is the Fibonacci numbers, which are defined as follows:

  • Fib(0) = 0
  • Fib(1) = 1
  • Fib() = Fib(-1) + Fib(-2) for all > 1

In a computer algebra system like Maple, the simplest way to generate individual members of this sequence is with a recursive function. This is also very efficient if option is used (and very inefficient if it is not; computing Fib() requires 2 Fib() - 1 calls, and Fib() grows exponentially):

> Fib := proc(N)
>     option remember;
>     if N = 0 then
>         0
>     elif N = 1 then
>         1
>     else
>         Fib(N-1) + Fib(N-2)
>     end if
> end proc:
> Fib(1);
                                       1

> Fib(2);
                                       1

> Fib(5);
                                       5

> Fib(10);
                                      55

> Fib(20);
                                     6765

> Fib(50);
                                  12586269025

> Fib(100);
                             354224848179261915075

> Fib(200);
                  280571172992510140037611932413038677189525

Let's start with the most straightforward, and most inefficient way to generate a sequence of the first 100 Fibonacci numbers, starting with an empty sequence and using a for-loop to append one member at a time. Part of the output has been elided below in the interests of saving space:

> Q := ();
                                     Q :=

> for i from 0 to 99 do
>     Q := Q, Fib(i)
> end do:
> Q;
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584,

    4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811,

    ...

    51680708854858323072, 83621143489848422977, 135301852344706746049,

    218922995834555169026

As mentioned previously, this actually produces 100 sequences of lengths 1 to 100, of which 99 will (eventually) be recovered by the garbage collector. This method is O(2) (Big O Notation) in time and space, meaning that producing a sequence of 200 values this way will take 4 times the time and memory as a sequence of 100 values.

The traditional Maple wisdom is to use the seq function instead, which produces only the requested sequence, and no intermediate ones:

> Q := seq(Fib(i),i=0..99);
Q := 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597,

    2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418,

    ...

    51680708854858323072, 83621143489848422977, 135301852344706746049,

    218922995834555169026

This is O() in time and space; generating a sequence of 200 elements takes twice the time and memory required for a sequence of 100 elements.

As of Maple 2019, it is also possible to achieve O() performance by constructing a sequence directly using a for-expression, without the cost of constructing the intermediate sequences that a for-statement would incur:

> Q := (for i from 0 to 99 do Fib(i) end do);
Q := 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597,

    2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418,

    ...

    51680708854858323072, 83621143489848422977, 135301852344706746049,

    218922995834555169026

This method is especially useful when you wish to add a condition to the elements selected for the sequence, since the full capabilities of Maple loops can be used (see The Two Kinds of Loops in Maple). The following two examples produce a sequence containing only the odd members of the first 100 Fibonacci numbers, and the first 100 odd Fibonacci numbers respectively:

> Q := (for i from 0 to 99 do
>           f := Fib(i);
>           if f :: odd then
>               f
>           else
>               NULL
>           end if
>       end do);
Q := 1, 1, 3, 5, 13, 21, 55, 89, 233, 377, 987, 1597, 4181, 6765, 17711, 28657,

    75025, 121393, 317811, 514229, 1346269, 2178309, 5702887, 9227465,

    ...

    19740274219868223167, 31940434634990099905, 83621143489848422977,

    135301852344706746049

> count := 0:
> Q := (for i from 0 while count < 100 do
>           f := Fib(i);
>           if f :: odd then
>               count += 1;
>               f
>           else
>               NULL
>           end if
>       end do);
Q := 1, 1, 3, 5, 13, 21, 55, 89, 233, 377, 987, 1597, 4181, 6765, 17711, 28657,

    75025, 121393, 317811, 514229, 1346269, 2178309, 5702887, 9227465,

    ...

    898923707008479989274290850145, 1454489111232772683678306641953,

    3807901929474025356630904134051, 6161314747715278029583501626149

> i;
                                      150

A for-loop used as an expression generates a sequence, producing one member for each iteration of the loop. The value of that member is the last expression computed during the iteration. If the last expression in an iteration is NULL, no value is produced for that iteration.

Examining after the second loop completes, we can see that 149 Fibonacci numbers were generated to find the first 100 odd ones. (The loop control variable is incremented before the while condition is checked, hence is one more than the number of completed iterations.)

Until now, we've been using calls to the Fib function to generate the individual Fibonacci numbers. These numbers can of course also be generated by a simple loop which, together with assignment of its initial conditions, can be written as a single sequence:

> Q := ((f0 := 0),
>       (f1 := 1),
>       (for i from 2 to 99 do
>            f0, f1 := f1, f0 + f1;
>            f1
>        end do));
Q := 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597,

    2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418,

    ...

    51680708854858323072, 83621143489848422977, 135301852344706746049,

    218922995834555169026

A Maple Array is a mutable data structure. Changing an element of an Array modifies the Array in-place; no new copy is generated:

> A := Array([a,b,c]);
                                A := [a, b, c]

> A[2] := d;
                                   A[2] := d

> A;
                                   [a, d, c]

It is also possible to append elements to an array, either by using programmer indexing, or the recently introduced ,= operator:

> A(numelems(A)+1) := e; # () instead of [] denotes "programmer indexing"
                               A := [a, d, c, e]

> A;
                                 [a, d, c, e]

Like appending to a sequence, this sometimes causes the existing data to be discarded and new data to be allocated, but this is done in chunks proportional to the current size of the Array, resulting in time and memory usage that is still O(). This can be used to advantage to generate sequences efficiently:

> A := Array(0..1,[0,1]);
                              [ 0..1 1-D Array       ]
                         A := [ Data Type: anything  ]
                              [ Storage: rectangular ]
                              [ Order: Fortran_order ]

> for i from 2 to 99 do
>     A ,= A[i-1] + A[i-2]
> end do:
> A;
                           [ 0..99 1-D Array      ]
                           [ Data Type: anything  ]
                           [ Storage: rectangular ]
                           [ Order: Fortran_order ]

> Q := seq(A);
Q := 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597,

    2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418,

    ...

    51680708854858323072, 83621143489848422977, 135301852344706746049,

    218922995834555169026

Although unrelated specifically to the goal of producing sequences, the same techniques can be used to construct Maple strings efficiently:

> A := Array("0");
                                   A := [48]

> for i from 1 to 99 do
>    A ,= " ", String(Fib(i))
> end do:
> A;
                           [ 1..1150 1-D Array     ]
                           [ Data Type: integer[1] ]
                           [ Storage: rectangular  ]
                           [ Order: Fortran_order  ]

> A[1..10];
                   [48, 32, 49, 32, 49, 32, 50, 32, 51, 32]

> S := String(A);
S := "0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 \
    10946 17711 28657 46368 75025 121393 196418 317811 514229 832040 134626\
    9 2178309 3524578 5702887 9227465 14930352 24157817 39088169 63245986 1\
    02334155 165580141 267914296 433494437 701408733 1134903170 1836311903 \
    2971215073 4807526976 7778742049 12586269025 20365011074 32951280099 53\
    316291173 86267571272 139583862445 225851433717 365435296162 5912867298\
    79 956722026041 1548008755920 2504730781961 4052739537881 6557470319842\
     10610209857723 17167680177565 27777890035288 44945570212853 7272346024\
    8141 117669030460994 190392490709135 308061521170129 498454011879264 80\
    6515533049393 1304969544928657 2111485077978050 3416454622906707 552793\
    9700884757 8944394323791464 14472334024676221 23416728348467685 3788906\
    2373143906 61305790721611591 99194853094755497 160500643816367088 25969\
    5496911122585 420196140727489673 679891637638612258 1100087778366101931\
     1779979416004714189 2880067194370816120 4660046610375530309 7540113804\
    746346429 12200160415121876738 19740274219868223167 3194043463499009990\
    5 51680708854858323072 83621143489848422977 135301852344706746049 21892\
    2995834555169026"

A call to the Array constructor with a string as an argument produces an array of bytes (Maple data type integer[1]). The ,= operator can then be used to append additional characters or strings, with O() efficiency. Finally, the Array can be converted back into a Maple string.

Constructing sequences in Maple is a common operation when writing Maple programs. Maple gives you many ways to do this, and it's worthwhile taking the time to choose a method that is efficient, and suitable to the task at hand.

1 discuss and show graphically the effects of decrease in wage on labor supply. if A, leisure is normal good. B, if leisure is inferior good.

How do I animate the cylinder width, or some variation of it as we trace it's path in the z-axes

with(plots);
with(plottools);
display([seq(cylinder([2, 2, 2], 3, i/10, capped = false), i = 1 .. 60)], insequence);

 

Hi,

I'm trying to create an agent vehicle which drives along a path of a uniform width, and finds the distance to the edge of the path directly ahead of it. Like this:

The aim is to somewhat simulate how far the agent can see down the road.

Since the thickness of a plot curve is unrelated to the units of the axis, and has no means of interacting with objects this would be no use.

I also considered shadebetween function, however this only can shade between the y values of 2 functions, so for a vertical curve it cannot produce any width to the path.

I then realised using parametric equations of form (x(t), y(t)) would likely make most sense and wrote some code which roughly gets the boundarys at a fixed distance from the centre path equation, by adding the x-y components of the reciprocal of the gradient:

For certain simple path equations such as this one, it roughly works other than the areas between which the boundary curves overlap themselves (I would need to find these points of intersection and break the curves up to remove these squigly inner bits). Any advice on this would be much appreciated cause this seems like it will be tricky, if not computationally heavy.

 

More annoyingly, due to the nature of the trig functions involved, for more complex graphs which include a vertical turning point, the left and right boundaries seem to swap over:

and

Clearly this is not the behaviour I had in mind.. and I'm not sure what I can do to fix it, I think maybe using piecewise trig may be a potential solution to avoid the jumping from + to -, though I'm not sure where I would put these breakpoints (I've tried just using abs(arctan(...)) with no luck).

 

If anyone could help wih this that would be really appreciated, or even suggest a better approach to this problem!

Thanks

 

[code] agentpath.mw

I just updated to Maple 2020

interface(version)

Standard Worksheet Interface, Maple 2020.0, Windows 10, March 4
   2020 Build ID 1455132

Physics:-Version()
         The "Physics Updates" package is not installed

My question is: For new Maple 2020 installation, should one go and install latest Physics package from the cloud, which I see is at version 619 now, or is it allready included in the new Maple 2020?

 

 

 

 

 

 

3 4 5 6 7 8 9 Last Page 5 of 1649