Joe Riel

9660 Reputation

23 Badges

20 years, 0 days

MaplePrimes Activity


These are answers submitted by Joe Riel

If you remove the square brackets from subs command the output is an algebraic expression rather than a list.

An alternative way to handle this is with the Syrup package, available on the Maple Cloud. With it you can do

with(Syrup):
ckt := [V3(1), R3(200),R49(1.3e3),1,C5(68e-12),L(3.3e-6),C4(100e-12),1,C6(8.2e-12),C2(10e-12),R8(10e3)]:
Draw(ckt);
sol := Solve(ckt,ac):
subs(sol, v[2]); # I'm not sure which node voltage you are interested in.

 

Note that n is charge carrier density, not charge density. So

(**) B := 0.5*Unit('T'):
(**) q := Unit('e'):
(**) n := 0.15*100000./Unit('L'):
(**) d := 1*Unit('micron'):
(**) Ih := 0.1*10^(-5)*Unit('A'):
(**) Vh := Ih*B/q/n/d:
(**) combine(Vh, units);
                .2080503041e12*Units:-Unit(V)

Seems a tad large.  Better check those values.

A slight clarification; the package will be loaded, regardless; what you don't want is binding its exports into the global namespace, which is what with does.

Those two procedures, alias and macro, have different purposes.  Alias causes a global name to be displayed as its defined alias, though it also allows entering the short name.  Macro is only for simplified input.  Because macro is builtin (alias is a library procedure) I'd probably use it rather than alias if your purpose is to simplify the input. Note that using alias will change the display of a printed procedure.  For example

restart;
alias(ST = StringTools):
foo := proc(s) ST:-UpperCase(s); end proc;

         foo := proc(s) ST:-UpperCase(s); end proc

foo("a");
                     "A"

restart;
macro(ST = StringTools):
foo := proc(s) ST:-UpperCase(s); end proc;
 
        foo := proc(s) StringTools:-UpperCase(s); end proc

foo("a");
                    "A"

 

In the Type menu, select Custom and then enter Modelica.Thermal.FluidHeatFlow.Interfaces.FlowPort in the text area and click Apply Custom.  You can also enter FlowPort_a to get a filled port or FlowPort_b to get an open port.

Something seems wrong.  I build a package with many includes. The number of source lines is over 100K.  It takes 2 seconds for Maple to process it. 

Are you sure you have write permission to the directory which is being used (execute currentdir() to determine that)?

The short answer is that unless you can just combine the modules into one, you'll probably have to edit code.  If it's a lot, you might consider how to automate it.  For example, use the exports Maple command to get the exports of a module, then use StringTools commands to update source files.  If a unix user, consider generating a sed script to do the update. Backup stuff so you can recover from the inevitable errors.

This is one of a few reasons to alway use the equation binding form in a uses statement.  For example

proc()
uses ST = StringTools;
      ST:-RegMatch(...);
end proc:

Another is that if you use the name form, an addition to the package being used could break code if you had used an identifier that matches an export. 

Because you have the source, an alternative is to hard-code a call to DEBUG() inside the procedure.  For example,
 

foo := proc()
local k,y;
    y := 0;
    for k to 10 do
        if k > 3 then
            DEBUG();
         end if;
        y := y + k;
    end do;
end proc:
foo();  # the debugger will be invoked when k reaches 4.

 

I've added an option to the Iterator:-Partition procedure that specifies the maximum value of a partition.  For example

P := Iterator:-Partition(100,'maxvalue'=35):
add(1, p=P);
                                    178299181

That took a bit under 8 minutes. The cardinality differs significantly from what you show.  Will investigate.

Later The cardinality from the Sage math output is different because it is returning partitions with distinct values.   Iterator:-Partition generates all partitions.  For example
 

(**) P := Iterator:-Partition(7,maxvalue=4):
(**) Print(P,showrank);
 1: 4 3 
 2: 4 2 1 
 3: 4 1 1 1 
 4: 3 3 1 
 5: 3 2 2 
 6: 3 2 1 1 
 7: 3 1 1 1 1 
 8: 2 2 2 1 
 9: 2 2 1 1 1 
10: 2 1 1 1 1 1 
11: 1 1 1 1 1 1 1 

 

A practical method is to create a Maple archive (mla file) from the source, then access it from Maple.  To access it from Maple you can either modify libname, or (better), install the mla into a custom toolbox where it will be automatically found.  On my linux box that means installing it in, say, /home/joe/maple/toolbox/foo/lib/foo.mla, where the package name is foo

Depends on what you want to do with the data structure.  Maple tables and MultiSets behave quite differently. 

The foldl procedure can be used to generate the expression

foldl(((o,k)->1+z^k/o),1,seq(7..1,-1)); 

In Maple2021 you can use the fold option to seq

seq[fold=(((o,k)->1+z^k/o),1)](7..1,-1);

Try the following
 

Y := Ym*(c/((d + 1)*(X - X__0) + c))^(d + 1)*exp((X - X__0)*(d + 1)^2/((d + 1)*(X - X__0) + c)):
Xsol := solve(Y = Ym/2, X):
simplify(Xsol);
                1/(d+1)*(d*X__0+X__0-c-1/LambertW(-2^(-1/(d+1))*exp(-1))*c)

 

A simple approach is to convert to a ZeroPoleGain form of transfer function and then truncate all poles and zeros greater than some arbitrary frequency.  That may give acceptable results if the frequencies of the truncated poles and zeros are much greater than the dominant ones.

Alas, in the Graph plotting returns, non-integer weights are printed as floats using sprintf("%0.3g", weight).  That should probably be modified.  There is a hack that you can use.  The idea is to temporarily replace the sprintf function with your own version, one which arbitrarily repaces any use of "%0.3g" as the format string with "%a".  Here's how you do so
 

unprotect(sprintf):
oldsprintf := eval(sprintf):
# temporarily replace sprintf with ad hoc version
sprintf := proc(fmt) oldsprintf(ifelse(fmt="%0.3g","%a",fmt),_rest); end proc:
# create the plot
P := (DrawGraph)(G, style=tree, root=Omega,size=[400,400]):
# restore sprintf
sprintf := eval(oldsprintf):
r := plottools:-rotate(P, Pi/4);

If you plan to draw several graphs, you might create your own procedure that incorporates this hack.

MyDrawGraph := proc()
global sprintf;
local oldsprintf;
    unprotect('sprintf');
    oldsprintf := eval(sprintf);
    sprintf := proc(fmt) oldsprintf(ifelse(fmt="%0.3g","%a",fmt),_rest); end proc;
    try
        return GraphTheory:-DrawGraph(_passed);
    finally
        sprintf := eval(oldsprintf);
        protect('sprintf');
    end try;
end proc:

 

First 7 8 9 10 11 12 13 Last Page 9 of 114