tomleslie

4601 Reputation

10 Badges

9 years, 120 days

MaplePrimes Activity


These are answers submitted by tomleslie

From the Maple toolbar

Help-> Manuals, Resources and more-> Manuals-> Programming Guide

Entering your vector as

v1:=Vector( [ (4/7)*exp(-t)*exp(-4*t)-(4/7)*exp(-t)*exp(3*t),
                     (10/7)*exp(-t)*exp(3*t)+(4/7)*exp(-t)*exp(-4*t)
                  ]
               );

Then I find either

(combine@expand)~(map(integrate, v1, t));

or

map(integrate, (combine@expand)~(v1), t);

provides the answer you desire - so I'm not sure what the problem is??

Personally I would probably integrate first and then do the simplification, so use

(combine@expand)~(map(integrate, v1, t));

Your posted code runs in 1070 seconds on my machine

If I reorganise your code so that stuff executes in what I consider to be a logical order, and nothing is executed repeatedly, unless it actually has to be, I can get this down to ~21secs, producing the same answer. The absolute numbers on your machine will differ, but you ought to obtain the 50x improvement

Note that I have done nothing to improve the performance of the fsolve() command based on your specific problem, I have simply eliminated "redundant" operations.

See the attached

fsprob.mw

Would further improvements be possible??
Probably, but the law of diminishing returns would set in fairly quickly. I did the above improvement in about 15mins. I suspect that there might be another factor of 2 (or so) to be gained, but only if I spent a couple of hours on the problem - not sure I have the time/inclination :-)

Just because I'd never used the geom3d package before, and it seemed like an obvious choice!

   restart;
   with(geom3d):
#
# Define the triangle
#
   triangle(ABC, [ point(A,3,0,0),
                          point(B,0,6,0),
                          point(C,0,0,4)
                      ]
              ):
#
# Compute all three altitudes
#
   altitude(hA, A, ABC):
   altitude(hB, B, ABC):
   altitude(hC, C, ABC):
#
# Generate the intersections of the
# altitudes taken in pairs - just to
# show one always gets the same result
#
   coordinates(intersection(H1, hA, hB));
   coordinates(intersection(H2, hA, hC));
   coordinates(intersection(H3, hB, hC));

 

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
First 97 98 99 100 101 102 103 Page 99 of 105