Doug Meade

 

Doug

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

MaplePrimes Activity


These are replies submitted by Doug Meade

Here's another way to construct a table of function values. One advantage of this method is the output is a Maple object that can be used for later steps, if needed.

restart;
interface( rtablesize=20 ):   # needed to display tables with more than 10 rows or columns
f := x->sin(x);
x -> sin(x)
X := [$0..10]/10;
                    [   1   1  3   2  1  3  7   4  9    ]
                    [0, --, -, --, -, -, -, --, -, --, 1]
                    [   10  5  10  5  2  5  10  5  10   ]
T := < seq( 

This constructs a table with three columns. You can modify the list of values from the domain to fit your needs. The specific functions, and number of columns is also completely customizable. Note the use of "|" to separate columns in the table. The output is omitted because MaplePrimes does not like to display Maple matrices.

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/

Maple's help is pretty good. You do have to know how to use it, however. The best part of many help pages is the examples that come at the end of every help page. Sometimes the earlier descriptions become too technical, giving information that most users will not need (but would be complained about if it were ever omitted). Commands with many options generally have a good description of all of the possible options. Again, the examples are helpful in these cases as well.

So, my advise to any newer user is to perserve and not feel bad if you don't understand everything in a help page.

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/

Maple's help is pretty good. You do have to know how to use it, however. The best part of many help pages is the examples that come at the end of every help page. Sometimes the earlier descriptions become too technical, giving information that most users will not need (but would be complained about if it were ever omitted). Commands with many options generally have a good description of all of the possible options. Again, the examples are helpful in these cases as well.

So, my advise to any newer user is to perserve and not feel bad if you don't understand everything in a help page.

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 are the two different solutions:

restart;
with( plots ):
ode1 := diff(y(x),x)^2 + 4*c*diff(y(x),x)+4*c^2*y(x)/(1-x^2);
ics := y(0)=1;
sol := frontend(solve, [ode1, [diff(y(x),x)]], [{`+`,`*`,`^`,list},{}]);
# manually choose one branch
dsol1 := dsolve(subs(c=3,[sol[1,1],ics]),numeric):
dsol2 := dsolve(subs(c=3,[sol[2,1],ics]),numeric):
                            2                       2     
                  / d      \        / d      \   4 c  y(x)
                  |--- y(x)|  + 4 c |--- y(x)| + ---------
                  \ dx     /        \ dx     /         2  
                                                  1 - x   
                                  y(0) = 1
   [[               /                                          (1/2)\  ]  
   [[               |      2   /       2    4                2\     |  ]  
   [[ d           2 \-1 + x  - \1 - 2 x  + x  - y(x) + y(x) x /     / c]  
   [[--- y(x) = - -----------------------------------------------------], 
   [[ dx                                       2                       ]  
   [[                                    -1 + x                        ]  

     [               /                                          (1/2)\  ]]
     [               |      2   /       2    4                2\     |  ]]
     [ d           2 \-1 + x  + \1 - 2 x  + x  - y(x) + y(x) x /     / c]]
     [--- y(x) = - -----------------------------------------------------]]
     [ dx                                       2                       ]]
     [                                    -1 + x                        ]]
P1 := odeplot( dsol1, [x,y(x)], 0..1 ):
   Warning, cannot evaluate the solution further right of .99999749, probably a singularity
P2 := odeplot( dsol2, [x,y(x)], 0..1, style=point ):
   Warning, cannot evaluate the solution further right of .99973275, probably a singularity
display( P1,P2 );

Change values for c or y(0) to see how these affect the solution.

Are we getting close to what you are trying to find?

---------------------------------------------------------------------
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 are the two different solutions:

restart;
with( plots ):
ode1 := diff(y(x),x)^2 + 4*c*diff(y(x),x)+4*c^2*y(x)/(1-x^2);
ics := y(0)=1;
sol := frontend(solve, [ode1, [diff(y(x),x)]], [{`+`,`*`,`^`,list},{}]);
# manually choose one branch
dsol1 := dsolve(subs(c=3,[sol[1,1],ics]),numeric):
dsol2 := dsolve(subs(c=3,[sol[2,1],ics]),numeric):
                            2                       2     
                  / d      \        / d      \   4 c  y(x)
                  |--- y(x)|  + 4 c |--- y(x)| + ---------
                  \ dx     /        \ dx     /         2  
                                                  1 - x   
                                  y(0) = 1
   [[               /                                          (1/2)\  ]  
   [[               |      2   /       2    4                2\     |  ]  
   [[ d           2 \-1 + x  - \1 - 2 x  + x  - y(x) + y(x) x /     / c]  
   [[--- y(x) = - -----------------------------------------------------], 
   [[ dx                                       2                       ]  
   [[                                    -1 + x                        ]  

     [               /                                          (1/2)\  ]]
     [               |      2   /       2    4                2\     |  ]]
     [ d           2 \-1 + x  + \1 - 2 x  + x  - y(x) + y(x) x /     / c]]
     [--- y(x) = - -----------------------------------------------------]]
     [ dx                                       2                       ]]
     [                                    -1 + x                        ]]
P1 := odeplot( dsol1, [x,y(x)], 0..1 ):
   Warning, cannot evaluate the solution further right of .99999749, probably a singularity
P2 := odeplot( dsol2, [x,y(x)], 0..1, style=point ):
   Warning, cannot evaluate the solution further right of .99973275, probably a singularity
display( P1,P2 );

Change values for c or y(0) to see how these affect the solution.

Are we getting close to what you are trying to find?

---------------------------------------------------------------------
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 cannot ask Maple to work magic and solve an improperly defined problem.

I suspect Maple's problem comes from trying to isolate diff(y(x),x). Since the ODE is quadratic in the derivative, there will be two solutions. Your initial condition should tell you which solution branch to use.

ODE := (diff(y(x),x))^2+4*c*diff(y(x),x)+4*c^2*y(x)/(1-x^2) = 0;
                          2                       2         
                / d      \        / d      \   4 c  y(x)    
                |--- y(x)|  + 4 c |--- y(x)| + --------- = 0
                \ dx     /        \ dx     /         2      
                                                1 - x       

isolate( ODE, diff(y(x),x) );
                    /                                          (1/2)\  
                    |      2   /       2    4                2\     |  
      d           2 \-1 + x  - \1 - 2 x  + x  - y(x) + y(x) x /     / c
     --- y(x) = - -----------------------------------------------------
      dx                                       2                       
                                         -1 + x                        

eval( ODE, diff(y(x),x)=DY );
                                          2         
                          2            4 c  y(x)    
                        DY  + 4 c DY + --------- = 0
                                             2      
                                        1 - x       

solve( %, {DY} );
      /         /                                          (1/2)\  \   
      |         |      2   /       2    4                2\     |  |   
      |       2 \-1 + x  - \1 - 2 x  + x  - y(x) + y(x) x /     / c|   
     < DY = - ----------------------------------------------------- >, 
      |                                    2                       |   
      |                              -1 + x                        |   
      \                                                            /   

        /         /                                          (1/2)\  \ 
        |         |      2   /       2    4                2\     |  | 
        |       2 \-1 + x  + \1 - 2 x  + x  - y(x) + y(x) x /     / c| 
       < DY = - ----------------------------------------------------- >
        |                                    2                       | 
        |                              -1 + x                        | 
        \                                                            / 

map( eval, [%], DY=diff(y(x),x) )[];
  [ /               /                                          (1/2)\  \   
  [ |               |      2   /       2    4                2\     |  |   
  [ | d           2 \-1 + x  - \1 - 2 x  + x  - y(x) + y(x) x /     / c|   
  [< --- y(x) = - ----------------------------------------------------- >, 
  [ | dx                                       2                       |   
  [ |                                    -1 + x                        |   
  [ \                                                                  /   

     /               /                                          (1/2)\  \ ]
     |               |      2   /       2    4                2\     |  | ]
     | d           2 \-1 + x  + \1 - 2 x  + x  - y(x) + y(x) x /     / c| ]
    < --- y(x) = - ----------------------------------------------------- >]
     | dx                                       2                       | ]
     |                                    -1 + x                        | ]
     \                                                                  / ]

Once you decide which of these is appropriate, I think you will find Maple is able to give you some results.

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 cannot ask Maple to work magic and solve an improperly defined problem.

I suspect Maple's problem comes from trying to isolate diff(y(x),x). Since the ODE is quadratic in the derivative, there will be two solutions. Your initial condition should tell you which solution branch to use.

ODE := (diff(y(x),x))^2+4*c*diff(y(x),x)+4*c^2*y(x)/(1-x^2) = 0;
                          2                       2         
                / d      \        / d      \   4 c  y(x)    
                |--- y(x)|  + 4 c |--- y(x)| + --------- = 0
                \ dx     /        \ dx     /         2      
                                                1 - x       

isolate( ODE, diff(y(x),x) );
                    /                                          (1/2)\  
                    |      2   /       2    4                2\     |  
      d           2 \-1 + x  - \1 - 2 x  + x  - y(x) + y(x) x /     / c
     --- y(x) = - -----------------------------------------------------
      dx                                       2                       
                                         -1 + x                        

eval( ODE, diff(y(x),x)=DY );
                                          2         
                          2            4 c  y(x)    
                        DY  + 4 c DY + --------- = 0
                                             2      
                                        1 - x       

solve( %, {DY} );
      /         /                                          (1/2)\  \   
      |         |      2   /       2    4                2\     |  |   
      |       2 \-1 + x  - \1 - 2 x  + x  - y(x) + y(x) x /     / c|   
     < DY = - ----------------------------------------------------- >, 
      |                                    2                       |   
      |                              -1 + x                        |   
      \                                                            /   

        /         /                                          (1/2)\  \ 
        |         |      2   /       2    4                2\     |  | 
        |       2 \-1 + x  + \1 - 2 x  + x  - y(x) + y(x) x /     / c| 
       < DY = - ----------------------------------------------------- >
        |                                    2                       | 
        |                              -1 + x                        | 
        \                                                            / 

map( eval, [%], DY=diff(y(x),x) )[];
  [ /               /                                          (1/2)\  \   
  [ |               |      2   /       2    4                2\     |  |   
  [ | d           2 \-1 + x  - \1 - 2 x  + x  - y(x) + y(x) x /     / c|   
  [< --- y(x) = - ----------------------------------------------------- >, 
  [ | dx                                       2                       |   
  [ |                                    -1 + x                        |   
  [ \                                                                  /   

     /               /                                          (1/2)\  \ ]
     |               |      2   /       2    4                2\     |  | ]
     | d           2 \-1 + x  + \1 - 2 x  + x  - y(x) + y(x) x /     / c| ]
    < --- y(x) = - ----------------------------------------------------- >]
     | dx                                       2                       | ]
     |                                    -1 + x                        | ]
     \                                                                  / ]

Once you decide which of these is appropriate, I think you will find Maple is able to give you some results.

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/

For a first-order ODE, you cannot specify both y(0) and D(y)(0). If these are the given ICs, then I agree that you really want to be looking at a second-order ODE. This would be much more typical.

---------------------------------------------------------------------
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/

For a first-order ODE, you cannot specify both y(0) and D(y)(0). If these are the given ICs, then I agree that you really want to be looking at a second-order ODE. This would be much more typical.

---------------------------------------------------------------------
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/

Use the green arrow on the third line of icons to upload a file to MaplePrimes. As part of the upload process you will be asked if you want to insert a link to this file. Say "Yes" (or "OK").

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/

Use the green arrow on the third line of icons to upload a file to MaplePrimes. As part of the upload process you will be asked if you want to insert a link to this file. Say "Yes" (or "OK").

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 output you show is the list of commands in the PDEtools package. Compare:

with( PDEtools ):    # no output
with( PDEtools );    # shows list of commands
[CanonicalCoordinates, ChangeSymmetry, CharacteristicQ, D_Dx, DeterminingPDE, 
  Eta_k, FromJet, InfinitesimalGenerator, Infinitesimals, InvariantSolutions, 
  InvariantTransformation, Invariants, PDEplot, ReducedForm, 
  SimilaritySolutions, SimilarityTransformation, SymmetryTest, 
  SymmetryTransformation, TWSolutions, ToJet, build, casesplit, charstrip, 
  dchange, dcoeffs, declare, diff_table, difforder, dpolyform, dsubs, mapde, 
  separability, splitstrip, splitsys, undeclare]

Which you use should have no bearing on anything else in your session.

Are you using a worksheet or a document? I would recommend using a worksheet.

To understand what you are seeing, please post your 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/

The output you show is the list of commands in the PDEtools package. Compare:

with( PDEtools ):    # no output
with( PDEtools );    # shows list of commands
[CanonicalCoordinates, ChangeSymmetry, CharacteristicQ, D_Dx, DeterminingPDE, 
  Eta_k, FromJet, InfinitesimalGenerator, Infinitesimals, InvariantSolutions, 
  InvariantTransformation, Invariants, PDEplot, ReducedForm, 
  SimilaritySolutions, SimilarityTransformation, SymmetryTest, 
  SymmetryTransformation, TWSolutions, ToJet, build, casesplit, charstrip, 
  dchange, dcoeffs, declare, diff_table, difforder, dpolyform, dsubs, mapde, 
  separability, splitstrip, splitsys, undeclare]

Which you use should have no bearing on anything else in your session.

Are you using a worksheet or a document? I would recommend using a worksheet.

To understand what you are seeing, please post your 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/

Let me be the first to express my thanks to Will for re-enabling this feature.

THANK 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/

This type of behavior is rather common, and is NOT a bug. It simply shows the differences between symbolic calculations, without careful consideration of the problem, and numeric calculations.

Let's consider the two results separately. First,

evalf( int( ln(2+2*cos(t)^2+cos(t)^4), t = 0 .. Pi));
                        -8.710344354 + 19.73920881 I

The int command produces an exact expression for the antiderivative:

F := int( ln(2+2*cos(t)^2+cos(t)^4), t);
                                          /
                                          |
4 I ln(2) ln(exp(I t)) - I ln(exp(I t)) ln|
                                          |
                                          \

               4                2                6                 8\
  54 (exp(I t))  + 12 (exp(I t))  + 12 (exp(I t))  + 1 + (exp(I t)) |
  ------------------------------------------------------------------|
                                       4                            |
                             (exp(I t))                             /

                             /                     -----                      
                             |                      \                         
                     2       |                       )                        
   - 2 I ln(exp(I t))  + 8 I |                      /                         
                             |                     -----                      
                             |            /     4        2        6         8\
                             \_R1 = RootOf\54 _Z  + 12 _Z  + 12 _Z  + 1 + _Z /

                                                               \
                                                               |
  /1                /_R1 - exp(I t)\   1      /_R1 - exp(I t)\\|
  |- ln(exp(I t)) ln|--------------| + - dilog|--------------|||
  \8                \     _R1      /   8      \     _R1      //|
                                                               |
                                                               /

This is not a very useful result. But, if we continue, evaluating this antiderivative at each endpoint and subtracting gives:

F1 := simplify(eval( F, t=Pi ));
F2 := simplify(eval( F, t=0  ));
                       /Sum(/       /_R1 + 1\        /_R1 + 1\\,             /
                       |    |I Pi ln|-------| + dilog|-------||  _R1 = RootOf\
                 2     |    \       \  _R1  /        \  _R1  //               
Pi ln(5) + 2 I Pi  + I |                                                      
                       |                                                      
                       |                                                      
                       \                                                      

       4        2        6         8\ .. )\
  54 _Z  + 12 _Z  + 12 _Z  + 1 + _Z /     |
                                          |
                                          |
                                          |
                                          |
                                          /
       /                     -----                                    \
       |                      \                                       |
       |                       )                             /_R1 - 1\|
     I |                      /                         dilog|-------||
       |                     -----                           \  _R1  /|
       |            /     4        2        6         8\              |
       \_R1 = RootOf\54 _Z  + 12 _Z  + 12 _Z  + 1 + _Z /              /
evalf( F1-F2 );
                        -8.710344359 + 19.73920881 I

The complex valued result is not expected. It is obtained because we have not give careful consideration to the branch cuts of the antiderivative.

On the other hand, the second option:

evalf( Int( ln(2+2*cos(t)^2+cos(t)^4), t = 0 .. Pi));
                                 3.658972529

does not try to do any symbolic evaluation, it immediately resorts to a numerical integration routine. Here, the integrand is always positive, so the real-valued and positive result is consistent with our expectations.

It is cases like this that make the distincition between int and Int important. With evalf( int( ) ), Maple will first attempt a symbolic evaluation of the definite integral. If this is not successful, then it will use numerical quadrature. But, if you want to avoid the time spent trying to find an antiderivative (or, worse, finding a useless antiderivative as in this example) use evalf( Int( ) ).

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 46 47 48 49 50 51 52 Last Page 48 of 76