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

I know Robert can address this, but it's pretty clear to me that this is another incidence of < being interpretted as the beginning of an HTML tag. I believe Robert was intending to write: 2) ln(1+x) ≥ x/2 for 0 ≤ x ≤ 1 I will let Robert add more to this if he intended to say more in his response. 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 do not understand. If you assign lists to a, b, and c, then combinat[powerset] gives what you request, right?
a := [1,0,0];
                                  [1, 0, 0]
b := [0,1,0];
                                  [0, 1, 0]
c := [0,0,1];
                                  [0, 0, 1]
combinat[powerset]( {a,b,c} );
{{}, {[0, 0, 1]}, {[1, 0, 0], [0, 1, 0]}, {[0, 1, 0]}, {[0, 0, 1], [0, 1, 0]}, 

  {[1, 0, 0]}, {[0, 0, 1], [1, 0, 0]}, {[0, 0, 1], [1, 0, 0], [0, 1, 0]}}

Or, have I missed something in your question? 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 had forgotten about the maplet builder. I have not used it is the current version of Maple, but when it first appeared it was IMHO useless. I see that you have two choices: write the maplet by hand or use embedded components. Writing the maplet by hand does not necessarily mean starting from scratch. I would find a maplet with a similar layout in the public domain (or the Maple online help) and start from here. This can all be done in a worksheet. Put all of your current programming at the top of the worksheet. Define the maplet at the end (well, it could be defined anywhere). What is important is that the last line of the worksheet is
Maplets[Display](MyMaplet);
where MyMaplet is the name of the maplet defined somewhere in the worksheet with
MyMaplet:=Maplet( ... );
The advantage of this is that if you export the worksheet at a .maplet file it can be launched directly without starting Maple. (The .maplet file is a text file containing all input regions in the worksheet. The .maplet files are then piped to command line Maple. This is what the Maplet Launcher does, it's not a separate executable - except on the Mac, but that's a different story for a different time. Ask if you want to hear it, it has a happy ending.) Based on the limited information in your post, I believe the best way for you to proceed is to use Embedded Components. You can hide all of the background information in a section that is auto-executed when the worksheet is opened. What the user will see is a "table". Insert this with more rows and columns than you expect to need. Individual cells will be resized to fit their contents, or you can merge, e.g., several cells to create a space large enough to hold a plot region. You have to use the Components palette to add elements to the table. To customize each element, right click on the element and select Component Properties. I would not put too much actual code in the component. Instead, I put a simple procedure call in the "action to apply when this element changes" field:
ThisElement_DoIt();
where this procedure is defined similar to:
ThisElement_DoIt := proc()
 local a, ...;
 uses DocumentTools;
 a := GetProperty( MathContainer0, value ); # gets a string, use parse to treat the input as Maple input
 ...
end proc;
The online help for Embedded Components has some decent examples. They will tell you how to put this code directly in the component, but I really recommend what I have suggested. A simple example can be found in the first worksheet that I have uploaded to MaplePrimes (below). The second worksheet is an even earlier version of this worksheet that I prepared for a different MaplePrimes topic last week. That one is similar, but it does not use the external proc as I have explained (and it does not evaluate the expression entered in the first box). View 178_EmbeddedComponentExample2.mw on MapleNet or Download 178_EmbeddedComponentExample2.mw
View file details View 178_EmbeddedComponentExample.mw on MapleNet or Download 178_EmbeddedComponentExample.mw
View file details Let us know if you have more questions.
---------------------------------------------------------------------
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 looked at the intersectplot command in the plots package? You do not give enough details about your surfaces to know if they will be suitable for this command, but it's probably worth a try. You mention that your surfaces have 7 parameters. But, if you are looking at a plot, they all must be assigned a numerical value. Are you looking for a general formula for the intersection? If so, then this suggestion is not going to be helpful. But, if your surfaces are as complicated as you indicate, then it might be necessary to give up on a general formula for the intersection. Or, maybe some graphical evidence will provide you with an insight to make progress by hand. 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/
In the example you posted, there is nothing to solve. All you have to do is compute the conductivity. There are three problems that I see with your attempt. You appear to have used implied multiplication in the definition of eq. Maple will interpret this as a single quotient with numerator L and denominator RA (names can be more than a single character). To assign values to L, R, and A, use := (not =). To solve an equation, the command is solve (not Solve). Maple is case sensitive. Here is how I would modify your code to do this:
restart;
eq := p=L/R/A;  # or L/(R*A)
                                    p = 1
L := 1; R := 1; A := 1;
                                      1
                                      1
                                      1
eq;
                                    p = 1

Personally, I tend to avoid assigning specific values to variables. Instead, I'll use eval to evaluate the equation for specific values of the variables. Like this:
unassign( 'L', 'R', 'A' );
vals := [ L=1, R=1, A=1 ];
                            [L = 1, R = 1, A = 1]
eval( eq, vals );
                                    p = 1
Note that the unassign is needed to erase the previously assigned values to the variables. To show you how to use solve, consider the following:
vals2 := [ L=1, R=2, p=3 ];
                            [L = 1, R = 2, p = 3]
eval( eq, vals2 );
                                        1 
                                   3 = ---
                                       2 A
solve( %, A );
                                      1
                                      -
                                      6
eq2 := p*R*A=L;
                                  p R A = L
eval( eq2, vals2 ); # an equivalent form of your equation
                                   6 A = 1
solve( %, {A} );
                                   /    1\ 
                                  { A = - }
                                   \    6/ 
I hope this has been 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/
The meaning of a row in a matrix depends on where the matrix originated. If the matrix is a coefficient matrix for a linear system, and the matrix is square, then the last row with a 1 in the last column means the original matrix is nonsingular. In your case, however, the matrix is an augmented matrix with a general right-hand side. The last row in this case would be interpreted as 0x1+0x2+0x3+0x4=1, or 0=1. Since this is impossible, there are no solutions to Ax=t for any choice of the vector t. This should be explained in any decent linear algebra text. 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/
Precisely! This is exactly the message that I preach whenever I have my students use Maple. Some people think Maple is a crutch that instantly promotes students with poor math preparation to the top of their class. My experience is the exact opposite: students who have poor math skills do worse in a Maple course - because they do not know how to determine what needs to be done and how to tell Maple what to do. It is not enough to tell Maple to "solve it". Maple is neither a black box nor an oracle. To make effective use of Maple, users must have enough understanding and knowledge to know what they are trying to do. Just as it is not necessary to completely understand the functioning of a car's engine to be able to drive a car, it is not necessary to understand all of the details involved in a mathematical process to be able to use Maple (or any other tool). This puts the focus more on the concepts and ideas - the big picture. In your case, you do have to know more about the actual functioning of specific Maple commands. Usually this boils down to paying close attention to the description of a command. While I remember going through the same process of being frustrated that subs would not make the substitution I wanted, it made sense when the difficulties were explained to me. I now use algsubs, isolate, and other substitutions to prepare an expression for the ultimate substitution that I want to do. In many cases, thinking in this way has led to unexpected observations about the work I was doing. Bottom line: I have been where you are, and I am happier because of it. Still, I do hope that someday there will be other paths through the learning curve that do not involve all of these trials. 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/
The typical way this is handled is by discretizing the boundary condition. This typically increases the number of equations that have to be solved. For example, when you write u[x](0,t)=0, I assume you mean the x-derivative of u at x=0 for all time t. If u(x[i],t[j]) is stored as u[i,j], then you would have the equations: u[0,j]=u[1,j] for each timestep. For a nonhomogeneous boundary condition you would start with (u[N,j]-u[N-1,j])/h=4, or u[N,j]=u[N-1,j]+4*h, where h is the distance between x[N] and x[N-1]. You will need to watch out for uniqueness of solutions. If a function u(x,y) satisfies these boundary conditions, then so does u(x,y)+C for any constant C. Something else in the problem will have to specify the correct value of C. 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/
To define a piecewise-defined function in Maple, use:
y := x-> piecewise( x>a and x<b, f(x), x>b and x<c, g(x) );
If you want only an expression, omit the "x->". You can include endpoints as you desire. To be useful, you are going to need explicit numeric values for a, b, c, and d. The piecewise command can be pretty useful. One thing to keep in mind is that Maple checks the conditions until it finds one that evaluates to true. The value returned is the next "piece". This means that it is usually necessary only to specify the uppper bound of the interval. For example:
y2 := piecewise( x<1, undefined, x<2, f(x), x<3, g(x), x>=4, undefined );
eval( y2, x=1 );
eval( y2, x=2 );
eval( y2, x=4 );
Note that the definition as an expression is displayed more attractively than the function. Hoping 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/
Florian, I will show you a couple ways to accomplish what you have requested. But, before I do, I will ask WHY you want to have this result. What will you do with the result once you have it? Based on my personal experience, I'll go out on a limb and conjecture that there is a way to do what you want without the step that is giving you so much trouble. Here's what you have in the document:
> X := CS(p)+p^2;
                                          2
                                 CS(p) + p 
> Y := diff(X, p);
                              / d       \      
                              |--- CS(p)| + 2 p
                              \ dp      /      
> solve(Y, p);
Error, (in solve) cannot solve expressions with diff(CS(p), p) for p
My first instinct was to suggest that you use isolate. But, this won't work as the derivative term also involves p.
> isolate(Y, p);
                            / d       \          
                            |--- CS(p)| + 2 p = 0
                            \ dp      /          
So, we have to give the derivative term a new name, then isolate p, and re-insert the derivative:
> q1 := eval(Y=0, diff(CS(p), p) = A);
                                 A + 2 p = 0
> q2 := isolate(q1, p);
                                        1  
                                  p = - - A
                                        2  
> q3 := eval(q2, A = diff(CS(p), p));
                                    1  d       
                              p = - - --- CS(p)
                                    2  dp      
Note that when I actually did the calculations, I used Maple's labels. When I copied this from the document to MaplePrimes, Maple automatically inserted the appropriate contents for the label. Nice. The three steps can be put in a single command:
> eval( isolate( eval( Y = 0, diff(CS(p), p) = A ), p ), A = diff(CS(p), p) );
                                    1  d       
                              p = - - --- CS(p)
                                    2  dp      
Note that solve could be used, but you will have to work a little harder to get the same output:
> solve(q1 = 0, p);
                                      1  
                                    - - A
                                      2  
> solve(q1 = 0, {p});
                                 /      1  \ 
                                { p = - - A }
                                 \      2  / 
> solve(q1 = 0, {p})[];

                                        1  
                                  p = - - A
                                        2  
For those involved in yesterday's discussion of max and min, note another instance of the empty square brackets. I look forward to hearing more from you about your real problem. 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/
The min and max commands expect an expression sequence, not a list (or set or ...). The seq approach suggested above is one way to create an expression sequence from a list. Personally, I find it easier to think that all I want to do is strip away the square brackets. This can be done with two keystrokes:
L := [ 1, 2, 3 ];
min( L[] );
The same works for sets. In fact, one way to convert a list to a set is
S := { L[] };
The op command does the same thing, but takes 5 characters (and requires moving the cursor).
min( op(L) );
To close, I must admit that I did find it slightly unnatural that min and max cannot handle a list or set as a basic data type. I would really like to be able to use min( L ) directly. Maple should automatically detect the list and act accordingly. Thanks for listening, 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/
This is a matter of personal choice. Here are the ways I would address your question using expressions and using mappings. First, expressions:
> restart;
> x := 5*t - 7*t^2;
> y := 4*t+t^4;
                                             2
                               x := 5 t - 7 t 
                                            4
                               y :=  4 t + t 

> c := diff( y, t$2 )*diff( x, t ) + 3*diff( x, t$2 );
                                   2                
                          c := 12 t  (5 - 14 t) - 42

> plot( c, t=-1..1 );
I can convert the expressions to mapping with unapply (or enter them as in the previous post). Then, working with the mappings, I would use D for the derivative (mapping).
> X := unapply( x, t );
> Y := unapply( y, t );
                                            2
                         X := t -> 5 t - 7 t 
                                           4
                          Y := t -> 4 t + t 

> C := D(D(Y)) * D( X ) + 3*(D@@2)(X);
                         /         2\                     
                    C := \t -> 12 t / (t -> 5 - 14 t) - 42

> C(t);
                                2                
                            12 t  (5 - 14 t) - 42

> plot( C, -1..1 );
There are two specific things to note in this approach.
  • Note that we do not write t=-1..1 in the plot command. If you want to plot the function C, the variable name is merely a placeholder. We could use plot( C(t), t=-1..1 ); but then you are plotting the value of the function C evaluated at t -- an expression.
  • The output from the definition of C is not a single mapping. This simplification can be obtained, but I'm not sure it's really worth the work.
Personally, generally find it easier to use expressions and to use eval when I need to evaluate the expression with other values of its independent variables. Others find it more mathematically elegant to work with mappings, but then have to deal with extra (t)'s in many places. There are a few places where only one version will work, so it is good to have a basic understanding of both approaches. 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/
This problem can probably be handled, but more information is needed. In addition to a small angle approximation (theta \approx 0), it appears that you are interested in small time (t \approx 0) and that alpha is bounded as a function of t for appropriate values of t. If the functions involved are only sin and cos, you could get by with simply telling Maple to replace the sine function with the identity function and to replace the cosine function with a constant function:
> eq1 := diff(theta(t),t,t) + x^2*sin(theta(t)) = 0;
> eq2 := diff(theta(t),t,t) = diff(theta(t),t) + sin(theta(t)) + cos(alpha(t)) + theta(t)*alpha(t) + alpha(t)^2 + sin(t)^2 + (diff(alpha(t),t))^2;
>
> LINfn := [ sin=proc(t) t end proc, cos=proc(t) 1 end proc ];
> 
> eval( eq1, [sin=proc(t) t end proc, cos=proc(t) 1 end proc] );
                   / d  / d          \\    2             
                   |--- |--- theta(t)|| + x  theta(t) = 0
                   \ dt \ dt         //                  
>
> eval( eq2, [sin=proc(t) t end proc, cos=proc(t) 1 end proc] );
  / d  / d          \\   / d          \                                   
  |--- |--- theta(t)|| - |--- theta(t)| - theta(t) - 1 - theta(t) alpha(t)
  \ dt \ dt         //   \ dt         /                                   

                                      2    
               2    2   / d          \     
     - alpha(t)  - t  - |--- alpha(t)|  = 0
                        \ dt         /     

>
>
From here you still need to work with the assumption that theta*alpha, alpha^2 and (diff(alpha(t),t))^2 will be small enough to ignore. These require some additional assumptions on alpha, which brings me back to my initial comment. What, exactly, do you know about the functions in this problem? As this information is made precise, it should be possible to suggest an appropriate way for Maple to help you with the full problem. Lastly, I do not know a robust way to automate the linearization of functions. The approach used here required explicit linearization of each function that is involved. Can anyone suggest a better way to do 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/
Jean, Here's an approach to your problem that uses the Tally command from the Statistics package. I assume your data is a "Matrix", so also use the LinearAlgebra package to access the columns. Variants of this approach could be used if your original data is in a different form.
restart;
> with( LinearAlgebra ):
> with( Statistics ):
> A := < <a|b|c>, <a|b|c>, <b|c|a> >:
> Tally( Column( A, 1 ) );
                               [b = 1, a = 2]
> seq( Tally(Column(A,i)), i=1..ColumnDimension(A) );
               [b = 1, a = 2], [b = 2, c = 1], [c = 2, a = 1]
The output could be put into other forms depending upon your specific needs. I hope this gets you started, 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/
Florian, As has already been posted, one way to avoid your problem is to avoid floating-point numbers. Replacing 0.9 with 9/10 should be sufficient. But, more importantly, I think you should let Maple do what it is designed to do, and to work with your problem symbolically. Do not assign any values to the parameters until the end, or until it is necessary to help Maple speed up its calculations. I illustrate this in a revised version of your document (see hyperlink below). If d is the only parameter that is going to be changed, then you could also consider assigning values to the other parameters (constants) and doing all of the derivation for a general unspecified parameter d. Since you have the general result, it's now much easier to simply evaluate the final expression for different values of the parameter. Hoping this has been helpful, Doug View 178_Max CS_G=0_1-revised.mw on MapleNet or Download 178_Max CS_G=0_1-revised.mw
View file details
---------------------------------------------------------------------
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 34 35 36 37 38 39 40 Last Page 36 of 44