Maple 2023 Questions and Posts

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

I have the function: 2*sin(x)+1/2x-1

I want the x-intercepts, but Maple only provides one answer with fsolve.

plot(2*sin(x)+1/2*x-1)

S := [1, 2];
                          S := [1, 2]

T := [1, 2];
                          T := [1, 2]

is(S = T);
                              true

Sv := Vector([1, 2]);
                              

Tv := Vector([1, 2]);
                              

is(Sv = Tv);
                             false

is(convert(Sv, list) = convert(Tv, list));
                              true

I obtained a Plot p, then trying to find if it has Float(undefined) in it. I am basically trying to find if DEplot returns an empty plot or not. I found that it the plot structure has HFlat(undefined) then this seems to imply an empty plot. So I said, then in the code I can check for HFlat(undefined) in the plot and it is there, then I know the plot is empty.

But this check is not working.

I used has(....,Float(undefined)) and this returns false. But if I copy and paste part of the plot structure and try the check on the copy, it gives true. 

I do not understand what is the difference. First here is screen shot, and below if complete code to reproduce.

restart;
ode2:=2*y(t)+t*diff(y(t),t) = t^2-t+1;

p:=DEtools:-DEplot(ode2,y(t),t=0..3.5,y=0..3,
                        linecolor = red,                        
                        arrowsize ='magnitude',
                        numpoints = 200 ,
                        axes = boxed,color = ('magnitude[legacy]')):


p0:=Array(1 .. 3,1 .. 2,{(1, 1) = HFloat(undefined), (1, 2) = HFloat(undefined), (2
, 1) = HFloat(undefined), (2, 2) = HFloat(undefined), (3, 1) = HFloat(undefined
), (3, 2) = HFloat(undefined)},datatype = float[8],order = C_order);
whattype(p0);
has(p0,HFloat(undefined)) 

p1:=op([1,2],p);
whattype(p1);
has(p1,HFloat(undefined)) 

Worksheet attached also.

Maple 2023.2 on windows 10
 

``

restart;

185876

ode2:=2*y(t)+t*diff(y(t),t) = t^2-t+1;
p:=DEtools:-DEplot(ode2,y(t),t=0..3.5,y=0..3,
                        linecolor = red,                        
                        arrowsize ='magnitude',
                        numpoints = 200 ,
                        axes = boxed,color = ('magnitude[legacy]')):




 

2*y(t)+t*(diff(y(t), t)) = t^2-t+1

p0:=Array(1 .. 3,1 .. 2,{(1, 1) = HFloat(undefined), (1, 2) = HFloat(undefined), (2
, 1) = HFloat(undefined), (2, 2) = HFloat(undefined), (3, 1) = HFloat(undefined
), (3, 2) = HFloat(undefined)},datatype = float[8],order = C_order);
whattype(p0);
has(p0,HFloat(undefined))

Matrix(3, 2, {(1, 1) = HFloat(HFloat(undefined)), (1, 2) = HFloat(HFloat(undefined)), (2, 1) = HFloat(HFloat(undefined)), (2, 2) = HFloat(HFloat(undefined)), (3, 1) = HFloat(HFloat(undefined)), (3, 2) = HFloat(HFloat(undefined))})

hfarray

true

p1:=op([1,2],p);
whattype(p1);
has(p1,HFloat(undefined))

Matrix(3, 2, {(1, 1) = HFloat(HFloat(undefined)), (1, 2) = HFloat(HFloat(undefined)), (2, 1) = HFloat(HFloat(undefined)), (2, 2) = HFloat(HFloat(undefined)), (3, 1) = HFloat(HFloat(undefined)), (3, 2) = HFloat(HFloat(undefined))})

hfarray

false

 


question is: Why the above give different result? And what is the correct way to check if the output plot from DEplot is empty or not (in code)?

Download why_has_works_different.mw

With the context-panel

P(x, y) = exp(-(x^2+y^2)/(2*sigma^2))/(2*Pi*sigma^2)

P(x, y) = (1/2)*exp(-(1/2)*(x^2+y^2)/sigma^2)/(Pi*sigma^2)

(1)

subs(sigma = 523.*Unit('`μm`'), P(x, y) = (1/2)*exp(-(1/2)*(x^2+y^2)/sigma^2)/(Pi*sigma^2))

P(x, y) = 0.5818576570e-6*exp(-0.1827959741e-5*(x^2+y^2)/Units:-Unit(`μm`)^2)/Units:-Unit(`μm`)^2

(2)

NULL


How to format all occurences of numbers?

Download Number_Format.mw

I have expressions with head Sum that are all either one single Sum or sum of these Sum's. So my expression is either

Sum(.....)+Sum(....)+Sum(...)   or Sum()  

Inside each Sum, I have indexed a[n] and also possibly nonindexed For an example

             Sum( a[n]*x + a, n=1..10)

And I want to change all the indexed a[n] to b[n] 

Hence the example above it will becomes  Sum( b[n]*x + a, n=1..10)

I can't just use eval(expr,a=b) as that will also change the non-indexed a to b which I want to leave as is. There will be only one single indexed variable in the sum. In this example it is `a`

Below is a general example and my solution. I'd like to find if there is a more canonical way or shorter more direct way to do this in Maple. 

restart;
expr:=Sum(x^(n+r)*a[n]*(n+r)*(n+r-1)+a[n-1]+3*a*x^10,n = 0 .. infinity)+Sum(4*a*x^(n+r)*a[n],n = 0 .. infinity)+Sum(4*a[n-1]*x^(n+r)+a[n]*x+a*x,n = 1 .. infinity) = 0;

evalindets(expr,specfunc( anything, 'Sum' ),f->Sum(evalindets(op(1,f),'indexed',ff->b[op(ff)]),op(2,f)))

I used evalindets twice. Once to look for Sum, and then to look for 'indexed' within each sum. It seems to work. Here is screen shot of the output

If you asking why I have indexed a and non indexed a in the same expression? Well, it is because the non-indexed happend to be a coefficient of the ode that the user used. So it is part of the input, which I have no control over. But the indexed is a local variable I am using inside the function being called to process the input.

On the screen they look the same. But they are actually not the same. The indexed is local to the function and the non-indexed is input via argument. So it is global symbol. 

 

 

How I can plot a volumetric body with the coordinates provided in the text file attachment?

after finding the geometry curve I want to find the curve that passes through the middle source.

1.txt

After I switched to using arrows = curve in the call to DEtools:-DEplot I found errors in some calls. 

Is there a workaround other than not using this option? As phase plot looks like better with this option. For now, I will remove this option.

Here is an example

restart;

ode:=diff(y(x),x)-1/(-x^2+1)^(1/2) = 0;
x_range:=-0.99 .. 0.99;
DEtools:-DEplot(ode,y(x),x =x_range,y = -1.6 .. 1.6,[y(0) = 0],arrows = 'curve')

Error, (in DEtools/DEplot/direction) cannot assign a complex value to a hardware float Array

But this works

restart;

ode:=diff(y(x),x)-1/(-x^2+1)^(1/2) = 0;
x_range:=-0.99 .. 0.99;
DEtools:-DEplot(ode,y(x),x =x_range,y = -1.6 .. 1.6,[y(0) = 0])

I will report this to Maplesoft as it looks like a bug to me. 

May be someone can find a workaround so I can use arrows = curve?

Maple 2023.2 on windows 10

``

restart;

292176

ode:=diff(y(x),x)-1/(-x^2+1)^(1/2) = 0;
x_range:=-0.99 .. 0.99;
DEtools:-DEplot(ode,y(x),x =x_range,y = -1.6 .. 1.6,[y(0) = 0],arrows = 'curve')

diff(y(x), x)-1/(-x^2+1)^(1/2) = 0

-.99 .. .99

Error, (in DEtools/DEplot/direction) cannot assign a complex value to a hardware float Array

restart;

292176

ode:=diff(y(x),x)-1/(-x^2+1)^(1/2) = 0;
x_range:=-0.99 .. 0.99;
DEtools:-DEplot(ode,y(x),x =x_range,y = -1.6 .. 1.6,[y(0) = 0])

diff(y(x), x)-1/(-x^2+1)^(1/2) = 0

-.99 .. .99

 

Download detools_deplot_arrows_curve_problem_NOV_10_2023.mw

Given a system of 2 first order ode's which are autonomous (i.e. the RHS does not explicitly depend on time), one can make phase plot in Maple using DEtools:-DEplot

I am trying to get my Maple output to look like I get with Mathematica. I am getting close, but there are two issues. First, here is what I get in Maple

restart;

ode1:=diff(x(t),t)=2*x(t)*y(t);
ode2:=diff(y(t),t)=1-x(t)^2-y(t)^2;

DEtools:-DEplot([ode1,ode2],[x(t),y(t)],
                           t=0..1,x = -4..4, y = -4..4,arrows=curve,linecolor=red,
                           numpoints =300,arrowsize='magnitude',scene=[x(t),y(t)]);

Here is the same thing in Mathematica

ode1=x'[t]==2*x[t]*y[t]
ode1=y'[t]==1-x[t]^2-y[t]^2

StreamPlot[{2 x*y,1-x^2-y^2},{x,-4,4},{y,-4,4},
    FrameLabel->{{y[t],None},{x[t],None}},BaseStyle->16,ImagePadding->{{50,10},{50,0}}]

Is it possible to get the arrows to be stream lines similar to how they show up? Also, the axes labels in Maple are internal and hard to see. Is it possible to have on the outside like above so they are easier to see?

On a side question: Should one use DEtools:-DEplot or DEtools:-phaseportrait I could never understand when to use one vs. the other.

Maple 2023.2 on windows

I want to solve the following elliptic integral with symbolic inputs a, b, c, and d, and requires a closed-form solution in Legendre's form in terms of these input variables. I want to know how can I solve this using Maple

  int(1/sqrt((a - t)(t - b)(t - c)(t - d)), t = b .. a)

Condition: a>t>b>c>d

Download maple_query.mw

For any given function solely and exclusively given by exponentials, as follows (expression A1), I need to select the argument of each exponential and apply it to any function, for example COS(X)

A1 :=  exp(4*k)/4 + exp(2*k)/2 - exp(-2*k)/2 - exp(-4*k)/4+5

That is, we would have

A1':=cos(4*k)/4 + cos(2*k)/2 - cos(-2*k)/2 - cos(-4*k)/4+5

I know this result is zero, but this is a simple example. What is the best way to do this?

I need some command that simplifies the exponentials (or a series of commands) so that there is no power over power.

What's happening (exp(k))^2

What do I need exp(2k)

What would be the most appropriate method? Below is a photo of my code

There are two opposing commands remove and select in Maple. According to the main help page, StringTools:-RegSplit effectively implements the removal (i.e., capturing substrings that does not match the given pattern), but as regards extracting the matching parts of the input string (e.g., this example from MatLab), where is the command to carry out the selection?
At present I can do something like 

use StringTools in RegFilter := (p::string, s::string) -> select[2](RegMatch, sprintf("^%s$", p), (op@NGrams)~(s, [`$`](Length(s)))) end:
RegFilter("a.++b", "aabbbaaabb");
 = 
 ["aab", "abb", "aab", "abb", "aabb", "abbb", "aaab", "aabb", 

   "aabbb", "aaabb", "abbbaaab", "aabbbaaab", "abbbaaabb", 

   "aabbbaaabb"]


Nevertheless, there exist at least two disadvantages to it.

This is essentially equivalent to letting the matcher keeps starting at the same position until no more new matches are found, while sometimes one may just need the matcher to continue the shortest-match testing at the character following the last matched substring after finding a match:

For instance, there should be three flags in “RegFilter("a.+?b", "aabbbaaabb", 'overlapped'=⁇);”: 
⒈“["aab", "aaab"]” (selection with no overlap), 
⒉“["aab", "abb", "aaab", "aab", "abb"]” ( with partial overlaps), and 
⒊“["aab", "aabb", "aabbb", "aabbbaaab", "aabbbaaabb", "abb", "abbb", "abbbaaab", "abbbaaabb", "aaab", "aaabb", "aab", "aabb", "abb"]” ( with full overlaps). 

Unfortunately, the  above can only handle the last mode.

Another disadvantage is its inefficiency. Considering the following regular expression which matchs email-like strings

sample := Import("https://github.com/mariomka/regex-benchmark/raw/optimized/input-text.txt"): # lengthy 
re := "[a-zA-Z_0-9\\.+-]+@[a-zA-Z_0-9\\.-]+\\.[a-zA-Z_0-9\\.-]+":
time[real]((remnants := StringTools:-RegSplit(re, sample)));
 = 
                             3.157

So Maple is capable of completing this removal within 4 seconds, yet if I execute the analogous

timelimit(60, time[real](RegFilter(re, sample))); 

Maple will end up running out of memory.

In view of these, where is the generic StringTools:-RegFilter functionality? Or can we construct those matched cases from  and the original text?

I am asking this beacuse I am rusty on using animate in plots. Just trying to show the line segment moving.

restart

with(plottools); with(plots)

Trvl := Matrix(5, 18, {(1, 1) = 0, (1, 2) = 1, (1, 3) = 2, (1, 4) = 3, (1, 5) = 4, (1, 6) = 5, (1, 7) = 6, (1, 8) = 7, (1, 9) = 8, (1, 10) = 9, (1, 11) = 10, (1, 12) = 11, (1, 13) = 12, (1, 14) = 13, (1, 15) = 14, (1, 16) = 15, (1, 17) = 16, (1, 18) = 17, (2, 1) = 25.00000000, (2, 2) = 25.62348980, (2, 3) = 26.24697960, (2, 4) = 26.87046941, (2, 5) = 27.49395921, (2, 6) = 28.11744901, (2, 7) = 28.81795052, (2, 8) = 29.70796779, (2, 9) = 30.69482490, (2, 10) = 31.66997559, (2, 11) = 32.64189447, (2, 12) = 33.63901734, (2, 13) = 34.59934793, (2, 14) = 35.46317753, (2, 15) = 36.17679740, (2, 16) = 36.69583812, (2, 17) = 36.98802824, (2, 18) = 37.03520080, (3, 1) = 9.50000000, (3, 2) = 10.28183148, (3, 3) = 11.06366296, (3, 4) = 11.84549445, (3, 5) = 12.62732593, (3, 6) = 13.40915741, (3, 7) = 14.11748988, (3, 8) = 14.56318511, (3, 9) = 14.69313898, (3, 10) = 14.49329251, (3, 11) = 14.26929209, (3, 12) = 14.29271187, (3, 13) = 14.56209574, (3, 14) = 15.06069470, (3, 15) = 15.75750830, (3, 16) = 16.60921202, (3, 17) = 17.56285107, (3, 18) = 18.55913279, (4, 1) = 26.55872458, (4, 2) = 27.18221431, (4, 3) = 27.80570411, (4, 4) = 28.44091912, (4, 5) = 29.26771501, (4, 6) = 30.27132826, (4, 7) = 31.26754127, (4, 8) = 32.19797655, (4, 9) = 33.15526524, (4, 10) = 34.16855668, (4, 11) = 35.08363639, (4, 12) = 35.87210441, (4, 13) = 36.48493760, (4, 14) = 36.88403298, (4, 15) = 37.04457671, (4, 16) = 36.95658698, (4, 17) = 36.62553455, (4, 18) = 36.06730316, (5, 1) = 11.45457880, (5, 2) = 12.23641019, (5, 3) = 13.01824167, (5, 4) = 13.79066482, (5, 5) = 14.38908368, (5, 6) = 14.67833203, (5, 7) = 14.61699479, (5, 8) = 14.33989949, (5, 9) = 14.25015666, (5, 10) = 14.40907532, (5, 11) = 14.80585186, (5, 12) = 15.41668792, (5, 13) = 16.20360467, (5, 14) = 17.11767545, (5, 15) = 18.10206776, (5, 16) = 19.09557685, (5, 17) = 20.03643114, (5, 18) = 20.86416514})

_rtable[36893489645234278260]

(1)

display(seq(line([Trvl[2, i], Trvl[3, i]], [Trvl[4, i], Trvl[5, i]], color = green), i = 1 .. 18))

 

animate(line([Trvl[2, i], Trvl[3, i]], [Trvl[4, i], Trvl[5, i]], color = green), i = 1 .. 18)

Error, bad index into Matrix

 

NULL

Download 23-11-03_Q_Animate_a_line.mw

May be someone could help me understand the logic that Maple goes through in this example.

restart;
ode:=diff(y(x), x) = sqrt(y(x))*sin(x);
dsolve([ode,y(0)=0]);
dsolve([ode,y(0)=0],'implicit');

For first dsolve it returns y(x)=0 and for the second it returns what is expected which is sqrt(y(x)) + cos(x)/2 - 1/2 = 0

Why this difference in result? Just trying to understand the logic behaind it. 

Maple 2023.1 on windows 10

``

restart;

ode:=diff(y(x), x) = sqrt(y(x))*sin(x);
dsolve([ode,y(0)=0]);
dsolve([ode,y(0)=0],'implicit');

diff(y(x), x) = y(x)^(1/2)*sin(x)

y(x) = 0

y(x)^(1/2)+(1/2)*cos(x)-1/2 = 0

 

Download why_dsolve.mw

The document block (copied from a larger document) in the attached file could be executed with Maple 2022 (in the larger document).

Maple 2023 evaluates... that I have to interrupt.

On my installation I cannot convert the block to 1d input to investigate for hidden characters. This works in 2022.

Trying to manipulate (splitting, cutting, ...) the block lead several times to the 2023 GUI not responding normally which required Maple restart.

What I found with Maple 2022 and lprint: There is a ndash character here

Ein Bild, das Text, Schrift, Reihe enthält.

Automatisch generierte BeschreibungEin Bild, das Schrift, Reihe, Handschrift, weiß enthält.

Automatisch generierte Beschreibung

which must be deleted in the attached file. The larger document does not lprint a ndash. So this might be a copy/paste artefact and is perhaps unrelated to the evaluation problem with 2023.

With Maple 2023 there is no ndash but the output looks differentEin Bild, das Schrift, Diagramm, Reihe, Design enthält.

Automatisch generierte Beschreibung

The whole thing is perhaps related to this

Can someone reproduce and/or help?


 

interface(version)

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

(1)

exp(`–`((1/2)*x^2)-(1/2)*y^2)/(2*Pi)

(1/2)*exp(-(1/2)*x^2-(1/2)*y^2)/Pi

(2)

`if`(evalf((1/2)*exp(-(1/2)*x^2-(1/2)*y^2)/Pi) < 0.7957747150e-1, (1/2)*exp(-(1/2)*x^2-(1/2)*y^2)/Pi, NONE); p3 := plot3d(%, x = -3 .. 3, y = -3 .. 3, color = blue); `if`(evalf((1/2)*exp(-(1/2)*x^2-(1/2)*y^2)/Pi) < 0.2153927929e-1, (1/2)*exp(-(1/2)*x^2-(1/2)*y^2)/Pi, NONE); p4 := plot3d(%+0.1e-3, x = -3 .. 3, y = -3 .. 3, color = red)

Warning,  computation interrupted

 

NULL


 

Download plot3d_in_2023_not_working.mw

First 8 9 10 11 12 13 14 Last Page 10 of 26