Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Hi, I am trying to enter into the Mini-Course Computer Algebra for Physicists from the help, but instead of going to the page I get the help page of Physics[FeynmanIntegral]. Can anyone confirm that this happens to them on Maple 2021.2?

Kevin

How do I make a new dataframe based on the criteria that a particular row is included when a particular element in that row is equal to a specific string, say, "Ontario"?

I downloaded the publicly availble covid dataset from the Gov. of Canada website.  I want to look at data pertaining to Ontario only. Each data entry corresponds to a row of data where the second column represents the province or territory.  My goal is to create a new dataframe of rows where the second column entry is equal to the string "Ontario".

I have attached my maplesheet.  I can't upload the data but it can be downloaded here: https://open.canada.ca/data/en/dataset/261c32ab-4cfd-4f81-9dea-7b64065690dc.

In the image below, see how the second column is a mix of different strings.  I want a new dataframe where the second column reads only "Ontario".  I have included my naive attempt to select data with 'prname'="Ontario".

sort_data_and_make_new_df_Covid_Analysis_Sheet_1.mw

Hi, I have problem at this coding. Can you help me?

restart;
eq1 := diff(u(u, t), t) = A[0] + A[1]*cos*omega*t + Beta[1]*[diff(u(u, r), r $ 2) + diff(u(u, r), r)/r];
                  d                                   
          eq1 := --- u(u, t) = A[0] + A[1] cos omega t
                  dt                                  

                       [                  d         ]
                       [/  2         \   --- u(u, r)]
                       [| d          |    dr        ]
             + Beta[1] [|---- u(u, r)| + -----------]
                       [|   2        |        r     ]
                       [\ dr         /              ]


The*number*of*node*points;
N := 4;
                             N := 4

The*length*of*domain;
L := 1;
                             L := 1

BC1 := u(1, t) = 0;
                       BC1 := u(1, t) = 0

IC1 := u(r, 0) = 0;
                       IC1 := u(r, 0) = 0

dudt := (u[m + 1] - u[m])/(delta*t);
                            u[m + 1] - u[m]
                    dudt := ---------------
                                delta t    

dudr := (u[m + 1, j] - u[m - 1, j])/(2*delta*r);
                       u[m + 1, j] - u[m - 1, j]
               dudr := -------------------------
                               2 delta r        

d2udr2 := (u[m + 1, j] - 2*u[m] + u[m - 1, j])/(delta*r^2);
                    u[m + 1, j] - 2 u[m] + u[m - 1, j]
          d2udr2 := ----------------------------------
                                        2             
                                 delta r              

Three point forward and backward difference expressions for the derivative are:
Error, unable to parse
Typesetting:-mambiguous(Typesetting:-mambiguous(

  Three point forward and backward difference expressions for, 

  Typesetting:-merror("unable to parse")) the derivative arecolon)


dudrf := (-u[2] + 4*u[1] - 3*u[0])/(2*delta*r);
                         -u[2] + 4 u[1] - 3 u[0]
                dudrf := -----------------------
                                2 delta r       

dudrb := (u[N - 1] - 4*u[N] + 3*u[N + 1])/(2*delta*r);
                         u[3] - 4 u[4] + 3 u[5]
                dudrb := ----------------------
                               2 delta r       

The*governing*equation in finite*difference*form*is;
Eq[m] := subs(diff(u(u, t), t) = dudt, diff(u(u, r), r) = dudr, diff*(u(u, r), r $ 2) = d2udr2, eq1);
         u[m + 1] - u[m]                                     [
Eq[m] := --------------- = A[0] + A[1] cos omega t + Beta[1] [
             delta t                                         [
                                                             [

  / d  /u[m + 1, j] - u[m - 1, j]\\   u[m + 1, j] - u[m - 1, j]]
  |--- |-------------------------|| + -------------------------]
  \ dr \        2 delta r        //             2              ]
                                             2 r  delta        ]


The*boundary*condition in finite*difference*form*are;
Eq[0] := subs(diff(u(r), r) = dudrf, u(r) = u[0], BC1);
                      Eq[0] := u(1, t) = 0

The*initial*condition in finite*difference*form*are;
Eq[N + 1] := subs(diff(u(r), r) = dudrb, u(r) = u[0], IC1);
                      Eq[5] := u(r, 0) = 0

for i to N do
    Eq[m] := subs(m = i, Eq[m]);
end do;
           u[2] - u[1]                                        
  Eq[m] := ----------- = A[0] + A[1] cos omega t + Beta[1] [0]
             delta t                                          

           u[2] - u[1]                                        
  Eq[m] := ----------- = A[0] + A[1] cos omega t + Beta[1] [0]
             delta t                                          

           u[2] - u[1]                                        
  Eq[m] := ----------- = A[0] + A[1] cos omega t + Beta[1] [0]
             delta t                                          

           u[2] - u[1]                                        
  Eq[m] := ----------- = A[0] + A[1] cos omega t + Beta[1] [0]
             delta t                                          

The node spacing is given by:
Error, unable to parse
        Typesetting:-mambiguous(Typesetting:-mambiguous(

          The node spacing is given by, 

          Typesetting:-merror("unable to parse"))colon)


h := L/(N + 1);
                                  1
                             h := -
                                  5

eqs := seq(evalm(subs(Beta = 0.25, Eq[i])), i = 0 .. N + 1);
  eqs := u(r, 0) = 0, Eq[1], Eq[2], Eq[3], Eq[4], u(r, 0) = 0

vars := seq(u[i], i = 0 .. N + 1);
           vars := u[0], u[1], u[2], u[3], u[4], u[5]

soll := fsolve({eqs}, {vars});
Error, (in fsolve) {r, Eq[1], Eq[2], Eq[3], Eq[4]} are in the equation, and are not solved for

Correction

Please ignore this question. dsolve does hang, but I had typo in the timelimit command itself when I wrote the test. Fixing this, now it timesout OK.

Maybe someone can look why dsolve hangs on this ode. But since timelimit does work, there is a workaround.

Original question

I was checking Maple's dsolve on this textbook problem

The book gives the answer in the back as

When using Maple's dsolve, I found it hangs. The stange thing, is that adding timelimit() also hangs. I can understand dsolve() hanging sometimes. But what I do not understand is why with timelimit it also hangs?

I've waited 20 minutes and then gave up. As you see, the timelimit is 20 seconds. May be if I wait 2 hrs or 20 hrs or 20 days, it will finally timeout. I do not know but can't wait that long.

Do others see same problem on this ode? Does it hang for you? How about on the mac or Linux?

During this time, I see mserver.exe running at very high CPU. I restarted Maple few times, but this did not help.

Maple 2021.2 on windows 10. May be one day Maplesoft will fix timelimit so it works as expected. 

interface(version)

`Standard Worksheet Interface, Maple 2021.2, Windows 10, November 23 2021 Build ID 1576349`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1122 and is the same as the version installed in this computer, created 2021, December 22, 16:3 hours Pacific Time.`

restart;

ode:=x*diff(y(x),x)=y(x)*cos(ln(y(x)/x));
try
   timeout(20,dsolve(ode));
catch:   
   print("timedout");       
end try;   
print("OK");

x*(diff(y(x), x)) = y(x)*cos(ln(y(x)/x))

 

Download test_ode_hang.mw

 

Some more difficult calculation with complex numbers

Starting from the equation     
A = arctan(z/b)/b and arctan(z/b)/b = int(1/(b^2+z^2), z = 0 .. z)
made the substitution                               
z = i*b(t-1)/(t+1)
Thus obtaining NULL
A = -(int(1/t, t = 1 .. t))/(2*bi) and -(int(1/t, t = 1 .. t))/(2*bi) = log[10](t)/(2*bi) and log[10](t)/(2*bi) = log[10]((b*i+z)/(b*i-z))/(2*bi)
One of the important relations between logarithms and inverse trigonometrische functions

Download logaritmisc_functie_betrekking_goniometrische_functie.mw

This might be a trivial question, but I have not been able to find the answer. I am using Maple 2018.

I am working with differential operators acting on real valued functions of a real variable. On the first hand, I want to be able to do simple algebra with these operators. For example, I might want to compute the commutator of two such operators. I have been using the DEtools package, toghether with the 'mult' command to perform such calculations. See the atached file containing a simplified version of what I am doing.

Now, I also want to be able to act with my differential operators on a function, and get the resulting function. 

(a) What command allows me to do that within my framework? (i.e. that of DEtools with the way I have defined and used my operators)

(b) I there a better way to proceed? (i.e. is there a better way to do both algebra with differential operators and to act with them on functions to get the resulting function)

Many thanks

Example.mw

# Below you find a small example about the function diffdiameter(conc,number), which has the unit length as long as the second argument number is not zero. Using the convert function it is possible to remove the units entirely, but this does not help, if I want to plot the functions. Is there a possibilty to plot diffdiameter(conc,number-not-zero) and diffdiameter(conc,0) in one diagramm? with(Units[Simple]); with(plots); diffdiameter := (conc, number) -> -number*diameter*exp(-conc/Unit(mol/kg)); diffdiameter := proc (conc, number) options operator, arrow; Units:-Simple:-`-`(Units:-Simple:-`*`(Units:-Simple:-`*`(numb\ er, diameter), Units:-Simple:-exp(Units:-Simple:-`-`(Units:-Si\ mple:-`*`(conc, Units:-Simple:-`/`(Unit(Units:-Simple:-`*`(mol\ , Units:-Simple:-`/`(kg))))))))) end proc diameter := 2*Unit(m); diameter := 2 Unit(m) evalf(diffdiameter(Unit(mol/kg), 6)); evalf(diffdiameter(Unit(mol/kg), 0)); -4.414553294 Unit(m) 0. convert(evalf(diffdiameter(Unit(mol/kg), 6)), unit_free); convert(evalf(diffdiameter(Unit(mol/kg), 0)), unit_free); -4.414553294 0. plot([convert(evalf(diffdiameter(conc, 0.001)), unit_free), convert(evalf(diffdiameter(conc, 6)), unit_free)], conc = 0 .. 4*Unit(mol/kg), title = "derivative Diameter with conc", labels = ["concentration / mol/kg", "deriv diameter / m"], color = ["blue", "red"], legend = ["bare diameter", "PLUS diameter"], labeldirections = ["horizontal", "vertical"], titlefont = [Helvetica, bold, 16], axesfont = [Helvetica, 14], labelfont = [Helvetica, 14], axes = boxed); plot([convert(evalf(diffdiameter(conc, 0)), unit_free), convert(evalf(diffdiameter(conc, 6)), unit_free)], conc = 0 .. 4*Unit(mol/kg)); Error, (in plot) invalid subscript selector

on DLMF page, they show this transformation on independent variable for second order ode

https://dlmf.nist.gov/1.13#Px7

About half way down the page, under Elimination of First Derivative by Change of Independent Variable section.

I tried to verify it using Maple dchange. But the problem it looks like dchange wants the old variable to be on the left side (z in this example) and the new variable (eta in this example) to be on the right side in the transformation. But on the above web page, it is the other way around.

Here are my attempts

restart;
ode:=diff(w(z),z$2)+f(z)*diff(w(z),z)+g(z)*w(z)=0;

tranformation:=eta=int(exp(-int(f(z),z)),z);

PDEtools:-dchange({tranformation},ode,known={z},unknown={eta});
PDEtools:-dchange({tranformation},ode,{eta},known={z});
PDEtools:-dchange({tranformation},ode,{eta});

All give errors

Error, (in dchange/info) missing a list with the new variables
Error, (in dchange/info) the new variables are not contained in the rhs of the direct transformation equations
Error, (in dchange/info) the new variables are not contained in the rhs of the direct transformation equations

The problem it does not seem possible to invert the transformation shown on the webpage, so that the old variable z show on the left side and the new variable (eta) on the right side.  

Why is this restriction on dchange  Since one tells it which is the new variable and which is the old variable? May be I am not using dchange correctly in this example.

Any suggestion for a workaround to use dchange to verify the above result?

Here is my hand derivation (pdf file attached also)

Can the above be done using dchange?

Maple 2021.2 on windows 10

sol.pdf

Tetrahedron with length of sides like this picture has volume is an integer number. Is there another tetrahedron like that?

Hi! I have recently started some Maple in chaos in dynamical systems and I am thinking about counting experimental invariant denisty measure (which is in brief  "how often the point visits the given interval") for some discrete mappings (in this case it's logistic mapping 3.7*x*(1-x)).

restart;
with(plots);
x := array(1 .. 10^6 + 2);

x[1] := 0.2;
for i to 10^6 do
    x[i + 1] := 3.7*x[i]*(1 - x[i]);
end do;

counter := 0;
for i to 10^6 do
    if 0 <= x[i] and x[i] < 0.1 then counter := counter + 1; end if;
end do;
counter;
counter := 0;
for i to 0^6 do
    if 0.2 <= x[i] and x[i] < 0.3 then counter := counter + 1; end if;
end do;
counter;
..........

counter := 0;
for i to 10^6 do
    if 0.9 <= x[i] and x[i] < 1 then counter := counter + 1; end if;
end do;
counter;
display(plot([[0, 0], [0.3, 0]]), plot([[0.3, 74089], [0.4, 74089]]), plot([[0.4, 57290], [0.5, 57290]]), plot([[0.5, 86726], [0.6, 86726]]), plot([[0.6, 122087], [0.7, 122087]]), plot([[0.7, 269178], [0.8, 269178]]), plot([[0.8, 185490], [0.9, 185490]]), plot([[0.9, 115405], [1, 115405]]))

I don't know how can I automate this code. I need smaller intervals because I took length 0.1 which is not good enough.

I want to get something like this (it is for logistic map such as above but in below example they plotted this graph for 4*x*(1-x) )

Figure 3 | Constructing Multi-Branches Complete Chaotic Maps That Preserve  Specified Invariant Density

thanks in advance 

Hello everyone,

The "rows and series" chapter is coming to an end. But im not getting this question. Ive got a feeling they are not really specific with this book. But that could just be me.

Any way here is the question:

"In classical physics there is the kinetic energy of a body with the mass m0 and the speed v given by E1=1/2*m0*v^2. According to Einstein the kinetic energy E2=(m*c^2)-(m0*c^2)=((m0*c^2)/sqrt(1-(v/c)^2))-m0*c^2, at which m is the relativistic mass with a speed v, and m0 the mass in rest. Further c is the speed of light. Wright down E2 as a linear function of v^2 and show that E2=E1 when v is small compared to c." 

Now i cant see what they did to get this answer:

A taylor series was probably used, the question before it also used a taylor series. 

If someone knows what they did. What did they do to get the the answer the book gave? 

Thank you!

Greetings,

The Function

But ODEsteps supports simliar ODEs (see attached).
Is the ODESteps command not generic enough to cover the pendulum or have I missed something?

ODESteps.mw

Hi everyone, how can i plot nonlinear phase portraithere k,w, alpha,K, k, gamma, beta are arbitrary constants and i have three equilibrium points:

I hope the resulting graphics are as follows :

How can I plot these phase portraits? Thanks in advance.

hello,
i want to animate a sequence from a nomeric solution i recived, i have a sequene for displacment and another one for time, is there a way to do that ? 

Has somebody experienced something like that before?

I was searching for a bug in a sheet, and was absolute unable to find out why some results in a sheet were different from another sheet.

Found out that it actually was a pure graphics problem. With normal zoom (100%) the minus signum is not visible.

Blowing up the zoom to 125% shows the signum again.

First 229 230 231 232 233 234 235 Last Page 231 of 2097