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 ExtremePoints are too complicated, one can use minimize and maximize. For example,

f:=3*x^4-4*x^3:
(minimize,maximize)(f,x=-1..2,location);

               -1, {[{x = 1}, -1]}, 16, {[{x = 2}, 16]}

But that may be erroneous in cases with several local minimums and maximums (as well as ExtremePoints). So it is always a good idea to look at the plot at least.

Alec

Student:-Calculus1:-ExtremePoints(3*x^4 - 4*x^3,-1..2);

                              [-1, 1, 2]

However, that answer is wrong if you need global extrema. The function has a minimum at x=1 and a maximum at x=2 on this interval, which can be found by evaluating

map(x->3*x^4-4*x^3,%);

                             [7, -1, 16]

Alec

As it stated, the problem doesn't have sense. However, for, say, cryptography purposes, that can be done using the conversion I described above,

k:=GF(2,4);
                                       4
                     k := Z[2] [T] / <T  + T + 1>

alias(a=RootOf(_Z^4+_Z+1));
                                  a

f:=p->eval(maptype(`+`,m->`if`(type(op(1,m mod 16),integer),
applyop(k:-ConvertOut@k:-input,1,m mod 16),m mod 16),p),
k:-variable=a):

Groebner:-Basis(map(f,[x^2-2*x*z+5, x*y^2+y*z^3, 3*y^2-8*z^3]),
plex(x,y,z),characteristic=2);

         3   3     2    3   8    9
  [(1 + a ) z  + (a  + a ) z  + z ,

           3    7  3         3    2       8            5
        y z  + z  a  + (a + a  + a  + 1) z  + (a + 1) z ,

         2         3   3
        y  + (1 + a ) z ,

           3            7     2        3   8     2       5
        x z  + (a + 1) z  + (a  + 1 + a ) z  + (a  + a) z ,

         2     3    2             2
        x  + (a  + a  + a) x z + a  + 1]

mods(eval(%,a=2),16);

       3      8    9     3      7    8      5   2      3
  [-7 z  - 4 z  + z , y z  + 8 z  - z  + 3 z , y  - 7 z ,

           3      7      8      5   2
        x z  + 3 z  - 3 z  + 6 z , x  - 2 x z + 5]

Groebner:-Basis(map(f,{x^2+2*y, x^3+5}),
plex(x,y),characteristic=2);
                       2    3    3            3   2
                 [1 + a  + a  + y , x + (a + a ) y ]

mods(eval(%,a=2),16);
                                3         2
                         [-3 + y , x - 6 y ]

Now, putting all things together, a procedure for the Groebner basis over the finite field with 2^n elements,

GB := proc (L::{set, list}, n::posint := 1) 
    local k, m, a, Z, f, p, Le;
    Le:=expand(L) mod 2^n; 
    k := GF(2,n); 
    a := RootOf(eval(k:-ConvertOut(k:-extension),
        k:-variable = Z)); 
    f := p -> eval(maptype(`+`,
        m -> `if`(type(op(1,m),integer),
        applyop(`@`(k:-ConvertOut,k:-input),1,m),
        m),p),
        k:-variable = a); 
    mods(eval(Groebner:-Basis(map(f,Le),
        plex(op(indets(Le))),
        characteristic = 2),
        a = 2),2^n) 
end proc:

In the examples above it works as

GB([x^2-2*x*z+5, x*y^2+y*z^3, 3*y^2-8*z^3],4);

       3      8    9     3      7    8      5   2      3
  [-7 z  - 4 z  + z , y z  + 8 z  - z  + 3 z , y  - 7 z ,

           3      7      8      5   2
        x z  + 3 z  - 3 z  + 6 z , x  - 2 x z + 5]

GB({x^2+2*y, x^3+5},4);

                                3         2
                         [-3 + y , x - 6 y ]

Alec

As it stated, the problem doesn't have sense. However, for, say, cryptography purposes, that can be done using the conversion I described above,

k:=GF(2,4);
                                       4
                     k := Z[2] [T] / <T  + T + 1>

alias(a=RootOf(_Z^4+_Z+1));
                                  a

f:=p->eval(maptype(`+`,m->`if`(type(op(1,m mod 16),integer),
applyop(k:-ConvertOut@k:-input,1,m mod 16),m mod 16),p),
k:-variable=a):

Groebner:-Basis(map(f,[x^2-2*x*z+5, x*y^2+y*z^3, 3*y^2-8*z^3]),
plex(x,y,z),characteristic=2);

         3   3     2    3   8    9
  [(1 + a ) z  + (a  + a ) z  + z ,

           3    7  3         3    2       8            5
        y z  + z  a  + (a + a  + a  + 1) z  + (a + 1) z ,

         2         3   3
        y  + (1 + a ) z ,

           3            7     2        3   8     2       5
        x z  + (a + 1) z  + (a  + 1 + a ) z  + (a  + a) z ,

         2     3    2             2
        x  + (a  + a  + a) x z + a  + 1]

mods(eval(%,a=2),16);

       3      8    9     3      7    8      5   2      3
  [-7 z  - 4 z  + z , y z  + 8 z  - z  + 3 z , y  - 7 z ,

           3      7      8      5   2
        x z  + 3 z  - 3 z  + 6 z , x  - 2 x z + 5]

Groebner:-Basis(map(f,{x^2+2*y, x^3+5}),
plex(x,y),characteristic=2);
                       2    3    3            3   2
                 [1 + a  + a  + y , x + (a + a ) y ]

mods(eval(%,a=2),16);
                                3         2
                         [-3 + y , x - 6 y ]

Now, putting all things together, a procedure for the Groebner basis over the finite field with 2^n elements,

GB := proc (L::{set, list}, n::posint := 1) 
    local k, m, a, Z, f, p, Le;
    Le:=expand(L) mod 2^n; 
    k := GF(2,n); 
    a := RootOf(eval(k:-ConvertOut(k:-extension),
        k:-variable = Z)); 
    f := p -> eval(maptype(`+`,
        m -> `if`(type(op(1,m),integer),
        applyop(`@`(k:-ConvertOut,k:-input),1,m),
        m),p),
        k:-variable = a); 
    mods(eval(Groebner:-Basis(map(f,Le),
        plex(op(indets(Le))),
        characteristic = 2),
        a = 2),2^n) 
end proc:

In the examples above it works as

GB([x^2-2*x*z+5, x*y^2+y*z^3, 3*y^2-8*z^3],4);

       3      8    9     3      7    8      5   2      3
  [-7 z  - 4 z  + z , y z  + 8 z  - z  + 3 z , y  - 7 z ,

           3      7      8      5   2
        x z  + 3 z  - 3 z  + 6 z , x  - 2 x z + 5]

GB({x^2+2*y, x^3+5},4);

                                3         2
                         [-3 + y , x - 6 y ]

Alec

The conversion can be done as follows,

k:=GF(2,4);
                                       4
                     k := Z[2] [T] / <T  + T + 1>

f:=p->maptype(`+`,m->`if`(type(op(1,m mod 16),integer),
applyop(k:-ConvertOut@k:-input,1,m mod 16),m mod 16),p);

f(5*x^2+3*y^2);
                         2       2            2
                       (T  + 1) x  + (T + 1) y

f(5*x^2-3*y^2);
                      2       2     3    2       2
                    (T  + 1) x  + (T  + T  + 1) y

Alec

The conversion can be done as follows,

k:=GF(2,4);
                                       4
                     k := Z[2] [T] / <T  + T + 1>

f:=p->maptype(`+`,m->`if`(type(op(1,m mod 16),integer),
applyop(k:-ConvertOut@k:-input,1,m mod 16),m mod 16),p);

f(5*x^2+3*y^2);
                         2       2            2
                       (T  + 1) x  + (T + 1) y

f(5*x^2-3*y^2);
                      2       2     3    2       2
                    (T  + 1) x  + (T  + T  + 1) y

Alec

Roman,

Thank you!

I thought that that may be the case, but wasn't sure. That, probably, is mentioned somewhere on the help pages - I didn't read them detaily.

Alec

Roman,

Thank you!

I thought that that may be the case, but wasn't sure. That, probably, is mentioned somewhere on the help pages - I didn't read them detaily.

Alec

Two workarounds. First, use Int instead of int,

evalf(Int(x*sin(Pi*x)*sin(3.141592653*x),x=0..1));
                             0.2500000000

Second, use evalf with more digits,

evalf[30](int(x*sin(Pi*x)*sin(3.141592653*x),x=0..1));

                   0.250000000046937858615676775405

Alec

That's what usually happen when people don't provide examples and don't tell what Maple versions they are using. It is the same as to call to a shop and say: "My TV is broken. What is wrong with it?" (The famous continuation of the dialog is: "Is it color TV or black and white?" - "Color - green.")

There are many data types in Maple, and "array" is one of them. It was pretty clear that you don't actually use "arrays", but it wasn't easy to guess what are you actually using and what data type you would like to have as an answer.

Different data types require different solutions. zip works with lists, and vector concatenation works with vectors. What data type you actually have, is still a secret.

Alec

That's what usually happen when people don't provide examples and don't tell what Maple versions they are using. It is the same as to call to a shop and say: "My TV is broken. What is wrong with it?" (The famous continuation of the dialog is: "Is it color TV or black and white?" - "Color - green.")

There are many data types in Maple, and "array" is one of them. It was pretty clear that you don't actually use "arrays", but it wasn't easy to guess what are you actually using and what data type you would like to have as an answer.

Different data types require different solutions. zip works with lists, and vector concatenation works with vectors. What data type you actually have, is still a secret.

Alec

Then you can either do

with(plots):

and then just use implicitplot. Or use it as plots[implicitplot].

Another option is to upgrade your Maple.

Alec

PS In general, it would be great if a few of plots commands were upgraded to the status allowing calling them without using the plots prefix (and without executing with(plots)). In particular, such often used commands as animate, densityplot, display, implicitplot, implicitplot3d, odeplot, spacecurve, textplot, and textplot3d. Some others, perhaps, too, such as contourplot and contourplot3d, but they need some additional work to make them more usable. -Alec

Then you can either do

with(plots):

and then just use implicitplot. Or use it as plots[implicitplot].

Another option is to upgrade your Maple.

Alec

PS In general, it would be great if a few of plots commands were upgraded to the status allowing calling them without using the plots prefix (and without executing with(plots)). In particular, such often used commands as animate, densityplot, display, implicitplot, implicitplot3d, odeplot, spacecurve, textplot, and textplot3d. Some others, perhaps, too, such as contourplot and contourplot3d, but they need some additional work to make them more usable. -Alec

Axel,

The first thing that comes to mind is that many ports of the gsl for windows use cdecl calling convention, while Maple expects stdcall. You, probably, checked that, though. Are other functions working?

The second thought is that the function might call blas, which sometimes is distributed in another dll (libgslblas, perhaps), and that might cause a problem.

When I tried your code in Linux (64-bit Ubuntu 8.10) with the library located at /usr/lib/libgsl.so.0, I got the following interesting responce (after the first command):

[Length of output exceeds limit of 1000000]

However, 3 other commands produced some (expected) results,

                                      4
     Array({}, datatype = float[8], storage = rectangular, order = C_order)
                                      0

But steedArr; after that crashed Maple's kernel.

Slightly correcting the procedure, and entering the Array of an appropriate length (as in acer's post below), produced correct results,

arrB_GSL := define_external('gsl_sf_bessel_jl_steed_array', 
'lmax'::(integer[4]), 
'x'::(float[8]), 
'jl_x_array'::(ARRAY(datatype = float[8])), 
'RETURN'::(integer[4]), 
LIB = "/usr/lib/libgsl.so.0");

nTst := 4; 
steedArr := Array([1, 2, 3, 4, 5], datatype = float[8], order = C_order); 
arrB_GSL(nTst, 1.0, steedArr);

                                      4
                               [1.,2.,3.,4.,5.]
                                      0
steedArr;

         [0.841470984807896505,0.301168678939756795,0.0620350520113738674,
                 0.00900658111711251722,0.00101101580841375270]

I filled the array with non-zero elements just to see if that would make any difference. No, it didn't. The answer can be checked as

seq(evalf((1/2)*sqrt(2*Pi)*BesselJ(n+1/2, 1.0)), n = 0 .. 4);

  0.8414709847, 0.3011686790, 0.06203505201, 0.009006581116, 0.001011015808

It was kinda painful to do that in Standard Maple, but 64-bit Linux doesn't have Classic. I am going to switch to command line from now on.

Alec

Yes, export as gif, and it will be animated.

Alec

First 77 78 79 80 81 82 83 Last Page 79 of 180