nm

11353 Reputation

20 Badges

13 years, 15 days

MaplePrimes Activity


These are questions asked by nm

I have a plain text file, with hundreds of lines. I read using the command

ImportMatrix(file_to_read, source=csv):

The files has mixed fields which are integers and strings. The problem happens when a string happeneds to be "0". Maple interprets this when reading as the integer zero and not as the string zero! So that when I print this field later on using printf("%s",field) I get an error. (since I know this field is string, the format for output is fixed in the code). 

I made a very small example to illustrate. One line with 4 fields. The 4ht field is string.

This specific field is always a string with alphanumeric content in the file. It has " " around it. But sometimes the content of the string happens to be the string "0".  Maple gets confused and reads "0" as integer 0.

Is there a way to tell Maple not to read this string as an integer using ImportMatrix?

Here is MWE to show the problem


restart;
currentdirName :="C:\\bug";
currentdir(currentdirName);
file_to_read := cat(currentdirName,"\\maple_input.txt");
data:=ImportMatrix(file_to_read, source=csv):

print(data);
whattype(data[1,1]);
whattype(data[1,4]);

printf("%d,%d,%d,%s",data[1,1],data[1,2],data[1,3],data[1,4]):

 

The input file maple_input.txt has this one line in it:

1,2,3,"0"

As you can see, the 4ht field is a string.  But Maple reads it as integer:

 

This is using Maple 2017.1 on windows. Also Attached the text file.

1,2,3,"0"

Download maple_input.txt

 

Is there a command to find out what is new in 2017.1 that just got installed on my PC?

kernelopts(version);
  Maple 2017.1, X86 64 WINDOWS, Jun 19 2017, Build ID 1238644

I searched and googled and could not find such a command.

It used to be that when I clicked on the little icon in the help window which tells Maple to display all examples in 1D, then I did not see any 2D or any document style (i.e. italic) notation in the examples.

Now in Maple 2017 I see many examples in help show up in 2D/italic. It is worst, on same page, some code displays in Maple language and some code displays in 2D notation.

I do not like 2D. I want to only see examples written in the plain good old fashioned Maple language (which Maplesoft seems to be trying very hard to kill as it seems to be trying to force document style/2D on users by any means).

Here is an example. ?diff shows this

The above has 2D as input and above it has Maple code as input. One can't even copy the input to the open worksheet. If I copy it, this what happens:

value(??);

Here is another example, from page titled

 

Scrolling down I see this

I want all the input code above in examples and documentation to be in plain 1D Maple language notation. Not italic and not 2D and not anything fancy.  I do not like to even look at italic code above.

But clicking on the icon has no effect.

Is there a way to force everything to show using Maple notation for input? 

Maple help and documenation is a big mess if you ask me.

 

 

Maple newbie here.

I do not understand why algsubs do not replace the symbol in the denominator in the following example, but does replace it in the numerator. This is on Maple 2017 on windows 7

Here is the expression

sol := u(x, t) = Sum((2*cos((1/2)*Pi*_Z1)+
       2+4*(-1)^(1+_Z1))*sin(Pi*_Z1*x/L)*
       exp(-k*Pi^2*_Z1^2*t/L^2)/(Pi*_Z1), 
       _Z1 = 1 .. infinity);

I wanted to replace _Z1  with n

But algsubs will not replace _Z1 in the denominator as seen in this screen shot but subs does:

 

 

From help, my impression is that algsubs is superset of subs. Only case where algsubs will not do what subs does is, according to help:

The algsubs command goes recursively through the expression . Unlike the subs command it does not substitute inside indexed names, and function calls are applied to the result of a substitution

 

But There is no indexed names here? 

Can someone please explain why algsubs fails to do the substitution in the denominator in this example?

 

 

 

 

UPDATE

Thanks for checking. I verify I get the error and made screen shots below

When I add the convert() command, the error goes away. Here is screen shot

 

I am using Maple 2017, student version, on windows 7, 64 bit, home edition.

 

Original post

This is using Maple 2017 on windows.

With the following input, Maple pdsolve gives an error

pde:=diff(u(x,t),t)=k*diff(u(x,t),x$2);
bc:=D[1](u)(0,t)=0,D[1](u)(L,t)=0:
assume(L>0):
ic:=u(x,0)=piecewise(0<x and x<=L/2,0,L/2<x and x<L,1):
sol:=pdsolve([pde,bc,ic],u(x,t)):

However, if I add one line to convert the piecewise function above to piecewise, then pdsolve no longer gives an error. So the following input works

restart;
pde:=diff(u(x,t),t)=k*diff(u(x,t),x$2);
bc:=D[1](u)(0,t)=0,D[1](u)(L,t)=0:
assume(L>0):
ic:=u(x,0)=piecewise(0<x and x<=L/2,0,L/2<x and x<L,1):
ic:=convert(ic,piecewise,x):
sol:=pdsolve([pde,bc,ic],u(x,t)):

 

Notice the extra line. Why does one have to convert piecewise to piecewise to make pdsolve accept the input?

sorry did not write down the error message and I am writing this from school library PC. But if you try the first case, you'll see the error.

 

First 166 167 168 169 170 171 172 Last Page 168 of 199