Alec Mihailovs

Dr. Aleksandrs Mihailovs

4495 Reputation

21 Badges

20 years, 344 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

In Windows, it is possible to change the background color of any window, just by modifying the settings in the theme used. See, for example, pictures in my old blog.

Alec

In this particular example, a diff can be used. An integration n times is the same as differention -n times with adding an arbitrary polynomial of degree (n-1), so

diff(cos(x),x$(-n));
                                     n Pi
                            cos(-x + ----)
                                      2

And in Jean-Marc's example above,

diff(sin(x)*exp(x),x$(-n));

                            (- n/2)          n Pi
                   -exp(x) 2        sin(-x + ----)
                                              4

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

               1/2          Pi
  -1/2 exp(x) 2    cos(x + ----), -1/2 cos(x) exp(x),
                            4

                     1/2          Pi
        -1/4 exp(x) 2    sin(x + ----), -1/4 sin(x) exp(x)
                                  4

Alec

Mathematica beats Maple in 2 aspects for calculating the digits of Pi. First - it is faster, and second - it has a built-in function for digits, as well as more convenient timing procedure:

In[1]:= Timing[RealDigits[Pi, 10, 1, -299999]]

Out[1]= {0.046, {{9}, -299998}}

Alec

The NthDigitOfPi from my blog seems to be faster,

st:=time(): p(300000); time()-st;

                                  9
                                15.522

st:=time(): NthDigitOfPi(29999); time()-st;

                                  7
                                  0.

st:=time(): NthDigitOfPi(299999); time()-st;

                                  9
                                  0.

Alec

See also my old blog, Search Pi.

Alec

Generally speaking, I am trying to avoid Standard, and use Classic. Unfortunately, it is not possible in 64-bit Linux where Maple doesn't have Classic.

Standard still has various issues with editing, including copying and pasting. The necessity of entering a backslash in front of the _ is very annoying (especially because I type rather fast and usually notice that too late). 

The 2-D input in normal programming is very annoying - it slows it down significantly, even without the editing issues. Originally I thought that it may be useful for entering formulas inside text, and it may be, but I didn't have a chance to test that.

Alec

Yes, 64-bit Maple doesn't have Classic.

Alec

You used = instead of := in IBC.

Alec

Perhaps, BarChart or ColumnGraph can be used.

Alec

For example,

plots:-animate(plot3d,
[exp(c+x^2+y^2),x=-1..1,y=-1..1,axes=box],c=-1..2);

Click on the plot, and then on the Play button.

Alec

It can be done manually using the plot structure. For example,

A:=LinearAlgebra:-RandomMatrix(100,generator=1..4);

                         [ 100 x 100 Matrix     ]
                    A := [ Data Type: anything  ]
                         [ Storage: rectangular ]
                         [ Order: Fortran_order ]

c:=table([1=(0.,0.,1.),2=(1.,0.,0.),3=(1.,1.,0.),4=(0.,0.,0.)]):

PLOT(POLYGONS(
seq(seq(Array(1..4,1..2,[[i,j-1],[i,j],[i-1,j],[i-1,j-1]],
datatype=float[8],order=C_order),j=1..100),i=1..100),
COLOR(RGB,seq(seq(c[A[i,j]],j=1..100),i=1..100))),
STYLE(PATCHNOGRID),SCALING(CONSTRAINED),AXESSTYLE(BOX));

135_colorplot.png

Alec

The second problem can be done by generating more numbers than necessary, and selecting those that satisfy the given condition. In one line,

S:=(mu,sigma,N)->select(x->x>mu-3*sigma and x<mu+3*sigma,
Statistics:-Sample(Normal(mu,sigma),trunc(1.1*N))[1..N]);

For example,

S(3,1,1000);

                     [ 1000 Element Row Vector ]
                     [ Data Type: anything     ]
                     [ Storage: rectangular    ]
                     [ Order: Fortran_order    ]

min(%);

                         0.211006775437672100

max(%%);

                         5.46493561106394666

The positivity condition can be added if necessary to the select as well.

Alec

You can construct a matrix A for your histogram first, and then use

plots:-matrixplot(A, heights=histogram);

For example,

with(Statistics):
X:=Sample(Normal(0,1),1000):
Y:=Sample(Normal(0,1),1000):

h_X:=FrequencyTable(X)[1..,2];

     h_X := [6., 26., 69., 175., 242., 221., 146., 82., 21., 12.]

h_Y:=FrequencyTable(Y)[1..,2];

     h_Y := [4., 18., 67., 140., 231., 231., 174., 89., 35., 11.]

A:=Matrix(10,(i,j)->h_X[i]*h_Y[j]):

plots:-matrixplot(A,heights=histogram);

Or, if the values of X and Y with the same index are related,

m_X:=min(X);
r_X:=Range(X)/10;
m_Y:=min(Y);
r_Y:=Range(Y)/10;
A:=Matrix(10):

for i to 1000 do
A[min(trunc((X[i]-m_X)/r_X),9)+1,min(trunc((Y[i]-m_Y)/r_Y),9)+1]:=
A[min(trunc((X[i]-m_X)/r_X),9)+1,min(trunc((Y[i]-m_Y)/r_Y),9)+1]+1
od:

plots:-matrixplot(A,heights=histogram);

Alec

It should be sin((2*n-1)*x) instead of sin(2*n-1)*x.

It can be plotted as usual.

f := 4/Pi*sum(sin((2*n-1)*x)/(2*n-1),n=1..infinity);

plot(f);

Alec

A normal way of using piecewise would be

f:=(x,y)->piecewise(And(x=0,y=0),0,x*y/(x^2+y^2));

Alec

First 34 35 36 37 38 39 40 Last Page 36 of 76