Alec Mihailovs

Dr. Aleksandrs Mihailovs

4455 Reputation

21 Badges

20 years, 307 days
Mihailovs, Inc.
Owner, President, and CEO
Tyngsboro, Massachusetts, United States

Social Networks and Content at Maplesoft.com

I received my Ph.D. from the University of Pennsylvania in 1998 and I have been teaching since then at SUNY Oneonta for 1 year, at Shepherd University for 5 years, at Tennessee Tech for 2 years, at Lane College for 1 year, and this year I taught at the University of Massachusetts Lowell. My research interests include Representation Theory and Combinatorics.

MaplePrimes Activity


These are answers submitted by Alec Mihailovs

Something like

plot3d(exp(sin(x))*cos(y)*sin(x*y),
    x=-5..5,y=-5..5,axes=boxed);

Alec

Why not to use just a and b instead of a(t) and b(t)?

Alec

Your name reminded me of an old joke.

A robber breaks into a home and hears a voice say, "Jesus is watching you."

Startled, he asks, "Who said that?"

Again, the voice says, "Jesus is watching you."

The robber turns around to see a parrot. He asks the parrot what his name is. The parrot replies, "Moses."

The robber asks, "What kind of people name a parrot Moses?"

The parrot replies, "The same kind of people who named that rottweiler Jesus."

Alec

That can be also done uaing coeffs,

co:=proc(f,x)
    local c,i,k;
    c:=[coeffs(f,indets(x),k)];
    if member(x,[k],i) then c[i] else 0 fi
end:

co(f,T);
                                  q

Alec

Well, I personally don't use Maple for sounds (or images) processing, so it seems certainly uncommon to me.

Alec

The rtable_scanblock help page has a couple of examples showing how to do that.

In your example,

rtable_scanblock( M, [],
    (val,ind,res) -> `if`(val > res[2],[ind,val],res),
    [[1,1],M[1,1]]);

                             [[3, 2], 9]

If the maximum occurs in more than one position, that gives the indices of its first occurence. Changing > to >= would give the indices of the last occurence. If you would like to have all the indices, then the procedure can be slightly modified, or select can be used instead,

M:=Matrix([[1,2,9],[-4,5,0],[3,9,4]]);

                              [ 1    2    9]
                              [            ]
                         M := [-4    5    0]
                              [            ]
                              [ 3    9    4]

select(x->M[x[]]=max(M),[indices(M)]);

                           [[1, 3], [3, 2]]

Alec

Perhaps, you could use

error "The calculation was interrupted"

instead of print.

Alec

Perhaps, Resample can be used and ArrayTools:-Replicate.

Alec

For example,

with(DifferentialGeometry):
DGsetup([x, y, z], M):

R:=evalDG(dx &w dy + dy &w dz - 2*dz &w dx);

                  R := dx ^ dy + 2 dx ^ dz + dy ^ dz

B:=Tools:-GenerateForms([dx,dy,dz],2);

                   B := [dx ^ dy, dx ^ dz, dy ^ dz]

C:=GetComponents(R,B);

                            C := [1, 2, 1]

zip(`&mult`,C,B);

                    [dx ^ dy, 2 dx ^ dz, dy ^ dz]

In Maple 13, that can be also done as

C &mult~ B;

                    [dx ^ dy, 2 dx ^ dz, dy ^ dz]

With opfuscation, the converting procedure can be written as

`convert/formlist`:=F->map2(op(0,F)@`[]`,
    op([1,1],F), map(`[]`,op([1,2],F))):

convert(R,formlist);

                    [dx ^ dy, 2 dx ^ dz, dy ^ dz]

Alec

Here is an example illustrating the topic.

G:=proc(x)
    local i;
    i:=1;
    to x do 
        i:=i*x
    od
end:

G(13-j);
Error, (in G) final value in for loop must be numeric or character

add(G(13-j),j=0..2);

                           312076518711120

sum('G'(13-j),j=0..2);

                           312076518711120

Alec

select(x->igcd(x[])=1,
    {indices(Array(100..110,100..110))});

  {[100, 101], [100, 103], [100, 107], [100, 109], [101, 100],

        [101, 102], [101, 103], [101, 104], [101, 105], [101, 106],

        [101, 107], [101, 108], [101, 109], [101, 110], [102, 101],

        [102, 103], [102, 107], [102, 109], [103, 100], [103, 101],

        [103, 102], [103, 104], [103, 105], [103, 106], [103, 107],

        [103, 108], [103, 109], [103, 110], [104, 101], [104, 103],

        [104, 105], [104, 107], [104, 109], [105, 101], [105, 103],

        [105, 104], [105, 106], [105, 107], [105, 109], [106, 101],

        [106, 103], [106, 105], [106, 107], [106, 109], [107, 100],

        [107, 101], [107, 102], [107, 103], [107, 104], [107, 105],

        [107, 106], [107, 108], [107, 109], [107, 110], [108, 101],

        [108, 103], [108, 107], [108, 109], [109, 100], [109, 101],

        [109, 102], [109, 103], [109, 104], [109, 105], [109, 106],

        [109, 107], [109, 108], [109, 110], [110, 101], [110, 103],

        [110, 107], [110, 109]}

Or

seq(seq(`if`(igcd(i,j)=1,[i,j],NULL),
    j=100..110),i=100..110);

Alec

One trick is to define also `print/sin` inside a module,

m := module() option package; 
    export sin; 
    global `print/sin`;
    sin := proc(x) :-sin(x*Pi/180) end;
    `print/sin`:=proc(x) :-sin(x*180/Pi) end
end:
with(m):

sin(x);

                                sin(x)

sin(30);

                                 1/2

Eval(y=sin(x),x=30);

                         (y = sin(x))|
                                     |x = 30

value(%);

                               y = 1/2

A side effect of that is that values with Pi are calculated in old-fashioned way,

sin(Pi/6);

                                 1/2

Alec

Perhaps, you could use KernelDensityPlot, something like

plots:-display(Statistics:-Histogram(dataset,range=0..10),
    Statistics:-KernelDensityPlot(dataset,color=red));

In this particular example, the picture might look better with setting a larger value of the binwidth in the Histogram - something like binwidth=2.

Alec

My guess is that plotsetup can be used. Set it to ps, give the output file name etc. I didn't check that though.

Alec

error or return can be used. For example,

f:=proc()
    local t;
    t:=iolib(25);
    do if iolib(25)-t mod 10=0 then 
        if Maplets:-Examples:-Alert("Quit?") then  
            error "%1 seconds passed",iolib(25)-t 
        fi 
    fi od 
end;

f();
Error, (in f) 33 seconds passed

Or

g:=proc()
    local t;
    t:=iolib(25);
    do if iolib(25)-t mod 10=0 then 
        if Maplets:-Examples:-Alert("Quit?") then  
            return iolib(25)-t 
        fi 
    fi od 
end;

g();
                                  51

Alec

First 22 23 24 25 26 27 28 Last Page 24 of 76