 Application Center - Maplesoft

# Drawing well-labelled diagrams; Maple assumptions

You can switch back to the summary page by clicking here.

Inv3_InverseTrigo.mws

Calculus II - worksheet 3

Drawing well-labelled diagrams

Simplifying inverse trigonometric expressions

Maple assumptions

Author: Carl Devore <devore@math.udel.edu>

13 February 2002

Audience:

1.  Second-semester calclus students

2.  Anyone who wants to learn to draw simple labelled diagrams with Maple

Objectives:

1. Draw simple labelled diagrams with Maple.

2. Learn how a reference triangle can be used to simplify a composition of trigonometric and inverse trigonometric functions.

New Maple commands/concepts  used:

textplot, convert, plotting line segments, assume , assuming , verifying inequalities with is

The primary purpose of this worksheet is to show you how you can use Maple to draw well-labelled diagrams.  To illustrate this, I will simplify an arctrig expression by drawing a reference triangle.  Of course, if your purpose was merely to do this problem, it would be far easier to just draw the triangle by hand.  This problem is just to illustrate how you could  use Maple to draw diagrams.   If your purpose is to display the solution on the world-wide web, then it may be easier to do it in Maple and use the "Export as HTML" feature than to draw it by hand, scan it in, and then cut-and-paste the scanned images into a document.

 > restart;

First, I will just draw a right triangle.  The plot command can be used to draw line segments by merely specifying the coordinates of the endpoints of the segments.  Each point ( ) is represented in Maple as a list of two numbers so it goes in square brackets.  Then the two points themselves are considered a list so they go into another pair of square brackets.  So the following command will draw the line segment from (0,0) to (1,1).

 > plot( [ [0,0], [1,1] ] ); That's going to be the hypothenuse of the triangle.  The blank spaces that I put in the command are not necessary; I just put them there to emphasize the extra square brackets.

To finish the triangle, I need line segments from (1,1) to (1,0) and from (1,0) back to (0,0).  I can make this into a single list and draw all the line segments at once with the following command:

 > plot( [ [0,0], [1,1], [1,0], [0,0] ] ); The x-axis is obscuring the bottom of the triangle.   The axes are not a useful part of this picture anymore.  I just want to see the triangle.  So I add the "axes= none" option to the plot command:

 > plot([[0,0], [1,1], [1,0], [0,0]], axes= none ); Now that I am satisfied with the triangle, I'd like to save it in a variable for future use.  The symbol "%" can always be used to refer the results of the last command that was actually executed.

 > Triangle:= %;  All that info is Maple's internal representation of the drawing.  Usually, there is no need to see this.  So I could have ended the above command with a colon instead of a semicolon.

Note that the % always refers to the last command that was actually executed.  It does not matter where your cursor is at the time that you use the percent sign.  Therefore, it is possible for the percent sign to refer to a command that is not the previous command on the screen.  This can cause great confusion, especially after you save and reload the worksheet, so be careful where you place your percent signs.

Now on to the trig problem.

Problem:

Evaluate , .

Let be the angle represented by .  Then .  In the diagram, I am going make the lower left angle of the triangle.  Since ,  I define these two sides of the triangle:  Note above that more than one command can be placed on a line.

Now have Maple apply the Pythagorean theorem to compute the hypothenuse. Sometimes Maple might print the above answer as and other times it might print it as .  It is very difficult to predict which order Maple will use.  Sometimes Maple chooses to represent things in an order that appears strange to us.  I could force Maple to print that as , but there's no need right now to delve into the complexities of that.  But remember not to rely on Maple printing an answer in any specific order.

Now we label the sides of the triangle.  Maple has over 2500 commands, but all of these are not immediately available when you start Maple.   Many of the commands are grouped together into sets called packages .  There are many commands for plotting other than the "plot" command that we've used up until now.   Some of these are in a package named plots .  To load a package, use the with  command:

 > with(plots);

```Warning, the name changecoords has been redefined
```      The list that Maple has printed above is all the new commands that are now available.  In this worksheet, we are going to use two of them: textplot  and display .

Move you mouse pointer back up to the picture of the triangle.  Click in several places within and near the triangle.  Notice the numbers that appear on the left side of the second toolbar.  These numbers are the and coordinates of the point that you just clicked on.  We can use this technique to figure out good coordinate positions to place the labels.  By doing this, I've decided that (0.2, 0.1) would be a good place to put the symbol in the lower right of the triangle.

The Greek letter is represented by the letter `q` in the SYMBOL  font.  So here's the command for printing the at position (0.2, 0.1):

 > textplot([.2,.1,`q`], font= [SYMBOL,24]); The 24 that appears in the above command is to specify the size of the that I'd like printed.

Save that plot in a variable:

 > Theta:= %:

The display command is used to combine two or more plots into a single plot.  I'd like to put the plots Theta and Triangle together.

 > display( [Theta,Triangle] ); Notice that I used square brackets to specify the list  of plots that I wanted.

Now I am going to label the adjacent side:

 > textplot([.5, -.1, `1`], font= [HELVETICA,BOLD,16]); However, to be general, I don't won't to have to refer to the specific value `1`.  I already set the value of the variable adj to be 1.  Now we can convert the value of any variable into a symbol for the purposes of printing by using the convert  command. Now I will refer to it this way in the textplot command.  There's no need for us to see the "raw" plot of the symbol `1`.  So this time, I am going to save the plot into a variable immediately.

Notice that I ended that command with a colon. Now we'll label the opposite side.  To do this, I choose a point near the center of the opposite side.  But I want the text to go to the right of this point, so I use the option "align= RIGHT".  Unfortunately, there is no way to get the text to print vertically or on a slant.

 > Opp:= textplot( [1.1, 0.5, convert(opp,symbol)]                ,font= [HELVETICA,BOLD,16]                ,align= RIGHT               ): Finally, we label the hypothenuse.  This time, I want the label to go to the left  of a point near the center of the hypothenuse.

 > Hyp:= textplot( [.4, .5, convert(hyp,symbol)]                ,font= [HELVETICA,BOLD,16]                ,align= LEFT               ): Finally, to answer the problem, we note that .

 > opp/hyp; It looks the denominator can be simplified.  However, unless you tell it otherwise, Maple assumes that all variables represent complex numbers (this is called a default  assumption).

 > simplify(%); If you ever see "csgn" (which stands for "complex sign") appear in an answer, you know that Maple is using the complex assumption.  Let's change the assumption.

 > simplify(%) assuming real; As you should all know from algebra, for real numbers, .  So that answer makes sense.  But the original problem contained the stronger assumption .

 > simplify(%) assuming 2<=x; The command modifier assuming  is a feature new to release 7.   In older releases you need to use the command assume  (as a separate command) before simplifying.

 > assume(x>=2);

Maple has no printed response to a correctly entered assume command.

 > simplify(opp/hyp); The ~ next to the variable names indicate that an assumption has been made about that variable.  Assumptions made with assume stay in effect until they are explicitly removed (for example, by assigning a value to the variable or by using another assume on the same variable) whereas those made with assuming  are only in effect for the single command that contains the assuming .

Finally, note that this reference triangle technique ignores the sign of the answer -- it always gives a positive answer.  To determine the sign of the answer, it is best to consider quadrants.  An arctrig function applied to a positive number (in the domain of the function) always gives an angle in the first quadrant.   Since the square root symbol always denotes a nonnegative number,  and since we are assuming , the above answer is nonnegative.  The is  can sometimes verify simple inequalities involving variables that have assumptions.

 > is(%>=0); But is will often return FAIL  for more complicated inequalities -- which means that it could not determine whether the inequality would be true for all values of the variables using the current assumptions.

 >

 >

 >