Alec Mihailovs

Dr. Aleksandrs Mihailovs

4475 Reputation

21 Badges

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

Social Networks and Content at Maplesoft.com

Maple Application Center

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

Another way can be seen in action in the procedure in that post.

It is done not in a loop though, which makes it (much) more effective (efficient too, but in this particular examle it's not that important).

Now - my this answer was voted down only once - unlike another answer voted down 3 times in this thread? That's a (nice) surprise! Some of "down voters" got scared of my tongue? Nah. Just have to wait for a little bit longer, I guess.

_______________
Alec Mihailovs, PhD
Maplesoft Member

A downside of using that signature is that I've started receiving tons of email (mostly from Asia), requiring immediate assistance to their Maple problems - they think that I am working in Customer Support.

_______________
Alec Mihailovs, PhD
Maplesoft Member

Seems to be working now,

f[1]:=x->x+a: (f[1]@f[1])(x);

                               x + 2 a

_______________
Alec Mihailovs, PhD
Maplesoft Member

Starting from 0,

L:=[2,3,3,3,4,5,5,5,6,7,7,7,8,9,9,9,10,11,11,11,12]:
gfun:-listtorec(L,a(n));

  [{(n + 7) a(n + 1) + (-n - 6) a(n + 2) + (n + 7) a(n + 3)

         + (-n - 6) a(n + 4), a(0) = 2, a(1) = 3, a(2) = 3, a(3) = 3}

        , ogf]

rsolve(%[1],a(n));

1/2*sin(1/2*n*Pi)+2+1/2*n

seq(%,n=0..20);

  2, 3, 3, 3, 4, 5, 5, 5, 6, 7, 7, 7, 8, 9, 9, 9, 10, 11, 11, 11, 12

Subtract 4 from n if you want to start from 4,

expand(eval(%%,n=n-4));

1/2*sin(1/2*n*Pi)+1/2*n

seq(%,n=4..24);

2, 3, 3, 3, 4, 5, 5, 5, 6, 7, 7, 7, 8, 9, 9, 9, 10, 11, 11, 11, 12

_______________
Alec Mihailovs, PhD
Maplesoft Member

For example,

trigsubs(sin(x)+sin(y))[];

2*sin(1/2*x+1/2*y)*cos(1/2*x-1/2*y)

eval(%,y=x+Pi/3);

sin(x+1/6*Pi)*3^(1/2)___________
Alec Mihailovs, PhD
Maplesoft Member

Also, StringTools:-FormatMessage might be useful for formatting the error message in try...catch. For example, with f from the first answer,

for i to 6 do
    try print(f(i))
        catch "bad argument at":
            printf(StringTools:-FormatMessage(
               "%-1 i created a problem", i))
    end
od:

1st i created a problem

                                 g(2)

3rd i created a problem

                                 g(4)

5th i created a problem

                                 g(6)

_______________
Alec Mihailovs, PhD
Maplesoft Member

 ?Statistics package has Select, Remove, SelectNonNumeric, RemoveNonNumeric, SelectInRange, RemoveInRange commands which can be applied to both Arrays and lists.

_______________
Alec Mihailovs, PhD
Maplesoft Member

Sphere point picking article in Mathworld describes several ways of constructing randomly distributed points on a sphere.

_______________
Alec Mihailovs, PhD
Maplesoft Member

I didn't look deep into the code, and it, probably, could be modified to avoid restarting - it is not something that people usually do. But, theoretically speaking, one could use save command to save the variables and then read to retrieve them.

__________________
Alec Mihailovs, PhD
Maplesoft Member

Shortcut keys are available at ?worksheet/reference/shortcutkeys and the package index at  ?index,package .

_______________
Alec Mihailovs, PhD
Maplesoft Member

Your code was correct (well, the posted part of it). It should work. For example,

for i from 100 by -0.01 to 0 do 
    if frem(i,20)=0 then print(i) fi 
od;
                                 100
                                80.00
                                60.00
                                40.00
                                20.00
                                  0.

_______________
Alec Mihailovs, PhD
Maplesoft Member

The list should be in second place, and additional arguments - after that,

L1:=remove(`<>`, L, 3);

                             L1 := [3, 3]

or

select(`=`,L,3);

                                [3, 3]

__________________
Alec Mihailovs, PhD
Maplesoft Member

Also, one could use  ?DifferentialGeometry/ExteriorDerivative (a rather new package, but still useful for some tasks).

with(DifferentialGeometry):
DGsetup([r,theta],M);

                            frame name: M

ExteriorDerivative(r*sin(theta));

sin(theta)*dr+r*cos(theta)*dtheta

_______________
Alec Mihailovs, PhD
Maplesoft Member

The answers (very clever) were submitted by Robert Israel. I came to this page with an intention to mark them up, and wasn't able to, because both of them were classified here as comments.

_______________
Alec Mihailovs
Maplesoft Member

Compare the expression for the composition of 2 rational functions,

collect(normal(eval((a*s+b)/(c*s+d),s=(A*s+B)/(C*s+D))),s);

                      (a A + b C) s + a B + b D
                      -------------------------
                      (c A + d C) s + c B + d D

with the matrix multiplication,

Matrix([[a,b],[c,d]]).Matrix([[A,B],[C,D]]);

                       [a A + b C    a B + b D]
                       [                      ]
                       [c A + d C    c B + d D]

Now, the composition repeated n times can be calculated using the n-th power of matrix

g:=Matrix([[0,1-p],[-p,1]]);

[0 1 - p]
g := [ ]
[-p 1 ]

F:=LinearAlgebra:-MatrixPower(g,n);

F :=

[ n (n + 1) n
[ p - p - p (1 - p)
[- -------------------------- ,
[ -1 + 2 p

n n n (n + 1)]
-(1 - p) + p + p (1 - p) - p ]
--------------------------------------]
-1 + 2 p ]

[ n (n + 1) (n + 1) n n]
[p (1 - p) - p p - (1 - p) + p (1 - p) ]
[--------------------- , --------------------------------]
[ -1 + 2 p -1 + 2 p ]

_______________
Alec Mihailovs
Maplesoft Member

First 6 7 8 9 10 11 12 Last Page 8 of 76