Joe Riel

9660 Reputation

23 Badges

20 years, 9 days

MaplePrimes Activity


These are replies submitted by Joe Riel

@herclau The reason is the presence of the empty function in the term on the right.  The empty function is the function with the empty name, that is, ``.   Note that any inert name could have been used, it is a hack to force Maple to keep the the term together.  The reason for using the empty function is that the complete term looks like the fraction that you want.  Also, the ?expand commands converts ``(x) to x, which is convenient.

@herclau One approach is to negate the operand of the square:

(**) z := (x-y)^2;
                                             2
                                 z := (x - y)

(**) applyop(`-`,1,z);
                                           2
                                   (-x + y)

@herclau One approach is to negate the operand of the square:

(**) z := (x-y)^2;
                                             2
                                 z := (x - y)

(**) applyop(`-`,1,z);
                                           2
                                   (-x + y)

Which algorithm?  I've rewritten quite a few from volume 4 (the fasicles).  I usually can do so by using conditionals and rearranging the order.

@karamand Using ?assign is almost certainly less efficient than using a do-loop.  That is,

for i to 3 do
    A[i,i] := i+2;
end do;

should be be more efficient than doing

seq(assign('A[i,i]'=i+2), i=1..3);

The procedure assign is not a Maple builtin, rather it is a Maple library procedure.

@karamand Using ?assign is almost certainly less efficient than using a do-loop.  That is,

for i to 3 do
    A[i,i] := i+2;
end do;

should be be more efficient than doing

seq(assign('A[i,i]'=i+2), i=1..3);

The procedure assign is not a Maple builtin, rather it is a Maple library procedure.

Rather than inserting an image, you should use text, so that an interested party can access your input without having to retype it.

Rather than copying, you could also use ?ArrayTools[Alias].  For this example that is about twice as fast, however, because each call to Alias returns an rtable object (of about 140 bytes), the memory allocated is greater.  Maybe Alias could be extended to permit reusing a given rtable structure so that the memory usage is minimal.

@pagan The problem is that the member operator (:-) gets evaluated before the expression is passed to stopat, etc.  Surrounding it with forward quotes or declaring the parameter with uneval won't help.  The only way around this is to use a different format, such as the double colon or string.  Another way is to use the bracket notation, that is somemodule[somelocal].

A drawback of that approach is that, because the :: operator is non-associative, parentheses are required.  In mdb, I parse a string inside a try/finally statement that temporarily assignes opaquemodules to false.  Thus

(**) mdb:-showstat("mdb:-showstat"); 
mdb:-showstat := proc(p::string)
local opacity;
   1   try
   2     opacity := kernelopts(('opaquemodules') = false);
   3     map2(`debugger/printf`,"\n%s",debugopts(('procdump') = parse(p)))
       finally
   4     kernelopts(('opaquemodules') = opacity)
       end try;
   5   return NULL
end proc


@acer Something I'd like to see Maplesoft adopt is a general method for applying user-specific options to packages, and specifically to the default values for keyword options.  For example, if you generally call CodeTools:-Usage with output=[output,realtime,cputime,bytesused,bytesalloc], then you should be able to set that as the default option in an initialization file.  Say SetDefault(CodeTools:-Usage, output=[...]). I wrote a small package that provides a mechanism for doing so, the only interesting part is that it has to work without loading the packages.  Alas, it is useless unless the packages have been built with support for it.

Another relevant example is `assuming`.  If you've installed mgrep, you can quickly find others by doing, say

$ mgrep -h 'uneval' maple.mla

With that I found `tools/bench`, which is essentially the equivalent of the benchmark code that John May presented, above. The tools hierarchy has a number of undocumented but quite useful procedures for common tasks.

@wzelik At t=80 hours the system will be essentially in the steady-state condition, so an accurate computation is straightforward.  I took a slightly different route and simulated the model using MapleSim.  That confirms that the steady-state temperature at the far end should be 683K.  So the output of Maple pdsolve is wrong.  The error appears to come when the radiation term is present. Note that if the convection loss is removed, then pdsolve computes an output temperature of 1597K, which makes no sense because it is higher than the source. 

@wzelik At t=80 hours the system will be essentially in the steady-state condition, so an accurate computation is straightforward.  I took a slightly different route and simulated the model using MapleSim.  That confirms that the steady-state temperature at the far end should be 683K.  So the output of Maple pdsolve is wrong.  The error appears to come when the radiation term is present. Note that if the convection loss is removed, then pdsolve computes an output temperature of 1597K, which makes no sense because it is higher than the source. 

@zhong chen Your model, from what I can see of it, looks okay.  The `msim/VAR#` is used internally to represent relations ( x < 1, etc).  The `msim/PIECEWISE` represents a piecewise expression (it is similar to the Maple ?piecewise function).

First 82 83 84 85 86 87 88 Last Page 84 of 195