Alec Mihailovs

Dr. Aleksandrs Mihailovs

4455 Reputation

21 Badges

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

It is already implemented in Mathematica.

Alec

Yes, for gmp numbers either g or StringTools:-IsPalindrome should be used. I got about the same timings for them,

N := (10^100000+1)^2:

time(g(N));
                                0.078

time(StringTools:-IsPalindrome(""||N));

                                0.078

Even implemented properly, f would be slower, probably, because of a lot of division operations.

Personally, I would use StringTools:-IsPalindrome. The OP, probably, didn't realize that such a procedure exists in Maple.

Alec

If you really want that, you could use a textplot command, and also manually plot lines and symbols for the legend, in the way you like, with or without the surrounding box.

Alec

You miss parentheses around -1. It should be (-1). Also, it is better to replace  ^ and * for mod operations with &^ and &* correspondingly. So your inverse could be entered either as 1/a mod p, or (better) as a&^(-1) mod p.

Alec

libname:="F:/Program Files/Maple 10/Syrup", libname;

Alec

There are 2 ways of doing that - using Statistics package (slow), and without it (fast).

First, using Statistics package.

Start with defining our function z(n) as the number of zeros in the representation of n as a 10-bit binary number (possibly including starting zeros),

z:=n->numboccur(0,convert(n+1024,base,2)):

Now, the probability function can be obtained by dividing the number of IP addresses corresponding to n, by the total number of IP addresses, which is 2^32,

p:=3^z/2^20:

The PDF then (for a continuous distribution) can be defined as

f:=x->add(p(n)*Dirac(x-n),n=0..1023):

Now, plot the CDF (wait for a while while it is plotting),

with(Statistics):
X:=RandomVariable(Distribution(PDF=f)):
plot(CDF(X,n),n=0..1023);

Now, the moments - I assume that you mean the mean and the standard deviation,

Mean(X);
                                1023/4
evalf(%);
                             255.7500000
StandardDeviation(X);
                                     1/2
                              5 41943
                              ----------
                                  4
evalf(%);
                             255.9998779

The second way, without the Statistics package, can be done as

DynamicSystems:-DiscretePlot([$0..1023],
    ListTools:-PartialSums(['p(n)'$n=0..1023]), 
    style=stair);

m:=add(p(n)*n,n=0..1023);
                             m := 1023/4

s:=sqrt(add(p(n)*(n-m)^2,n=0..1023));
                                       1/2
                                5 41943
                           s := ----------
                                    4

Alec

A usual way of writing an exponent is exp(0.5*x-1). That doesn't help with solve though.

Also, it would be easier (less typing) to use expressions for f and g instead of functions,

f:=0.5*x^4-3*x^3-x^2+x+10;
g:=x*exp(0.5*x-1);
plot([f,g], x=-4..8);
fsolve(f=g);
...

Alec

Perhaps, instead of sparce matrices, one can use procedures with either option remember, or with cache. Since there is no matrix operations, the using of matrices seems to be not necessary.

Alec

Arrays can be entered as parameters. The ?Compiler:-Compile help page has some examples. In this case that can be done as

M3 := proc(x::float[8],A::Array(datatype=float[8])) 
A[1,1]:=x^2;
A[1,2]:=x;
A[2,1]:=1;
A[2,2]:=x;
NULL
end;

cm2:=Compiler:-Compile(M3);

M:=Matrix(2,2,datatype=float[8]);

cm2(0.1,M);
M;

           [0.0100000000000000020    0.100000000000000004]
           [                                             ]
           [         1.              0.100000000000000004]

Alec

If you tried exactly that code that I posted, and it didn't work, that means that you are using an older Maple version than I. In this case, 1.. should be replaced with either 1..-1 or 1..4

If that won't help, then you could assign p, q, f, and a one by one, avoiding the multiple assignment, i.e. write something like

p:=P[i];
q;=Q[i];
f:=F[i];
a:=A[i];

instead of p,q,f,a:=...

Alec

Also, that can be done using style=stem in DynamicSystems:-DiscretePlot,

DynamicSystems:-DiscretePlot(
    [$1..9],[3,1,4,1,5,9,2,6,5],style=stem);

Points are not centered at the stems, but I think that that was already reported as a bug (in a different situation.)

Alec

For example,

d := diff(int(abs(x), x = cos(t) .. sin(t)), t);

plot(d, t = 0 .. 2*Pi, axes = boxed);

plots:-display(
    seq(plot(abs, sin(t) .. cos(t), 
        filled, color = blue, 
        title = sprintf("t = %.2f, d = %.2f", t, d)), 
        t = evalf([$0 .. 50]*Pi/200)),
    seq(plot(abs, cos(t) .. sin(t), 
        filled, 
        title = sprintf("t = %.2f, d = %.2f", t, d)),
        t = evalf([$51 .. 250]*Pi/200)),   
    seq(plot(abs, sin(t) .. cos(t), 
        filled, color = blue, 
        title = sprintf("t = %.2f, d = %.2f", t, d)),    
        t = evalf([$251 .. 399]*Pi/200)), 
    insequence = true, scaling = constrained):

Alec

bmeps does a good work for producing transparency effects in eps. See, for example, here and here. So you could try, for example, export to jpg (if that supports transparency - I didn't check), and then use bmeps to produce an eps.

It may be not well known only because most people use either pdf, or png for transparency (both unavailable in Maple).

Postscript is pretty much outdated nowadays. Everybody (except Maple) is using svg for vector graphics, and svg has a native transparency support.

Alec

See that recent thread, for example.

Alec

For example,

e:=POINTS([.6735015928, -.6914808110, .2612468034]) 

op(e);
             [.6735015928, -.6914808110, .2612468034] 

ex,ey,ez:=%[];

       ex, ey, ez := .6735015928, -.6914808110, .2612468034

Also, you could use Student:-LinearAlgebra:-RotationMatrix command. Note however that it rotates in the opposite direction than the rotate command from plottools. 

Alec

First 37 38 39 40 41 42 43 Last Page 39 of 76