tomleslie

13876 Reputation

20 Badges

15 years, 163 days

MaplePrimes Activity


These are answers submitted by tomleslie

Maple will only search the current working directory for the file.

Your current working directory can be ascertained by executing

currentdir()

If this isn't where the file is stored,  then you can reset the current working directory by supplying an argument to currentdir() followed by read(), as in (on Windows)

currentdir("C:/dir1/subdir2/subdir3");
read "02ExactSoln.m";

Or you could simply supply the path in the read command, as in (for example)

read "C:/dir1/subdir2/subdir3/02ExactSoln.m";

The most important thing to realise is that there is a big overlap between the capabilities of the two commands

Generally speaking I find that cat() is the more "general" command, if only because it can concatenate names as well as strings. Consider the output of the following

for k from 1 by 1 to 5 do
    cat( sq, k )=k*k;
od;

where the variables with names sq1, sq2,...sq5 are created. You can do this with StringTools[Join], as in

for k from 1 by 1 to 5 do
    convert( StringTools[Join]( ["sq", convert(k,string)], "" ), name)=k*k;
od;

but as you can see it is a bit more awkward. In particular the strings have to be presented as a list, and the default separator is a space, unless you supply an alternative as the second argument (as in the above).

Join() works strictly on strings but cat() can concatenate a mixture of strings and names with the output being coerced to the type of the first argument: so

cat(a, "1");

will produce the name a1 and

cat("a", 1);

will produce the string "a1" - whic is sometimes useful, and sometimes not

In general, I would say that unless you want/need to specify the separator then cat() is more useful. However you should also consider the followiing

myLis:=[ "This", "is", "an", "example"];
StringTools:-Join(myLis);
cat(myLis[]);

So how do you get the spaces between the words when using cat()???? Adding separators when using cat() is possible but awkward.

So when do I actually use which command??? Well basically, if I happen to be doing lots of string manipulation, then I would probably use Join(). If I just happen to need a quick/dirty concatenation, in the middle of something else, then I probably use cat(). (Actually I probably use ||, but since this is now deprecated I probably shouldn't even mention that!)

 

Try the attached

deProb.mw

 

Looks like yu have been using 2-D math input and somewhere/somehow got a syntax error in your boundary conditions. If I convert everything to 1-D match input and rewrite the boundary conditions in what I know to be the corrct format, then the code runs and I can plot answers. See attached

PDEprob.mw

Short fast answer is no, not really. If you enter

f:=x+x;

in Maple then this will automatically be "simplified" to 2x. Now this can be circumvented in various ways, but why would you want to???

If you try

restart;
p:=x^2*y-2*y*z+3*x^2+2*y-z:
cl:=[coeffs(p, [x,y,z])];
t1:=[seq(op(j,p)/cl[j],j=1..numelems(cl))];

then c1 contains the coefficients of each of the terms in t1 - which is the information you require

restart;
p:=x^2*y-2*y*z+3*x^2+2*y-z:
cl:=[coeffs(p, [x,y,z])]:
[seq(`if`(cl[j]>0,seq(op(j,p)/cl[j], i=1..cl[j]),NULL),j=1..numelems(cl))];

 

This is your 4th or 5th question in the last 15 minutes or so - have you tried then help documentation????

As in

L:=[1,-1,-5,2,-3]:
map(abs, L);
map( signum, L);

As in

L:=[2,4,6,3];
T:=[2,2,3,1];
L/~T;

Save the file in either foo.mw or foo.mpl to achieve what you desire - foo.m is Maple internal format which as the manual says is not intended for end users.

So many solutions to this problem - and the "obvious" ones are a little bit less "sophisticated" than the one provided by Carl. Nothing wrong with clever solutions, but sometimes *simple* is good.

The attached shows three ways of solving your problem without getting too clever

limFunc.mw

My ability to help is limited because I don't really understand what you are trying to achieve.

However with your first method there is a simple syntax error at the line

if ii <> ii2 && jj <> jj2 then

because "&&" does not mean "and". If you change this line to

if ii <> ii2 and jj <> jj2 then

then the first method prints a sequence of 13 matrices. I have no way of knowing if these are what you want!

I decided not to try debugging your second method using the the delta() procedure because

  1. it runs and produces an output - so I'm not sure what is supposed to be wrong
  2. if I changed anything I might make it worse!!
  3. the procedure itself is very badly written, particularly with reference to variable scope. I suggest that check out the local and global statements

Many ways to do this: three possibilities are shown in the attached

mulLoop.mw

SFloat() seesm to work for me in Maple18 and 2015. - as in

h:= HFloat(5.67,14);# define hfloat
type(h, hfloat); #check type
s:=SFloat(h);# convert
type(s, sfloat);#check type

Sounds like you are in Document Mode, rather than Worksheet Mode.

Check out the help entry

Document Mode vs Worksheet Mode

One simple way to do this is shown in the attached worksheet. Obviously, one could add an awful lot of options to each of the constituent sub-plots

aplot.mw

First 199 200 201 202 203 204 205 Page 201 of 207