Doug Meade

 

Doug

---------------------------------------------------------------------
Douglas B. Meade <><
Math, USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
Phone: (803) 777-6183 URL: http://www.math.sc.edu

MaplePrimes Activity


These are replies submitted by Doug Meade

Or, just use the dchange command in the PDEtools package (the replacement for the dchangevar command in DEtools):

ODE := diff(f(x,y),x$2) + diff(f(x,y),x) + diff(f(x,y),y);
             / d  / d         \\   / d         \   / d         \
             |--- |--- f(x, y)|| + |--- f(x, y)| + |--- f(x, y)|
             \ dx \ dx        //   \ dx        /   \ dy        /
dchange( {x=xi*x0, y=zeta*z0}, ODE, [xi,zeta] );
          d   / d                      \    d                      
         ---- |---- f(xi, zeta, x0, z0)|   ---- f(xi, zeta, x0, z0)
          dxi \ dxi                    /    dxi                    
         ------------------------------- + ------------------------
                         2                            x0           
                       x0                                          

                d                       
              ------ f(xi, zeta, x0, z0)
               dzeta                    
            + --------------------------
                          z0            

Note that you have to express the original variables in terms of the new variables, not the other way around.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

Here's an enhancement of the maplet from your message. When you click Show, this maplet displays, to the GUI, each city that you select, then removes that city from the list. Select another city and click Show again to see what happens. The Reset button can be used to reset your list, but it does not move the default selection to the first city in the list. (This can probably be done, but I've not re-read the help document for DropDownBox to see the exact syntax to do this.

The onclick action for a button can take an Action, which can be a Maple command or a call to a Maple proc (my preference). You can also specify an action to be executed before the maplet starts.

So, without further delay, here's my code:

restart;
with(Maplets[Elements]):
Reset := proc()
  global L, n;
  L := ["Waterloo", "Ottawa", "Victoria", "Edmonton", "Regina",
        "Winnipeg", "Toronto", "Quebec City", "Fredericton",
        "Halifax", "Charlottetown", "St. John\'s", "Whitehorse",
        "Yellowknife", "Iqaluit"] :
  Maplets:-Tools:-Set('D1'(itemlist)=L);
  n := 1;
end proc:
ShowIt := proc()
  global L, n;
  local city;
  if not assigned('n') then Reset() end if;
  city := Maplets:-Tools:-Get('D1');
  print( nprintf("My # %a favorite Canadian city is %s.", n, city ) );
  L := remove( `=`, L, city );
  Maplets:-Tools:-Set( 'D1'(itemlist) = remove(`=`,L,city) );
  n := n+1;
end proc:
maplet := Maplet(
 onstartup=Action( Evaluate(function='Reset'),
                   RunWindow('Main') ),
 Window['Main']([
  ["Pick your favorite Canadian city:  ", DropDownBox[D1](L[1], L)],
  [Button("OK", Shutdown(['D1'])),
   Button("Show", onclick='AShowIt'),
   Button("Reset", onclick='AReset'),
   Button("Cancel", Shutdown())]
 ]),
 Action['AReset']( Evaluate(function='Reset') ),
 Action['AShowIt']( Evaluate(function='ShowIt') )
):
Maplets[Display](maplet);

 

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

Here's an enhancement of the maplet from your message. When you click Show, this maplet displays, to the GUI, each city that you select, then removes that city from the list. Select another city and click Show again to see what happens. The Reset button can be used to reset your list, but it does not move the default selection to the first city in the list. (This can probably be done, but I've not re-read the help document for DropDownBox to see the exact syntax to do this.

The onclick action for a button can take an Action, which can be a Maple command or a call to a Maple proc (my preference). You can also specify an action to be executed before the maplet starts.

So, without further delay, here's my code:

restart;
with(Maplets[Elements]):
Reset := proc()
  global L, n;
  L := ["Waterloo", "Ottawa", "Victoria", "Edmonton", "Regina",
        "Winnipeg", "Toronto", "Quebec City", "Fredericton",
        "Halifax", "Charlottetown", "St. John\'s", "Whitehorse",
        "Yellowknife", "Iqaluit"] :
  Maplets:-Tools:-Set('D1'(itemlist)=L);
  n := 1;
end proc:
ShowIt := proc()
  global L, n;
  local city;
  if not assigned('n') then Reset() end if;
  city := Maplets:-Tools:-Get('D1');
  print( nprintf("My # %a favorite Canadian city is %s.", n, city ) );
  L := remove( `=`, L, city );
  Maplets:-Tools:-Set( 'D1'(itemlist) = remove(`=`,L,city) );
  n := n+1;
end proc:
maplet := Maplet(
 onstartup=Action( Evaluate(function='Reset'),
                   RunWindow('Main') ),
 Window['Main']([
  ["Pick your favorite Canadian city:  ", DropDownBox[D1](L[1], L)],
  [Button("OK", Shutdown(['D1'])),
   Button("Show", onclick='AShowIt'),
   Button("Reset", onclick='AReset'),
   Button("Cancel", Shutdown())]
 ]),
 Action['AReset']( Evaluate(function='Reset') ),
 Action['AShowIt']( Evaluate(function='ShowIt') )
):
Maplets[Display](maplet);

 

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

These requests sound very much as though they are from a homework assignment.

The "solutions" that we could suggest depend on the exact context of these questions. What course are you taking? How have you used Maple before in this course?

Exactly what are you calling a "built-in procedure"? I can see a context in which I would classify element selection  using square brackets, e.g., A[1], as using a built-in procedure.

Have you been given any guidance about what commands you are allowed to use?If not, how are the other students in the course going about getting this information. What similar examples have you done before, or been given as part of the course?

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

These requests sound very much as though they are from a homework assignment.

The "solutions" that we could suggest depend on the exact context of these questions. What course are you taking? How have you used Maple before in this course?

Exactly what are you calling a "built-in procedure"? I can see a context in which I would classify element selection  using square brackets, e.g., A[1], as using a built-in procedure.

Have you been given any guidance about what commands you are allowed to use?If not, how are the other students in the course going about getting this information. What similar examples have you done before, or been given as part of the course?

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

Sounds like you are trying to find the intervals on which a function is increasing and the intervals where it is decreasing. If so, this is a concept question and not a Maple question.

What do you learn when you find the points where the derivative is zero? How can you use this to determine where the function is increasing or decreasing?

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

Sounds like you are trying to find the intervals on which a function is increasing and the intervals where it is decreasing. If so, this is a concept question and not a Maple question.

What do you learn when you find the points where the derivative is zero? How can you use this to determine where the function is increasing or decreasing?

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

You should be able to do this through the mapleinit file. See ?worksheet,reference,initialization for the platform-specific details.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

You should be able to do this through the mapleinit file. See ?worksheet,reference,initialization for the platform-specific details.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

Or, are you supposed to find these from the eigenvalues and eigenvectors of A? There are very nice relationships between the eigen* of A and those of the powers of A. Look at almost any linear algebra book and you should find what you need.

Of course, if you just want to form A^5 and let Maple do the work, the previous post gives you what you need to know.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

Or, are you supposed to find these from the eigenvalues and eigenvectors of A? There are very nice relationships between the eigen* of A and those of the powers of A. Look at almost any linear algebra book and you should find what you need.

Of course, if you just want to form A^5 and let Maple do the work, the previous post gives you what you need to know.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

Like this?

X := a*cos(t);
                                  a cos(t)
Y := b*sin(t);
                                  b sin(t)
L := Int( sqrt(diff(X,t)^2+diff(Y,t)^2), t=0..2*Pi );
                    /2 Pi                          (1/2)   
                   |      / 2       2    2       2\        
                   |      \a  sin(t)  + b  cos(t) /      dt
                   |                                       
                  /0                                       
value( L ) assuming positive;
                                  /          (1/2)\  
                                  |/  2    2\     |  
                                  |\-b  + a /     |  
                       4 EllipticE|---------------| a
                                  \       a       /  

As pointed out by others, there is no elementary closed form for the perimeter of an ellipse. But, in the case when a=b, we can see that this reduces to what we expect:

eval( %, a=b );
                                   2 Pi b

This approach will work for any parametric curve, just replace the definitions of X and Y and adjust the interval in the integral.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

 

Like this?

X := a*cos(t);
                                  a cos(t)
Y := b*sin(t);
                                  b sin(t)
L := Int( sqrt(diff(X,t)^2+diff(Y,t)^2), t=0..2*Pi );
                    /2 Pi                          (1/2)   
                   |      / 2       2    2       2\        
                   |      \a  sin(t)  + b  cos(t) /      dt
                   |                                       
                  /0                                       
value( L ) assuming positive;
                                  /          (1/2)\  
                                  |/  2    2\     |  
                                  |\-b  + a /     |  
                       4 EllipticE|---------------| a
                                  \       a       /  

As pointed out by others, there is no elementary closed form for the perimeter of an ellipse. But, in the case when a=b, we can see that this reduces to what we expect:

eval( %, a=b );
                                   2 Pi b

This approach will work for any parametric curve, just replace the definitions of X and Y and adjust the interval in the integral.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

 

Acer has identified the real issue here:

If you are only going to evaluate this using specific values for n_0, n_P, and n_max then perhaps you could rewrite it as a procedure which uses add instead of sum/Sum. That could let the simple result compute easily, and avoid the hypergeom. Or, are you hoping to manipulate the symbolic sums?

Most mathematicians are instantly drawn to the sum command but this is appropriate only if you are intending to work with a symbolic sum,  including infinite sums. If we read the online help we would see that there is a significant distinction between sum and add, and that for many uses add is the preferrable command to be using.

Here's a simple implementation of your calculation as a proc, using add:

MyCount := proc( n_0, n_P, n_max )
  local D_n, N2, N;
  D_n := n_max+1-n_0;
  N2:=u -> add((2*u2-D_n)!/(u2!*(u2-D_n)!),u2=D_n..min(u,n_max-1));
  N:=add((n_0-2+u)!/(u!*(n_0-2)!)-piecewise(u<D_n,0,N2(u)),u=0..n_P-2);
end proc:

The only complication is that N2 needs to be defined as a proc since it does not have a definite value for u to use to evaluate the sum.

MyCount( 3, 4, 4 );
                                      5

If you call MyCount with non-numeric arguments, it will spit back an error. You could add type checking to the definition of MyCount, as follows:

MyCount := proc( n_0::posint, n_P::posint, n_max::posint )

I hope this is helpful.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

Acer has identified the real issue here:

If you are only going to evaluate this using specific values for n_0, n_P, and n_max then perhaps you could rewrite it as a procedure which uses add instead of sum/Sum. That could let the simple result compute easily, and avoid the hypergeom. Or, are you hoping to manipulate the symbolic sums?

Most mathematicians are instantly drawn to the sum command but this is appropriate only if you are intending to work with a symbolic sum,  including infinite sums. If we read the online help we would see that there is a significant distinction between sum and add, and that for many uses add is the preferrable command to be using.

Here's a simple implementation of your calculation as a proc, using add:

MyCount := proc( n_0, n_P, n_max )
  local D_n, N2, N;
  D_n := n_max+1-n_0;
  N2:=u -> add((2*u2-D_n)!/(u2!*(u2-D_n)!),u2=D_n..min(u,n_max-1));
  N:=add((n_0-2+u)!/(u!*(n_0-2)!)-piecewise(u<D_n,0,N2(u)),u=0..n_P-2);
end proc:

The only complication is that N2 needs to be defined as a proc since it does not have a definite value for u to use to evaluate the sum.

MyCount( 3, 4, 4 );
                                      5

If you call MyCount with non-numeric arguments, it will spit back an error. You could add type checking to the definition of MyCount, as follows:

MyCount := proc( n_0::posint, n_P::posint, n_max::posint )

I hope this is helpful.

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu
First 26 27 28 29 30 31 32 Last Page 28 of 76