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),

Then I find either

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


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

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!

# Define the triangle
   triangle(ABC, [ point(A,3,0,0),
# 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


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)

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;

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;

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"];

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


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

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


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

cl:=[coeffs(p, [x,y,z])];

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

cl:=[coeffs(p, [x,y,z])]:


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

As in

map(abs, L);
map( signum, L);

As in


Save the file in either 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

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