Alec Mihailovs

Dr. Aleksandrs Mihailovs

4455 Reputation

21 Badges

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

Also, that can be done as
Student:-Calculus1:-TaylorApproximation(
  100+sin(w+1)^3 , w = 1, order = 1..2);

Student:-Calculus1:-TaylorApproximation(
  100+sin(w+1)^3 , w = 1, order = 1..2, output=plot);
__________ Alec Mihailovs http://mihailovs.com/Alec/
Here is an example,
Calc:=proc()
  local t;
  global m,Timer;
  uses Maplets, Maplets:-Elements;
    Timer:=proc() 
      t:=iolib(25);
      while iolib(25)-t<3 do od end;
    m:=Maplet(
      'onstartup'=Action(RunWindow('Splash'),
        Evaluate(function="Timer"), RunWindow('Main'), 
        CloseWindow('Splash')),      
      Window['Splash']('title'="Welcome",
        [Label(Image(cat(kernelopts(datadir),
           "/help/ImageTools/fjords.jpg")))]),
      Window['Main']('title'="Calculator",
        'width'=640, 'height'=480, []));
    Display(m) end:

Calc();
__________ Alec Mihailovs http://mihailovs.com/Alec/
The problem is that in z1 you have = instead of := Correcting that, your first command gives
add(add(add(x*y+y*z+z*x+a,x=x1),y=y1),z=z1);

                            54675 + 729 a
How many a's do you need? I don't exactly understand what you would like to get. __________ Alec Mihailovs http://mihailovs.com/Alec/
Well, you might try to find approximate values of k from animations. Start from something like
plots[animate](plot,[h3d(x,k),x=0..40],k=3..9,frames=600);
When you click on the plot, you'll see the play and stop buttons. Finding an approximate value of k where the change happens, you might do another animation, similar to the animation above, just with different values of x (a smaller interval around the important value of x) and k (also close to the guessed value). That could be repeated few times to make values of k more precise. Doing that, you will hopefully understand what happens with values of diff(h3d(x,k),x) and diff(h3d(x,k),x,x) in the second case and what happens with (which) derivatives in the first case. After that, fsolve can be used to find more precise approximations of k and x,
fsolve({diff(h3d(x,k),x),diff(h3d(x,k),x,x)},{x=0..40,k=3..9});

                  {k = 7.400440850, x = 32.71182263}

fsolve({diff(h3d(x,k),x,x),diff(h3d(x,k),x,x,x)},{x=0..40,k=3..9});

                  {k = 4.486645552, x = 28.44231572}
__________ Alec Mihailovs http://mihailovs.com/Alec/
For example,
plots[display](plottools[rectangle]([0,1],[1,0],color=red));
__________ Alec Mihailovs http://mihailovs.com/Alec/
A lot of things are wrong.
  1. There is no declaration of local (or global) variables.
  2. die should be assigned to rand outside of the loop.
  3. There is no such format code b in printf, and formats a and c would print not what you expected, probably. Reread ?printf .
  4. pabs2 inside if doesn't make sense.
  5. The loop is not closed (it should be either od, or end, or end do at the end of the loop) - or, maybe, the end of the procedure is missing.
  6. There should be a semicolon after the end of the procedure.
  7. a and b are not used in the procedure - instead, m and n are used. I guess, m should be a and n should be b.
A lot of other things can be improved. For example, you could skip from 1 at the beginning of the loop - if it is not mentioned, it starts from 1 automatically. Also, a1 and b1 don't change in the procedure, so there is no sense in assigning them to m and n (or a and b) - m and n (or a and b) can be used instead. __________ Alec Mihailovs http://mihailovs.com/Alec/
New type can be created as
`type/Point`:=x->type(x,list(algebraic)):
For example,
type([1,2,3],Point);
                                 true
type([1,[2,3]],Point);
                                false
PointList constructor can be done as
PointList:=module() export ModuleApply; option package;
  ModuleApply:=proc() local L,n;
    if nargs=0 then error "either a dimension, 
      or a sequence of points should be entered" 
    elif nargs=1 and args::nonnegint then n:=args; L:=NULL 
    elif type([args],list(Point)) then n:=nops(args[1]);
      if andmap(x->nops(x)=n,[args]) then L:=[args] 
      else error "Points should have the same dimension" fi
    else error "correct calls are PointList(n) where n 
      is a nonnegative integer specifying the dimension,
      or PointList(p) where p is a sequence of points" fi;  
    module() export element,elements,length,add;
      option package;
      element:=table(L);
      length:='nops(op(op(element)))';
      elements:='convert(element,list)';
      add:=proc()
        unprotect(element);  
        if nargs=n and type([args],Point) then 
          assign(element[length+1],[args])
        elif type([args],list(Point)) 
          and andmap(x->nops(x)=n,[args]) then
          assign(seq(element[length+1]=args[k],k=1..nargs))
        else error "points should be %1-dimensional", n fi;
        protect(element)
end end end end:
For example,
a:=PointList(2):
a:-add(2,5);
a:-add([1,2],[3,4]);
a:-length;
                                  3
a:-elements;
                       [[2, 5], [1, 2], [3, 4]]
a:-element[2];
                                [1, 2]
b:=PointList([2,5],[1,2],[3,4]):
b:-add(8,9);
b:-elements;
                   [[2, 5], [1, 2], [3, 4], [8, 9]]
This is just an example. PointList lacks many usual list methods. Other examples can be found in ?Stack, ?Queue, and reading PrintProc(SimpleStack); PrintProc(SimpleQueue); PrintProc(MeteredStack); PrintProc(BoundedStack); where PrintProc is the procedure for printing procedures written by Joe Riel. _____________ Alec Mihailovs http://mihailovs.com/Alec/
The formula for the second derivative and the idea how to obtain a formula for the third derivative can be found in ?fdiff (just before examples.) __________ Alec Mihailovs http://mihailovs.com/Alec/
On Unix, LinBox can be used, see Maple-LinBox Package - Project LinBox. __________ Alec Mihailovs http://mihailovs.com/Alec/
It can be done in 2 steps. First, one solution can be obtained by using LPSolve,
Optimization:-LPSolve(3*x+2*y,{3*x+2*y<=18},x=0..4,y=0..5,maximize);

                       [18., [y = 3., x = 4.]]
Now, when we know that the maximum is 18, we can find all solutions using solve,
solve({3*x+2*y=18,0<=x,x<=4,0<=y,y<=5});

                                 3 x
                  {x <= 4, y = - --- + 9, 8/3 <= x}
                                  2
__________ Alec Mihailovs http://mihailovs.com/Alec/
Suppose that a curve is given parametrically, [x(t),y(t),z(t)], then "the number of counterclockwise rotations" around z-axis doesn't depend on z and can be calculated using the formula for the winding number of a plane curve,
f:=(x,y,t,r)->1/2/Pi*int((diff(y,t)*x-y*diff(x,t))/(x^2+y^2),t=r)/(2*Pi);

  f := (x, y, t, r) ->

            /       /                                   \
            | 1    |  diff(y, t) x - y diff(x, t)       |
        1/2 |----  |  --------------------------- dt = r|
            | Pi   |             2    2                 |
            \     /             y  + x                  /
For example, for the spiral [cos(t),sin(t),t/2+3] with t changing from 0 to 10*Pi it equals
f(cos(t),sin(t),t,0..10*Pi);

                                  5
__________ Alec Mihailovs http://mihailovs.com/Alec/
That was discussed earlier in Plotting the Dirac Function thread. It is interesting that my first response there was almost word for word the same as Doug Meade's reply above. Great minds think alike :) __________ Alec Mihailovs http://mihailovs.com/Alec/
One can use the same toolbar in all windows, and switch between windows using it. For example,
with(Maplets:-Elements):

t:=i->ToolBar(
ToolBarButton("Window1",'onclick'=Action(CloseWindow('i'),RunWindow('W1'))),
ToolBarSeparator(),
ToolBarButton("Window2",'onclick'=Action(CloseWindow('i'),RunWindow('W2'))),
ToolBarSeparator(),
ToolBarButton("Window3",'onclick'=Action(CloseWindow('i'),RunWindow('W3')))):

m:=Maplet('onstartup'=RunWindow('W1'), 
Window['W1']('title'="Window1", 'toolbar'=t('W1'),[]),
Window['W2']('title'="Window2", 'toolbar'=t('W2'),[]),
Window['W3']('title'="Window3", 'toolbar'=t('W3'),[])):

Maplets:-Display(m);
Closing Windows is not necessary for running new windows. They could be made invisible if desirable. __________ Alec Mihailovs http://mihailovs.com/Alec/
By the way, a fast way to save all variables (i.e. almost to save the session), is using anames() and anames(environment) in the save command. That provides an unexpected effect in the Document mode though. I had some fun executing anames(); in the Document mode. __________ Alec Mihailovs http://mihailovs.com/Alec/
The following procedure should work,
test:=proc(N::posint,L::list(posint)) local f,n;
f:=proc(K) local k; k:=K;
while lcoeff(k)::even do k:=`if`(tcoeff(k)::even, k/2, (3*k+1)/2) od end;
select(x->lcoeff(f(N*n+x)-N*n-x)::posint,L) end:
For example,
test(16,[3,7,11,15]);
                             [7, 11, 15]
__________ Alec Mihailovs http://mihailovs.com/Alec/
First 65 66 67 68 69 70 71 Last Page 67 of 76