Alec Mihailovs

Dr. Aleksandrs Mihailovs

4495 Reputation

21 Badges

20 years, 343 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 replies submitted by Alec Mihailovs

if you look at

showstat(`convert/string`);

you'll see that it is the same as sprintf (just with fixed format "%a" that is the most used anyway.)

Alec

If a multiple precision number is written in usual format, as an array of (binary in computer) integers, the bits (i.e. binary digits) can be extracted using 2-3 lines of assembler code (by shifting). Then that can be accessed from Maple as in an example in my old blog post here, Binomial Coefficients mod 2. That, I think, would be the fastest way.

Alec

Also, I have a similarly written (just in Javascript instead of Maple) online Day of the Week Calculator.

Alec

The fastest way in Maple, probably, instead of using digits of Pi or sqrt(2), use

with(Statistics):
X:=RandomVariable(Bernoulli(1/2)):
Sample(X,1000000);

Alec

The web page was updated since I wrote that code, and the code needs to be updated, too. Here is the updated version,

SearchPi:=proc(x) 
local s,a,b;
uses StringTools, Sockets;
s:=Open("www.angio.net",80);
Write(s,cat("GET /pi/bigpi.cgi?UsrQuery=",x," HTTP/1.0\n\n"));
a := "";
		b := Read(s):
		while b <> false do
			a := cat(a,b);
			b := Read(s):
		end do;
Close(s);
s:=parse(Select(IsDigit,a[Search("occurs",a)+19..Search("counting",a)-2]));
if length(s)<16 then s else FAIL fi
end:

As a bonus, I am adding here a similar procedure, using the same web site, for determining the x-th digit after the decimal dot in Pi,

NthDigitOfPi:=proc(x) 
local s,a,b;
uses StringTools, Sockets;
s:=Open("www.angio.net",80);
Write(s,cat("GET /pi/bigpi.cgi?UsrQuery=1&querytype=substr&startpos=",x," HTTP/1.0\n\n"));
a := "";
		b := Read(s):
		while b <> false do
			a := cat(a,b);
			b := Read(s):
		end do;
Close(s);
s:=parse(a[Search("string",a)+12])
end:

For example,

NthDigitOfPi(1);
                                  1

Alec

Fantastic!

It looks as if all combstruct could be improved this way?

Alec

PS I remember times (70s, in Russia), when writing 2 lines of code per day (average) was considered being a very good performance :)

That's a very good explanation. Thank you!

Alec

That also explains crashes. They happened not because the arrays were large, as I thought, but because I executed AddAlongDimension (A,2) and Maple tried to add more rows than the Matrix had.

Alec

Actually, that not that bad as using 100% of CPU. People with Maple on their computers using 100% of CPU might consider you being lucky :)

Plus, you could run 2 copies of Maple at the same time, taking 50% of CPU each if you would like that.

By the way, it may be just known counter issue in Win XP SP2 when 100% load on dual core shows as 50%-50%, see this article. I think it was fixed in SP3 (that is available now for download from Windows Update.)

Alec

Actually, that not that bad as using 100% of CPU. People with Maple on their computers using 100% of CPU might consider you being lucky :)

Plus, you could run 2 copies of Maple at the same time, taking 50% of CPU each if you would like that.

By the way, it may be just known counter issue in Win XP SP2 when 100% load on dual core shows as 50%-50%, see this article. I think it was fixed in SP3 (that is available now for download from Windows Update.)

Alec

I wonder why it was done this way, with introducing a new environment variable OMP_NUM_THREADS. Wouldn't it be more simle just to use standard Windows environment variable NUMBER_OF_PROCESSORS that is already set to the correct value by Windows?

Alec

That's a very interesting link. Thank you for giving it. I read it once, very briefly, and then forgot about that. Unfortunately, I access Maple remotely and I don't have administrator priveleges there, so I can't set environmental variables to try it out.

Alec

That's a very interesting link. Thank you for giving it. I read it once, very briefly, and then forgot about that. Unfortunately, I access Maple remotely and I don't have administrator priveleges there, so I can't set environmental variables to try it out.

Alec

dy/dx = (dy/dt) / (dx/dt)

The trajectories can be plotted using contourplot. Something like

contourplot((y-2*x)^3*(y+2*x),x=-5..5,y=-5..5,
contours=[-1000,-100,-10,-1,-0.1,0.1,1,10,100,1000],numpoints=10000);

Both together they can be plotted as something like

a:=plot3d((y-2*x)^3*(y+2*x),x=-5..5,y=-5..5,style=patchnogrid):
b:=contourplot3d((y-2*x)^3*(y+2*x),x=-5..5,y=-5..5,color=blue,
contours=[-100,-10,0,10,100],numpoints=10000):
display(a,b,axes=boxed);

Alec

dy/dx = (dy/dt) / (dx/dt)

The trajectories can be plotted using contourplot. Something like

contourplot((y-2*x)^3*(y+2*x),x=-5..5,y=-5..5,
contours=[-1000,-100,-10,-1,-0.1,0.1,1,10,100,1000],numpoints=10000);

Both together they can be plotted as something like

a:=plot3d((y-2*x)^3*(y+2*x),x=-5..5,y=-5..5,style=patchnogrid):
b:=contourplot3d((y-2*x)^3*(y+2*x),x=-5..5,y=-5..5,color=blue,
contours=[-100,-10,0,10,100],numpoints=10000):
display(a,b,axes=boxed);

Alec

First 125 126 127 128 129 130 131 Last Page 127 of 180