Maple 2020 Questions and Posts

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

"with(LinearAlgebra):  T := proc(n::integer)  local t0, tn, i, t, t1;  if (n>0) then t0 := Matrix(1, 1, 1); tn := Matrix(1,1,0);  for i from 1 to n do local z := 2^i;  t := Matrix([[Add(t0, tn), x .~ t0], [t0, ZeroMatrix(z/(2))]]);  t1 := Matrix([[y .~ t0, ZeroMatrix(z/(2))], [ZeroMatrix(z/(2)), ZeroMatrix(z/(2))]]);  t0 := t; tn := t1;  end do;  else 'T'(n) end if; t0; end proc;"

Error, unterminated loop

"with(LinearAlgebra):  T := proc(n::integer)  local t0, tn, i, t, t1;  if (n>0) then t0 := Matrix(1, 1, 1); tn := Matrix(1,1,0);  for i from 1 to n do local z := 2^i;  t := Matrix([[Add(t0, tn), x .~ t0], [t0, ZeroMatrix(z/2)]]);  t1 := Matrix([[y .~ t0, ZeroMatrix(z/2)], [ZeroMatrix(z/2), ZeroMatrix(z/2)]]);  t0 := t; tn := t1;  end do;  else 'T'(n) end if; t0; end proc;"

 

T(2)

T(2)

(1)

``

 

Download G2.mw

Hello everyone. I was trying to code the recurrence relation given in the image below (without taking the mth power):

 

But, as I run the program, I am getting an "unterminated loop" error. Can someone please point out the mistake(s)?

rfin := proc(m::integer) 
local c, i, flg := 0;
for i from 0 to m do
	local b := i;
	do 
		c := b mod 3;
		if (c <> 2) then next else flg := 1; 
		end if;
		b := 1/3*b - 1/3*c;
	until b = 0;
	if evalb(flg = 0) then print(i); 
	end if; 
end do;
end proc;

Hello everyone. I've written a procedure that outputs all numbers <= a given user I/P whose ternary representation has no 2.

However, I get an "Error, unterminated loop" message. Can someone please out the mistake(s)?

Update:This bug ONLY occurs when the file title containing Chinese Characters.

 

The .mw files have already been associated with Maple 2020, but when clicking on any of them, Maple 2020 won't launch as expected and nothing actually will happen.
I have tried to reinstall Maple 2020, but the problem just keep existing.

The Windows version where the bug occurs is Windows 10 version 1909.

I'm using the 15 day trial as a Computer Science student. For my first project, Maple worked very well. I've been using the ApproximateInt() command. This command worked in the first assignment, and so I created a new document to start on my second assignment, and suddenly:

Entering the same ApproximateInt() command in a prompt line will not execute the command. Where it should display a plot of Riemann sums, it only displays the text I had entered. If I open the first document in which it was working properly, it also breaks upon re-iterating the command lines.

Image of expected behaviour:

Image taken right after pressing enter:

Is anyone familiar with this Maple behaviour? Thank you for any help. Meanwhile, I will attempt a reinstallation. The maple file is attached, as well.

P.S: Interestingly, the plot() command does work, as well as simple commands such as 1+2 (Displays "3")

Hello!

Using a geometry package, I ran into a problem: the area() function returns the wrong value for square elements.

What am I doing wrong?

_local(D)

with(geometry)

b := 2

h := 1

square(sq1, [point(A, 0, 0), point(B, b, 0), point(C, b, h), point(D, 0, h)])

evalf(area(sq1))

2.500000000

(1)

draw([sq1, A(printtext = true), B(printtext = true), C(printtext = true), D(printtext = true)])

 

triangle(tr1, [point(A, 0, 0), point(B, b, 0), point(C, b, h)])

evalf(area(tr1))

1.

(2)

draw([tr1, A(printtext = true), B(printtext = true), C(printtext = true)])

 

NULLNULL

NULL

b := .1

h := 1

square(sq2, [point(A, 0, 0), point(B, b, 0), point(C, b, h), point(D, 0, h)])

evalf(area(sq2))

.5050000000

(3)

draw([sq2, A(printtext = true), B(printtext = true), C(printtext = true), D(printtext = true)])

 

triangle(tr2, [point(A, 0, 0), point(B, b, 0), point(C, b, h)])

evalf(area(tr2))

0.5000000000e-1

(4)

draw([tr2, A(printtext = true), B(printtext = true), C(printtext = true)])

 

``


 

Download GeometryAreaTest.mw

Word-cloud is popular function which many languages have as add-on. Sometime called tag-cloud. https://en.wikipedia.org/wiki/Tag_cloud

"A tag cloud (word cloud or wordle or weighted list in visual design) is a novelty visual representation of text data"

I did help and did some google search, but can not find function in Maple. May be I did not search correctly.

In Mathematica is it called WordCloud. Here is an example of its use

WordCloud[Import["http://maplesoft.com"]]

And it returns this image back to the screen

 

Can one do the above in Maple? And what is the function name? Is it in special package?

 

Can one hope that next version of Maple will be able to solve the standard convection-diffusion pde in 1D?

pde:=diff(u(x,t),t)=d*diff(u(x,t),x$2)+c*diff(u(x,t),x);

in 1D. Even the most simple form with zero boundary conditions can't be solved.

pde:=diff(u(x,t),t)=d*diff(u(x,t),x$2)+c*diff(u(x,t),x);
bc:=u(0,t)=0,u(L,t)=0;
ic:=u(x,0)=f(x);
sol:=pdsolve([pde,ic,bc],u(x,t)) assuming d>0,c>0,L>0

              sol := NULL

I tried some HINT's also but not all of them.

FYI, Mathematica 12.1 is now able to solve the above PDE

ClearAll["Global`*"];
pde=D[u[x,t],t]==d*D[u[x,t],{x,2}]+c*D[u[x,t],x];
bc={u[0,t]==0,u[L,t]==0};
ic=u[x,0]==f[x];
DSolve[{pde,bc,ic},u[x,t],{x,t},Assumptions->{d>0,c>0,L>0}]

Gives

Is it possible I am overlooking some other option or a trick to obtain solution for the above using pdsolve? Only reason I am asking is that Maple can solve much more complicated PDE's and the above is one of the basic diffusion based PDE's. So I am surprised why Maple still can't solve this as it is just a seperation of variables method.

Maple 2020 on windows 10. Physics version 631

I am exploring the idea of porting some of my functions to Maple from Mathematica. But I just found a big problem in importing comma delimited data that contains a string within a string. This is not a problem being imported in Mathematica, but I need help to do same thing in Maple.

I tried ImportMatrix (as suggested in https://www.mapleprimes.com/questions/221509-How-To-Read-Lines-From-File-With-Quoted-Strings and also tried Import then convert and in both cases Maple does not read the full string in the field. I will show simple example

This file, called data.txt

1,2,3,"x+y, algorithm=["123"]","OK",5

It has 6 fields (since comma seperated.

But when importing it, Maple reads the 4th field above as "x+y, algorithm=[" and drops the rest 123"]"

Here is the code

#currentdir("C:\\bug"); #change as needed
data:=ImportMatrix("data.txt", source=csv);
print(data(4));
print(data(5));

This is the output

I also tried

data := Import("data.txt",format="CSV");
data := convert(data,Matrix):
print(data(4));
print(data(5));

Same output as above.

Compare the output in Mathematica. Using the same file as input. It automatically escapes the embedded strings and reads the full field OK

SetDirectory[NotebookDirectory[]];
data = First@Import["data.txt", "Table", "FieldSeparators" -> {","}, "Numeric" -> True]

               {1, 2, 3, "x+y, algorithm=[\"123\"]", "OK", 5}

data[[4]]

              "x+y, algorithm=[\"123\"]"

What would be the right way in Maple to import such files without losing part of the field?

The file has mixed strings and non strings, just like this example shows, and each file fields are seperated by comma, but I need to be able to read fields that can contain embedded strings in them automatically.

I am using Maple 2020. I think I might have to forget about import and try to do it using lower level code using scanf, or may be there is better method using Filetools package? but thought to check first if I am overlooking some option.

I depend alot on bracket matching to help me during writing code.

Maple suddenly losses bracket matching at some lines. I think it related to using strings with "\\" in them.

I make sure I have bracket matching on

 

I use worksheet mode (corrected), Maple 2020 under windows 10.

I made small video. Notice how the brackets do not match on the second line there.

Do you see how the brackets do not match on that second line there? This movie below shows what happens when I remove "\\string" from the line. Now bracket match starts to work again.

This is a serious problem for me. Any suggestions what to try to fix it and what can cause it?. Once bracket matching is lost, it is lost all the way to the rest of the code below the location where it started to lose first time.

restart;
if length(data_last(k,8))>300 then
   fprintf(file_id,"%s\n","\\footnotesize");
fi;

I think I have to find different editor to use and write the code to .mpl file since I have lots of such code and I need to have bracket matching working.

I noticed some problems with pdsolve in 2020. Using Maple 2020 on windows 10 with latest Physics 626.

This PDE now hangs when the timeout is increased. This does not happen in Maple 2019.2.1/
 

restart; 
pde := diff(w(x,y),x)+(a*sin(lambda*x + mu)^k * (y-b*x^n -c)^2 + y - b*x^n + b*n*x^(n-1) - c)*diff(w(x,y),y) = 0; 
cpu_time := timelimit(60*5,CodeTools[Usage](assign('sol',pdsolve(pde,w(x,y))),output='realtime'));

In Maple 2019.2 it gives

    Error, (in trig/reduce/reduce) time expired

Which is good. Since I can now go on to the next PDE.

The hang goes away in Maple 2020 when small timeout is used.  For example I just tried 30 seconds timeout instead of 300 or more seconds and it did expire ok.

This tells me that it depends where it was in the kernel at the time. But as a user, I have no way to control this and so I use the same timeout for all the problems.

Do others using Maple 2020 see the same issue? I know that the timeout does not happen at exactly the same amout given, but for this one, I waited for almost 40 minutes and it still did not time out.

Is this a new bug and is there a better way to handle this other than using timelimit()?

Thank you

With this application our students of science and engineering in the areas of physics will check the first condition of balance using Maple technology. Only with entering mass and angles we obtain graphs and data for a better interpretation.

First_equilibrium_condition.zip

Lenin AC

Ambassador of Maple

This behavior by Maple is completely wrong if you ask me.

But given this is how Maple works, the question I have is how to explictly close a file opened by call to readline()?

I have a proc(), where inside it, it wants to read say first 3 lines by calling readline("input.txt") on a file. Then the proc() returns back to caller.

The first call reads the first 3 lines from the file OK.

I expected all resources to be removed after the call returns, including any files opened to be automatically closed. So next time proc() is called, I expected the first 3 lines to be read again.

It turns out the next time  proc() is called, now lines 4,5,6 are read. This is becuase the file remained open between calls!  Only way to close the file is to call restart() on the whole session. But I do not want to do this. 

Looking at help, I see no method to explicity close the file other than reading all the lines.

How does one explicitly close a file opened by readline() without reading the whole file?

Here is example

restart;

foo := proc()
local n,current_line;

   for n from 1 to 3 do
       current_line:= readline("input.txt");
       print("line read is ",current_line);
   od;
end proc;

And now the above is called as follows

currentdir("C:\\test"); #change as needed
foo()
                   "line read is ", "line 1"
                   "line read is ", "line 2"
                   "line read is ", "line 3"

Next call

foo()
                   "line read is ", "line 4"
                   "line read is ", "line 5"
                   "line read is ", "line 6"

Where input.txt is 

line 1
line 2
line 3
line 4
line 5
line 6

I know how to do all this using fopen() and fscanf() and explicit fclose(). I also know I can use FileTools package.

But wanted to check first if readline() will do what I wanted more easily if I can figure how to close the file explicitly.

So here's something silly but cool you can do with Maple while you're "working" from home.

  • Record a few seconds of your voice on a microphone that's close to your mouth (probably using a headset). This is your dry audio.
  • On your phone, record a single clap of your hands in an enclosed space, like your shower cubicle or a closet. Trim this audio to the clap, and the reverb created by your enclosed space. This is your impulse response.
  • Send both sound files to whatever computer you have Maple on.
  • Using AudioTools:-Convolution, convolve the dry audio with the impulse response . This your wet audio and should sound a little bit like your voice was recorded in your enclosed space.

Here's some code. I've also attached my dry audio, an impulse response recorded in my shower (yes, I stood inside my shower, closed the door, and recorded a single clap of my hands on my phone), and the resulting wet audio.

with( AudioTools ):
dry_audio := Read( "MaryHadALittleLamb_sc.wav" ):
impulse_response := Read( "clap_sc.wav" ):
wet_audio := Normalize( Convolution( dry_audio, impulse_response ) ):
Write("wet_audio.wav", wet_audio );

A full Maple worksheet is here.

AudioSamplesForReverb.zip

I was reviewing the StringTools features and I'm curious about some parts of it.

(1)     Here is a section from the StringTools[Length] help topic:

Notice that, like length, the Length command counts the number of bytes in the string, not the number of characters.
Length("d303251cembre");
                               9
 
When I execute the command in Maple 2020, it actually returns 13 instead of 9.  The length command also returns 13.  I do not understand the information from StringTools[Length] help.  I looked back to Maple 18 and it did not include these lines in the help topic.
 
(2)   I am confused about the rng argument in StringTools commands of LowerCase, UpperCase and OtherCase.  It seems that these commands consider -2 as the last character in the string.  The help topic shows this:
 
UpperCase("abcdefghij", 3 .. -2);
                          "abCDEFGHIJ"
 
I'm expected to use -1 as the last character such as:
 
S:="This is a test";
S[-4..-1];
                       "test"
 
(3)  Next, I looked at StingTools[SubString].  The help topic gives the following example:
 
SubString("abcdef", -5 .. -3);
                             "bcd"
That works like I expected.  So, -1 is the last character for SubString.
 
Thanks,
Lee
 

Hello,

I have installed Maple 2020 and I tried some examples of the new capabilities of command is:

restart;
is(0 <= (a - b)^2 + (c - d)^2) assuming real;

It gives FAIL instead of true,

Similarly the simpler example

is(x = 0) assuming (0 < abs(x));

also gives FAIL incorrectly.

Perhaps, does this problem relate to a problem with calling SMTLIB package?

Best Regards,

1 2 Page 1 of 2