Alec Mihailovs

Dr. Aleksandrs Mihailovs

4455 Reputation

21 Badges

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

In some languages, there are procedures proc and functions func(...). Not in Maple. In Maple both functionalites, such as returning only one value (which can be a sequence in Maple) for functions, and changing values of (some) arguments for procedures, are combined in Maple procedures proc(...).

Maple also has modules which have some functionalities of classes in other languages (without interface or inheritance though.)

Alec

In such situations it is easier to use sequences instead of lists,

L:=1,3,6,7;

                           L := 1, 3, 6, 7

L:=L,5;

                          L := 1, 3, 6, 7, 5

If you would like your lists sorted, it is easier to use sets instead,

L:={1,3,6,7};

                          L := {1, 3, 6, 7}

L:=L union {5};

                         L := {1, 3, 5, 6, 7}

Alec

Or

A[..,[1,3,2]];
                            [1    7    4]
                            [           ]
                            [2    8    5]
                            [           ]
                            [3    9    6]

If that doesn't work in Maple 9.5, replacing .. with 1..3 or 1..-1 should work.

Alec

A lot of choices, and it is hard to chose something without trying. Anything on the NEOS list is worth trying - and many of them, if not free, offer a 30 day free trial.

I, perhaps, would start from FortMP and Mosek - but not because they are better than others, but because I had some experience with them earlier.

Alec

In this example, you don't need the optimization package. Just assign all possible combinations of w[1] and w[2], evaluate SR in each case, and choose the values giving maximum of SR.

You can do that in LPSolve, either specify assume=integer, in addition to the constraints, or specifically listing all the variables that have only integer values as integervariables=[w[1],w[2]], or integervariables={w[1],w[2]}.

Alec

A simple workaround for plots with jumps in this thread is to add numpoints=2, adaptive=false to the plot command. That produces plots looking more or less normal,

plot(cos(x)-x, x = -10^(-16) .. 10^(-16), 
    numpoints = 2, adaptive = false)

in Standard and

plot(cos(x)-x, x = -10^(-7) .. 10^(-7), 
    numpoints = 2,adaptive=false);

in Classic.

Alec

If A and B are of the same sign (and not 0), the derivative can not be equal 0. That means that Ax^3+Bx is monotonic. Choosing A+B=60, with both A and B positive, or A+B=-60 with both A and B negative assures that y changes from -60 to 60 for x changing from -1 to 1. There are also other solutions, with A and B being different signs, and possibly 0. For instance, A=60, B=0, or A=0, B=60. So the solution is not unique in the original formulation.

Alec

 

It is also possible to use

MmaTranslator:-Mma:-ReadList("s.txt"); 

It may be not that efficient, but for not very large files that doesn't matter.

Alec

And here are few Classic plots.

Not Ok:

plot(1-x,x=-10^(-7)..10^(-7));

135_Classic7.gif

Also not Ok:

plot(1-x,x=-10^(-6)..10^(-6));

135_Classic6.gif

Finally, (more or less) OK:

plot(1-x,x=-10^(-5)..10^(-5));

135_Classic5.gif

Alec

Since nobody posted plots from Standard, I am doing that here.

First, the plot that looks OK.

plot(x, x = -10^(-16) .. 10^(-16));

135_OK.gif

Second, the plot that doesn't look OK.

plot(1+x, x = -10^(-16) .. 10^(-16));

135_NotOK.gif

Alec

Another pearl (in Classic),

Digits:=1000;

plot(1,x=-10^(-16)..10^(-16),scaling=constrained);
Plotting error, plot X-range is too large

Alec

L:=[1,3,5,8,9];
                    
     L := [1, 3, 5, 8, 9]

member(3,L,'k');

                                 true

k;

                                  2

member(9,L,'k');

                                 true

k;

                                  5

Alec

Another solution is to quote the rhs in the Evaluate,

with(Maplets:-Elements):
myMaplet := Maplet(Window(title="Logic Test",
[
["A : ", TextField['A'](5),
 "B : ", TextField['B'](5)],
["A = B?", TextField['TF'](10)],
[Button['EX']("Do", onclick=ACT),
 Button['QT']("Quit", enabled=true, Shutdown())]
]),
Action[ACT](Evaluate('TF'='evalb(A=B)'))
):
Maplets[Display](myMaplet);

Disabling of the quit button can be done the following way,

with(Maplets:-Elements):

g:=proc() uses Maplets:-Tools; 
Set('QT'('enabled')=parse(Get('TF'))) end;

myMaplet := Maplet(Window(title="Logic Test",
[
["A : ", TextField['A'](5),
 "B : ", TextField['B'](5)],
["A = B?", TextField['TF'](10)],
[Button['EX']("Do", onclick=ACT),
 Button['QT']("Quit", enabled=true, Shutdown())]
]),
Action[ACT](Evaluate('TF'='evalb(A=B)'),
 Evaluate('function'="g"))
):

Maplets[Display](myMaplet);

Alec

For example,

convert(trunc(0.008727*60^3),base,60);

                               [25, 31]

Alec

First 24 25 26 27 28 29 30 Last Page 26 of 76