Maple 2023 Questions and Posts

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

I wanted to debug some code from worksheet A.  So added DEBUG(); command in the code where I want to start the GUI debugger from, and then run the command from the worksheet. All is working OK. the debugger GUI comes up and I can step in. 

Now I wanted to debug some other code from worksheet B. But without closing the currect debugger which is open and running.

It turned out this is not possible.  When running debugger from worksheet B, it uses the same debugger GUI that was up and running. I think it closed that session automtically also.

So basically using same Maple process, one can't open two debgging sessions at same time? Is there a way around this.

I run each worksheet using its own math engine. So each is separated from each other.

But this is first time I wanted to debug two things at same time, i.e. side by side, thinking I will be able to open two GUI debuggers at same time.

I know ofcourse I can open two separate Maple processes and then I will be able to do this. I think I am allowed to have two Maple's open at same time. Will try that next.

But it will be better if one is able to open two debuggers from same Maple at same time. I do not see why this should not be possible.

Any suggestions if there is a workaround? May be some hidden setting that allows this?

Maple 2023.2.1 on windows 10

Plots of physical quantities has significantly improved with Maple 2022. The updated useunits option makes unit conversion errors in plots very unlikely. A lot of time is saved when creating plots of physical quantities where values and units must be correct.

One final source of user errors remains: The manual entry of incorrect units in labels.

Below is a way to avoid such errors by computing labels with units for three prevalent axis labeling schemes.


Other desireable labels are given as a suggestion for future plot label enhancements where plot commands could provide formating functionality.

The rendering on this website adds double brakets ⟦ ⟧ wherever units are used. You have to open the document to see how Maple renders.

NULL

Simple plot example: Solar irradiance in space

G__0 := 1361*Unit('W'/'m'^2)

1361*Units:-Unit(W/m^2)

(1)

G__0*sin(2*Pi*t/(24*Unit('h')))

1361*Units:-Unit(W/m^2)*sin((1/12)*Pi*t/Units:-Unit(h))

(2)

plot(1361*Units:-Unit(W/m^2)*sin((1/12)*Pi*t/Units:-Unit(h)), t = 0 .. 12*Unit('h'))

 

This plot has inconsistent axis labeling:

• 

The vertical axis has units but no name

• 

The horizontal axis has a name and units but they are not easily distinguishable. Misinterpretation is possible. Due to the close spacing the label could be read as a product of the dimension "time squared" (the time t times hours h is of the dimension time squared). Or the reader confounds name and units. (The use of italic fonts for names and roman fonts for units might not be noticeable and is a convention that is not used everywhere.)

 

The above labeling should be improved for communication, documentation or publication purposes.

 

A quick attempt using strings and the options useuints and labels.

plot(1361*Units:-Unit(W/m^2)*sin((1/12)*Pi*t/Units:-Unit(h)), t = 0 .. 12*Unit('h'), useunits = ['d', kW/m^2], labels = ["Time t in days", "Exposure G in kV/m^2"])

 

Axes are now consistent and can be interpreted unambiguously. Formatting can still be improved.

 

Unfortunately, using the options useunits (for unit conversion) and labels this way introduces a new source of user error when labels are entered with the wrong units.

 

A way to address this and to ensure unit error-free plotting of expressions of physical quantities is the following:

 

Step1: Define two lists, one for the units to display and the other for the names to display

a := [Unit('s'), Unit('W'/'cm'^2)]; b := [t, G]

[t, G]

(3)

Step2: Compute labels from the lists

This step avoids the labeling error: No manual entry of units in labels required.

c := [b[1]/a[1], typeset(b[2]/a[2])]; d := [typeset(b[1], "  ", "⟦", a[1], "⟧"), typeset(b[2], "  ⟦", a[2], "⟧")]; e := [typeset(b[1], "  ", "(", a[1], ")"), typeset(b[2], "  (", a[2], ")")]

[typeset(t, "  ", "(", Units:-Unit(s), ")"), typeset(G, "  (", Units:-Unit(W/cm^2), ")")]

(4)

NULL

 

Dimensionless labels

 Double brackets

Parenthesis

plot(1361*Units:-Unit(W/m^2)*sin((1/12)*Pi*t/Units:-Unit(h)), t = 0 .. 12*Unit('h'), useunits = a, labels = c)

 

plot(1361*Units:-Unit(W/m^2)*sin((1/12)*Pi*t/Units:-Unit(h)), t = 0 .. 12*Unit('h'), useunits = a, labels = d)

 

plot(1361*Units:-Unit(W/m^2)*sin((1/12)*Pi*t/Units:-Unit(h)), t = 0 .. 12*Unit('h'), useunits = a, labels = e)

 

The axis values equal physical quantities divided by their units. The algebraic equation G*cm^2/W = 0.8e-1, for example, is physically speaking correct. Most functions of Maple can process dimensionless expression of the kind G*cm^2/W if G is given with appropriate physical units.

This way of using physical quantities is consistent with ISO 80000.  

Used in Maple to enter units in 2D-Math input mode

Can be confounded with functional notation. Units are therefore often written as a whole word (e.g. seconds instead of s).

 

 

NULL

The time to produce the above three plots was about 10 Minutes. The most part was spent to get the typesetting of the second and third plot correct.

 

What takes significant more time (more a question of hours when Typesetting is used for the first time) are

 

Labels with "/ cm^(2) "or 1/cm^2 formatting.

 

This formatting might be preferred but is unfortunately again not free from user errors. (I would probably use it if there was a simple and safe way).

f := [b[1]/a[1], b[2]/`#mrow(mo("W "),mo(" "),mo(" / "),msup(mo("cm"),mn("2")))`]; g := [typeset(b[1], "  ", "⟦", a[1], "⟧"), typeset(b[2], "  ⟦", (`@`(`@`(Units:-Unit, numer), op))(a[2]), "/", (`@`(`@`(Units:-Unit, denom), op))(a[2]), "⟧")]; h := [typeset(b[1], "  ", "(", Unit('s'), ")"), typeset(b[2], "  (", `#mrow(mo("W"),mo(" "),msup(mo("cm"),mn("-2")))`, ")")]

[typeset(t, "  ", "(", Units:-Unit(s), ")"), typeset(G, "  (", `#mrow(mo("W"),mo(" "),msup(mo("cm"),mn("-2")))`, ")")]

(5)

 

plot(1361*Units:-Unit(W/m^2)*sin((1/12)*Pi*t/Units:-Unit(h)), t = 0 .. 12*Unit('h'), useunits = a, labels = f)

 

plot(1361*Units:-Unit(W/m^2)*sin((1/12)*Pi*t/Units:-Unit(h)), t = 0 .. 12*Unit('h'), useunits = a, labels = g)

 

plot(1361*Units:-Unit(W/m^2)*sin((1/12)*Pi*t/Units:-Unit(h)), t = 0 .. 12*Unit('h'), useunits = a, labels = h)

 

NULL

 

 

 

Remarks

• 

For two reasons, I have not given an example with the often used square brackets [ ] because:
    
    Maple uses square brackets already for lists and indexing purposes,
    and ISO 80000 uses square brackets as an operator that extracts the unit from a physical quantity (e.g.       [G] = Unit('W'/'cm'^2)).

• 

Adding a unit to each value at axes ticks would definitely be a nice labeling feature for simple units.

• 

Programmatically analyzing the units defined in list a above and converting them in a generic way to a typesetting structure is not possible with a few high-level commands.

 

• 

For inline quotients like in 1/2, an additional backslash must be entered in 2D-Math: \/  

Unit('W')/Unit('cm')^2

Units:-Unit(W)/Units:-Unit(cm)^2

(6)

     This will not prevent evaluation to a normal quotient but the input can be used to create an atomic variable (select with mouse -> 2-D Math -> Atomic Variable)

`#mrow(mfenced(mi("W",fontstyle = "normal"),open = "⟦",close = "⟧"),mo("/"),mo("⁢"),msup(mfenced(mi("cm",fontstyle = "normal"),open = "⟦",close = "⟧"),mn("2")),mo("⁢"))`

`#mrow(mfenced(mi("W",fontstyle = "normal"),open = "⟦",close = "⟧"),mo("/"),mo("⁢"),msup(mfenced(mi("cm",fontstyle = "normal"),open = "⟦",close = "⟧"),mn("2")),mo("⁢"))`

(7)

     This makes labeling much easier as compared to typesetting commands (compare to the above statements).

f := [b[1]/a[1], b[2]/`#mrow(mfenced(mi("W",fontstyle = "normal"),open = "⟦",close = "⟧"),mo("/"),mo("⁢"),msup(mfenced(mi("cm",fontstyle = "normal"),open = "⟦",close = "⟧"),mn("2")),mo("⁢"))`]

[t/Units:-Unit(s), G/`#mrow(mfenced(mi("W",fontstyle = "normal"),open = "⟦",close = "⟧"),mo("/"),mo("⁢"),msup(mfenced(mi("cm",fontstyle = "normal"),open = "⟦",close = "⟧"),mn("2")),mo("⁢"))`]

(8)

In any case it is a good idea to read ?plot,typesetting before experimenting with typesetting.

 

Axes_with_unit_labels.mw

My personal preference is for dimensionless labels.

Note:

The solution to avoid labeling errors works only for Maple 2022 and higher.

Some plot commands do not support plotting with units, or they do not fully support it yet.

The attached worksheet shows that Maple 2023 produces an incomplete plot of a function.  Maple 2021, however, produces the full graph.  I wonder if Maple 2023's behavior is due to a bad setting in my environment or a plotting bug in Maple.

restart;

kernelopts(version);

`Maple 2023.2, X86 64 LINUX, Oct 25 2023, Build ID 1753458`

y := -cos(sqrt(x))*x^3/(-x^2 + 24*cos(sqrt(x)) + 12*x - 24);

-cos(x^(1/2))*x^3/(-x^2+24*cos(x^(1/2))+12*x-24)

plot(y, x=0..1);

Here is the graph of the same function plotted correctly in Maple 2021:

Download cannot-plot.mw

As I am new to using the statistics package, I have some doubts about how to perform certain operations in Maple.

For example, let sigma be a variable containing any real number, finding the average is easy, just use the command A0:=Median(sigma) and if you want A (see image below) just take A1:=A0^2. However, the terms that make up <sigma^2> cause a certain difficulty, how to do this? In other words, calculate the B of the image?

sigma := [2, 4, 0, 6]

AMedia := (2 + 4 + 0 + 6)/4;
AMedia1 := AMedia^2;

 

A0 := Median(sigma)

A1 := A0^2

BMedia := (2^2 + 4^2 + 0^2 + 6^2)/4

sigma0 := sigma^2

sigma1 := Mean(sigma0)

.......................................................................................

hi every one.

in the attached maple file at line x=o in the plotted figure we have some inconsistency in starting the branches from x=0 and the branches do not start from the same value on this axis.

I can not find the problem because there are not any differences between phi 1 and phi 2! 

evalf(f1 - f2)= -5* 10 ^-49

h-x_nemodar-e.mw

I thought I was improving my code by adding ::type to all the _self in my OOP code. As this is one main advantage in programming in Maple, which is being able to attach types to all name and variables. Make code more robust.

But it turned out Maple is not very happy now and gives that drearded error

    Error, static procedure ... refers to non-static local or export ... in surrounding scope

Only place I found that adding ::type_name is to _self is allowed, is on the constructor signature.

But in no other method of the object module. local or export method, it does not matter. 

My question is, why is that?

So I went and removed all those _self::type_name and made it just _self to make Maple happy.

I also noticed this happes regardless of having kernelopts('assertlevel'=2): there or not.  Attached  is the worksheet.

Just tryting to understand the logic, that is all. 

This is using Maple 2023.2.1

interface(version)

`Standard Worksheet Interface, Maple 2023.2, Windows 10, November 24 2023 Build ID 1762575`

restart;

24100

interface(warnlevel=4);
kernelopts('assertlevel'=2):

3

A:=module()

  export module person()
   option object;
   local m_name::string;
   local m_age::integer;
   export ModuleCopy::static:=proc(_self::A:-person,proto::A:-person,name::string,age::integer,$)
          _self:-m_age := age;
          _self:-m_name:=name;
          NULL;
   end proc;
   export name::static:=proc(_self,$) m_name; end proc;
   export age::static:=proc(_self,$) m_age; end proc;
 end module;

export  module young_person()
   option object;
   local m_person::A:-person;
   export ModuleCopy::static:=proc(_self::A:-young_person,proto::A:-young_person,p::A:-person,$)
          _self:-m_person := p;     
          _self:-process_it();    
   end proc;
   local process_it::static:=proc(_self,$)
         print(m_person:-name());
         print(m_person:-age());
   end proc;

   #to fix the problem, check _self::A... to just _self,  then no error!
   export process_it_from_outside::static:=proc(_self::A:-young_person,$)
         print(m_person:-name());
         print(m_person:-age());
   end proc;

end module;

end module;

_m2782933017664

o:=Object(A:-person,"me",99);

module person () local m_name::string, m_age::integer; option object; end module

p:=Object(A:-young_person,o);

 

Error, static procedure `young_person:-process_it_from_outside` refers to non-static local or export `young_person:-m_person::A:-person` in surrounding scope

 


Download why_adding_type_on_self_gives_error.mw

We have just released an update to Maple 2023 to address a couple of issues.

  • We’ve had a few reports of people encountering “Kernel connection has been lost” errors, and this update should fix that problem.
  • We fixed a problem involving entering math (specifically, the right curly bracket, } ) using an international keyboard.

If you are experiencing kernel connection problems or use Maple with an international keyboard, you should install this update.

This update is available through Tools>Check for Updates in Maple, and is also available from the Maple 2023.2.1 download page. MapleSim users can get this update from the MapleSim Check for Updates or from the MapleSim 2023.2.1 download page, where you will also find an update to the MapleSim Ropes and Pulleys Library.

This is probably a real dummy question. Why can I not plot the units in this worksheet? Thanks in advance for your help PlotUnit.mw

I have a pretty ugly nested integral (in my opinion) that I am trying to compute. I thought that I simplified the problem to an easier siutation however during my attempted calculations I am recieving: "Error, (in evalf/int) cannot handle unevaluated name `L` in evalhf

I am unsure where this is coming from, I would assume something in procedure or my attempted use of unapply is incorrect. Any comments are welcome, including those that state I am doing this entirely incorrectly. 

Thanks. 

NestedError.mw

I need to highlight all terms that contain eta, my variable, for example (A0)+(A1)*1/eta+(A2)*1/eta^2+...(An)**1/eta^n and so on in my expression call from P. However, when I select eta through the collect command, maple is unable to carry out the command.

P := expand((cosh(k*eta) + alpha*m*sinh(k*eta)/eta)^3);
P := convert(P, exp);
P := expand(P);
P := collect(P, eta);
P := combine(P);

Once these have are in evidence I need to select the coefficients A0, A1, A2, etc. How to proceed if eta are in the denominator and maple does not work with this possibility? This it'was my tentative

B0 := subs(eta = 0, P);

B1 := coeff(P, eta)

B2 := coeff(P, eta^2)

I actually tested the possibility of  1/eta instead of  eta and it didn't work

I am an ophthalmologist and a novice in programing. I am having a problem obtaining the x-y coordinate equations for each of the fitted Splines.  I can send the raw data and MapleSoft work sheet for which I need the individual spline equations, in x-y coodinates not parametric format and also need to be able to plot the splines on the raw data. I will pay for the service. Can you please obtain the x-y Cartesian equations for each of the fitted Splines and give me a step-wise method for obtaining them?  I am unable to attach the raw data and the worksheet to this email.  Please send me your personal email so that I can send them.

Your assistance is most appreciated. 

With my best,
Ron
Ronald A Schachar MD , PhD
7241 Encelia Drive
La Jolla, CA 92037
Cell: (858) 784-1705
Email: ron@2ras.com

WHen using _self in object, help says

"As of Maple 2021, if the method has a formal parameter named _self, references
to its object's local or exported variables may be written without prefixing them.
That is, _self:-variable may be written as just variable. Maple will
add the self:- prefix internally when the method is simplified."

And the above is true for all static methods inside an object module, except for ModuleCopy which is also static.

It seems ModuleCopy is special. But why?  I am thinking it is because at time this is called, the object itself does not yet exist, but for all other methods, the object by then is fully constructed. But wanted to be sure.

Here is an example

restart;

person := module()
option object;
local  m_name::string;
local  m_age::integer;
export ModuleCopy :: static := proc(_self :: person
                                   , proto :: person, name::string, age::integer,$
                                )
         m_age := age;
         m_name := name;
    end proc;

export name::static:= proc(_self, $);
    RETURN(m_name); #no need to write _self:-m_name;
    end proc;

export age::static:= proc(_self, $);
    RETURN(m_age); #no need to write _self:-m_age;
    end proc;

export set_name::static:= proc(_self, name, $);
    m_name := name;   #no need to write _self:-m_name := name
    NULL;
    end proc;

export process::static:=proc(_self,$)
   print("name is ",m_name," age is ",m_age);
end proc;

end module:

And now


o:=Object(person,"me",10);

Error, static procedure `ModuleCopy` refers to non-static local or export `m_age::integer` in surrounding scope

Changing ModuleCopy to

export ModuleCopy :: static := proc(_self :: person
                                   , proto :: person, name::string, age::integer,$
                                )
         _self:-m_age := age;
         _self:-m_name := name;
    end proc;

Now there is no error. But notice that in all other static methods, I can write  m_name directly without using _self:-m_name;

I looked at help page for ModuleCopy but see no mention of this.

Why ModuleCopy is different?

Maple 2023.2 on windows 10

Can you generate equation numbers for inline equations?

Folks,

What is the simplist Maple code needed to isolate a vector that has two components?  See below:

Vector[column](2, [25.00000000*pi*r/(r^2 + z^2), 25.00000000*pi*z/(r^2 + z^2)])

I want to get the magnitude of this vector which is simply the square root of the sum of the squares of the individual components as shown above.

How do I do that?

Chris

5 6 7 8 9 10 11 Last Page 7 of 26