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 answers submitted by Doug Meade

Jean, One way to do this is with printf (formatted printing). The syntax closely parallels that for C. For the case you give in your original post, here is what I would suggest:
for i from 1 to 10 do
  printf( "%3d %3d %5.3f\n", i, i^2, i^(1/3) );
end do;
  1   1 1.000
  2   4 1.260
  3   9 1.442
  4  16 1.587
  5  25 1.710
  6  36 1.817
  7  49 1.913
  8  64 2.000
  9  81 2.080
 10 100 2.154
Note that this only generates output. There is no matrix of results. This makes this more efficient than your method, but not if you want to have the matrix of values for other purposes. See the online help ?printf for complete details about printf and the different formatting options that are supported. With fprintf you can print results directly to a file. sprintf and nprintf produce strings and names, respectively. 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/~meade/
Brian, First, let me apologize for misreading your original message. The question as you have refined it does not have a unique solution. What should be returned for arctan( -1 )? Do you want arctan( -1, 1 ) or arctan( 1, -1 )? Even positive arguments cause problems: arctan( 1 ) = arctan( 1, 1 ) and arctan( 1 ) = arctan( -1, -1 ). What do you know about the arguments to arctan? Are they always numeric? Are they always a fraction? Depending on your answers to the above, it's still possible to use patmatch to come close to what you are describing.
> y := arctan(11,15);
                                         /11\
                              y := arctan|--|
                                         \15/
> patmatch( y, arctan(AB::rational), 's' );
                                    true
> s;
                                  [     11]
                                  [AB = --]
                                  [     15]
> [numer,denom]( eval( AB, s ) )[];
                                   11, 15
> arctan( [numer,denom]( eval( AB, s ) )[] );
                                       /11\
                                 arctan|--|
                                       \15/

> 'arctan'( [numer,denom]( eval( AB, s ) )[] );
                               arctan(11, 15)
Unfortunately, Maple will automatically convert the two argument arctan to a one argument arctan. The above works only when the argument to arctan is a numerical fraction. This idea could be modified for arguments of a different form. I hope this gives you some (useful) ideas. 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/~meade/
Here's an approach to this problem that does not use any op's.
restart;
y := A+B*arctan(x);
                            y := A + B arctan(x)
patmatch( y, a::anything+b::anything*arctan(x), 's' );
                                    true
s;
                               [b = B, a = A]
assign( s );
a,b;
                                    A, B
unassign( 'a', 'b' );
a,b;
                                    a, b
y2 := (x^2+3)+sin(x)*cos(x)*arctan(x);
                          2                              
                    y2 = x  + 3 + sin(x) cos(x) arctan(x)
patmatch( y2, a::anything+b::anything*arctan(x), 's' );
                                    true
s;
                       [                            2]
                       [b = sin(x) cos(x), a = 3 + x ]
assign( s );
a,b;
                                 2               
                            3 + x , sin(x) cos(x)


Note that if you do assign values to the names used in the patmatch command then you will need to unassign them before they can be used in another patmatch. You can get much fancier with the arguments to patmatch, if you so choose. See the online help for complete details. Does this fit your needs? 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/~meade/
Here's one way to do this. Define a new procedure with just one argument:
Q_opt1 := unapply( Q_opt(x,0,0.6), x );
Then, plot this univariate procedure:
plot( Q_opt1, 0.5..0.59, axes=BOXED );
Without knowing more details about your situation it's not possible to be 100% confident this will work, but it should get you closer. You might need to modify your definition of Q_opt so that it returns unevaluated when the arguments are not numeric. There should be examples of this elsewhere on MaplePrimes (or the web). It's too late for me to give the details here. If this is still unresolved by the morning, I'll fill in these 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/~meade/
S.V., I'm glad my previous response was useful. Let's see what I can do with your newest question. First, there appears to be a mismatched single quote. After adding a single quote before doublederivcov, here is what I get from Maple 11 for add, sum, and Sum:
restart;
addRiemann:=Array(1..4,1..4,1..4,1..4,(i,j,k,m)->add(add(''eta''[A,B]*('doublederivcov'(Z(X[])[A],Chris(X[]),i,k)*'doublederivcov'(Z(X[])[B],Chris(X[]),j,m) -'doublederivcov'(Z(X[])[A],Chris(X[]),j,k)*'doublederivcov'(Z(X[])[B],Chris(X[]),i,m)),A=1..6),B=1..6)):
sumRiemann:=Array(1..4,1..4,1..4,1..4,(i,j,k,m)->sum(sum(''eta''[A,B]*('doublederivcov'(Z(X[])[A],Chris(X[]),i,k)*'doublederivcov'(Z(X[])[B],Chris(X[]),j,m) -'doublederivcov'(Z(X[])[A],Chris(X[]),j,k)*'doublederivcov'(Z(X[])[B],Chris(X[]),i,m)),A=1..6),B=1..6)):
SumRiemann:=Array(1..4,1..4,1..4,1..4,(i,j,k,m)->Sum(Sum(''eta''[A,B]*('doublederivcov'(Z(X[])[A],Chris(X[]),i,k)*'doublederivcov'(Z(X[])[B],Chris(X[]),j,m) -'doublederivcov'(Z(X[])[A],Chris(X[]),j,k)*'doublederivcov'(Z(X[])[B],Chris(X[]),i,m)),A=1..6),B=1..6)):
addRiemann[1,1,1..4,1..4]; convert(%,listlist);
                           Array(%id = 164471836)
          [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
sumRiemann[1,1,1..4,1..4]; convert(%,listlist);
                           Array(%id = 164517788)
          [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
SumRiemann[1,1,1..4,1..4]; convert(%,listlist);
                           Array(%id = 164580792)
  [[  6   /  6    \    6   /  6    \    6   /  6    \    6   /  6    \]  
  [[----- |-----  |  ----- |-----  |  ----- |-----  |  ----- |-----  |]  
  [[ \    | \     |   \    | \     |   \    | \     |   \    | \     |]  
  [[  )   |  )    |    )   |  )    |    )   |  )    |    )   |  )    |]  
  [[ /    | /    0|,  /    | /    0|,  /    | /    0|,  /    | /    0|], 
  [[----- |-----  |  ----- |-----  |  ----- |-----  |  ----- |-----  |]  
  [[B = 1 \A = 1  /  B = 1 \A = 1  /  B = 1 \A = 1  /  B = 1 \A = 1  /]  

    [  6   /  6    \    6   /  6    \    6   /  6    \    6   /  6    \]  
    [----- |-----  |  ----- |-----  |  ----- |-----  |  ----- |-----  |]  
    [ \    | \     |   \    | \     |   \    | \     |   \    | \     |]  
    [  )   |  )    |    )   |  )    |    )   |  )    |    )   |  )    |]  
    [ /    | /    0|,  /    | /    0|,  /    | /    0|,  /    | /    0|], 
    [----- |-----  |  ----- |-----  |  ----- |-----  |  ----- |-----  |]  
    [B = 1 \A = 1  /  B = 1 \A = 1  /  B = 1 \A = 1  /  B = 1 \A = 1  /]  

    [  6   /  6    \    6   /  6    \    6   /  6    \    6   /  6    \]  
    [----- |-----  |  ----- |-----  |  ----- |-----  |  ----- |-----  |]  
    [ \    | \     |   \    | \     |   \    | \     |   \    | \     |]  
    [  )   |  )    |    )   |  )    |    )   |  )    |    )   |  )    |]  
    [ /    | /    0|,  /    | /    0|,  /    | /    0|,  /    | /    0|], 
    [----- |-----  |  ----- |-----  |  ----- |-----  |  ----- |-----  |]  
    [B = 1 \A = 1  /  B = 1 \A = 1  /  B = 1 \A = 1  /  B = 1 \A = 1  /]  

    [  6   /  6    \    6   /  6    \    6   /  6    \    6   /  6    \]]
    [----- |-----  |  ----- |-----  |  ----- |-----  |  ----- |-----  |]]
    [ \    | \     |   \    | \     |   \    | \     |   \    | \     |]]
    [  )   |  )    |    )   |  )    |    )   |  )    |    )   |  )    |]]
    [ /    | /    0|,  /    | /    0|,  /    | /    0|,  /    | /    0|]]
    [----- |-----  |  ----- |-----  |  ----- |-----  |  ----- |-----  |]]
    [B = 1 \A = 1  /  B = 1 \A = 1  /  B = 1 \A = 1  /  B = 1 \A = 1  /]]
value( SumRiemann[1,1,1..4,1..4] ); convert(%,listlist);
                           Array(%id = 149420696)
          [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
Because it is not possible to copy the "Array" contents from the worksheet to another application without losing the contents (WYSInotWYG), I have uploaded the worksheet to MaplePrimes. You can access it from the following links:
View 178_RiemannTensor.mw on MapleNet or Download 178_RiemannTensor.mw
View file details So, I do not see any problem with any of the three forms for constructing this tensor. Of course, I do not have your definitions for doublederivcov, Chris, X, Z, ... so my results are not very interesting. In general, because you have a fixed finite sum, I would think that you would want to use add. You should be using sum only if you think the individual terms involved will include expressions that could benefit from a summation formula. Only after the specifics of this problem are known can I make a final suggestion about this. 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/~meade/
I understand your sentiments. I remember when I first learned this "trick". While it is not at all intuitive (until you know about it), it does make sense. Suppose Maple's response from dsolve was to make assignments. That means that all future references to y would be referring to the solution to this ODE. While that does not seem completely unreasonable, you would not be able to do any further analysis on the equation. You could not use the ODE as input to the DEplot command (to create a plot of a direction field, or solution curves). If the ODE were nonlinear, you could not linearize the equation and compare solutions between the nonlinear and linear equations. Or, suppose you were interested in another function expressed in terms of the solutions (and independent variables). For example, continuing from my previous post:
> eval( y(x)^2+u(x)^2, soln2 );
                                    2                            2
           (_C1 sin(x) + _C2 cos(x))  + (_C1 cos(x) - _C2 sin(x)) 
> simplify( % );
                                    2      2
                                 _C1  + _C2 
Of course, as my previous post indicates, the user can choose to make this assignment, but it's not the default. I know I found that the more I thought about a problem mathematically, the more sense I saw in Maple's output. In this case, the solution to an equation is an equation and the solution to a system of equations is a set of equations. With experience, this way of thinking can become second-nature. 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/~meade/
Matt, dsolve returns an equation showing the solution to the ODE. You still need to assign this to a name (and do a little more processing to get this to be a Maple function). Let me illustrate with your example:
> eqn := diff( y(x),x ) + c^2*y(x)=0;
                          / d      \    2         
                  eqn :=  |--- y(x)| + c  y(x) = 0
                          \ dx     /              
> soln := dsolve( eqn, y(x) );
                                             /  2  \
                     soln :=   y(x) = _C1 exp\-c  x/
> Y := unapply( rhs(soln), x );
                                        /  2  \
                       Y := x -> _C1 exp\-c  x/
> Y(3);
                                      /    2\
                               _C1 exp\-3 c /
If you have a system of ODEs, dsolve returns a set of equations. In such situations you will also need to be sure you get the correct part of the solution assigned to the appropriate name. For example,
> sys := [ diff( y(x), x ) = u(x), diff( u(x), x ) = -y(x) ];
                        [ d                d              ]
             sys :=     [--- y(x) = u(x), --- u(x) = -y(x)]
                        [ dx               dx             ]
> soln2 := dsolve( sys, {y(x),u(x)} );
   soln2 := {y(x) = _C1 sin(x) + _C2 cos(x), u(x) = _C1 cos(x) - _C2 sin(x)}
> Y := unapply( eval(y(x),soln2), x );
> U := unapply( eval(u(x),soln2), x );
                Y := x -> _C1 sin(x) + _C2 cos(x)
                U := x -> _C1 cos(x) - _C2 sin(x)
> Y(0);
> U(0);
                                     _C2
                                     _C1
I hope this answers your question, and furthers your Maple understanding, 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/~meade/
One way to do make this type of assignment is with the assign command. The argument to assign needs to be an equation, or a list or set of equations. There are many ways to construct the equations. You can use a loop (or seq) but I like to promote the zip command. The first argument of zip is a mapping from elements of two different lists/sets/arrays.
> restart;
> Ecce:=array(1..2,[x,y]);
                              Ecce := [ x y ]
> ZERO:=array(1..2,[0,0]);
                              ZERO := [ 0 0 ]
> eqs := zip( (n,v)->n=v, Ecce, ZERO );
                          eqs := [ x = 0  y = 0 ]
> zip( (n,v)->assign(n=v), Ecce, ZERO ):
> 'x'=x,'y'=y;
                                x = 0, y = 0
Note that the output from the first zip is an array (there is no comma between the elements). If we were working with lists, we could work as follows:
> unassign( 'x', 'y' );
> eqs := zip( (n,v)->n=v, convert(Ecce,list), convert(ZERO,list) );
                               [x = 0, y = 0]
> assign( eqs );
> 'x'=x,'y'=y;
                                x = 0, y = 0
Note the comman between the elements in eqs. Also, it was necessary to unassign the previous assignments before we could repeat this step. An alternate here would have been to use restart to completely erase everything. I hope this is instructive, 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/~meade/
Jean, Something is not right in what you posted. Your code generates one random number, then repeats the same maximization 10 times. In spite of this, I believe I can give you some information to help you plot the data that you will eventually generate. And, this maximization is over a set that does not intersect the domain of the objective function. Both x and y need to be positive and the constraint x+y=0 forces one of the variables to be negative (or both are zero). I believe Maximize is getting confused due to Maple's definition of logarithms for negative real numbers. Still, the output does not seem like it is appropriate:
Warning, no iterations performed as initial point satisfies first-order conditions
                    [-Float(infinity), [x = 0., y = 0.]]
Back to your question about how to plot the data generated. You can collect a list of data [x,y,z], if you modify your code as follows:
restart:
with(stats):
with(Optimization):stats[random, normald](1);
PTS := array( 1..10 ):
for i from 1 to 10 do
  z:= Maximize(1/3*ln(x)+1/3*ln(y), {x+y=0,y>=0});
  PTS[i] := [rhs(z[2,1]),rhs(z[2,2]),z[1]];
end do;
print( PTS );
If it turns out it's better to have the data as a list of vectors or as a matrix, this can be done in a similar manner. You can then perform the necessary data analysis on PTS and generate the plots you desire. One last suggestion. I think you will find the Statistics package more useful to use than the stats package. I hope something in here is useful to you. 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/~meade/
Rick, I will guess that your calculator is in degree mode. Maple works with radians. Here is one way in which you could compute the sine of 26 degrees in Maple.
xD := 26*degrees;
xR := convert( xD, radians );
s  := sin( xR );
evalf( s );
Note that it is necessary to multiply the angle (in degrees) by degrees. This is Maple's way of writing the little circle to indicate degrees. Notice that Maple's value for the sine is exact. The evalf is needed to force Maple to compute a floating point number. The six trigonometric functions are
sin( xR ); evalf( % );
cos( xR ); evalf( % );
tan( xR ); evalf( % );
sec( xR ); evalf( % );
csc( xR ); evalf( % );
cot( xR ); evalf( % );
The inverse functions are formed by putting the three letters "arc" as a prefix (with no spaces) to the trig function:
yR := arccos( s );
yD := convert( yR, degrees );
You could define new functions that automatically convert the angles to degrees. Instead, I would encourage you to start to think in terms of radians. This is the way angles are described in calculus and other areas of mathematics. You should also look at the online help for more information. To get started, I suggest looking at:
?convert,radians
?convert,degrees
?sin
?arcsin
I hope this has been helpful.
---------------------------------------------------------------------
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/~meade/
With the spacing in the original posting I wonder if the problem could be that the "end proc" is in a different execution group? Even then, I would not expect the error message to be "unterminated procedure". So, maybe this isn't it. Before making more unfounded attempts at solutions, maybe I should ask for more information: Are you working in a worksheet? Or, are you writing a text file and feeding it to command-line Maple? Or, are you working in a document? 1D or 2D input? To close, here is how I might write this procedure:
func:=proc( eta_f, eta_s, eta_w, eta_int, omega, G, u0 ,a::posint, b::posint )
  local n, Arand, A;
  uses LinearAlgebra;
  n:=a+b:
  Arand:=RandomMatrix(n,n):
  A:= Arand-Arand:
end proc;
debug( func );
func( [1,2,3,4,5,6,7][], 2, 3 );
func( [1,2,3,4,5,6,7][], 0, 3 );
Note the use of the uses command to load LinearAlgebra only within this procedure. Note also the modified calling sequence, with some type-checking. I show these only to give you some ideas about what is possible. If there is any chance the argments will not always have this format I suggest you look at defining the procedure with no formal arguments and using nargs and args to process the arguments within the body of the procedure. STOP THE PRESSES! As I was getting ready to tell you to look at the online help for args and nargs I discovered that in Maple 11 these have been changed to _passed and _npassed (but that args and nargs do still work, for backward compatibility). See ?parameter for more complete details. This looks interesting. I'll have to read more about this and start to take advantage of these new features. Enough rambling. If you can provide some more details about your specific situation I'm confident we can help you to work through the problems you are experiencing. 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/~meade/
There are several issues involved in this question. I do not have complete answers but hope this will help you get started and, maybe, others will add to this discussion. The first problem is that Maple assumes all variables are, by default, complex-valued. You are probably expecting mu, sigma (and V) to be real-valued. Also, the result you expect is not true for ANY function V. You know what types of functions you are thinking about, but Maple's rules for manipulating this integral and limit do not allow for any shortcuts. Let's start with a specific example:
MyFunc1:=(t,sigma,mu)->int(V(t)*1/2*2^(1/2)/Pi^(1/2)/sigma*exp(-1/2*(t-mu)^2/sigma^2), t=-infinity..+infinity);
value( MyFunc1(t,sigma,mu) );        # no simplifications possible for general V
V := t -> exp(t*x);
GF := value( MyFunc1(t,sigma,mu) );  # moment generating function
The last result involves csgn, which is a strong reminder that Maple is assuming all parameters are complex-valued. Here,
limit( GF, sigma=0 );         # no simplification in complex limit
limit( GF, sigma=0, right );  # implicitly declares sigma to be real
So, under appropriate circumstances Maple is able to come up with an answer that is consistent with your expected result. I hope this gives you some ideas about how to proceed to get a more general result that you appear to be seeking. 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/~meade/
Pat, Here is how I would work with your problem. Since Maple automatically simplifies expressions, you have to take care to give it objects that it cannot simplify. In this case, we will convert the numerical values to "names" and then use the names in the calculations. Here is how I would do this for your case:
   aaN,ccN,BRadN := map(convert,[aa,cc,BRad],name)[];
   b2N1:=sqrt(aaN^2+ccN^2-2*aaN*ccN*cos(BRadN));
If only it were this simple. This works, but only uses space to indicate the multiplication of aa and cc. If you are OK with this, great. If not, then you will probably want to do something like the following:
   b2N2:=sqrt(aaN^2+ccN^2-2*`(`*aaN*`) (`*ccN*`) `*cos(BRadN)); 
The following definition of your SetParms procedure uses both of these ideas. Note also that I made a slight modification to Robert's presentation of your results. If only the elements of the vector could be left justified (not centered), and the delimiting parentheses removed, this would look great.
SetParms:=proc()
   local aa,bb,cc,AA,BB,CC,BRad,b1,b2,b3,Sideb, aaN,ccN,BRadN,b2N1,b2N2;  
   aa:=14.2; BB:=115; BRad:=(Pi/180)*BB; cc:=16.2; AA:=0; CC:=0; bb=0;
   aaN,ccN,BRadN := map(convert,[aa,cc,BRad],name)[];
   b1:=sqrt(a^2+c^2-2*a*c*cos(B));
   b2N1:=sqrt(aaN^2+ccN^2-2*aaN*ccN*cos(BRadN));
   b2N2:=sqrt(aaN^2+ccN^2-2*`(`*aaN*`) (`*ccN*`) `*cos(BRadN)); 
   b3:=evalf(sqrt(aa^2+cc^2-2*aa*cc*cos(BRad)));  
   Set(AaBc=MathML[Export](< (b=b1),
                             (``=b2N1),
                             (``=b2N2),
                             (``=b3) >) );
end proc: 
I hope this is useful, 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/~meade/
First of all, Maple cannot "think". The sooner users realize this, the sooner they learn to think carefully about the instructions (commands) they enter. Let's look at the expressions from the recent posts in this forum:
(x-2)(2x+3);     # no space between the two terms
(x-2) (2x+3);    # space between the two terms
Mathematically, we EXPECT this to be the product of two terms. However, Maple has several uses for parentheses. In the first case, with no space between the terms, the second set of parentheses are the delimiters for the function (x-2). This means that Maple uses linearity of function evaluation and the definition of a constant function, i.e., 2(anything)=2, to interpret the first expression as follows:
(x-2)(2x+3) = x(2x+3) - 2(2x+3) = x(2x+3) - 2
There is not much Maple can do with the first term, x(2x+3); it's the value of the unspecified function x evaluated at the 2x+3. The second form is interpreted correctly - as 2D input - because the presence of the space changes the basic form from function evaluation to multiplication. Notice that the implied multiplication between a constant and a name does not require a space but the implied multiplication. These nuances can be confusing to users - new or experienced. This is one reason why I prefer to NEVER use implied multiplication - ALWAYS use the * (using either 1D or 2D input). The next example has even more serious problems. While I expect most of these problems are simply errors in entering the expression in the MaplePrimes composition window, they do point share some of the challenges of the original examples.
int( x(x+1) ) / x^4, x = 1 .. 2 );  # extra spaces added for clarity
First, note that the parentheses are not balanced. I believe the real problem of interest is
int( x(x+1)/x^4, x = 1 .. 2 );
The numerator of the integrand is interpreted (by Maple) as a function evaluation, not as a product. One suggestion I give to my students using Maple to evaluate integrals is to enter the integral as an "inert" integral:
Int( x(x+1)/x^4, x = 1 .. 2 );
% = value( % );
Here you get an initial hint that Maple's interpretation of the input is not what the user expects. Compare this with
Int( x (x+1)/x^4, x = 1 .. 2 );
% = value( % );
The final example shows how the syntax, not the visual appearance, carries mathematical meaning.
sec^2 x;      # product of square of secant function and x
sec^2(x);     # square of the secant function
sec(x)^2;     # square of value of secant function
(sec^2)(x);   # square of value of secant function
The new feature introduced here is the algebra of functions. Even though most mathematical typesetting uses something that looks like one of the first two versions, neither of these carries the intended mathematical meaning. Since most new users (and students) tend to be more comfortable working with expressions and values of functions, I tend to use the third line. I hope something in here has been enlightening to someone who reads it. 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/~meade/
You are off to a decent start. It appears that you are executing these commands in a worksheet (or document). At some point, you should probably put them into a procedure, but that's not necessary at this point. What is necessary is that the matrix (array) A and the integer n have to have specific values BEFORE starting the loop. From your post, this is not clear. Unless you KNOW that all matrix entries are postive, starting a_max at 0 is not a good choice. (You can just as easily start with -infinity, or -1.) If the matrix is all zeroes, you will never set p or q, and the interchange loop will not be able to determine if k<p. (This is the source of the final error message you report.) In general, work one step at a time. First, locate the entry with the largest value (in absolute value). Check that this works flawlessly before going on to the next step. If you need more help, show us some improvements and someone will likely provide more assistance. Good luck, 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/~meade/
First 35 36 37 38 39 40 41 Page 37 of 44