## How to handle substrings in a string with specia...

Dear Maple users

As a followup on my recent question about how to count the number of characters in a string containing special Danish characters here: https://www.mapleprimes.com/questions/236478-How-To-Count-Length-Of-String-When-Special

I also need to handle substrings from a string in my work in Cryptography. In my attached file I present an example with a string containing two special characters. The problem is however, that I need to access individual characters in the string. Normally I would do so by using the command substring. As indicated in the file it doesn't work very well, because the special characters are represented by TWO elements (bytes)!

Is there a smart way to create a new command named SUBSTRING to accompanying the great LEN command suggested by vv?

Regards,

Erik V.

substrings.mw

## Error, (in collect/recursive) invalid subscript se...

Why this error with PDEtools:-Solve  but not with solve on same exact input? > interface(version); > restart; > expr:=1/9*b^2*(cos(x)^4*hypergeom([3/2, 1/2*m+2],[5/2],-cot(x)^2)^2*m^2-6*sin(x)^2*cos(x)^2*hypergeom([1/2, 1/2*m+1],[3/2],-cot(x)^2)*hypergeom([3/2, 1/2*m+2],[5/2],-cot(x)^2)*m+4*cos(x)^4*hypergeom([3/2, 1/2*m+2],[5/2],-cot(x)^2)^2*m+9*sin(x)^4*hypergeom([1/2, 1/2*m+1],[3/2],-cot(x)^2)^2-12*sin(x)^2*cos(x)^2*hypergeom([1/2, 1/2*m+1],[3/2],-cot(x)^2)*hypergeom([3/2, 1/2*m+2],[5/2],-cot(x)^2)+4*cos(x)^4*hypergeom([3/2, 1/2*m+2],[5/2],-cot(x)^2)^2-9*sin(x)^(8+2*m))*csc(x)^8:
 > PDEtools:-Solve(expr =0,x):

Error, (in collect/recursive) invalid subscript selector

 > PDEtools:-Solve(expr =0,x):

Error, (in collect/recursive) invalid subscript selector

 > solve(expr =0,x):

Warning, solutions may have been lost

 > solve(expr =0,x,AllSolutions):

Warning, solutions may have been lost

 >

This looks like regression? as it works ok on Maple 2022

 > interface(version); > restart;
 > expr:=1/9*b^2*(cos(x)^4*hypergeom([3/2, 1/2*m+2],[5/2],-cot(x)^2)^2*m^2-6*sin(x)^2*cos(x)^2*hypergeom([1/2, 1/2*m+1],[3/2],-cot(x)^2)*hypergeom([3/2, 1/2*m+2],[5/2],-cot(x)^2)*m+4*cos(x)^4*hypergeom([3/2, 1/2*m+2],[5/2],-cot(x)^2)^2*m+9*sin(x)^4*hypergeom([1/2, 1/2*m+1],[3/2],-cot(x)^2)^2-12*sin(x)^2*cos(x)^2*hypergeom([1/2, 1/2*m+1],[3/2],-cot(x)^2)*hypergeom([3/2, 1/2*m+2],[5/2],-cot(x)^2)+4*cos(x)^4*hypergeom([3/2, 1/2*m+2],[5/2],-cot(x)^2)^2-9*sin(x)^(8+2*m))*csc(x)^8:
 > PDEtools:-Solve(expr =0,x):
 > solve(expr =0,x):

Warning, solutions may have been lost

 >

## Problem with calculating the integration of an equ...

hallo every body

Please, I have a small problem in this program in Maple 18 at the end of the programme when i want to calculat the intgral given in variable (f2i)  i see this message and I can't calculate the integral

Please what is the solution to calculate this integral?

The program in Maple 18 is below

Thanks a lot

hopf12.mw

## Error, (in type/complex) too many levels of recurs...

I do not know if this is known issue. Any one else see this problem also?

odetest(sol,ode) assuming positive, real:

gives error Error, (in type/complex) too many levels of recursion but

odetest(sol,ode)

Gives no error.  If you do not get this error from the first call, try again. sometimes it depends on how many times it is called.

 > interface(version); > restart; > sol:=y(x) = 1/128*2^(1/3)*1024^(2/3)*((3/32*(x-1)^3*ln(1+x)-3/32*(x-1)^3*ln(x-1)+c*x^3+(-3*c-3/16)*x^2+(3*c+9/16)*x-c-5/8)^2)^(2/3)/(3/32*(x-1)^3*ln(1+x)-3/32*(x-1)^3*ln(x-1)+c*x^3+(-3*c-3/16)*x^2+(3*c+9/16)*x-c-5/8)^2; ode:=(-x^2+1)*diff(y(x),x)-2*(1+x)*y(x)-y(x)^(5/2) = 0; timelimit(40,`assuming`([odetest(sol,ode)],[positive, real])):  Error, (in type/complex) too many levels of recursion

 > restart; > sol:=y(x) = 1/128*2^(1/3)*1024^(2/3)*((3/32*(x-1)^3*ln(1+x)-3/32*(x-1)^3*ln(x-1)+c*x^3+(-3*c-3/16)*x^2+(3*c+9/16)*x-c-5/8)^2)^(2/3)/(3/32*(x-1)^3*ln(1+x)-3/32*(x-1)^3*ln(x-1)+c*x^3+(-3*c-3/16)*x^2+(3*c+9/16)*x-c-5/8)^2; ode:=(-x^2+1)*diff(y(x),x)-2*(1+x)*y(x)-y(x)^(5/2) = 0; odetest(sol,ode) assuming positive, real:  > odetest(sol,ode) assuming positive, real:

Error, (in type/complex) too many levels of recursion

 > odetest(sol,ode) assuming positive, real:

Error, (in type/complex) too many levels of recursion

 > odetest(sol,ode) assuming positive:

Error, (in type/complex) too many levels of recursion

 > odetest(sol,ode):
 >

Here is a worksheet showing the random nature of these errors. I tried these calls and you see how it sometimes works and sometimes gives internal error. There is something random about Maple behavior that I wish I know the cause of it.

 > interface(version); > restart; > sol:=y(x) = 1/128*2^(1/3)*1024^(2/3)*((3/32*(x-1)^3*ln(1+x)-3/32*(x-1)^3*ln(x-1)+_C1*x^3+(-3*_C1-3/16)*x^2+(3*_C1+9/16)*x-_C1-5/8)^2)^(2/3)/(3/32*(x-1)^3*ln(1+x)-3/32*(x-1)^3*ln(x-1)+_C1*x^3+(-3*_C1-3/16)*x^2+(3*_C1+9/16)*x-_C1-5/8)^2; ode:=(-x^2+1)*diff(y(x),x)-2*(1+x)*y(x)-y(x)^(5/2) = 0; timelimit(40,`assuming`([odetest(sol,ode)],[positive, real])):  Error, (in type/complex) too many levels of recursion

 > odetest(sol,ode) assuming positive, real:

Error, (in type/complex) too many levels of recursion

 > odetest(sol,ode) assuming positive, real:
 > odetest(sol,ode) assuming positive:
 > odetest(sol,ode) assuming positive, real:
 > odetest(sol,ode) assuming positive, real:
 > timelimit(40,`assuming`([odetest(sol,ode)],[positive, real])):
 > odetest(sol,ode) assuming positive, real:

Error, (in type/complex) too many levels of recursion

 >

## Weyl Scalars for the Kerr metric....

I am trying to calculate the Weyl Scalars for the Kerr metric and I get an error

"Error, (in simplify/recurse) numeric exception: division by zero"

restart;
with(Physics);
g_[[5, 29, 1]];

When I try:
Weyl[scalars];

It gives me the weyl scalars  but they dont look correct because some of the scalars are supposed to be zero for a type D spacetime.

## How to debug Maple hanging problems...

I am looking for suggestions on how to debug this problem. For me, this is the number one problem with using Maple over the years.

Before I completely give up on Maple and move on to something else (I am getting very close to this point, as the time I am wasting is too much) as I invested long time on the code I have in Maple.

I like Maple programming and since it has debugger, I find it very useful, but I can't keep waiting 5 days each time on something that should finish running in 3-4 hrs on some other system.

This is a problem I have for many years with no solution version after version.

Obviously I can't make a MWE else I would, as this happens on my large program and happens randomly.

I can only explain what happens and I am asking what can I do to try to find the cause of the problem.  I am not the only one who faced these types of problems. On the net, others complain about this.

This is what happens. I have my code in .mla and then I have a very small worksheet (I am also now running from command line line cmaple.exe, with same problem) where the code simply does a LOOP.

The loop reads problems one by one from sqlite database using Maple, and simply solves each problem one at a time then saves the result back to the sqlite database.

What happens is this:  Lets says it reached problem 100. It suddenly hangs.  I can wait 1,2,3,5 hrs and it does not move to the next problem.

I see mserver.exe sitting either at zero CPU or at high CPU. But most of the time at high CPU. Each problem should in theory not take more than few minutes to solve as I have timelimit of 20 seconds on each and every Maple call I make. (such as solve or simplify or any Maple call, I add timelimit to it).

So I have no choice left but to kill mserver.exe from windows when I noticed it has been long time running on one problem (as I print the time stamp).

Then restart the script and have the LOOP start from the same problem number it was hanging on which is 100 in this example, and now it runs and do not hang on this same problem.

So it was not that specific problem which was the cause else it would have hanged again.

The same thing happens now after few more dozen problems are processed. It is all random where it hangs next and how long it takes before the next hang shows up. I have thousands of problems in the database.  On average it does this every 50 to 200 problems or so, it hangs. i.e.  it can take one hr to few hrs before the next hang happens.

So I repeat the same thing and now it runs again until it hangs after few hrs or so again.

My PC is very fast intel PC (new) with 128 GB Ram and there is nothing else much running on it. It is a personal PC.

My question is: What could I look at when this happens to try to figure what the problem is? Is there any code I can add to problem more messages that could help when it hangs?

Any tools Maple provide to help debug this? Any ideas why it happens? Is there a way to turn on some Maple system level debugging that shows what it is doing when it hangs?

It can't be memory. And since it happens also when I run from command line and not just worksheet, it can't be Java interface problem. It might be hanging on sql call also (as it reads and writes to the database all the time) but I do not know for sure. This program is the only one accessing the SQL database at the time. I find Maple's SQL API very fast actually and never had problems with it.

The program does not do any outside calls to other systems, no internet calls and nothing like this. It only uses Maple functions and lots of call to latex() command. But it is all Maple code.

I am on windows 10 professional.

I am willing to try anything to find the cause of these random hangs.

## How to count length of string when special Danish ...

Dear Maple users

I wanted to count the number of characters in a string containing special Danish letters beyond a...z. When using the special Danish letters æ, ø and å, those letters or characters are being counted as 2 characters each. I hope someone can help me having Maple count the length of strings containing those characters properly.

Regards,

Erik V.

## finding average error in maple...

I desire to find the summation value of errors from EA1 to EA19. After finding the summation, i want to find the average error. Can any of experts show how the maple should be done?

 > ERROR COMPARISON

 >  (1)
 >  (2)
 • >  (3)
 > >  (4)
 > >                    (5)
 > >  (6)

## How to solve this ?... ## How to extract the numerators of equations and si...

I have a system of 3 (very large) nonlinear equations in 3 variables. Since I cannot feed non-algebraic expressions into polynomial solvers, I want to extract only their numerators (which should be algebraic) and solve the three numerators for the 3 variables. These solutions should also solve the non-algebraic system then.

This is the original system (sorry I don't know why but I was not able to include the massive expression in the startup code): System.mw

I think I am not understanding the syntax. To extract the numerators, I am using ((numer@evala@:-Norm@numer)~@eval)(Eqs) (scroll down to the very bottom of my script):

1. Am I wrong?
2. What exactly am I doing with this combined command?
3. Why length(((numer@evala@:-Norm@numer)~@eval)(Eqs)) is much larger than length(Eqs)? Shouldn't it be smaller since I just extract the numerators?

Thank you.

## maple: fatal error, lost connection to kernel when...

Please ignore. Just found the problem googling around an old question.

I needed to REMOVE font=[times,12]. Now it works.

I tried first to change it to font=[TIMES,12] and thought it worked, but it did not. So the solution is to simply remove the font settings!

And now the crash is gone. At least for this one case. I need to do more testing for other cases. But this seems to be the problem. It was the font settings.

----------------------------------------- closed/resolved ------------------------------------------

I have been trying to move my my test mainline from the worksheet to .mpl and to run the .mpl from the command line usuing cmaple.exe hoping that the slow down due to large output into the worksheet will be elminated.

This is all on windows. So I am using DOS/Command line.

Everthing seems to be working fine, and it seems to run faster now, but I get maple: fatal error, lost connection to kernel on some problems.

After some debugging I found where it happens. In the code, I generates plots and then save each to .eps file.  This all works find when I run the code from the worksheet ofcourse.

Below I show an example .mpl and the command I used. I also show same code works just fine in the worksheet.

I suspect when running cmaple.exe it is using different driver for postscript than the one used when running maple.exe?  If so, what to change in the code to make it work OK from command line?

This is the .mpl file. You can put this anywhere. Say C:/tmp/ folder. First this is screen shot of the error Here is the .mpl file

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

ode:=diff(y(x),x)=y(x)*(1-y(x)^2):

try
p1 := timelimit(60,DEtools:-dfieldplot(ode,y(x),x=-3..3,y=-3..3,
arrows=SLIM,
labels=[x,y(x)],
font=[times,12])):
catch:
print("Error make phase plot. Skippping. Error is ", StringTools:-FormatMessage(lastexception[2..-1]));
return "";
end try:

try
full_file_name := "C:\\tmp\\phase_plot.eps": #same problem using .ps extension
plotsetup(ps, plotoutput=full_file_name,plotoptions=noborder);
print(p1);   # also tried without "display"
plotsetup(default):
catch:
print("Error make phase plot. Skippping. Error is ", StringTools:-FormatMessage(lastexception[2..-1]));
end try:```

Here is the command used

`"C:\Program Files\Maple 2023\bin.X86_64_WINDOWS\cmaple.exe" generator_command_line.mpl`

The crash happens even if I remove the kernelopts('assertlevel'=2):

To reproduce, simply put the above .mpl file into your c:\tmp folder and start the windows command line (DOS) and type the above command.

Important: if I use different device, say "gif" instead of "ps", then Maple does not crash. But I need to use "ps" in order to convert to pdf as I need vector graphics which is much better quality. So it looks like the ps driver used by cmaple.exe is the problem, but I am not sure. But looking for a workaround as without the ability to generate the plots, this setup will not work for me.

I rememebr now seeing this problem many years ago, but never was able to find workaround.

Any workaround I should try? I need to try the command line, hoping the frequent hangs and slow down will go away if I do that.

Maple 2023 on windows 10.

## Error, (in convert/parfrac) cannot convert to part...

Is this something known or should be fixed? I check it is exists also in V 2022 for same input.

```restart;

expr:=40/9*(43/32*2^(1/3)*(2*exp(16*c)*y^15-46/43*exp(11*c)*y^10+1/86*exp(6*c[2
])*y^5)*y*16^(2/3)*(exp(c)^7*y^7)^(2/3)-5/4*2^(2/3)*(2*exp(20*c)*y^20-169
/40*exp(15*c)*y^15+1/5*exp(10*c)*y^10)*16^(1/3)*(exp(c)^7*y^7)^(1/3)+(
2*exp(24*c)*y^20-53/2*exp(19*c)*y^15+17/4*exp(14*c)*y^10)*y^4)*exp(3*c
)/y^3/exp(5*c)/(1/9*(-1/4-exp(10*c)*y^10+8*exp(5*c)*y^5)*16^(2/3)*(
exp(c)^7*y^7)^(2/3)+(-2/3*(11/4*exp(9*c)*y^5-1/2*exp(4*c))*2^(1/3)*y*
16^(1/3)*(exp(c)^7*y^7)^(1/3)+2^(2/3)*(2*exp(13*c)*y^10-2*exp(8*c)*y^5
))*y^3)/(-3/8*2^(2/3)*16^(2/3)*(exp(c)^7*y^7)^(2/3)*exp(c)*y+(exp(5*c)
*y^5-1/4)*16^(1/3)*(exp(c)^7*y^7)^(1/3)+3/2*2^(1/3)*exp(4*c)*y^4):

int(expr,y);
```

Error, (in convert/parfrac) cannot convert to partial fraction form

But for some reason I do not now understand, I am able to actually trap this error, which makes it much less serious for me, as the program can continue.

In all other cases where Maple generated such internal exceptions, it was not cought by try/catch.

So I am able to bypass this problem, but thought to check if someone can shed more light on this and why it happens.

 > interface(version) > restart; > interface(warnlevel=4); kernelopts('assertlevel'=2): > expr:=40/9*(43/32*2^(1/3)*(2*exp(16*c)*y^15-46/43*exp(11*c)*y^10+1/86*exp(6*c[2 ])*y^5)*y*16^(2/3)*(exp(c)^7*y^7)^(2/3)-5/4*2^(2/3)*(2*exp(20*c)*y^20-169 /40*exp(15*c)*y^15+1/5*exp(10*c)*y^10)*16^(1/3)*(exp(c)^7*y^7)^(1/3)+( 2*exp(24*c)*y^20-53/2*exp(19*c)*y^15+17/4*exp(14*c)*y^10)*y^4)*exp(3*c )/y^3/exp(5*c)/(1/9*(-1/4-exp(10*c)*y^10+8*exp(5*c)*y^5)*16^(2/3)*( exp(c)^7*y^7)^(2/3)+(-2/3*(11/4*exp(9*c)*y^5-1/2*exp(4*c))*2^(1/3)*y* 16^(1/3)*(exp(c)^7*y^7)^(1/3)+2^(2/3)*(2*exp(13*c)*y^10-2*exp(8*c)*y^5 ))*y^3)/(-3/8*2^(2/3)*16^(2/3)*(exp(c)^7*y^7)^(2/3)*exp(c)*y+(exp(5*c) *y^5-1/4)*16^(1/3)*(exp(c)^7*y^7)^(1/3)+3/2*2^(1/3)*exp(4*c)*y^4); > try    int(expr,y); catch:    print("error"); end try; > int(expr,y);

Error, (in convert/parfrac) cannot convert to partial fraction form

 > int(simplify(expr),y);

Error, (in convert/parfrac) cannot convert to partial fraction form

 >

## Differentiate differential equation by function (S...

Hi Maple friends,

I want to use Maple to solve a motion equation problem by using Lagrange 2 method. For that I for example have to calculate the derivative of the lagrange function by one of the generalized coordinates.

So let L for example be: L = diff(q1(t), t) + 2*diff(q2(t), t) + 3*q1(t)        // I`m sorry the insert Maple Math doesn`t work for me...

I now want to calculate diff(L,q1(t)) which leads to the error Message: "Error, invalid input: diff received q1(t), which is not valid for its 2nd argument".

The correct answer to this should be: diff(L, q1(t)) = 3

I`ve now tried a few different differentiate commands but none of them seems to work...

Would be great if someone could give me a hint or the right code. ## Annotation in plots... 1 2 3 4 5 6 7 Last Page 1 of 2025