chapter19.mws

Chapter 19

> with(plots):

plotting functions

> plot(sin);

[Maple Plot]

> plot(sin, -10..10);

[Maple Plot]

> plot(sin(x), x=-10..10);

[Maple Plot]

> plot( {sin(x), x^2/20}, x=0..2*Pi);

[Maple Plot]

> plot( {seq(sin(n*x)/n, n=1..5)}, x=0..Pi);

[Maple Plot]

> plot( x/(x^2-1), x=-2..3);

[Maple Plot]

> plot( x/(x^2-1), x=-2..3, -10..10);

[Maple Plot]

> plot( x/(x^2-1), x=-2..3, -10..10,discont=true, color=black);

[Maple Plot]

> plot( {x,1+x^2,2+x^x}, x=0..infinity, 0..infinity);

[Maple Plot]

> plot( sin(x^3), x=1..5,numpoints=1500);

[Maple Plot]

> plot( subs(a=1, b=-2, c=2, a*x^2+b*x+c), x=0..3);

[Maple Plot]

> f:=proc(x) if x>0 then sin(x) else x fi end:

> plot( f(x), x=-2..5);

Error, (in f) cannot evaluate boolean

> plot( 'f(x)', x=-2..5);

[Maple Plot]

> plot( sin(I*x), x=-1..1);

Plotting error, empty plot

> plot( { Re(sin(1+I*x)), Im(sin(1+I*x)) }, x=-2..2);

[Maple Plot]

plotting parametric functions

> plot( [ t*cos(t), t*sin(t), t=0..6*Pi], scaling=constrained );

[Maple Plot]

> plot( [ sin(phi)*sin(3*phi), phi,phi=0..2*Pi],coords=polar );

[Maple Plot]

plotting implicit functions

> with(plots):

> implicitplot( x^2-x=y^3-3*y, x=-3..3, y=-2..3);

[Maple Plot]

> implicitplot( (x,y)-> x^2-x-y^3+3*y, -3..3, -2..3);

[Maple Plot]

> implicitplot( sin(x*y), x=-3..5, y=0..10, grid=[80,80]);

[Maple Plot]

points and lines

> plot( [[1,1], [2,2], [3,2], [4,1]] );

[Maple Plot]

> plot(sin(x),x=0..2*Pi, style=point);

[Maple Plot]

> data:=seq( [rand(100)(),rand(100)()], n=1..100):

> plot( [data], style=point );

[Maple Plot]

> listplot( [data], style=point );

[Maple Plot]

> pointplot( [data] );

[Maple Plot]

displaying multiple plots

> f:=x+sin(x): df:=diff(f,x):

> x0:=evalf(solve(df=1));

x0 := 1.570796327

> y0:=evalf(subs( x=x0, f));

y0 := 2.570796327

> p1:=plot(x+sin(x), x=0..4):

> p2:=plot( [[x0-0.5, y0-0.5], [x0+0.5, y0+0.5]] ):

> display( [p1, p2], scaling=constrained);

[Maple Plot]

> datax:=[seq(i*0.3,i=1..20)]:

> datay:=map(sin, datax):

> data:=zip( (x,y)->[x,y], datax, datay):

> with(share): readshare(fit,numerics):

See ?share and ?share,contents for information about the share library

> f:=fit( datax, datay, [1,x,x^2, x^3], x);

f := -.3173777320+2.065951896*x-.9378759199*x^2+.99...

> p1:=plot( data, style=point):

> p2:=plot( f, x=0..6):

> display( [p1,p2] );

[Maple Plot]

> restart: with(plots):

> p1:=plot(sin(x),x=-Pi..Pi,-1..1):
p2:=plot(cos(x),x=-Pi..Pi):
p3:=plot(sinh(x),x=-Pi..Pi):
p4:=plot(cosh(x),x=-Pi..Pi):

> display(array(1..2,1..2,[[p1,p2],[p3,p4]]) );

[Maple Plot]

> p1;p2;p3;p4;

[Maple Plot]

[Maple Plot]

[Maple Plot]

[Maple Plot]

>

labelling plots

> plot( sin(x), x=0..2*Pi, title=`Sinus function`,labels=[`x Axis`, `y Axis`]);

[Maple Plot]

> p1:=plot(sin(x), x=0..2*Pi):

> p2:=textplot([3*Pi/2, 0.5,`sin(x)`] ):

> display( [p1, p2] );

[Maple Plot]

> display( [p1, p2], font=[TIMES, ITALIC, 50],axesfont=[TIMES,ROMAN,30]);

[Maple Plot]

options

> plot( [seq(sin(x+n*Pi/8),n=1..3)], x=0..2*Pi, thickness=[1,2,3], color=black);

[Maple Plot]

> plot( [seq(sin(x+n*Pi/8),n=1..4)], x=0..2*Pi, linestyle=[1,2,3,4], color=black);

[Maple Plot]

> plot( [seq(sin(x+n*Pi/4),n=1..5)], x=0..2*Pi, style=point,
symbol=[BOX, CROSS, CIRCLE, DIAMOND, POINT], color=black, numpoints=100);

[Maple Plot]

> implicitplot( x^2+y^2=1, x=-1..1, y=-1..1);

[Maple Plot]

> implicitplot( x^2+y^2=1, x=-1..1, y=-1..1, scaling=constrained);

[Maple Plot]

> plot( [ sin(3*t), cos(5*t), t=0..2*Pi ], axes=boxed);

[Maple Plot]

> plot( [ sin(3*t), cos(5*t), t=0..2*Pi ], axes=frame);

[Maple Plot]