Alec Mihailovs

Dr. Aleksandrs Mihailovs

4495 Reputation

21 Badges

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

Another example,
A:=f->eval(indets(f,function),[cos=(x->x),t=1]):

f:=(2*cos(t)+1.5*cos(3*t)+3*cos(4*t))/Pi:

A(f);
                              {1, 3, 4}
a:=3/4*cos(w1*t+w2*t):

A(a);
                              {w1 + w2}
or
B:=f->map(coeff,map(op,indets(f,function)),t):

B(f);

                              {1, 3, 4}

B(a);

                              {w1 + w2}
__________ Alec Mihailovs http://mihailovs.com/Alec/
Another example,
A:=f->eval(indets(f,function),[cos=(x->x),t=1]):

f:=(2*cos(t)+1.5*cos(3*t)+3*cos(4*t))/Pi:

A(f);
                              {1, 3, 4}
a:=3/4*cos(w1*t+w2*t):

A(a);
                              {w1 + w2}
or
B:=f->map(coeff,map(op,indets(f,function)),t):

B(f);

                              {1, 3, 4}

B(a);

                              {w1 + w2}
__________ Alec Mihailovs http://mihailovs.com/Alec/
In Mathematica, you have to use square brackets for function arguments, Cos[w1 t]/Cos[1]. Extracting w1+w2 from cos(w1*t+w2*t) can be done, for example, as
a:=cos(w1*t+w2*t):
coeff(op(a),t);
                               w1 + w2
__________ Alec Mihailovs http://mihailovs.com/Alec/
In Mathematica, you have to use square brackets for function arguments, Cos[w1 t]/Cos[1]. Extracting w1+w2 from cos(w1*t+w2*t) can be done, for example, as
a:=cos(w1*t+w2*t):
coeff(op(a),t);
                               w1 + w2
__________ Alec Mihailovs http://mihailovs.com/Alec/
Maple and Mathematica are both symbolic and numerical systems, but Matlab's numerics is usually better. Matlab uses Maple kernel in its Symbolic toolbox. If you are a student, it is good to try all of them - student versions are very cheap. Comparing them doesn't have much sense - it is like asking what is better, MS Word, or MS Excel - each of them is good for its own purpose. __________ Alec Mihailovs http://mihailovs.com/Alec/
Maple and Mathematica are both symbolic and numerical systems, but Matlab's numerics is usually better. Matlab uses Maple kernel in its Symbolic toolbox. If you are a student, it is good to try all of them - student versions are very cheap. Comparing them doesn't have much sense - it is like asking what is better, MS Word, or MS Excel - each of them is good for its own purpose. __________ Alec Mihailovs http://mihailovs.com/Alec/
Many people recommend manuals and guides that come with Maple. I've never read them in full, so I can't tell how good they are actually are. Those fragments that I read (mostly in the Advanced Programming guide), were useful. Help pages are often useful, you can type something like ?plot and read a short description of it, with examples, then follow links at the bottom of the page, or at the top in Classic Maple and from the left hand side in Standard Maple. New user's tour (in the Help menu) can be useful. Then, some of tutorials and PowerTools in Maple Application Center can be used for some specific topics, such as Calculus, Abstract Algebra, or Differential Equations. __________ Alec Mihailovs http://mihailovs.com/Alec/
Many people recommend manuals and guides that come with Maple. I've never read them in full, so I can't tell how good they are actually are. Those fragments that I read (mostly in the Advanced Programming guide), were useful. Help pages are often useful, you can type something like ?plot and read a short description of it, with examples, then follow links at the bottom of the page, or at the top in Classic Maple and from the left hand side in Standard Maple. New user's tour (in the Help menu) can be useful. Then, some of tutorials and PowerTools in Maple Application Center can be used for some specific topics, such as Calculus, Abstract Algebra, or Differential Equations. __________ Alec Mihailovs http://mihailovs.com/Alec/
The situation in which you are trying to use that, is not very typical. First, you have function Y of 3 variables, X, θ1, and θ2. Then you are assuming that X, θ1, and θ2 are functions of t, i.e. you have a curve in a 3-dimensional space, and through the values of Y on that curve, we can think of Y as a function of 1 variable t, and we can find the derivative of that function over t. It is Ypr in your notation. Now, what sense has the derivative of Ypr over θ1? One meaning is that Ypr can be considered as a function of 6 variables, X, θ1, θ2, X', θ1', and θ2'. In this case, the partial derivative of Ypr in respect to θ1 can be calculated very carefully using freeze and thaw,
PDEtools[declare]((X,theta)(t),prime=t):
                   
Y:=X(t) + L1*sin(theta[1](t))+ L2*sin(theta[1](t)-theta[2](t));

       Y := X + L1 sin(theta[1]) + L2 sin(theta[1] - theta[2])

Ypr:=diff(Y,t);

                                       '
  Ypr := X' + L1 cos(theta[1]) theta[1]

                                                '           '
         + L2 cos(theta[1] - theta[2]) (theta[1]  - theta[2] )

thaw(diff(
 eval(Ypr,[diff(theta[1](t),t)=freeze(diff(theta[1](t),t)),
  theta[1](t)=freeze(theta[1](t))]),
 freeze(theta[1](t))));

                            '
  -L1 sin(theta[1]) theta[1]

                                                 '           '
         + L2 sin(-theta[1] + theta[2]) (theta[1]  - theta[2] )
__________ Alec Mihailovs http://mihailovs.com/Alec/
op is a sequence of terms, type ?op in Maple for examples. If it used with indexes, such as op(1,a) or op([2,1,2],a), then the corresponding subterms are selected. In the last example,
s:=op(S);

  s := 1.500000000 Dirac(w - 3.), 2. Dirac(w + 1.), 3. Dirac(w + 4.),

        1.500000000 Dirac(w + 3.), 2. Dirac(w - 1.), 3. Dirac(w - 4.)

op(1,s[1]);

                             1.500000000

op([2,1,2],s[1]);

                                 -3.
?map is also useful in this context. __________ Alec Mihailovs http://mihailovs.com/Alec/
op is a sequence of terms, type ?op in Maple for examples. If it used with indexes, such as op(1,a) or op([2,1,2],a), then the corresponding subterms are selected. In the last example,
s:=op(S);

  s := 1.500000000 Dirac(w - 3.), 2. Dirac(w + 1.), 3. Dirac(w + 4.),

        1.500000000 Dirac(w + 3.), 2. Dirac(w - 1.), 3. Dirac(w - 4.)

op(1,s[1]);

                             1.500000000

op([2,1,2],s[1]);

                                 -3.
?map is also useful in this context. __________ Alec Mihailovs http://mihailovs.com/Alec/
From my time measurements, [op(f)] is faster than [op](f), as well as [seq(...)] is faster than [seq](...) . _________ Alec Mihailovs http://mihailovs.com/Alec/
From my time measurements, [op(f)] is faster than [op](f), as well as [seq(...)] is faster than [seq](...) . _________ Alec Mihailovs http://mihailovs.com/Alec/
All terms should be homogeneous for using map. That means that coefficients should be added to every term. In this case, the formula from my earlier post in Plotting the Dirac Function thread, that I cited above, can be used,
f:=(2*cos(t)+1.5*cos(3*t)+3*cos(4*t))/Pi:
S:=inttrans[fourier](f,t,w);

  S := 1.500000000 Dirac(w - 3.) + 2. Dirac(w + 1.)

         + 3. Dirac(w + 4.) + 1.500000000 Dirac(w + 3.)

         + 2. Dirac(w - 1.) + 3. Dirac(w - 4.)

F:=S->map(x->plottools[line]([-op([2,1,2],x),0],[-op([2,1,2],x),op(1,x)]),[op(S)]):

plots[display](F(S),color=blue,
  tickmarks=[[-4="-w3",-3="-w2",-1="-w1",1="w1",3="w2",4="w3"],
    [0=0,1.5=K2,2=K1,3=K3]],
  labels=[`w [Rad/sec]`,Amplitude],view=[-6..6,0..4]);
__________ Alec Mihailovs http://mihailovs.com/Alec/
All terms should be homogeneous for using map. That means that coefficients should be added to every term. In this case, the formula from my earlier post in Plotting the Dirac Function thread, that I cited above, can be used,
f:=(2*cos(t)+1.5*cos(3*t)+3*cos(4*t))/Pi:
S:=inttrans[fourier](f,t,w);

  S := 1.500000000 Dirac(w - 3.) + 2. Dirac(w + 1.)

         + 3. Dirac(w + 4.) + 1.500000000 Dirac(w + 3.)

         + 2. Dirac(w - 1.) + 3. Dirac(w - 4.)

F:=S->map(x->plottools[line]([-op([2,1,2],x),0],[-op([2,1,2],x),op(1,x)]),[op(S)]):

plots[display](F(S),color=blue,
  tickmarks=[[-4="-w3",-3="-w2",-1="-w1",1="w1",3="w2",4="w3"],
    [0=0,1.5=K2,2=K1,3=K3]],
  labels=[`w [Rad/sec]`,Amplitude],view=[-6..6,0..4]);
__________ Alec Mihailovs http://mihailovs.com/Alec/
First 147 148 149 150 151 152 153 Last Page 149 of 180