Joe Riel

9610 Reputation

23 Badges

19 years, 182 days

MaplePrimes Activity


These are answers submitted by Joe Riel

I suspect that a proof is not what you are looking for in that the statement is practically a definition of Pi.

With that in mind, see the first example in the help page for VectorCalculus,ArcLength.

Was Maple's current directory the same as the directory in which the file was located? The current directory is displayed in the bar at the bottom of the GUI.  Click on it to change the directory.

verify is the wrong procedure to use here, it is for doing type-based verifications. Use is

is(2*q/(q^4+q^2+1)-1/((q-1)^2*(q+1)) >= 0) assuming q>7;
                       true

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:
First 21 22 23 24 25 26 27 Last Page 23 of 114