Joe Riel

9665 Reputation

23 Badges

20 years, 28 days

MaplePrimes Activity


These are answers submitted by Joe Riel

The simple answer is yes, the profiling feature doesn't work with gotos.

That aside, you really should not be using gotos, and not just for Dijkstra's structural concerns.  Maple gotos are for the most part undocumented.  The kernel implementation is not efficient (a goto statement is implemented via a search through the statements for the label, put more unexecuted statements between them and it will take longer).  The argument to the goto is evaluated and the target cannot be a local variable, so there are namespace issues.

Followup

The namespace issues can be avoided by using strings as labels. A little experimentation indicates that the search for the label appears to progress by first checking the preceding statement, then the following statement, then the statement before the preceding statement, etc.

The content of that library does not include squarefree; it appears to only have Auxiliary.  How did you create the respository?

Use forward quotes.  For good measure you should also use them around units:

with(Units[Standard]):
with(ScientificConstants):
c := evalf(Constant('c', 'units'));

Thanks for reporting this.  I'm submitting a bug report.

Use the factors command.  For example

   y := (a+b)^3:
   f := factors(y);
                   f := [1, [[a + b, 3]]]
   map(L -> `$`(op(L)), f[2]);
                    [a + b, a + b, a + b]

See help on @@:  (f@@3)(x);

Right-click on the combo box (assume it has label ComboBox0), select Edit Select Action and change it to

use DocumentTools in 
  Do(a = %ComboBox0);
end use;

I'm assuming that the combo box holds the values and you want the selected value to be assigned to the global variable a.

I use the following

kerneloptsall := proc( typ :: type := anything
                       , { returnlist :: truefalse := false }
                       , $
                     )
local eq, eqs, fields, maxlen;
    fields := [NULL
               , 'ASSERT'
               , 'assertlevel'
               , 'bindir'
               , 'byteorder'
               , 'bytesalloc'
               , 'bytesused'
               , 'cacheclearlimit'
               , 'cpulimit'
               , 'cputime'
               , 'cputype'
               #, 'dagtag'
               , 'datadir'
               , 'datalimit'
               , 'dirsep'
               , 'display_zero_complex_part'
               , 'filelimit'
               , 'gcbytesavail'
               , 'gcbytesreturned'
               , 'gcfreq'
               , 'gcmaxthreads'
               , 'gcthreadmemorysize'
               , 'gctimes'
               , 'gctotaltime'
               , 'gmpthreshold'
               , 'gmpversion'
               , 'homedir'
               , 'includepath'
               , 'inline'
               , 'jvmheaplimit'
               , 'level'
               , 'limitjvmheap'
               , 'locale'
               , 'mapledir'
               , 'max_record_depth'
               , 'maxdigits'
               , 'maximmediate'
               #, 'memusage'
               , 'multithreaded'
               , 'numcpus'
               , 'numactivethreads'
               , 'opaquemodules'
               , 'pathsep'
               , 'pid'
               , 'platform'
               , 'printbytes'
               , 'printlevel'
               , 'processlimit'
               , 'profile'
               , 'setsort'
               , 'sparse_sort_cutoff'
               , 'stackalloc'
               , 'stacklimit'
               , 'system'
               , 'toolboxdir'
               , 'toolboxversion'
               #, 'unread'
               , 'username'
               , 'version'
               , 'wordsize'
              ];
    eqs := map(proc(fld)
               local val;
                   val := kernelopts(fld);
                   if val :: typ then
                       return fld = val;
                   else
                       return NULL;
                   end if;
               end proc, fields);
    if returnlist then
        return eqs;
    else
        maxlen := max(map(eq -> length(lhs(eq)), eqs));
        for eq in eqs do
            printf("%-*a = %a\n", maxlen, op(eq));
        end do;
        return NULL
    end if;
end proc:

LibraryTools:-Save(kerneloptsall, sprintf("%s/maple/lib/kerneloptsall.mla", kernelopts('homedir')));

The older technique is to use the map procedure. For example,

map(ln, [a,b,c]);

Note that [a,b,c] is a Maple list, not an array. Both map and ~ work on various structures, though map is more general.

  A := Array([a,b,c]):
  ln~(A);
                 [ln(a)  ln(b)  ln(c)]
  map(ln, A);
                 [ln(a)  ln(b)  ln(c)]

Command-Shift-G invokes Greek mode on a Mac. Use Ctrl-Shift-G for Windows or Linux. The next key typed is interpreted as a Greek letter.  See Worksheet,Documenting,2DMathShortCutKeys.

Another route, with a slightly different result, is

seq(curry(`*`,a), a=1..3);   
          () -> `*`(1, args), () -> `*`(2, args), () -> `*`(3, args)

(**) %(x);
                                  x, 2 x, 3 x

I don't know what model you are referring to, however, I'll describe one method, with MapleSim 2016, using the Linearization app.

  1. Put the mechanism of interest in a subsystem, with causal inputs and outputs.  
  2. Open the Linearization app and select the subsystem.
  3. Linearize the subsystem.
  4. Choose the Bode analysis and generate the Bode plot.

I don't know of a good way to do that, using Maple's invztrans procedure. You can get some useful information by tracing the `invztrans/ratpoly` procedure. For example

debug(`invztrans/ratpoly`):
invztrans(z/(z^2+1),z,n);

For the most part, Maple modules cannot be constructed in the way you are attempting, i.e. by doing

Q := module()
export Qdef;
end module:

Qdef := proc(a,b,c,d)
  a + b*I + c*J + d*K;
end proc:

Aside from the issue that I, J, and K appear to be undeclared, the assignment to Qdef must be inside the body of the Qdef module assignment, for example

Q := module()
export Qdef;
    Qdef := proc(a,b,c,d)
        a + b*I + c*J + d*K;
    end proc:
end module:

The usual way to achieve this is do write the code in text files. One can then use $include statements to include a file:

Q := module()
export Qdef;
$include <Qdef.mpl>
end module:

The file Qdef.mpl would then contain the source for Qdef.

One way to do that is to put the assignment in the Maple Initialization file.  See the help page Worksheet,reference,initialization.

A variation is to add the following to the said initialization file

ScientificConstants:-AddConstant( CoulombForceConstant, symbol='k_', derive=1/4/Pi/epsilon[0]):

In a worksheet you could access it as a regular scientific constant.

First 23 24 25 26 27 28 29 Last Page 25 of 114