MaplePrimes Questions

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

Why this error with PDEtools:-Solve  but not with solve on same exact input?

235572

interface(version);

`Standard Worksheet Interface, Maple 2023.0, Windows 10, March 6 2023 Build ID 1689885`

restart;

235572

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

 

Download problem_Solve_may_30_2023.mw

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

interface(version);

`Standard Worksheet Interface, Maple 2022.2, Windows 10, October 23 2022 Build ID 1657361`

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

 

Download problem_Solve_may_30_2023_maple_2022.mw

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

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);
with(Tetrads);
g_[[5, 29, 1]];
WeylScalars(TransformTetrad(canonicalform));

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.

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.

Hi,

I imported a CAT diagram from (Solidworks) to (MapleSim 2023) and I defined the coordinates. The problem is when I want to show the 3D workspace, the coordinates are not at places I defined them. All the coordinates shows in single same place.

 

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?

restart

ERROR COMPARISON

 

n := [84, 83, 83, 81, 85, 86, 86, 83, 82, 83, 84, 83, 81, 80, 83, 79, 82, 81, 85]

[84, 83, 83, 81, 85, 86, 86, 83, 82, 83, 84, 83, 81, 80, 83, 79, 82, 81, 85]

(1)

nops(n)

19

(2)
• 

-BBDF*FORMULA*FORWARD+PC

A := [90.3333, 85.3636, 80.1313, 81.4518, 78.9241, 90.2078, 89.8305, 85.9949, 78.7198, 79.8495, 84.3264, 86.2465, 82.7222, 78.1001, 77.8260, 86.7687, 77.2371, 85.2345, 81.7439]

[90.3333, 85.3636, 80.1313, 81.4518, 78.9241, 90.2078, 89.8305, 85.9949, 78.7198, 79.8495, 84.3264, 86.2465, 82.7222, 78.1001, 77.8260, 86.7687, 77.2371, 85.2345, 81.7439]

(3)

``

nops(A)

19

(4)

NULL

for i to 19 do EA[i] := abs(A[i]-n[i]) end do

6.3333

 

2.3636

 

2.8687

 

.4518

 

6.0759

 

4.2078

 

3.8305

 

2.9949

 

3.2802

 

3.1505

 

.3264

 

3.2465

 

1.7222

 

1.8999

 

5.1740

 

7.7687

 

4.7629

 

4.2345

 

3.2561

(5)

``

 

NULL

``

(6)

Download error_pc-bbdf_forward_formula.mw

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.

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[2])*y^15-46/43*exp(11*c[2])*y^10+1/86*exp(6*c[2
])*y^5)*y*16^(2/3)*(exp(c[2])^7*y^7)^(2/3)-5/4*2^(2/3)*(2*exp(20*c[2])*y^20-169
/40*exp(15*c[2])*y^15+1/5*exp(10*c[2])*y^10)*16^(1/3)*(exp(c[2])^7*y^7)^(1/3)+(
2*exp(24*c[2])*y^20-53/2*exp(19*c[2])*y^15+17/4*exp(14*c[2])*y^10)*y^4)*exp(3*c
[2])/y^3/exp(5*c[2])/(1/9*(-1/4-exp(10*c[2])*y^10+8*exp(5*c[2])*y^5)*16^(2/3)*(
exp(c[2])^7*y^7)^(2/3)+(-2/3*(11/4*exp(9*c[2])*y^5-1/2*exp(4*c[2]))*2^(1/3)*y*
16^(1/3)*(exp(c[2])^7*y^7)^(1/3)+2^(2/3)*(2*exp(13*c[2])*y^10-2*exp(8*c[2])*y^5
))*y^3)/(-3/8*2^(2/3)*16^(2/3)*(exp(c[2])^7*y^7)^(2/3)*exp(c[2])*y+(exp(5*c[2])
*y^5-1/4)*16^(1/3)*(exp(c[2])^7*y^7)^(1/3)+3/2*2^(1/3)*exp(4*c[2])*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)

`Standard Worksheet Interface, Maple 2023.0, Windows 10, March 6 2023 Build ID 1689885`

restart;

138508

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

3

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

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

try
   int(expr,y);
catch:
   print("error");
end try;

"error"

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

 

Download int_error_may_29_2023.mw

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.

Thanks in advance!

I am trying to put an annotation  (dimension of a distance) into a plot.

Any hints about what would the best way to do that?

 i’ve run the coding. The result is almost my expectation. However, why is the previous value not be substituted into the next one? As example, f4 should be submitted into f5 to evaluate its value

restart:

m := [80, 79, 83, 92, 74, 80, 87, 77, 103, 84, 87, 77, 88, 86, 83, 80, 79, 80, 93, 68, 106, 76, 103]

[80, 79, 83, 92, 74, 80, 87, 77, 103, 84, 87, 77, 88, 86, 83, 80, 79, 80, 93, 68, 106, 76, 103]

(1)

 

F := k -> `if`(
                k::even,
                2/3*m[k] + 2/3*f[k-1] - 1/3*f[k-2],
                2/11*f[k-3] - 9/11*f[k-2] + 12/11*f[k-1] + 6/11*m[k]
                ):


f[2] := m[2];
f[3] := m[3];
for i from 4 to 23 do
  F(i):
end do;

79

 

83

 

271/3

 

-145/11+(12/11)*f[4]

 

160/3+(2/3)*f[5]-(1/3)*f[4]

 

(2/11)*f[4]-(9/11)*f[5]+(12/11)*f[6]+522/11

 

154/3+(2/3)*f[7]-(1/3)*f[6]

 

(2/11)*f[6]-(9/11)*f[7]+(12/11)*f[8]+618/11

 

56+(2/3)*f[9]-(1/3)*f[8]

 

(2/11)*f[8]-(9/11)*f[9]+(12/11)*f[10]+522/11

 

154/3+(2/3)*f[11]-(1/3)*f[10]

 

(2/11)*f[10]-(9/11)*f[11]+(12/11)*f[12]+48

 

172/3+(2/3)*f[13]-(1/3)*f[12]

 

(2/11)*f[12]-(9/11)*f[13]+(12/11)*f[14]+498/11

 

160/3+(2/3)*f[15]-(1/3)*f[14]

 

(2/11)*f[14]-(9/11)*f[15]+(12/11)*f[16]+474/11

 

160/3+(2/3)*f[17]-(1/3)*f[16]

 

(2/11)*f[16]-(9/11)*f[17]+(12/11)*f[18]+558/11

 

136/3+(2/3)*f[19]-(1/3)*f[18]

 

(2/11)*f[18]-(9/11)*f[19]+(12/11)*f[20]+636/11

 

152/3+(2/3)*f[21]-(1/3)*f[20]

 

(2/11)*f[20]-(9/11)*f[21]+(12/11)*f[22]+618/11

(2)

 

Download bbdf.mw

I do not know if this is new error in 2023. But solve gives this strange error first time it is called. Second time the error goes away.

Any workaround possible and why does it happen? It happens when kernelopts('assertlevel'=2): is set. But I need to have this set all the time.     Same problem when using PDEtools:-Solve. I can't even trap this error since it is internal. So program crash and no way to continue.

restart;
interface(warnlevel=4):
kernelopts('assertlevel'=2):
eq:=exp(x)*sin(y(x))-3*x^2+(exp(x)*cos(y(x))+1/3/y(x)^(2/3)) = 0;
solve(eq,y(x));

Error, (in SolveTools:-CancelInverses) assertion failed, simplify should not leak _Z variables out from RootOfs

1331348

interface(version);

`Standard Worksheet Interface, Maple 2023.0, Windows 10, March 6 2023 Build ID 1689885`

restart;

1331348

interface(warnlevel=4):
kernelopts('assertlevel'=2):
eq:=exp(x)*sin(y(x))-3*x^2+(exp(x)*cos(y(x))+1/3/y(x)^(2/3)) = 0;
solve(eq,y(x));

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

Error, (in SolveTools:-CancelInverses) assertion failed, simplify should not leak _Z variables out from RootOfs

solve(eq,y(x)); #second time no error. Very strange.

RootOf(3*exp(x)*sin(_Z)*_Z^(2/3)+3*exp(x)*cos(_Z)*_Z^(2/3)-9*x^2*_Z^(2/3)+1)

 


Download problem_in_solve_may_29_2023.mw

Finding too many problems in Version 2023 :(

Update

This seems new problem in V 2023? I just tried it on V 2022 on same PC and no error there. First time used no error.  Here is V 2022 worksheet. So this seems like regression.

interface(version);

`Standard Worksheet Interface, Maple 2022.2, Windows 10, October 23 2022 Build ID 1657361`

restart;

interface(warnlevel=4):
kernelopts('assertlevel'=2):
eq:=exp(x)*sin(y(x))-3*x^2+(exp(x)*cos(y(x))+1/3/y(x)^(2/3)) = 0;
solve(eq,y(x));

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

RootOf(-3*exp(x)*sin(_Z)*_Z^(2/3)-3*exp(x)*cos(_Z)*_Z^(2/3)+9*x^2*_Z^(2/3)-1)

 

 

Download solve_may_29_2023_V2022.mw

Update: 

This bug is still not fixed in Maple 2024.1. I do not understand why bugs do not get fixed for years in Maple. I will report it again.

restart;

interface(version);

`Standard Worksheet Interface, Maple 2024.1, Windows 10, June 25 2024 Build ID 1835466`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1788 and is the same as the version installed in this computer, created 2024, August 10, 8:50 hours Pacific Time.`

restart;

restart;

kernelopts('assertlevel'=2):
ode:=exp(x)*sin(y(x))-3*x^2+(exp(x)*cos(y(x))+1/3/y(x)^(2/3))*diff(y(x),x) = 0;
DEtools:-odeadvisor(ode)

exp(x)*sin(y(x))-3*x^2+(exp(x)*cos(y(x))+(1/3)/y(x)^(2/3))*(diff(y(x), x)) = 0

Error, (in SolveTools:-CancelInverses) assertion failed, simplify should not leak _Z variables out from RootOfs

 

 

Download leaked_Z_still_not_fixed_in_maple_2024_1.mw

Update Nov 6, 2024

fyi, The above bug is still not fixed in Maple 2024.2

interface(version);

`Standard Worksheet Interface, Maple 2024.2, Windows 10, October 29 2024 Build ID 1872373`

kernelopts('assertlevel'=2):

ode:=(exp(x)*sin(y(x))-3*x^2)+(exp(x)*cos(y(x))+y(x)^(-2/3)/3)*diff(y(x),x)=0;
DEtools[odeadvisor](ode,y(x))

exp(x)*sin(y(x))-3*x^2+(exp(x)*cos(y(x))+(1/3)/y(x)^(2/3))*(diff(y(x), x)) = 0

Error, (in SolveTools:-CancelInverses) assertion failed, simplify should not leak _Z variables out from RootOfs

 

 

Download leak_Z_bug_in_maple_2024_2.mw

First 195 196 197 198 199 200 201 Last Page 197 of 2428