LearningGuide

# It calculates the value of the function or expression

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: r special case. The function x → 1/(x − 1)2 has a singularity at x = 1. &gt; plot( 1/(x-1)^2, x=-5..6 ); 250000 200000 150000 100000 50000 –4 –2 0 2 4 6 x In the previous plot, all the interesting details of the graph are lost because there is a spike at x = 1. The solution is to view a narrower range, perhaps from y = −1 to 7. &gt; plot( 1/(x-1)^2, x=-5..6, y=-1..7 ); 5.1 Graphing in Two Dimensions • 113 7 6 5 y 4 3 2 1 –4 –2 0 –1 2 x 4 6 The tangent function has singularities at x = integer. &gt; plot( tan(x), x=-2*Pi..2*Pi ); π 2 + πn, where n is any 3000 2000 1000 –6 –4 –2 2 x 4 6 To see the details, reduce the range to y = −4 to 4. &gt; plot( tan(x), x=-2*Pi..2*Pi, y=-4..4 ); 4 3 y2 1 –6 –4 –2 0 –1 –2 –3 –4 2 x 4 6 Maple draws almost vertical lines at the singularities. To speciﬁy a plot without these lines, use the discont=true option. 114 • Chapter 5: Plotting &gt; plot( tan(x), x=-2*Pi..2*Pi, y=-4..4, discont=true ); 4 3 y2 1 –6 –4 –2 0 –1 –2 –3 –4 2 x 4 6 Multiple Functions To graph more than one function in the same plot, give plot a list of functions. &gt; plot( [ x, x^2, x^3, x^4 ], x=-10..10, y=-10..10 ); 10 8 6 y 4 2 –10 –8 –6 –4 –2 0 –2 –4 –6 –8 –10 2 4 x 6 8 10 &gt; f := x -&gt; piecewise( x&lt;0, cos(x), x&gt;=0, 1+x^2 ); f := x → piecewise(x &lt; 0, cos(x), 0 ≤ x, 1 + x2 ) &gt; plot( [ f(x), diff(f(x), x), diff(f(x), x, x) ], &gt; x=-2..2, discont=true ); 5.1 Graphing in Two Dimensions • 115 5 4 3 2 1 –2 –1 0 –1 1 x 2 This technique also works for parametrized plots. &gt; plot( [ [ 2*cos(t), sin(t), t=0..2*Pi ], &gt; [ t^2, t^3, t=-1..1 ] ], scaling=constrained ); 1 0.5 –2 –1 –0.5 –1 1 2 To distinguish between several graphs in the same plot, use diﬀerent line styles such as solid, dashed, or dotted. Use the linestyle option where linestyle=SOLID for the ﬁrst function, sin(x)/x, and linestyle=DOT for the second function, cos(x)/x. &gt; plot( [ sin(x)/x, cos(x)/x ], x=0..8*Pi, y=-0.5..1.5, &gt; linestyle=[SOLID,DOT] ); 1.4 1.2 1 y0.8 0.6 0.4 0.2 0 –0.2 –0.4 5 10 x 15 20 25 116 • Chapter 5: Plotting You can also change the line style by using the standard menus and the context-sensitive menus. Similarly, specify the colors of the graphs by using the color option. Note that in this manual, the lines appear in two diﬀerent shades of gray. &gt; plot( [ [f(x), D(f)(x), x=-2..2], &gt; [D(f)(x), (D@@2)(f)(x), x=-2..2] ], &gt; color=[gold, plum] ); 4 3 2 1 0 –1 1 2 3 4 5 For more details on colors, refer to the ?plot,color help page. Plotting Data Points To plot numeric data, call pointplot in the plots package with the data in a list of lists of the form [[x1 , y1 ], [x2 , y2 ], . . . , [xn , yn ]]. If the list is long, assign it to a name. &gt; data_list:=[[-2,4],[-1,1],[0, 0],[1,1],[2,4],[3,9],[4,16]]; data _list := [[−2, 4], [−1, 1], [0, 0], [1, 1], [2, 4], [3, 9], [4, 16]] &gt; pointplot(data_list); 5.1 Graphing in Two Dimensions...
View Full Document

## This note was uploaded on 08/27/2012 for the course MATH 1100 taught by Professor Nil during the Spring '12 term at National University of Singapore.

Ask a homework question - tutors are online