Maple 2023 Questions and Posts

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

Ever wonder how to show progress updates from your executing code without printing new lines each time?

One way to do this is to use a TextArea component and the DocumentTools package. The TextArea could be inserted from the Components Palette in Maple, or programmatically like so:

restart;

with(DocumentTools):

with(DocumentTools:-Components):

with(DocumentTools:-Layout):

s := "0": #initial text value

T := TextArea(s, identity = "TextArea0"):
xml := Worksheet(Group(Input(Textfield(T)))):

insertedname:=InsertContent(xml)[1,1]: #find the inserted component name in case changed

for i to 10 do #start the demonstration procedure
   Threads:-Sleep(1);
   SetProperty(insertedname,value,sprintf("%d",i),refresh=true);
end do:

Maplets:-Examples:-Message("Done");


Download text-area-update-progress.mw

y'' + 1/x * u' + u = 6 - 9x + x^2 - x^3

with baundary condition :

u(0) = 0 , and u(1) = 0

Assuming I have an expression

you can know that the derivative with respect to y will vanish when y is a constant y0.

How can we use the mathematical software Maple to simplify this expression?

There appears to be a bug in Maple 2023 where constants beginning with a Greek letter cannot be saved.  Assigning a constant to a Greek letter works in the Maple interface but does not work when reading an MPL file encoded as UTF-8.  Example:

read "D:/Nikki/docs/Maple/constants.mpl" :

MPL file contents:

alias(asec=arcsec) : # arcsecant

ζX1 := asec(1) : # first airmass zenith angle
ζX2 := asec(2) : # second airmass zenith angle

The constant "ζX1" can be assigned/saved in Maple but shows as unassigned when imported from an MPL file encoded as UTF-8.

Any assistance in how to use Greek letters in MPL files is much appreciated.

Maple 2023 still can't verify its own series solution. This happens with Frobenius method when the indicial root are repated. I think I mentioned or reported this long time ago but unable to find a link now.

My question is: Since this looks like it will not be fixed by Maplesoft anytime soon, any one could suggest an alternative method to verify this solution?

restart;

ode:=2*x^2*diff(y(x), x, x) + 2*x*diff(y(x), x) - x*y(x) =0;
sol:=dsolve(ode,y(x),'series');
odetest(sol,ode,'series')

Maple's solution is correct, I solved it by hand and get same solution.

Maple 2023 on windows 10.

I could not find a way to check whether or not a given value belongs to an interval expressed as RealRange (or a union of them e.g. RealRange(Open(-10),-5), RealRange(Open(-6),infinity).

Ideally, I would like a Boolean function that takes two arguments (i) a value v and (ii) a (union of) RealRange r, and returns true/false depending on whether or not value v is in/out of the range r.

When trying to load/import/read an MPL file with Maple 2023, I get an error message of "Error, recursive assignment" which only links to a page which states "There is no help page available for this error."

https://www.maplesoft.com/support/help/errors/view.aspx?path=Error,%20recursive%20assignment

Presumably there is an error in the Maple syntax that prevents execution, but I cannot find a way to debug.  Maple Code Editor Diagnostics says "No Errors" but Maple Code Editor Console says "Error: recursive assignment."  The MPL file is 485 lines but I am assuming the error could be anywhere in the file.  Is there any way to fix this?

Update: I found the error by copying just a handful of lines at a time into Maple until the error was reproduced.  It was a typo of just one character out of 16,960 characters.  But this is very frustrating.  Why can't Maple 2023 tell me what line the error is on?  Is there a better way to debug MPL files?

Why is a change in the text area component triggering an action three times in a row?

Download ThePostmanKnocksThreeTimes.mw

This code fails in Maple 2023.  It used to work in earlier versions.  Did I miss something in the release notes?

restart;

kernelopts(version);

`Maple 2023.0, X86 64 LINUX, Mar 06 2023, Build ID 1689885`

with(plots):

setoptions3d(font=[Times,roman,12]);

arrow(<1,1,1>);

Error, (in plottools:-rotate) invalid arguments for 3-D transformation

 

The following program:

with(RealDomain):
sol1 := solve(x-1 > 0, x);
sol2 := solve(1/x^2 > 0, x);
sol3 := solve(1/(x^2-1) > 0, x);
sol4 := solve(x^2+1 > 0, x);
sol5 := solve(x^2+1 < 0, x);

Gives the following output:

sol1 := RealRange(Open(1),infinity)
sol2 := {x <> 0}
sol3 := RealRange(-infinity,Open(-1)), RealRange(Open(1),infinity)
sol4 := x
sol5 := NULL

I would like to force some consistency in the output of solve because I need to feed the output to a third-party program. For example, what's the deal with sol2 and sol3? Why are they formatted differently?

Ideally, I would like the previous output to be:

sol1 := RealRange(Open(1),infinity)
sol2 := RealRange(-infinity,Open(0)), RealRange(Open(0),infinity)
sol3 := RealRange(-infinity,Open(-1)), RealRange(Open(1),infinity)
sol4 := RealRange(-infinity,infinity)
sol5 := NULL

How do I achieve this?

I find that no matter how I modify the style in the Maple command, the LaTeX output seems to be always fixed. This is a bit frustrating. 

G:=Graph(6,{{1,2},{1,4},{4,5},{2,5},{2,3},{3,6},{5,6}});
DrawGraph(G);
vp:=[[0,0],[0.5,0],[1,0],[0,0.5],[0.5,0.5],[1,0.5]]:
SetVertexPositions(G,vp):
DrawGraph(G);

Latex(G, terminal, 100, 100)

\documentclass{amsart}
\begin{document}
\begin{picture}(100,100)
\qbezier(12.40,87.60)(12.40,50.00)(12.40,12.40)
\qbezier(12.40,87.60)(31.20,50.00)(50.00,12.40)
\qbezier(12.40,12.40)(31.20,50.00)(50.00,87.60)
\qbezier(12.40,12.40)(50.00,50.00)(87.60,87.60)
\qbezier(50.00,87.60)(68.80,50.00)(87.60,12.40)
\qbezier(50.00,12.40)(68.80,50.00)(87.60,87.60)
\qbezier(87.60,87.60)(87.60,50.00)(87.60,12.40)
\put(12.400000,87.600000){\circle*{6}}
\put(10.194,96.943){\makebox(0,0){1}}
\put(12.400000,12.400000){\circle*{6}}
\put(8.726,3.531){\makebox(0,0){2}}
\put(50.000000,87.600000){\circle*{6}}
\put(50.000,97.200){\makebox(0,0){3}}
\put(50.000000,12.400000){\circle*{6}}
\put(50.000,2.800){\makebox(0,0){4}}
\put(87.600000,87.600000){\circle*{6}}
\put(91.274,96.469){\makebox(0,0){5}}
\put(87.600000,12.400000){\circle*{6}}
\put(89.806,3.057){\makebox(0,0){6}}
\end{picture}
\end{document}

 

DrawGraph(G,
stylesheet=[vertexborder=false,vertexpadding=20,edgecolor = "Blue",
vertexcolor="Gold",edgethickness=3], font=["Courier",10],size=[180,180])

Even when I change their colors (any other thing), they always go their own way. I don't know if there is a setting that can make the LaTeX output more flexible and in line with our expectations after adjustment.

A Hamiltonian walk on a connected graph is a closed walk of minimal length which visits every vertex of a graph (and may visit vertices and edges multiple times). (See https://mathworld.wolfram.com/HamiltonianWalk.html)

 

Please note that there is a distinction between a Hamiltonian walk and a Hamiltonian cycle. Any graph can have a Hamiltonian walk, but not necessarily a Hamiltonian cycle.  The Hamiltonian number h(n) of a connected G is the length of a Hamiltonian walk. 

For example, let's consider the graph FriendshipGraph(2).

g:=GraphTheory[SpecialGraphs]:-FriendshipGraph(2);
DrawGraph(g)

Then its Hamiltonian number is 6.  A Hamiltonian walk is as shown in the following picture.

 

 

 

PS: After being reminded by others, I learned that a method in the following post seems to work, but I don't understand why it works for now. 

it's possible to formulate this as a Travelling Salesman Problem by augmenting the sparse graph into a complete graph by adding edges. These new edges represent shortest paths between any two vertices in the original graph and have weight equal to the path length.

 

It seems that the correctness of this transformation requires rigorous proof.

 

I would like to collect in derivatives of a function(s) in a worksheet where I have the Physics package loaded but It does not want to do it. When I bring the expression to a blank worksheet it does everything just fine. Am I missing something small? Or is there additional commands/options I need to input? 

Thoughts?

CollectDiff.mw

The highly oscillatory integrand is: 

(sin(x + sqrt(x)) + x*BesselJ(0, x^2))/(1 + x): # int(%, x = 0 .. infinity, numeric); # Note that the upper limit of `x` is NOT finite.

Unfortunately, Maple still cannot return a result in a few minutes. For instance, 

restart;
infolevel[`evalf/int`] := 1:

smartplot((sin(x+sqrt(x))+x*BesselJ(0, x^2))/(1+x))

 

timelimit(0.1e3, evalf(Int((sin(x+sqrt(x))+x*BesselJ(0, x^2))/(1+x), x = 0 .. infinity)))

Control: Entering NAGInt

trying d01amc (nag_1d_quad_inf)
Control: d01amc failed
evalf/int/control: NAG failed result = result
evalf/int/improper: integrating on interval 0 .. infinity
evalf/int/improper: applying transformation x = 1/x
evalf/int/improper: interval is 0 .. 1 for the integrand:

                        /     (1/2)\            /    2\
                     sin\x + x     / + x BesselJ\0, x /
                     ----------------------------------
                                   1 + x               

and interval is 0 .. 1 for the integrand:

                                                /   1 \
                                         BesselJ|0, --|
                        /       (1/2)\          |    2|
                        |1   /1\     |          \   x /
                     sin|- + |-|     | + --------------
                        \x   \x/     /         x       
                     ----------------------------------
                                 /    1\  2            
                                 |1 + -| x             
                                 \    x/               

Control: Entering NAGInt
Control: trying d01ajc (nag_1d_quad_gen)
Control: d01ajc failed
evalf/int/control: NAG failed result = result

evalf/int/control: singularity at left end-point
evalf/int/transform: series contains {x^(1/2), x^(3/2), x^(5/2), x^(7/2), x^(9/2), x^(11/2), x^(13/2), x^(15/2), x^(17/2), x^(19/2), x^(21/2), x^(23/2), x^(25/2)}

evalf/int/singleft: applying transformation x = x^2
evalf/int/singleft: interval is 0 .. 1. for the integrand:

                  /   / 2            \    2        /    4\\  
                2 \sin\x  + csgn(x) x/ + x  BesselJ\0, x // x
                ---------------------------------------------
                                        2                    
                                   1 + x                     

evalf/int/control: Applying simplify/ln, integrand is 2*(sin(x^2+x)+x^2*BesselJ(0,x^4))/(1+x^2)*x
evalf/int/CreateProc: Trying easyproc
evalf/int/CreateProc: Trying makeproc
evalf/int/ccquad: n = 2 integral estimate = .7758263476953
                    n = 6 integral estimate = .8097413335347
evalf/int/ccquad: n = 18 integral estimate = .8097470386638
                                  error = .8097470386638e-11
From ccquad, result = .8097470386638 integrand evals = 19 error = .8097470386638e-11
Control: Entering NAGInt
Control: trying d01ajc (nag_1d_quad_gen)
Control: d01ajc failed
evalf/int/control: NAG failed result = result

evalf/int/control: singularity at left end-point

evalf/int/transform: series contains {1/x^(3/2), x^(1/2), cos(1/x^2+1/4*Pi), sin((x+x^(1/2))/x^(3/2)), sin(1/4*(4+Pi*x^2)/x^2)}
evalf/int/singleft: applying transformation x = x^2
evalf/int/singleft: interval is 0 .. 1. for the integrand:

                   /   /        /1\  \                    \
                   |   |1 + csgn|-| x|                    |
                   |   |        \x/  |  2          /   1 \|
                 2 |sin|-------------| x  + BesselJ|0, --||
                   |   |      2      |             |    4||
                   \   \     x       /             \   x //
                 ------------------------------------------
                                 3 /     2\                
                                x  \1 + x /                

evalf/int/control: Applying simplify/ln, integrand is 2*(sin((1+x)/x^2)*x^2+BesselJ(0,1/x^4))/x^3/(1+x^2)
evalf/int/control: Applying simplify/trig, integrand is (2*sin((1+x)/x^2)*x^2+2*BesselJ(0,1/x^4))/(x^3+x^5)
evalf/int/control: singularity at left end-point

evalf/int/transform: series contains {cos(1/x^4+1/4*Pi), sin((1+x)/x^2), sin(1/4*(4+Pi*x^4)/x^4)}
evalf/int/transform: no transform found
evalf/int/series: integrating on 0 .. .2493468135214 the series:

       2 (%2)     2 (%2) x   /2 (%2)      \  3   /  2 (%2)      \  5   
      --------- - -------- + |------- - %3| x  + |- ------- + %3| x    
        (1/2)       (1/2)    |  (1/2)     |      |    (1/2)     |      
      Pi      x   Pi         \Pi          /      \  Pi          /      
                                                                       
           /       2 (%2)      \  7   /     2 (%2)      \  9           
         + |- %3 + ------- - %4| x  + |%3 - ------- + %4| x            
           |         (1/2)     |      |       (1/2)     |              
           \       Pi          /      \     Pi          /              
                                                                       
                                                                       
           /2 (%2)           \  11   /          2 (%2) \  13           
         + |------- - %4 - %5| x   + |%4 + %5 - -------| x             
           |  (1/2)          |       |            (1/2)|               
           \Pi               /       \          Pi     /               
                                                                       
           /       2 (%2)      \  15   /     2 (%2)      \  17    / 19\
         + |- %5 + ------- + %6| x   + |%5 - ------- - %6| x   + O\x  /
           |         (1/2)     |       |       (1/2)     |             
           \       Pi          /       \     Pi          /             
                                                                       
                                                                       
                      /        4\                                      
             (1/2)    |4 + Pi x |                                      
      %1 := 2      sin|---------|                                      
                      |     4   |                                      
                      \  4 x    /                                      
                    /1 + x\   (1/2)                                    
      %2 := %1 + sin|-----| Pi                                         
                    |  2  |                                            
                    \ x   /                                            
             (1/2)    /1    1   \                                      
            2      cos|-- + - Pi|                                      
                      | 4   4   |                                      
                      \x        /                                      
      %3 := ---------------------                                      
                      (1/2)                                            
                  4 Pi                                                 
                        /        4\                                    
               (1/2)    |4 + Pi x |                                    
            9 2      sin|---------|                                    
                        |     4   |                                    
                        \  4 x    /                                    
      %4 := -----------------------                                    
                       (1/2)                                           
                  64 Pi                                                
                (1/2)    /1    1   \                                   
            53 2      cos|-- + - Pi|                                   
                         | 4   4   |                                   
                         \x        /                                   
      %5 := ------------------------                                   
                        (1/2)                                          
                  512 Pi                                               
                           /        4\                                 
                  (1/2)    |4 + Pi x |                                 
            1371 2      sin|---------|                                 
                           |     4   |                                 
                           \  4 x    /                                 
      %6 := --------------------------                                 
                          (1/2)                                        
                  16384 Pi                                             

evalf/int/CreateProc: Trying easyproc
evalf/int/CreateProc: Trying makeproc

evalf/int/CreateProc: Trying procmake
evalf/int/control: applying double-exponential method
evalhf mode unsuccessful -- retry in software floats
evalf/int/quadexp: applying double-exponential method

Error, (in tools/sign) time expired

 

time() =

3999.500

(1)

 =

%?

Download oscillatoryInt.mws

I tried to specify another method (as described in evalf/int), but it seems that this doesn't work. Any ideas?

First 24 25 26 27 28 29 30 Page 26 of 32