Joe Riel

9530 Reputation

23 Badges

20 years, 23 days

MaplePrimes Activity


These are answers submitted by Joe Riel

You need to add C:\emacs\bin\.emacs.d\maple to the load-path variable for Emacs.  I do this, in my .emacs file, with

(add-to-list 'load-path (concat user-emacs-directory "maple"))

That assumes the emacs-defined variable user-emacs-directory points to C:\emacs\bin\.emacs.d\. To determine that, execute the command describe-variable and enter user-emacs-directory. 

Because aa is an equation rather than an expression, I'll assume you just want to collect the rhs and leave the lhs alone.  The following works

lhs(aa) = frontend(collect, [rhs(aa), omega^(-sigma+1)]);   

The command Matrix(15) returns a 15 x 15 Matrix.  An initializer can be passed to the Matrix procedure to assign the initial values, see the ?Matrix help page.

f := sqrt(x^2+x+1)-sqrt(x^2-x+1):
(minimize..maximize)(f,x);
                             -1 .. 1

A clever but not the most efficient way to do this

A := add(``(x), x=op~([g[]])):
cnt := i -> coeff(A,``(i)):

The following should be more efficient, assuming you want to access all the counts eventually

L := op~([g[]]);
cnt := table('sparse'):
for x in L do cnt[x] := cnt[x]+1; end do:
# Now access cnt by
cnt[i];

The index variable j goes to 3, the for loop references K[j], but K only has two elements.

You could use one of the filters in Signal Blocks > Continuous.  Alternatively, you could build your own from the various blocks.  Feedback works fine; what did you try?

There is a typo, change

if ndisk = 1 then

to

if ndisks = 1 then

Followup

While I was able to spot the error by inspection, a more useful and practical technique is to use a syntax checker. The maplemint procedure can be used for procedures assigned in a worksheet. Here is an example of using it on a simplified version of the original code.

myproc := proc(ndisks) if ndisk = 1 then return; end if; end proc:
maplemint(myproc);
    These names were used as global names, but were not declared: 
      ndisk
    These parameters were never used explicitly: 
      ndisks

The printed message should alert the user that there is a problem with the ndisk usage.

@sigl1982 Here's a first cut at the basic implementation.

Factorization := module()
option object;

local expr        # the expression to factor
    , factors     # its factorization
    , prof := ""  # the profiled output string
    ;

export
    ModuleApply :: static := proc( )
        Object(Factorization, _passed);
    end proc;

export
    ModuleCopy :: static := proc( self :: Factorization
                                  , proto :: Factorization
                                  , ex :: algebraic
                                  , { profile :: truefalse := false }
                                  , $
                                )
        self:-expr := ex;
        if profile then
            debugopts('traceproc' = factor);
        end if;

        self:-factors := factor(ex);

        if profile then
            self:-prof := debugopts('procdump' = factor);
            debugopts('traceproc' = false);
        end if;

    end proc;

    # Return the computed factorization
export
    Factors :: static := proc(self :: Factorization);
        self:-factors;
    end proc;

export
    Profile :: static := proc(self :: Factorization);
        printf("%s", self:-prof);
    end proc;

    # Implement the actual factorization.  Here just call the global factor procedure.
local
    factor :: static := proc(expr)
        :-factor(expr);
    end proc;

end module:

f1 := Factorization(x^3-1, profile);

Factors(f1);
Profile(f1);
# savelib('f1', "f1.mla");

This appears to be an issue with the 2D parser. The simplest workaround is to manually expand the input: Array(1..3,1..3,1..3);

If the node names of your tree structure are always symbols, consider using packed records, rather than tables, as the data structure.  Here I've modified the code to use records.

RecordTest1 := proc(a := NULL, b := NULL)
local aindx, bindx;
    if a::'record' and b::'record' then
        aindx := {exports(a)};
        bindx := {exports(b)};
        aindx = bindx and andmap(i->RecordTest1(a[i],b[i]), aindx);
    else
        evalb(a = b);
    end if;
end proc:

Note that sets have to be used here for the indices, the exports procedure has no indexorder option. With a depth of 6 and width of 10, this ran twice as fast as the table-based version. Constructing the structure is also faster.

Here's a simple recursive test.

TableTest := proc(a := NULL, b := NULL)
local aindx, bindx;
    if a::table and b::table then
        aindx := {indices(a)};
        bindx := {indices(b)};
        aindx = bindx and andmap(i->TableTest(a[op(i)],b[op(i)]), aindx);
    else
        evalb(a = b);
    end if;
end proc:

The immediate issue is that ModuleApply, which is what is called by TestModule(3), returns not a module but the result of a computation.  Modify the procedure to return thismodule.  Also, there is a bug in CodeTools:-Profiling:-PrintProfiles; you can work around it by replacing that line by

printf("%s",debugopts('procdump' = run));

Using modules as dynamic objects is possible, however, the newer Maple construct, an object (implemented as a specialization of a module) is generally better.

Change

ModelSet(1):= Model1;

to

ModelSet(1):= eval(Model1);

See the help page last_name_eval for a discussion of why this is necessary.

A simple way to see understand what happens during parallel transport on a constant latitude of a sphere is to consider parallel transport on the cone that is tangent to the sphere at that latitude. A cone is flat, so the change in angle is equal to the angle of the cut from a flat sheet that is used to form the cone.

First 21 22 23 24 25 26 27 Last Page 23 of 114