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

The int command is used to perform integration in Maple.

The first integral is not easy to evaluate, but the second one is much easier. Let's start with the easier one.

g := arctan( cos(2*x) ) + Pi/4;
                                              1   
                      g := arctan(cos(2 x)) + - Pi
                                              4   
int( g, x=0..Pi );
                                    1   2
                                    - Pi 
                                    4    


We can try to evaluate the first one in the same way, but this makes Maple think much harder and gives a much less satisfying result:

h := arctan( tan(x)^2 );
                                     /      2\
                               arctan\tan(x) /
int( h, x=0..Pi );
     /            -----                   /_R1 - 1\\
     |             \                 dilog|-------||
     |              )                     \  _R1  /|
-2 I |             /                 --------------|
     |            -----                 /   2    \ |
     |            /  4             2\ 4 \_R1  + I/ |
     \_R1 = RootOf\_Z  + 1 + 2 I _Z /              /

       /            -----                                  \
       |             \                                     |
       |              )                /  1      /_R1 - 1\\|
   - 2 |             /                 |- - dilog|-------|||
       |            -----              \  4      \  _R1  //|
       |            /  4             2\                    |
       \_R1 = RootOf\_Z  + 1 - 2 I _Z /                    /

       /            -----                 2      /_R1 - 1\\                   
       |             \                 _R1  dilog|-------||                   
       |              )                          \  _R1  /|   1               
   - 2 |             /                 -------------------| - - I Pi ln(1 + I)
       |            -----                   /   2    \    |   2               
       |            /  4             2\   4 \_R1  + I/    |                   
       \_R1 = RootOf\_Z  + 1 + 2 I _Z /                   /                   

     5   2   1               
   + - Pi  + - I Pi ln(1 - I)
     4       2               

                   -----                 2 /       /_R1 + 1\        /_R1 + 1\\
                    \                 _R1  |I Pi ln|-------| + dilog|-------||
     1               )                     \       \  _R1  /        \  _R1  //
   + -              /                 ----------------------------------------
     2             -----                                 2                    
                   /  4             2\                _R1  + I                
       _R1 = RootOf\_Z  + 1 + 2 I _Z /                                        

                   -----                                                  
                    \                                                     
     1               )                /        /_R1 + 1\        /_R1 + 1\\
   + -              /                 |-I Pi ln|-------| - dilog|-------||
     2             -----              \        \  _R1  /        \  _R1  //
                   /  4             2\                                    
       _R1 = RootOf\_Z  + 1 - 2 I _Z /                                    

         /            -----                     /_R1 + 1\        /_R1 + 1\\
         |             \                 I Pi ln|-------| + dilog|-------||
     1   |              )                       \  _R1  /        \  _R1  /|
   + - I |             /                 ---------------------------------|
     2   |            -----                             2                 |
         |            /  4             2\            _R1  + I             |
         \_R1 = RootOf\_Z  + 1 + 2 I _Z /                                 /

                         /  (1/2)      (1/2)\
   - I Pi ln(2) + I Pi ln\-2      + I 2     /

We can ask Maple for a numerical approximation to this exact answer:

evalf( % );
                                             -9  
                           4.934802199 - 2 10   I

 

The imaginary part is due to numerical roundoff with complex numbers. The answer must be real. To end we can see if Maple recognizes the real part:

identify( Re(%) );
                                    1   2
                                    - Pi 
                                    2    

Now, do we believe this? A quick plot of g and h (omitted) suggests they enclose the same area over [0,Pi]. The above results do not agree with this. Let's see what Maple gives us with a purely numerical approximation to the integral. For this we use the inert integration, Int, followed by evalf, as follows:

evalf( Int( h, x=0..Pi ) );
                                 2.467401100
identify( % );
                                    1   2
                                    - Pi 
                                    4    

So, there is something wrong with the exact integral. Either it is incorrect, or there is a problem with the numerical approximation. There could be an issue with branch cuts, but I'm not certain - and do not have the time to look at this further.

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.ed

In your original post you have plots[display( .... )] when you should have plots[display]( ... )

In your later posts you do not give as much detail, but I'll guess that you have some error in  your input.

It's better to load the plots package once and for all by using with( plots ) as in Jean-Marc's response above.

If you are continuing to have troubles, please post your EXACT input so that we diagnose your 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.ed

What equation are you trying to solve?

Your post has a complex-valued expression. You can convert it to different forms, but in order to "solve" something you need an equation (equal sign) and an unknown. If you can clarify your request, we'll have a better chance of providing a useful response to 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.ed

Here is alec's animation implemented using the animate command:

plots:-display(
  plots:-animate( plot, [abs, sin(t)..cos(t), filled, color=blue], t=evalf([$0..50]*Pi/200) ),
  plots:-animate( plot, [abs, cos(t)..sin(t), filled, color=red], t=evalf([$51..250]*Pi/200) ),
  plots:-animate( plot, [abs, sin(t)..cos(t), filled, color=blue], t=evalf([$251..399]*Pi/200) ),
  insequence=true, scaling=constrained );
 

In general, once you learn how simple it is to use animate, you'll want to use it for most of your animations. In this case, the only complication comes from the fact that t never has a value and I don't have the time right now to get the titles exactly as alec did.

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.ed

I'm not exactly sure what you are trying to do, but here are two possibilities that might be close to what you are seeking. First, let's look at the function you mention in your post.

diff(int(abs(x),x=cos(t)..sin(t)),t);
   -cos(t) sin(t) + 2 cos(t) piecewise(cos(t) < 0, 0, 1) sin(t)

              2                            
      - cos(t)  piecewise(cos(t) < 0, 0, 0)

      + piecewise(sin(t) <= 0, -cos(t) sin(t), 0 < sin(t), cos(t) sin(t))
simplify( %, piecewise );
  -cos(t) sin(t) + 2 cos(t) piecewise(cos(t) < 0, 0, 0 <= cos(t), 1) sin(t)

     + piecewise(sin(t) <= 0, -cos(t) sin(t), 0 < sin(t), cos(t) sin(t))
plot( %, t=0..2*Pi );

As for the animations, here is where I have some questions about what you are looking for. I'll start with
animate( plot, [diff(int(abs(x),x),x), x=cos(t)..sin(t)], t=0..2*Pi, axes=box );

But also suggest

animate( plot, [abs(x), x=cos(t)..sin(t)], t=0..2*Pi, axes=box );
animate( plot, [[abs(x),diff(int(abs(x),x=cos(t)..sin(t)),t)], x=cos(t)..sin(t)], t=0..2*Pi, axes=box );

I hope one, or more, of these are 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.ed

You can extract the three components of the point you call e in one line with the following multiple assignment::

ex,ey,ez := op(e)[];

The op command used in this way extracts the operands of the object it receives. Here, the operand of the POINTS object is a list containing the three coordinates of the point you have plotted. If you want the three coordinates as a list, just use:

eP := op(e);

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.ed

It depends. What do you want to do with the new coordinates?

In what form do you have the coordinates? Exactly how did you do the rotation?

If you give us some more information about what you are trying to do, I'm sure we can give you some useful pointers. Please post the commands you are using and/or a worksheet showing what you have done.

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.ed

The answer to your question probably depends on your answers to the following questions.

Are you using a document or a worksheet?

Is the input Maple Notation (1d) or 2-D Math Notation?

If you don't know these answers, you can get them from Tools ... Options. Then look at the Display and Interface tabs.

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.ed

If your inputs were sets, you could use the builtin minus command.

{a[]} minus {b[]};
                                     {5}

or, if you want the result back as a list:

[( {a[]} minus {b[]} )[]];
                                     [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.ed

Alec's implementation is very appealing - short, compact, very flexible.

I'll leave it to the original poster to decide if it fulfills his request.

Personally, I would like a little more. I'd like something that I could type that "flips a switch" so that all calculations are done using floating-point arithmetic and numeric algorithms (not symbolics). Something like this could conceivably be very helpful in some graphing problems.

`&/`:=(a,b)->b(a):
A := sin( Pi/6 ): A = evalf(A);
                              1               
                              - = 0.5000000000
                              2               
B := sin( Pi/6. ): B = evalf(B);
                     sin(0.1666666667 Pi) = 0.5000000001
C := sin( Pi/6 ) &/ evalf[20];
                           0.50000000000000000000

E := sin( Pi/6. ) &/ evalf[20];
                           0.50000000009068996821

I would like the value of C to be what is returned as the value of E. Any ideas on this? (Or, am I tilting at windmills?)

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.ed

I'm not completely sure what you are asking.

If you feed your command to evalf, then Maple will (usually) perform the inner calculation exactly(if posible) and then approximate the result. It does NOT use a numerical method to do the inner calculation. For example, compare:

evalf( int( sin(100*x), x=0..Pi ) );
                                     0.
evalf( Int( sin(100*x), x=0..Pi ) );
                                            -13
                             -1.624479833 10   

The first command computes the exact value of the integral (0) and then evaluates that as a floating point number (0.). The second command tells Maple not to attempt to evaluate the integral and uses a numerical method for this calculation (hence the different, but not unreasonable, answer).

Another way to force Maple to use floating point approximations is to include a floating point number in the input. Here are two examples that show the differences that can be observed just by putting a decimal point in the input:

solve( x^2=2, x );
                                (1/2)    (1/2)
                               2     , -2     
solve( x^2=2., x );
                          1.414213562, -1.414213562

sin( Pi/6 );
                                      1
                                      -
                                      2
sin( Pi/6. );
                            sin(0.1666666667 Pi)

As a final test, do you understand why Maple produces different answers in the following example?

evalf( sin( Pi/6 ) );
                                0.5000000000
evalf( sin( Pi/6. ) );
                                0.5000000002

If I've missed your question, please let us know and we'll try again.

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.ed

OK, I was wrong about you wanting to work mod 5.

Maple's convert command can be used to convert between bases, but the output is a list with entries in the reverse order. Here's a simple (and not optimal) procedure for displaying numbers in a different base.

B := (L,b) -> convert(
               StringTools:-Reverse(
                StringTools:-Join(
                 map(convert,convert(L,base,b),string),
                 "")
                ),
               name):

Then, I'd use this as follows:

A^2;
map( B, A^2, 5 );

My routine is far from optimal, it's just showing the basic idea. I think it would probably be easier to do the conversion directly.

It would sure be nice if there were a true inverse for convert,decimal.

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.ed

I'm sure the orginal poster was talkiing about working with matrices mod 5.

You will need to load the LinearAlgebra[Modular] package.

with( LinearAlgebra[Modular] );
[AddMultiple, Adjoint, BackwardSubstitute, Basis, CharacteristicPolynomial, 

  ChineseRemainder, Copy, Create, Determinant, Fill, ForwardSubstitute, 

  Identity, IntegerCharacteristicPolynomial, IntegerDeterminant, 

  IntegerLinearSolve, Inverse, LUApply, LUDecomposition, LinearSolve, 

  MatBasis, MatGcd, Mod, Multiply, Permute, Random, Rank, RankProfile, 

  RowEchelonTransform, RowReduce, Swap, Transpose, ZigZag]

To demonstrate its use, I'll create a random matrix then compute its square, then its square mod 5 (in two ways).

A := RandomMatrix(3,3,generator=0..4);
A^2;
Mod(5,A^2,integer);
Multiply(5,A,A);

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.ed

It sounds as though you want a Maple plot in a file that can be included into a LaTeX document. If so, simply call up the context menu for the plot (move cursor to the plot you want to export, then press the right-hand button on your mouse). At the bottom of this context menu you will find Export, select this, then select the format in which you want the plot exported. Once you specify the filename (and location), the plot will be exported in the selected format.

If you are using LaTeX, then EPS might be the best format. I use pdfLaTeX, so usually export to GIF then convert to PDF.

If this is not what you are trying to do, please post again with more details (and possibly an 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.ed

While I cannot see the two different views in your post, I'm going to guess that the difference is whether the input is being entered as in Text or Math mode.

In the attached worksheet I show the same simple expression, a/b, in Text mode (red > prompt, vertical prompt, red input), Math mode with 2D Math input, and Math mode with Maple input. You can change between these using the buttons in the context bar above the worksheet window and/or the Convert to selection in the context menu (right mouse click).

View 178_input_modes.mw on MapleNet or Download 178_input_modes.mw
View file details

I hope this is a start towards answering your question. If not, please let us know and we'll try again.

2D input

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.ed
First 23 24 25 26 27 28 29 Last Page 25 of 44