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

You would sort the polynomial, with the ascending optional argument:
P := 12412315 + 1235234*X^2 + 32454*X^3 + 2400*X^4 + 24525434*X^5 + 23412452*X;
sort( P );
sort( P, X, ascending );
Note that it is necessary to insert the variable, X, when sorting a polynomial. 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 believe the only problem is your use of brackets. Square brackets are used for lists and squiggly brackets are used for sets. Only parentheses can be used for grouping in mathematical expressions. In your definitions for tc and U, you used square brackets to delimit some of the nested expressions. Once I replaced all of the square brackets with parentheses, a nice plot was obtained. I found this by accident. I looked at the full definition of Tw and just happened to notice that it contained square brackets. Then, I had to find where the square brackets were used in the definition of Tw. Once I replaced [ ] with ( ), all was fine. I hope this helps, 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/
Without more information, it is impossible to see what causes the error. The error message indicates that Maple found an index that was not appropriate. Maybe something negative, or zero? Or, if you gave explicit sizes to your matrices (arrays?), maybe you had an index that was too large. (I would expect a different error message in this case; what version of Maple are you using?) Without seeing exactly how you created everything that goes into the one line of code that you showed I can't say much more. You can do some debugging of your code by breaking it into several pieces and seeing exactly which part of the expression causes the problem. For example:
q1 := w*(1/(M[k,k]))*(add(M[k,j]*u[i][j],j=1..5);
q2 := e*b[k]+add(T[k,j]*p[j],j=1..5);
q3 := add(M[k,j]*u[i+1][j],j=1..k-1);
q4 := add(M[k,j]*u[i][j],j=1..k-1));
u[i+1][k]:=u[i][k]-q1+q2-q3+q4;
As I worked on the above I did make a few observations. First, the term q2 does not involve the solution, u; it is a constant (for each k). Second, I see no reference to u[0] even though you mention this in your posting. Is it possible you have changed the name of something? Third, the most likely sources of problems are going to be q3 and q4. What is the first value of k? It would be best if you posted your full worksheet. 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/
What do you expect for a plot? Infinity isn't even a real number. If you an ampproximation, you could try reassigning the value of infinity to some reasonable value. Try the following:
> W := piecewise( x=0, 1, infinity );          # define well function
> plot( W, x=-10..10 );                        # initial plot
> Wf := eval( W, infinity=10 );                # make infinity finite
> plot( Wf, x=-10..10 );
> plot( Wf, x=-10..10, sample=[-10,0,10] );
> plot( Wf, x=-10..10, sample=[-10,0,10], axes=framed );
> plot( Wf, x=-10..10, sample=[-10,0,10], axes=framed, style=point );
The sample option provides an initial set of points that Maple will use to construct the plot. This is used here to ensure the special point is included in set of points used to construct the plot. The axes option allows better visibility of the points on the axes. The style=point option shows exactly which points are used. This shows how Maple's adaptive point selection algorithm. I note that discont=true does NOT work in this case. For even more possibilities for customizing your plot, look at the online help for plot,options (?plot,options). I hope this is helping, 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/
Take a look at the worksheet at View 178_FunWithPolys1.mw on MapleNet or Download 178_FunWithPolys1.mw
View file details This might be 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/
João, You were close, but you were making this harder than it needed to be. Let me comment about the maplet code posted below. 1. I added a FORMULACAO procedure just to have something in its place to generat the model equation. 2. The button accepts a single action to take place when pressed. To have multiple steps executed with a single button press, you can either create an action or create a separate procedure to be executed when the button is pressed. 3. Here, this is unnecesary as the only action to take place when the button is pressed is to typeset the model equation. The code below is somewhat simpler than the original. Fewer global variables; fewer local variables. I believe that's about all that I changed. You will need to replace the FORMULACAO procedure with something that creates the desired model equation. Good luck! Doug
with(Maplets[Elements]):
Cond:=module()
  option package;
  local maplet, FORMULACAO;
  export Model;
  global deptemp;
  use Maplets[Elements] in
    FORMULACAO := proc(a,b)
      a+b
    end proc:

    maplet := Maplet([
      [
       "Time Dependence: ",
       ComboBox['CoB1']("stationary",
                        sort(["stationary","transient"], lexorder))
      ],
      [
       "Coordinate System: ",
       ComboBox['CoB2']("cartesiano",
                        sort(["cartesiano","cilindrico","esferico"], lexorder))
      ],
      [
       "Models: ",
       ComboBox['CoB3']("COND_C",
                        sort(["COND_C","ALETAS","FIBRAS"], lexorder))
      ],
      [
       "Domains: ",
       ComboBox['CoB4']("1", sort(["1","2","3","4"], lexorder))
      ],
      [BoxCell("Model Equation:")],
      MathMLViewer[MMLV1](),
      [Button("Model Eq.",Evaluate('MMLV1'=FORMULACAO(CoB2,CoB3)))
      ], #procedure that takes the action
      [Button("OK", Shutdown(['CoB2','CoB3','CoB4'])),
       Button("Cancel", Shutdown())
      ]
    ]
  ):
  end use;
  Model:=proc()
    local result;
    result:=Maplets[Display](maplet);
  end proc;
end module:
Cond[Model]();
---------------------------------------------------------------------
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/
Let me start by stating that I really dislike document mode. I'll guess you are working in document mode. I am working in worksheet mode. The exact same keystrokes give different results in the two modes.
plot( sin(x), x=0...1 );
Gives a plot on [0,1] in worksheet mode and a plot on [0,0.1] in document mode. So, I now believe you when you said you saw only the third quadrant of the plot. BUT, this is a bug. According to the Maple documenation (cited previously) three consecutive dots should have been treated as a range indicator. I am still perplexed by the way your ellipsis was displayed in your initial posting. Copy the lines from your original post:
with(DEtools):
desgn := diff(y(x),x)=-x/y
DEplot(desgn,y(x),x=-10…10,y=-10…10);
There is only one character between the -10 and the 10. In conclusion:
  • Todd: please accept my apologies for the hasty comments in my previous post
  • Maple: please work to eliminate the incorrect treatment of documented Maple syntax in document mode.
---------------------------------------------------------------------
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, I recommend using the LinearAlgebra package (assuming you are using a new enough version of Maple). Here is how I would approach your problem:
restart;
with( LinearAlgebra ):
C := Matrix( [[a,b,c],[d,e,f],[g,h,i]] ):
K := RowOperation( C, [1, 2], 1 ):
Determinant( C );
         a e i - a f h + d h c - d b i + g b f - g e c
Determinant( K );
         a e i - a f h + d h c - d b i + g b f - g e c
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/
Nasos, I do not have the time to fully understand your problem, but I can tell you how to combine a 2d and a 3d plot. You need to use the transform command from the plottools package. For example, to plot a 2d curve in the xy-plane in 3-space, define: to3d := plottools:-transform( (x,y)->[x,y,0] ); Then, if p1 is a 3d plot and p2 is a 2d plot, you can create a combined plot as follows: plots:-display( [p1,to3d(p2)] ); The online help for transform (?plottools,transform) has some additional examples and information. I hope you can see how to generalize this to your situation. 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 should have thought about this: 2d Math Notation vs. Maple Notation and document vs. worksheet. Personally, I work in worksheet mode with Maple notation for input. I do not know how to convert a worksheet from 2D math to Maple notation. If you working in document mode, this could easily present additional complications. There should be some tools for this, but they are likely to not preserve any formatting that you have done. Do you know about the showstat command? This provides a pretty-printed version of a procedure. I would hope it would also apply to a module. You could then copy and paste this to a text file. If you do this, you would have to delete the line numbers. A decent text editor should make this not too difficult. 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/
Ivan, For complete information about the Maplesoft Beta Program, visit http://beta.maplesoft.com/betafaq.html. 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/
Have you tried to copy the contents of your worksheet to a text file? Remove all output from the worksheet. Select all. Copy. Open an empty text document. Paste. Save the text document as mymodule.mpl. This should preserve the formatting that you have already entered. Depending on how you entered the commands, it might be necessary to remove the prompts (>) from the beginning of each line. This should be a simple search and replace in a reasonable text editor (e.g., emacs or TextPad). 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/
Your problem, as you have described it, does not involve implicit differentiation, at least not in the classical sense. As suggested by J. Tarr, you need to show the explicit dependence on t. Then, just use diff. For example:
> F1 := Pi*(0.5)^2*x(t)+Pi/3*(y(t)/2)^2*y(t)=Pi/3;
> dF1 := diff( F1, t );

The result is an expression that involves y, dx/dt, and dy/dt. You indicate that you want to solve of dy/dt manually. If you want Maple to do this, you could use

> isolate( dF1, diff(y(t),t) );
If you really want an implicit differentiation problem from your example, they you use the implicitdiff command to find dy/dx (note: not dy/dt!) as follows:
> implicitdiff( F, y, x );
I hope all of 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/
Dai Kiri, I am involved in a project to develop Maplets for Calculus in multiple languages. Phil Yasskin (at Texas A&M) and I have written about 70 maplets for calculus. For the past year we have been working with the WebALT project (based at Univ. of Helsinki) to see if we can put together a convenient way to make these maplets available in other languages. The demo site is currently password protected. If you are interested, I can probably grant short-term access to see what we are doing. What language(s) are you interested in? The maplets in Maplets for Calculus are, in our opinion, much better, more educational, more diverse, ... than the built-in maplets included with Maple. Phil and I will be talking about some of our work at the upcoming Joint Math Meetings in New Orleans in early January. If you happen to be planning to attend, please let me know and we can sit down to talk. I look forward to hearing from you and seeing if our work will be useful for you. Doug P.S. The offers in this message apply to others besides the original poster. I welcome any inquiries to this work.
---------------------------------------------------------------------
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 two things missing from your example. The GSeidel procedure produces a plot during each iteration but nothing happens with this plot until the procedure terminates. At that point the only thing returned is the last plot. You need to collect each iteration and return the composite plot. Second, the Plotter element needs to be setup to handle an animation. I have cut-and-pasted the example from Maple's online help for Maplets,Elements,Plotter. It could be made to look a little better, but it is certainly functional and shows the basic ideas needed to implement what you want. Both changes are in the code that I show below (which I have reformatted a little to better show the structure). There are much more efficient ways to encode Gauss-Seidel iterative solvers but that would be the subject of another thread.
restart;with(linalg):with(stats[statplots]):with(plots):with(CurveFitting):
GSeidel:=proc(a, prec, nmax)
  local n, xnew, i, j, k, m, erro, soma, P:
  global xold,x,y,R2,R3,h,X,Y,vetor,xix,z,p,vetor_erro,vetor_iterada,R4,R5:
  P := NULL:
  n:=rowdim(a):
  xold:=vector(n,1):
  xnew:=vector(n,1):
  erro:=1:
  vetor_erro:=vector(nmax);
  vetor_erro:=0;
  vetor_iterada:=vector(nmax);
  vetor_iterada:=0;
  for j from 1 to nmax do
    x:=vector(j);
    y:=vector(j);
    xix:=vector(nmax);
    vetor:=vector(n);
    if erro > prec then
      #Calculando vetor xnew para iterada j
      for i from 1 to n do
        soma:=0:
        for k from 1 to n do
          if i<>k then soma:=soma+a[i,k]*xnew[k]: fi
        od:
        xnew[i]:=(a[i,n+1]-evalf(soma))/a[i,i]:
      od:
      for z from 1 to j do
        xix[z]:=erro;
      od:
      for p from 1 to j do
        y[p]:=y[j];
      od:
      vetor_erro[j]:=erro;
      vetor_iterada[j]:=j;
      R2 := convert(xix,'list');
      R3 := convert(y,'list');
    else break
    fi:
    for k from 1 to n do
      erro:=0:
      m:=abs(xnew[k]-xold[k]):
      if erro < m then erro:=m: fi:
      xold[k]:=xnew[k]:
    od:
    R4 := convert(vetor_erro,'list');
    R5:= convert(vetor_iterada,'list');
    p:=plots[display]({scatterplot(R4,R5)},view = [0..10, 0..10],axes=frame);
    P := P, p;
  od:
  return plots[display]( [P], insequence=true );
end:
A := linalg[matrix](3,4,[1,2,0,4,5/2,6,2,0,5,2,9,1]);
with(Maplets[Elements]):
maplet2d := Maplet([
[Button("Plot", Evaluate('P' = 'GSeidel(A,0.0001,20)') ),
 Button("OK", Shutdown())]
#,Plotter['PL1']( plot(undefined, x = 0..10,y=0..10) )
,Plotter[P](plot(undefined, x = 0..10,y=0..10), continuous=false),
        [ Button("play",SetOption(P('play')=true)),
          Button("stop",SetOption(P('`stop`')=true)),
          Button("pause",SetOption(P('pause')=true)) ],
        [ Button("to start",SetOption(P('to_start')=true)),
          Button("to end",SetOption(P('to_end')=true)) ],
        [ Button("backwards",SetOption(P('frame_backwards')=true)),
          Button("forward",SetOption(P('frame_forward')=true)) ],
        [ "continuous",
          CheckBox[CONTINUOUS](value=false,
                onchange=SetOption(target=P, `option`='continuous',
                                Argument(CONTINUOUS))) ],
        [ "delay",
          Slider[DELAY](100..500, 200,
                onchange=SetOption(target=P, `option`='delay', Argument(DELAY))) ]

]):
Maplets[Display](maplet2d);
I hope you find this 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/
First 38 39 40 41 42 43 44 Page 40 of 44