Maple 2023 Questions and Posts

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

Hello

I have programs below for the cases n=3 and n=4. If n is increasing by 1, then there is one loop more. As you can see, that additional loop has always the structure:

x[i+1] from ceil(((n-2)*24-d[i])/(n-i)) to x[i]

whereas d[i] is the sum of the values of x before.

Now I want to write "nequaln":=proc(k), which goes through all the values for n from 3 to k and produces a list [a_3,a_4,a_5,...,a_n].

I guess that I need to program a kind of dynamical loop, but I failed completely. May someone help me? That would be very kind.

 

nequal3:=proc()
    local u,v,a_3;
    a_3:=0;
    for u from ceil((3-2)*24/(3-0)) to (3-2)*24-3+1 do
        for v from ceil(((3-2)*24-u)/(3-1)) to u do
            if (3-2)*24-u-v>=1 then
                a_3:=a_3+1;
            end if;
        end do;
    end do;
    print(a_3);
end proc:

 

nequal4:=proc()
    local u,v,w,a_4;
    a_4:=0;
    for u from ceil((4-2)*24/(4-0)) to (4-2)*24-4+1 do
        for v from ceil(((4-2)*24-u)/(4-1)) to u do
            for w from ceil(((4-2)*24-u-v)/(4-2)) to v do
                if (4-2)*24-u-v-w>=1 then
                    a_4:=a_4+1;
                end if;
            end do;
        end do;
    end do;
    print(a_4);
end proc:

The old question "Longest distance in a graph via Maple code" offers some general methods to find longest paths in a given graph, while for directed acyclic graphs, the longest paths can be found much more directly via built-in functions. However, it apprears that even for small dags, Maple cannot solve this in an acceptable time. In the following example, I'd like to count the number of nodes that on longest paths for certain source and target vertexes.
 

restart;

_seed := 1234

Warning, the use of _seed is deprecated.  Please consider using one of the alternatives listed on the _seed help page.

 

G := GraphTheory:-RandomGraphs:-RandomNetwork(200, .2, 'acyclic', 'weights' = 0. .. 2)

G__0 := applyop(`-`, -1, G)``

GRAPHLN(directed, weighted, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200], Array(1..200, {(1) = {2, 3, 4}, (2) = {5}, (3) = {4, 5}, (4) = {5}, (5) = {6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18}, (6) = {11, 12, 13, 14, 15, 17, 18, 19, 21}, (7) = {9, 10, 11, 16, 17, 20, 22}, (8) = {12, 14, 16, 17, 19, 20, 21, 22, 23}, (9) = {11, 14, 21, 23}, (10) = {11, 13, 18, 19, 20, 21, 23}, (11) = {14, 15, 16, 17, 18, 21, 23}, (12) = {13, 15, 18, 19, 20, 22}, (13) = {14, 15, 16, 17, 21}, (14) = {19, 20, 22}, (15) = {19, 20, 22, 23}, (16) = {17, 18, 21}, (17) = {19, 20, 23}, (18) = {19, 20, 21}, (19) = {20, 24, 25}, (20) = {22, 23, 25}, (21) = {23, 24, 25}, (22) = {23, 24, 25}, (23) = {24, 25}, (24) = {26, 27, 29}, (25) = {27, 28, 29}, (26) = {28, 29, 30}, (27) = {28, 29, 31, 32, 33}, (28) = {32, 33}, (29) = {32, 33}, (30) = {34, 35, 38, 39}, (31) = {32, 37, 38, 39}, (32) = {33, 36, 37, 38}, (33) = {35, 36, 39}, (34) = {36, 38, 39}, (35) = {37, 39}, (36) = {37, 39}, (37) = {39, 40}, (38) = {39, 40}, (39) = {40}, (40) = {41, 42}, (41) = {43, 44, 47, 48, 49}, (42) = {44, 45, 46, 47, 48, 49}, (43) = {47, 49, 50, 55, 56, 57}, (44) = {45, 48, 50, 51, 52, 53, 54, 56}, (45) = {46, 47, 49, 50, 52, 56}, (46) = {47, 48, 49, 50, 51, 52, 53, 56, 57}, (47) = {49, 50, 51, 52, 54, 56, 57}, (48) = {49, 51, 52, 53, 54, 55, 56, 57}, (49) = {50, 52, 53, 54, 57}, (50) = {51, 57}, (51) = {53, 54, 57}, (52) = {53, 55, 57}, (53) = {54, 56}, (54) = {56, 58}, (55) = {58}, (56) = {58}, (57) = {58}, (58) = {59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75}, (59) = {60, 61, 66, 68, 70, 71, 74, 75, 76, 77}, (60) = {61, 63, 67, 68, 70, 72, 73, 77}, (61) = {62, 66, 69, 70, 71, 72, 73, 75, 76, 77}, (62) = {65, 68, 75, 76, 77}, (63) = {65, 66, 69, 70, 72, 73, 76, 77}, (64) = {65, 67, 68, 69, 70, 71, 73, 77}, (65) = {66, 70, 72, 73, 74, 76}, (66) = {68, 70, 71, 72, 73, 74, 75, 76, 77}, (67) = {69, 70, 71, 74, 76}, (68) = {73, 74}, (69) = {71, 76, 77}, (70) = {71, 73, 77}, (71) = {72, 76, 77}, (72) = {75}, (73) = {75, 76}, (74) = {76}, (75) = {76}, (76) = {77, 78, 79, 80, 81, 82, 83, 85, 86}, (77) = {79, 80, 82, 84, 85}, (78) = {79, 83, 85, 87}, (79) = {81, 82, 83, 85, 86, 87}, (80) = {83, 86}, (81) = {83, 84, 87}, (82) = {87}, (83) = {85, 86, 87}, (84) = {85, 87}, (85) = {87}, (86) = {87}, (87) = {88, 89}, (88) = {90, 91, 92, 93, 94}, (89) = {90, 91, 93, 94, 95}, (90) = {96, 97, 99, 101, 103, 104, 107, 108, 109, 110, 112, 115, 117, 118, 120}, (91) = {92, 94, 96, 97, 98, 100, 101, 102, 105, 106, 107, 110, 113, 116, 117, 118, 120}, (92) = {95, 97, 98, 99, 101, 103, 106, 107, 108, 111, 112, 113, 115, 117, 119, 120}, (93) = {95, 96, 98, 100, 104, 106, 109, 111, 112, 113, 116, 118, 119, 120}, (94) = {95, 99, 100, 102, 103, 104, 106, 108, 109, 110, 111, 112, 113, 114, 115, 117, 118, 119, 120}, (95) = {97, 98, 99, 100, 102, 103, 104, 105, 107, 108, 109, 111, 112, 113, 114, 115, 116, 117, 118, 120}, (96) = {98, 100, 102, 103, 104, 106, 107, 110, 111, 114, 119, 120, 121}, (97) = {99, 100, 102, 104, 106, 107, 108, 109, 111, 114, 118, 119}, (98) = {102, 103, 107, 110, 111, 112, 113, 114, 116, 117, 119, 120, 121}, (99) = {101, 102, 104, 106, 107, 112, 117, 120}, (100) = {101, 104, 105, 106, 109, 110, 116, 117, 119, 120, 121}, (101) = {102, 105, 109, 110, 111, 112, 113, 114, 115, 117, 118, 119, 120}, (102) = {103, 106, 107, 108, 110, 112, 113, 114, 117, 118, 119}, (103) = {104, 105, 107, 108, 109, 110, 111, 113, 115, 116, 119, 120, 121}, (104) = {105, 106, 109, 110, 114, 115, 116, 118, 119}, (105) = {106, 108, 109, 110, 113, 114, 116, 117}, (106) = {107, 108, 109, 112, 114, 117, 118, 119, 121}, (107) = {110, 114, 116, 119, 120}, (108) = {111, 112, 113, 114, 118, 119, 120, 121}, (109) = {113, 116, 117, 118, 121}, (110) = {111, 113, 117, 119, 120, 121}, (111) = {112, 113, 115, 118, 120}, (112) = {113, 114, 116, 117, 118, 119, 120}, (113) = {116, 117, 119, 121}, (114) = {115, 116, 117, 121}, (115) = {116, 120}, (116) = {119, 121}, (117) = {118, 119, 121}, (118) = {121}, (119) = {121}, (120) = {121}, (121) = {122, 123, 124, 125, 126}, (122) = {123, 124, 125, 126, 127}, (123) = {126}, (124) = {126, 127}, (125) = {127}, (126) = {127}, (127) = {128, 129}, (128) = {130}, (129) = {130}, (130) = {131, 132}, (131) = {132, 133, 135}, (132) = {134, 135}, (133) = {134, 136, 137, 138, 140, 141, 142}, (134) = {135, 136, 139, 140, 141}, (135) = {136, 137, 139, 140, 141, 142}, (136) = {145, 146, 147}, (137) = {139, 141, 143, 145, 147, 148}, (138) = {139, 140, 143, 144, 145, 148}, (139) = {141, 143, 145}, (140) = {143, 145, 146, 147, 148}, (141) = {142, 144, 145, 146, 147}, (142) = {143, 144, 146, 148}, (143) = {145, 146, 147, 148}, (144) = {146, 149}, (145) = {147}, (146) = {149}, (147) = {149}, (148) = {149}, (149) = {150, 151, 152, 153, 154, 155, 156, 157, 158}, (150) = {152, 153, 155, 157, 158}, (151) = {152, 153, 159}, (152) = {154, 158}, (153) = {154, 155, 156}, (154) = {156, 158, 159}, (155) = {158}, (156) = {157, 158, 159}, (157) = {158}, (158) = {159}, (159) = {160, 161, 162, 163}, (160) = {161, 163, 166, 167}, (161) = {165, 166, 167}, (162) = {163, 165}, (163) = {164, 166, 167}, (164) = {166}, (165) = {166, 168, 169}, (166) = {169}, (167) = {168}, (168) = {169, 170, 171, 172, 173, 174, 177, 178, 179, 180, 182}, (169) = {170, 171, 172, 173, 174, 175, 176, 177, 178, 180, 181, 182}, (170) = {172, 173, 174, 175, 176, 180, 182, 183, 185}, (171) = {172, 174, 176, 177, 181, 182, 185}, (172) = {175, 176, 177, 183, 185}, (173) = {175, 176, 178, 183, 185}, (174) = {175, 180, 181, 183, 184, 185}, (175) = {181, 182, 183, 185}, (176) = {177, 178, 179, 182}, (177) = {178, 179, 184, 185}, (178) = {179, 180, 182, 183, 184}, (179) = {180, 182, 185}, (180) = {181, 182}, (181) = {184}, (182) = {185}, (183) = {187, 188, 190}, (184) = {187, 188, 189}, (185) = {186, 188, 190}, (186) = {187, 188, 190, 191, 193, 194, 196}, (187) = {188, 190, 192, 193, 194, 195}, (188) = {189, 190, 191, 192, 194}, (189) = {190, 191, 196}, (190) = {191, 192, 195, 196}, (191) = {193, 196, 199}, (192) = {194, 196, 198, 199}, (193) = {197, 199}, (194) = {195, 196, 197}, (195) = {196, 198, 199}, (196) = {198, 199}, (197) = {198}, (198) = {199, 200}, (199) = {200}, (200) = {}}), `GRAPHLN/table/1`, )

(1)

t, s := combinat:-randcomb(GraphTheory:-Vertices(G__0), 5^2), combinat:-randcomb(GraphTheory:-Vertices(G__0), integermul2exp(5, 2))

[12, 13, 22, 23, 41, 65, 70, 80, 88, 97, 105, 119, 124, 127, 129, 132, 135, 138, 146, 150, 165, 170, 189, 193, 199], [6, 13, 28, 29, 31, 41, 42, 49, 55, 85, 98, 104, 136, 141, 162, 166, 167, 168, 192, 199]

(2)

"DataFrame((`M__1`:=CodeTools:-Usage(Matrix(numelems(s),numelems(t),(i,j)->numelems((GraphTheory:-BellmanFordAlgorithm(`G__0`,s[i],t[j]))[1]),datatype=integer[2]))),'columns'=t,'rows'=s)"

memory used=7.99GiB, alloc change=0 bytes, cpu time=5.74m, real time=5.63m, gc time=22.55s

 

module DataFrame () description "two-dimensional rich data container"; local columns, rows, data, binder; option object(BaseDataObject); end module

(3)

"DataFrame((`M__2`:=CodeTools:-Usage(Matrix(numelems(s),numelems(t),proc(i::posint,j::posint,` $`)::nonnegint;  uses ListTools,GraphTheory; local ts::list(posint):=TopologicSort(`G__0`,'output'='permutation'),q::posint:=Search(t[j],ts),p::posint:=Search(s[i],ts); if  p>q then 0 elif q=p then 1 else numelems(BellmanFordAlgorithm(`G__0`,s[i],t[j])[1]) fi end,datatype=integer))),':-columns'=t,':-rows'=s)"

memory used=4.34GiB, alloc change=32.00MiB, cpu time=3.26m, real time=3.19m, gc time=14.34s

 

module DataFrame () description "two-dimensional rich data container"; local columns, rows, data, binder; option object(BaseDataObject); end module

(4)

EqualEntries(M__ || (1 .. 2))

true

(5)

 


 

Download longest_paths_in_a_DAG.mw

Unfortunately, I have to wait for almost four minutes in the above instance. Can this task be done in 0.4s?

Hi, I am using ArchLinux and used Maple's official installer to install it. Whenever I export my Maple files as PDF all my "-" symbols are converted to "K" for some reason. Has anyone else had this issue or have an idea on how to fix it?

Below is a screenshot of what I mean. "-" has been replaced with "K"

Hello

I have a list with n positive integer numbers and a positive integer k.

I would like to write a Malple programm, that calculates, in how many ways k can be written as a sum of numbers in the list.

Easy examles: let the list be [2,3,6,9].

k=9 can be written in 4 ways: 9=9, 9=6+3, 9=3+3+3, 9=3+2+2+2. The result therefore shoud be 4.

k=8 can be written in 3 ways: 8=6+2, 8=3+3+2, 8=2+2+2+2. The result therefore shoud be 3.

Thank you very much your help!

GraphTheory:-GraphEqual says that G1 and G2 are equal, but GraphTheory:-AllPairsDistance gives different results instead: 

restart;

with(GraphTheory)

M := `<|>`(`<,>`(0, 0, 0), `<,>`(1, 0, 0), `<,>`(1, 1, 0))

G__1 := Graph(convert(-M, Matrix, datatype = integer[8]))

G__2 := Graph(convert(-M, Matrix, datatype = integer))

GraphEqual(G__1, G__2)

true

(1)

AllPairsDistance(G__1)

AllPairsDistance(G__2)

Matrix(%id = 36893491227039185244)

 

Error, (in GraphTheory:-AllPairsDistanceExt) negative cycle detected

 

 

Download allpairs.mw

So, which one is incorrect? Any reasons?

I have a very simple procedure that I wrote to get information for an inequality using data from two lists, upon which I can create a pointplot . Now I know people will see what I have done and probably cringe, and believe me I do as well. I know it is not efficient and there is probably a numerous number of ways to do it better but my procedural skills for Maple are lacking. 

From my file you will see what I am attempting to do,nonetheless I will mention it here. I have two lists X,W. for each value in I want to fine the value in W that yields F(X,L)<G(X,L) where F(X,L) is a complicated integral that I have to evalute numerically, I have tried using unapply as outline in https://www.mapleprimes.com/questions/229070-How-Can-I-Speed-Up-This-Numerical-Integral it however only made my problem worse. For small lists it seems to be reasonable but for larger precision it is not the useful. I have looked through the ?do help page and some other resources but to no avail. From what I have seen though I believe I should be using the until command in do but I can't figure it out with having two lists. 

Any help,tips or tricks will be greatly appreciated.

NumericScale.mw

Here is a symmetric matrix with three real parame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,0,0,0\
,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\
,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\
,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,-1/\
2,0,-2*k__3,0,-1/2,0,0,0,0,0,0,0,0,k__3,0,k__3,0,0,0,0,0,0\
,1,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0>#assuming'real':
cc:={evalindets}(LinearAlgebra:-IsDefinite(mm,query='positive_semidefinite'),`and`,op):

As the title says, I hope to find some values satisfying andseq('cc') (so `mm` becomes positive semidefinite). Unfortunately, these don't work: 

# SMTLIB:-Satisfy(cc);
Optimization:-Maximize(0, cc, initialpoint = eval({k__ || (1 .. 3)} =~ 'rand(-2e1 .. 2e1)'()));
Error, (in Optimization:-NLPSolve) no feasible point found for the nonlinear constraints
timelimit(1e2, RealDomain:-solve(cc, [k__ || (1 .. 3)](*, 'maxsols' = 1*)));
Error, (in RegularChains:-SemiAlgebraicSetTools:-CylindricalAlgebraicDecompose) time expired

 Is there a way to do so as accurately (and precisely) as possible?

 

Maple introduced "Copy as LaTeX" a few versions ago and I have used this feature exensively when it suddenly stopped working.

After som experiments I found the root cause and easy (but irritating) workaround for OSX

Problem:

"Copy as LaTeX" suddenly stops working ("Copy as MathML" still works fine)

Cause:

This problem appears if in “Display Setting”-tab in settings dialogue the “Input display” is set to “Maple Notation

In that case all attempts on “Copy as LaTeX” will be a null-function and not move anything at all into the copy buffer.

The “Copy as MathML” is not affected by this in the same way.

I have confirmed this on OSX in Maple versions 2022, 2023, and 2024

Workaround:

Adjusting “Display Setting”-tab in settings dialogue so that the “Input display” is set to “2-D Math” and “Apply Globally” makes it work again.

A bit annoying as a prefer the maple notation input and I cannot have this setting if I want the copy to latex to work.

Note:

in OSX this can also be fixed by removing the Maple preferences file and letting Maple restore it.

~/Library/Preferences/Maple/2023/Maple Preferences

Edit: Added 2024 as affected version.

Since I began to use Maple for teaching back in 2014 (now on 2023 version), the following happens to some students. 

While they are in math mode, the Maple engine suddenly stops being unable to do anything (even 2+2). Only way to solve this is to start a new document or restart Maple. I have seen this issue on both Mac and PC version. 

So my question is what causes this? 

Hi everyone,

I'd like to draw your attention to a package we recently uploaded to the Maple Cloud, here. You can download the package from the linked Cloud page, or directly from here as a workbook file: NaturalLanguage.maple. I'll include a lightly edited version of the "cover sheet" that introduces the package below. I have left the first four sections folded closed - you can see those in the linked Maple Cloud page or the workbook - because I think the last section is the most interesting.
 

Using natural language models in Maple


This package explores using large language models such as ChatGPT for processing natural language in Maple. Let's load the package from source, save it in this workbook, and load it.

restart

read "this:///lib/NaturalLanguage.mpl"

savelib('NaturalLanguage', "this://")

with(NaturalLanguage)

Warning, the NaturalLanguage package is an experimental package designed as an interface to publicly available large language models such as ChatGPT. Use of this package is entirely at the user's risk. Results may be inconsistent, misleading, or flat out incorrect. 

[Explain, GetCommand, GetMath, Query, RawQuery]

(1)

We note there is a warning: we will see output of large language models, which will often include inaccurate statements. Please keep this in mind - this is not (yet?) technology that you want to use to build a bridge!

We also note that there are five publically exposed commands. Let's look at them in turn.

RawQuery

   

Query

   

GetMath

   

GetCommand

   

Explain

 
• 

The Explain command asks the given model to explain the item in the query. After an explanation, you can ask for more detail by issuing the command Explain(more), Explain("go on"), Explain(elaborate), Explain(further), Explain("continue"), or minor variations. The item you ask about can be a mathematical expression, equation, list of equations, or a string.

• 

The default model is GPT-4; you can select the other model by using the model = ChatGPT option, or forcing use of the GPT-4 model by using the model = GPT4 option. Note that OpenAI may deprecate and disable models, so the set of models supported may change in the future.

display(Explain(x^2+y^2=1));display(Explain(x^2+y^2 = 1))

This equation represents a circle with a radius of 1 centered at the origin (0,0) on a coordinate plane.

 

display(Explain(more));display(Explain(more))

The equation x^2 + y^2 = 1 represents a circle in a two-dimensional plane (specifically, a Cartesian plane).

The center of the circle is at the origin of the coordinates (0,0) and its radius is 1. This is because any point (x, y) on the circle is a distance r (the radius) away from the center, and by the Pythagorean theorem, this distance is given by the square root of (x^2 + y^2). The fact that x^2 + y^2 = 1 implies that the radius r = sqrt(1) = 1.

This fundamental equation is also the unit circle in trigonometry, where angles are measured in radians. The coordinates (x, y) represent the cosine and sine of the angle respectively. The unit circle is a crucial concept in trigonometry, complex number theory, and calculus. It simplifies many mathematical concepts and provides a geometric interpretation of a variety of phenomena in physical sciences and engineering.

 

display(Explain(Re(exp(x*I + y*I)) = Re(exp(x*I)) * Re(exp(y*I)) - Im(exp(x*I)) * Im(exp(y*I))));display(Explain(Re(exp(I*x+I*y)) = Re(exp(I*x))*Re(exp(I*y))-Im(exp(I*x))*Im(exp(I*y))))

The equation seems to be using Euler's formula, which states that e^(ix) = cos(x) + i*sin(x). The 'Re' refers to the real part of a complex number, and 'Im' refers to the imaginary part. So, if you put Euler's formula in there your equation is equivalent to cos(x + y) = cos(x)cos(y) - sin(x)sin(y), which is basically the well-known trigonometric formula for the cosine of a sum. In a nutshell, it's dealing with the trigonometric identities and properties of exponential functions with complex numbers.

 

display(Explain("go on", model = ChatGPT));display(Explain("go on", model = ChatGPT))

The given equation appears to be dealing with the real part of a complex exponential expression. Let's break it down step by step to understand its meaning:

1. The equation involves the expression e^(i*x+i*y), where e represents Euler's number (~2.718), i is the imaginary unit (√(-1)), and x and y are real numbers.
2. The expression e^(i*x+i*y) can be rewritten using Euler's formula: e^(i*x+i*y) = cos(x+y) + i*sin(x+y). This is a complex number in the form a + bi, where 'a' represents the real part (Re) and 'b' represents the imaginary part (Im).
3. The real part of e^(i*x+i*y) is, therefore, Re(e^(i*x+i*y)) = cos(x+y).
4. The right side of the equation consists of the product of two complex exponential expressions: Re(e^(i*x))*Re(e^(i*y))-Im(e^(i*x))*Im(e^(i*y)).
5. The expression Re(e^(i*x)) represents the real part of e^(i*x), which is cos(x), and Im(e^(i*x)) represents the imaginary part of e^(i*x), which is sin(x).
6. Similarly, Re(e^(i*y)) represents the real part of e^(i*y), which is cos(y), and Im(e^(i*y)) represents the imaginary part of e^(i*y), which is sin(y).
7. Therefore, the right side becomes: (cos(x)*cos(y)) - (sin(x)*sin(y)).

So, the equation Re(e^(i*x+i*y)) = Re(e^(i*x))*Re(e^(i*y))-Im(e^(i*x))*Im(e^(i*y)) essentially states that the real part of e^(i*x+i*y) (i.e., cos(x+y)) is equal to the real part of e^(i*x) (i.e., cos(x)) multiplied by the real part of e^(i*y) (i.e., cos(y)), minus the imaginary part of e^(i*x) (i.e., sin(x)) multiplied by the imaginary part of e^(i*y) (i.e., sin(y)).

In simpler terms, the equation is connecting the real part of the sum of two complex exponential expressions with the product of the real parts and the difference of the imaginary parts of those individual expressions.

 

display(Explain(Re(sigma) < 0));display(Explain(Re(sigma) < 0))

The inequality "Re(sigma) < 0" is a statement in complex number theory. It is saying that the real part (Re) of a complex number sigma is less than zero. This means that the complex number is to the left of the imaginary axis in the complex number plane. This kind of inequality is often used in the study of complex functions, in areas such as control systems or signal processing in electrical engineering, and also in number theory and the study of dynamical systems in mathematics.

 

display(Explain(continue));display(Explain(continue))

The inequality "Re(sigma) < 0" is typically related to the field of complex numbers. Here, "Re" stands for the real part of a complex number and "sigma" is usually used to represent a complex number. So, "Re(sigma) < 0" is saying that the real part of the complex number sigma is negative.

Complex numbers are usually written in the form a + bi, where a and b are real numbers and i is the imaginary unit. The "Re" in "Re(sigma)" refers to the a part of this form, i.e. the real part of the complex number.

This inequality is often found in fields like control systems engineering or signal processing. For instance, in control systems, all the poles of a stable system must have a negative real part. Another context you might come across this inequality is in complex analysis, one might examine the region where the real part of a complex function is negative. So, the inequality "Re(sigma) < 0" expresses that a complex number is in the left half of the complex plane, which is often crucial for the stability of many systems in engineering.

 

display(Explain("The Maple command simplify"));display(Explain("The Maple command simplify"))

The Maple command "simplify" is used to simplify mathematical expressions. In Maple, this command applies various rules to reduce an equation or expression to its simplest or most compact form.

For example, if you have an equation like `(x^3 - x^2)/x^2`, using the simplify command would reduce it to `x - 1`. It simplifies algebraic expressions, performs factorization, combines like terms, cancel out common factors, etc.

The general syntax is `simplify(expr)`, where `expr` is the expression that you want to simplify. The simplified expression is returned as output.

Please note that the simplifications made by this command are based on general rules and may not always give the expected results for some specific expressions due to the complexity of mathematical simplifications.

 

display(Explain(continue, model=ChatGPT));display(Explain(continue, model = ChatGPT))

The Maple command "simplify" is used to simplify mathematical expressions. It takes an expression as input and attempts to find a simplified form by applying various algebraic rules and simplification techniques.

When you use the "simplify" command, Maple applies a series of simplification steps, which can include:

1. Expanding and factoring polynomials: This step expands products of terms and factors out common terms.
2. Simplifying fractions: The command simplifies fractions by canceling common factors in the numerator and denominator.
3. Simplifying trigonometric expressions: Maple applies trigonometric identities to simplify expressions involving trigonometric functions.
4. Simplifying logarithmic and exponential expressions: The command applies rules of logarithms and exponents to simplify expressions with these functions.
5. Simplifying square roots and radicals: It simplifies square roots by expressing them in simplest radical form.
6. Simplifying expressions involving absolute values: Maple simplifies absolute value expressions by considering different cases based on the sign of the argument.
7. Applying mathematical identities and rules: The command uses various mathematical identities and rules to simplify expressions further.

The "simplify" command in Maple is very powerful and can handle a wide range of mathematical expressions. However, it may not always produce the most simplified form, as simplification can sometimes be a subjective task. In such cases, you can try using other commands or options available in Maple to refine the simplification process.

To use the "simplify" command in Maple, you can simply type "simplify(expression)" where "expression" represents the mathematical expression you want to simplify.

 

display(Explain("Weight of a W10X54 beam?"))

The weight of a W10X54 beam refers to the weight specification of a beam in the W Beam series, commonly used in construction and engineering projects. The nomenclature "W10X54" is decoded as follows:

- W: it stands for 'wide flange', a type of structural steel beam where the flanges are parallel to each other.
- 10: it indicates the nominal depth of the wide flange, which is about 10 inches.
- 54: it indicates the weight of the beam per linear foot, which is about 54 pounds.

So, a W10X54 beam weighs 54 pounds per foot.

 

display(Explain(further))

"Weight of a W10X54 beam" refers to the weight of a specific kind of structural steel beam used in construction and architecture. The "W" stands for "wide flange", which is a particular type of I-beam.

The "10" means the nominal depth of the beam in inches (also known as its height when standing upright).

The "54" represents the beam's weight per foot in pounds. In other words, for every foot of length the beam has, it weighs 54 pounds.

 So if you have a W10X54 beam that is 10 feet long, its total weight would be 540 pounds (10 feet times 54 pounds per foot).

Please note that these are nominal dimensions and may not exactly match the true dimensions of the beam due to manufacturing variables.

 

NULL

 

What do you think? Will this be an important part of mathematical software in the near future, or are we still far away from that point? We'd love to hear your opinions.

I installed Maple 2023.1 update and immediately noticed a problem with the worksheet editor.

Specifically, the editor seems to be replacing "<" with "!" in the maple code. I first noticed the problem with code copied from the maple code editor into a worksheet, but then noticed the same problem with code on another worksheet which was loaded from file. Thus, it seems the problem is actually in the worksheet editor and not the copy paste function.  Note that the problem occurred immediately on reloading files after I restarted maple from the update. Normally, when this occurs, it starts after Maple has been loaded for an hour or more. Fortunately, when I restarted Maple and reloaded files, the problem seems to have cleared itself.

I have attached images showing the maple screen with the error, and also the specific code copied from the code editor to a worksheet for comparison.  I have also attached the worksheets in which I saw the problem. For now my goto workaround is to save and restart because the problem does not seem to corrupt the actual files even when I save them.

 

Attachments: chain.mw  chain2.mw

According to print - Maple Help (maplesoft.com),

calling print[N] instead of print where N is an integer between -2 and +3, temporarily overrides the prettyprint interface variable.

However, I find that 

print[-2]();
Error, prettyprint must be an integer in the range 0..3
print[-1]();
Error, prettyprint must be an integer in the range 0..3

Also, 

interface(prettyprint = -2);
Error, (in interface) prettyprint must be an integer in the range 0..3
interface(prettyprint = -1);
Error, (in interface) prettyprint must be an integer in the range 0..3

Did I miss something?

I'd like to reproduce Initial Value DDE of Neutral Type in Maple.
The differential equation is: 

deq := D(y)(t) = 2*cos(2*t)*y(t/2)^(2*cos(t)) + ln(D(y)(t/2)) - ln(2*cos(t)) - sin(t): # with y(0) = 1 and known D(y)(0)

Unfortunately, if I type valid initial values, Maple will simply generate , and yet if I just give a partial initial condition, Maple will display and only return incorrect results. 
 

restart;

interface(version)

`Standard Worksheet Interface, Maple 2023.1, Windows 10, July 7 2023 Build ID 1723669`

(1)

deq := (D(y))(t) = 2*cos(2*t)*y((1/2)*t)^(2*cos(t))+ln((D(y))((1/2)*t))-ln(2*cos(t))-sin(t)

RealDomain:-solve(subs(t = 0, y(0) = 1, deq), (D(y))(0))

2, -LambertW(-2*exp(-2))

(2)

dsolve({deq, y(0) = 1, (D(y))(0) = (2, -LambertW(-2*exp(-2)))[1]}, 'numeric', 'delaymax' = Pi, 'range' = 0 .. 2*Pi)

Error, (in dsolve/numeric/DAE/initial) too many initial conditions, the following are not needed: {D(y)(0) = 2}

 

dsolve({deq, y(0) = 1, (D(y))(0) = (2, -LambertW(-2*exp(-2)))[2]}, 'numeric', 'delaymax' = Pi, 'range' = 0 .. 2*Pi)

Error, (in dsolve/numeric/DAE/initial) too many initial conditions, the following are not needed: {D(y)(0) = -LambertW(-2*exp(-2))}

 

dsn := dsolve({deq, y(0) = 1}, 'type' = 'numeric', 'delaymax' = Pi, 'range' = 0 .. 2*Pi)

plots['odeplot'](dsn, 0 .. 2*Pi)NULL

Warning, cannot evaluate the solution past the initial point, problem may be complex, initially singular or improperly set up

 

`[Length of output exceeds limit of 1000000]`

 

Warning, cannot evaluate the solution past the initial point, problem may be complex, initially singular or improperly set up

 

 


 

Download ndelay.mw

The output is wrong. Note that "y(0) = 1" is insufficient to uniquely specify a solution, as "D(y)(0)" can be either -LambertW(-2/exp(2)) or 2. But Maple does not allow sufficient constraints here. How do I avoid such an unexpected behavior?

Maple's fsolve command can quickly solve expressions involving large floating point numbers where the (symbolic) solve command can take much longer attempting to solve the equivalent rational expression. For example, consider the following worksheet:

restart;

sys := {a + b^0.2784982189 = c+1, b + c^0.9575068354 = a+2, c + a^0.1576130817 = b+3};

{a+b^.2784982189 = c+1, b+c^.9575068354 = a+2, c+a^.1576130817 = b+3}

(1)

fsolve_start:=time[real]():

fsolve(sys);

{a = 3.561242843, b = 1.994950678, c = 3.773320855}

(2)

fsolve_elapsed_seconds:= time[real]()-fsolve_start;

0.50e-1

(3)

solve_start:=time[real]():

###warning, the following command may crash and/or execute indefinitely###

solve(sys);

solve_elapsed_hours:=(time[real]()-solve_start)/3600;


 

Download solve-fsolve-primes.mw

Here is a test: 

For small matrices, apart from the first call, the performance is almost perfect (🎉!). 
As a comparison, an equivalent test may be performed in modern Python:

As you can see, for 1024×1024, 2048×2048, 4096×4096, 8192×8192, and 16384×16384 matrices, Maple's performance gets pretty poor. Is the FFT procedure not well optimized for larger matrices? I do have read the Fourier Transforms in Maple, yet I cannot find any information on this subject. 
In accordance with the following output 

showstat(DiscreteTransforms::FFT_complex8, 3):

FFT_complex8 := proc()
       ...
   3   :-DiscreteTransforms:-FFT_complex8 := LinkExternal('hw_FFT',2003);
       ...
end proc

it appears that the code hasn't been developed for 20 years. Is it possible to improve the performance of the FFT built into Maple in order that the computation on such a 2¹⁴×2¹⁴ matrix can be achieved in about twenty seconds (rather than in two minutes)?

Note. For these matrices, exact transform results (see below) can be obtained symbolically.

for n from 0 to 12 do
    m := LinearAlgebra:-HankelMatrix(<$ (1 + 1 .. 2**n + 2**n)>, datatype = complex[8], shape = []): gc();
    print(n, andseq(abs(_) < HFloat(1, -10, 2), _ in SignalProcessing:-FFT(m, normalization = none, inplace = true) - Matrix(2^n, <2^(2*n)*(2^n + 1), <'2^(2*n - 1)*(:-cot((k - 1)/2^n*Pi)*I - 1)' $ 'k' = 1 + 1 .. 2^n>>, shape = symmetric, storage = sparse, datatype = complex[8])) (* faster than `rtable_scanblock` and `ArrayTools:-IsZero` and much faster (🎊!) than `comparray` and `verify/Matrix` with testfloat *) )
od:
 = 
                            0, true

                            1, true

                            2, true

                            3, true

                            4, true

                            5, true

                            6, true

                            7, true

                            8, true

                            9, true

                            10, true

                            11, true

                            12, true

However, the main goal is to test the numerical efficiency of Maple's fast Fourier transform algorithm.

First 18 19 20 21 22 23 24 Last Page 20 of 31