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

First, load the plots package. When Maple echos back your input, the most likely reason is that it does not understand the command you've given. The pointplot3d command is a part of the plots package. So, either load the package using with( plots ); or use the long form plots:-pointplot3d(...). Otherwise, your syntax should be OK.

Personally, I would not use the double subscript. Instead I would use a Matrix, as follows:

X := Matrix( 4,3, (i,j)->i+1/j ):
Y := Matrix( 4,3, (i,j)->i^2/j ):
Z := Matrix( 4,3, (i,j)->i-1/j ):
plots:-pointplot3d( X[..,1], Y[..,1], Z[..,1] );

Note, also, that you don't put the three data vectors inside square brackets.

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

Did you try looking in the online help?

From the help dialog, enter "inflection"

or

?inflection

The new help pages should be available on the web at http://www.maplesoft.com/support/help/, but you have to use "inflectionpoint" (all one word) to get the most useful information. (Also, the online search is pretty slow, so be patient.)

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

Change the sum's to add's and I think you'll like the result.

The sum command uses indefinite summation (an analog of the FTC for symbolic sums) while the add command actually adds the indicated terms.

The inner sum collapses to just a single term, with k=2-m-j.

sum(1/k!/j!/m!,k=2-m-j..2-m-j);
                                     1                       
               ----------------------------------------------
               factorial(2 - m - j) factorial(j) factorial(m)

It's the next sum that gives 0.

sum(sum(1/k!/j!/m!,k=2-m-j..2-m-j),j=0..2-m);
                                      0
sum(sum(1/k!/j!/m!,k=2-m-j..2-m-j),j=0..N);
                 4            hypergeom([1, -1 + m + N], [N + 2], -1)
        ------------------- - ---------------------------------------
                          m    factorial(1 - m - N) factorial(N + 1) 
        factorial(2 - m) 2                                           
        -------------------------------------------------------------
                                factorial(m)                         
eval( %, N=2-m );
Error, numeric exception: division by zero
limit( %%, N=2-m );
                                      0

Now, the last sum has to give 0.

But, if you use add you'll get:

add(add(add(1/k!/j!/m!,k=2-m-j..2-m-j),j=0..2-m),m=0..2);
                                      9
                                      -
                                      2

And, if you remove the m! (as you did in your sample code) the result is:

add(add(add(1/k!/j!,k=2-m-j..2-m-j),j=0..2-m),m=0..2);
                                      5

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

indets is the command I would recommend. However, it can return more than you expect unless you use an optional second argument:

r^2-3*s^2+2*t^2 = 0;
                             2      2      2    
                            r  - 3 s  + 2 t  = 0
indets( % );
                                  {r, s, t}
y = (sqrt (u^2-5)-7) / surd (u^3-6*u^2,3);
                                       (1/2)     
                               / 2    \          
                               \u  - 5/      - 7 
                           y = ------------------
                                   / 3      2   \
                               surd\u  - 6 u , 3/
indets( % );
                  /              (1/2)                    \ 
                 {       / 2    \           / 3      2   \ }
                  \u, y, \u  - 5/     , surd\u  - 6 u , 3// 
indets( %%, name );
                                   {u, y}


Note that I fixed what appears to be a typo in  your second example.

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

Look at the boundaries.

The bottom is z=0, the x-y plane, and the top is z=2*y, a slanted plane.

The base is bounded on the left by y=0, a line, and on the right by y=sqrt(1-x^2), with x between -1 and 1, a semi-circle.

So, with this information it's pretty easy to get Maple to draw this region:

plot3d(   0, y=0..sqrt(1-x^2), x=-1..1, axes=boxed, scaling=constrained );                    # bottom
plot3d( 2*y, y=0..sqrt(1-x^2), x=-1..1, axes=boxed, scaling=constrained );                    # top
plot3d( [0,2*y], y=0..sqrt(1-x^2), x=-1..1, axes=boxed, scaling=constrained );                # bottom and top
plot3d( [0,2*y], y=0..sqrt(1-x^2), x=-1..1, axes=boxed, scaling=constrained, filled=true );   # solid region

I'll let you supply the final description of this region.

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

Does pointplot3d, in the plots package, do what you want? If not, maybe you can tell us a little more about how you are going to find your point.

There is also the intersectplot command, also in the plots package, that is very helpful when trying to plot the intersection of two 3D surfaces.

See the online help for each of these commands for more detailed information, and examples of their usage.

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

For starters, the constant pi is written as Pi in Maple.

The online help for pdsolve is not very complete. But, it appears it's possible to provide IC and/or BC only when you are looking for a numeric solution.

But, we can apply the IC and BC by hand to find the analytic solution:

PDE := diff(u(x,t),t)=1/2*diff(u(x,t),x,x);
IBC := {u(x,0)=T0, u(0,t)=0, u(d,t)=0};
vals := {a=1/2, T0=0.1*sin(x), d=Pi};
                       d            1  d  / d         \
                      --- u(x, t) = - --- |--- u(x, t)|
                       dt           2  dx \ dx        /
                  {u(0, t) = 0, u(d, t) = 0, u(x, 0) = T0}
                      /                     1        \ 
                     { T0 = 0.1 sin(x), a = -, d = Pi }
                      \                     2        / 
PDE2 := eval(PDE,vals);
IBC2 := eval(IBC,vals);
                       d            1  d  / d         \
                      --- u(x, t) = - --- |--- u(x, t)|
                       dt           2  dx \ dx        /
              {u(0, t) = 0, u(Pi, t) = 0, u(x, 0) = 0.1 sin(x)}

Let Maple find the general form of the solution, and build the solution from these pieces:

sol := pdsolve(PDE2,build);
                                                             /1        \    
                                                      _C3 exp|- _c[1] t| _C2
              /     (1/2)  \        /1        \              \2        /    
 u(x, t) = exp\_c[1]      x/ _C3 exp|- _c[1] t| _C1 + ----------------------
                                    \2        /            /     (1/2)  \   
                                                        exp\_c[1]      x/   

To begin to apply the BC, let's make the solution into a function:

U := unapply( rhs(sol), (x,t) );
                                                            /1        \    
                                                     _C3 exp|- _c[1] t| _C2
             /     (1/2)  \        /1        \              \2        /    
(x, t) -> exp\_c[1]      x/ _C3 exp|- _c[1] t| _C1 + ----------------------
                                   \2        /            /     (1/2)  \   
                                                       exp\_c[1]      x/   

eq1 := U(0,t)=0;
                    /1        \              /1        \        
             _C3 exp|- _c[1] t| _C1 + _C3 exp|- _c[1] t| _C2 = 0
                    \2        /              \2        /        
eq2 := U(Pi,t)=0;
                                                      /1        \        
                                               _C3 exp|- _c[1] t| _C2    
      /     (1/2)   \        /1        \              \2        /        
   exp\_c[1]      Pi/ _C3 exp|- _c[1] t| _C1 + ---------------------- = 0
                             \2        /            /     (1/2)   \      
                                                 exp\_c[1]      Pi/      

We want Maple to solve these two equations, finding solutions that are valid for all values of t:

solve( {identity(eq1,t),identity(eq2,t)} );
   /                                      2                            \   
  {                   /   /     (1/2)   \\                              }  
   \_C1 = _C1, _C2 = -\exp\_c[1]      Pi//  _C1, _C3 = 0, _c[1] = _c[1]/ , 

    {_C1 = 0, _C2 = 0, _C3 = _C3, _c[1] = _c[1]}, 

    {_C1 = _C1, _C2 = -_C1, _C3 = _C3, _c[1] = 0}, 

    {_C1 = _C1, _C2 = -_C1, _C3 = _C3, _c[1] = -1}

Only one of these leads to a nontrivial solution

sol2 := eval( sol, %[4] );
                                                        /  1  \    
                                                 _C3 exp|- - t| _C1
                                   /  1  \              \  2  /    
         u(x, t) = exp(I x) _C3 exp|- - t| _C1 - ------------------
                                   \  2  /            exp(I x)     

Now, turning to the IC:

U2 := unapply( rhs(sol2), (x,t) );
                                               /  1  \    
                                        _C3 exp|- - t| _C1
                          /  1  \              \  2  /    
(x, t) -> exp(I x) _C3 exp|- - t| _C1 - ------------------
                          \  2  /            exp(I x)     
eq3 := U2(x,0)=sin(x)/10;
                                      _C3 _C1    1        
                   exp(I x) _C3 _C1 - -------- = -- sin(x)
                                      exp(I x)   10       
solve( identity(eq3,x) );
                          /        1              \ 
                          |        -- I           | 
                         <         20              >
                          |_C1 = - ----, _C3 = _C3| 
                          \        _C3            / 
sol3 := eval( sol2, % );
                                                  1       /  1  \
                                                  -- I exp|- - t|
                       1                /  1  \   20      \  2  /
            u(x, t) = --- I exp(I x) exp|- - t| + ---------------
                       20               \  2  /      exp(I x)    

We want to convert the complex exponentials in x into trig functions - without changing the exponential in t. If we try to use convert, this will apply to all parts of the expression (x and t). While there's probably a way this can be done, I feel like doing some Maple surgery. Let's pull out all of the terms that involve x:

X := select( has, rhs(factor(sol3)), x );
                        (exp(I x) + 1) (exp(I x) - 1)
                        -----------------------------
                                  exp(I x)           
convert( X, trig );
               (cos(x) + I sin(x) + 1) (cos(x) + I sin(x) - 1)
               -----------------------------------------------
                              cos(x) + I sin(x)               
XX := simplify( % );
                                 2 I sin(x)

Now, rewrite the solution using this expression for the spatial terms:

simplify( rhs(sol3)/X*XX );
                            1     /  1  \       
                            -- exp|- - t| sin(x)
                            10    \  2  /       

Very nice. Exactly the solution I could have written down from the beginning if I had just stopped to think.

I will add that I had originally hoped to be able to apply the BC and IC simultaneously, but Maple was not helpful when I tried:

eq3a := U(x,0)=sin(x)/10;
             /     (1/2)  \                _C3 _C2        1        
          exp\_c[1]      x/ _C3 _C1 + ----------------- = -- sin(x)
                                         /     (1/2)  \   10       
                                      exp\_c[1]      x/            
solve( {identity(eq1,t),identity(eq2,t),identity(eq3a,x)} );
Warning, solutions may have been lost

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 what the code should look like, in 1D:

a := n -> ln(n)/n:                  # define the function of interest
q := seq([n, a(n)], n = 1 .. 25);   # sequence of points on the graph of y=a(x)
evalf[3]( q );                      # evaluate points using floating-point arith (w/3 sig digits)
plot( [q], style=point );           # plot points on graph of y=a(x)

I'll let you enter and execute these commands to see exactly what the output, including the plot, look like.

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 are two options:

plot( 8-8*sin(theta), theta=0..2*Pi, coords=polar );

plots:-polarplot( 8-8*sin(theta), theta=0..2*Pi );

There are slight differences in the output. Personally, I ilke the default options for polarplot. Check them out for yourself.

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

Assignments made outside a proc are known inside the proc. See, for example, the following:

X := 2;
                                      2
f := proc(x)
 if x<2 then X else -X end if;
end proc;
proc(x)  ...  end;
f(1);
                                      2
f(3);
                                     -2

The following also works (but only because I did not use x as the variable in F and G):

F := sin(t);
G := cos(t);
                                   sin(t)
                                   cos(t)
f := proc(x)
 if x>0 then plot( F, t=-Pi..Pi ) else plot( G, t=-Pi..Pi ) end if;
end proc;
proc(x)  ...  end;
f(1);
f(-1);

Just because you CAN do this does not mean you SHOULD use this type of programming. It's better to pay more attention to do a careful job of coding. What would happen if your proc was called without an assignment having been made to the objects referred to in the proc?

As Edgar wrote, please give us more 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

Gerogios has explained how to avoid this problem, but you ask what Maple was doing - which I'll now try to explain.

The critical issue is going to be how Maple interprets parentheses. While recent versions of Maple support implied multiplication, parentheses are also used to indicate arguments to a function (procedure). Also, in Maple, every constant is actually a constant function. This means that 2(x) is 2 - and so is 2(3).

2(x);
                                      2
2(3);
                                      2

Let's look closely at what you entered using 2-d input and see what Maple thinks this means:

Example 1, with Maple's output

(-5.05)(23.83-100)c = (4.186)(10)(23.83-22)
                             -5.05 c = 76.60380

When I copy and paste this 2-d input into MaplePrimes' composition window, it is translated into 1-d notation. This appears as

> (-5.05)(23.83-100)*c = (4.186*10)*(23.83-22);
                             -5.05 c = 76.60380

The LHS is actually the constant function -5.05 evaluated at -76.17 multiplied by the symbol c. The RHS is parsed correctly, as the product of the three numbers. While you can solve this equation for c, you're not working with the equation you want and won't get the correct answer.

Let's repeat this for your second example:

(-5.05)(c)(23.83-100) = (4.186)(10)(23.83-22)
                              -5.05 = 76.60380
 

The same expression, converted by Maple to 1-d input, appears as:

> ((-5.05)(c))(23.83-100) = (4.186*10)*(23.83-22);
                              -5.05 = 76.60380

Now, the LHS is interpreted as the -5.05 constant function evaluated at c, which gives -5.05. This (constant function) is in turn evaluated at -76.17, which returns -5.05. The RHS is as before. Since this does not involve c, it's not possible to solve for c.

I note that the output you report is not obtained with the input you provided. If I omit the parentheses around the c on the LHS, then I get what you report:

(-5.05)c(23.83-100) = (4.186)(10)(23.83-22);
                         -5.05 c(-76.17) = 76.60380

Or, in 1-d input:

> (-5.05)*c(23.83-100) = (4.186*10)*(23.83-22);
                         -5.05 c(-76.17) = 76.60380

Now we see that this is interpretted as the c function evaluated at -76.17 multiplied by -5.05.

The situation gets even more interesting if you put a space between the (-5.05) and (23.83-100). This single space changes the interpretation from function evaluation to implied multiplication, which yields:

(-5.05) (23.83-100)c = (4.186)(10)(23.83-22)
                            384.6585 c = 76.60380

Or, as Maple reports this same expression in 1-d input:

> ((-5.05)*(23.83-100))*c = (4.186*10)*(23.83-22);
                            384.6585 c = 76.60380

Anyone who has read all of this has to be asking why Maple doesn't report 4.186 as the RHS in each of these examples. To be honest, I wish I knew. I'll guess that there is a slightly different interpretation because Maple recognizes that the RHS is purely numeric. But, it appears completely inconsistent. The LHS and the RHS have the same structure -- three terms in parentheses. On the RHS this is treated as the product of 3 numbers but on the LHS, function evaluation enters the picture.

I can't call this a bug, as I'm sure this is all well documented and consistent. I would call it a design flaw. The original poster's usage is very reasonable - if you are going to take advantage of implied multiplication. The two things you have to keep in mind are: constants are really functions and implied multiplication is best entered as a space (but if you are going to type a space you might as well type *).

I hope this is helpful, and prevents others from falling into a similar trap.

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

 

An interesting question. I think I'll take some time to respond to this, even though I should be preparing for the lecture I have to give later this morning.

Idea #1:

If you can solve the two problems separately, with generic boundary conditions at the interface, then you should be able to use the continuity conditions to solve for the unknown boundary conditions. But, this essentially requires that you are able to find a closed form expression for the solution. Since your command suggests you are looking for a numeric solution, this is not likely to work.

Idea #2:

Use an extension of the traditional "shooting method" for BVPs for ODEs. Solve the problems with reasonable boundary conditions at the left of the first rod and the right of the second rod. These won't match at the interface, but you can use this to suggest how to modify the boundary conditions so that you'll move closer to solutions that do match at the interface. This should work out fairly nice, but I might be missing something in my rush to get this done.

I look forward to hearing how you are eventually able to work through this 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

The default grid for plotting a vector field appears to be 5x5. You can change this by providing the desired grid size within the fieldplot option. For example, to have arrows drawn on a 10x10 grid withing your viewing window, try:

VectorField(<y^2 -2*x*y, 3* x* y  -6*x^2>,output=plot,view=[-4..4,-4..4],scaling=constrained, fieldoptions=[grid=[10,10]] );

The arrows this produces are pretty thin. You can get thicker arrows with:

VectorField(<y^2 -2*x*y, 3* x* y  -6*x^2>,output=plot,view=[-4..4,-4..4],scaling=constrained, fieldoptions=[grid=[10,10], thickness=2] );

You can, of course, choose a different grid size to meet your specific needs. You may need to read the online help for plot/options to see a more complete collection of attributes that you can control.

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

Is there a question in your posts? These look like statements of exercises from a text, or from another assignment for your course. This is not an appropriate use of MaplePrimes.

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

Is there a question in your posts? These look like statements of exercises from a text, or from another assignment for your course. This is not an appropriate use of MaplePrimes.

Oh! I do see your question. The answer is "Yes" someone can help, but are you sure it's OK to have someone else do your homework?

If you let us know where you are having trouble with this problem, I think you'll find someone willing to provide some assistance.

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 21 22 23 24 25 26 27 Last Page 23 of 44