Curve Tracing in SageMath

Polar Curves

Q:- Plot the curve :r = 1+cos(t)

Ans: Give the command at sage prompt.

t,s=var(‘t,s’)

s=polar_plot(1+cos(t),(t,0,pi),aspect_ratio = 1, color = ‘red’)

s.show()

s.save(‘cardoid.png’)

Note: Aspect_ratio=1 forces the x and y axes to use the same scale. In other words, one unit on the x-axis takes up the same number of pixels on the screen as one unit on y-axis.

s.save(‘cardoid.png’) will save the image formed as output of above curve as cardoid.png in home folder.

Q:- r=cos(2t)

Ans:

t,s=var(‘t,s’)

s=polar_plot(cos(2*t),(t,0,pi),aspect_ratio = 1, color = ‘red’)

s.show()

s.save(‘cardoid.png’)

Parametric Equations

Q:- x=cos(x) , y= sin(x)

Ans:

x = var(‘x’)

pp = parametric_plot((cos(x),sin(x)),(x,0,2*pi),fill = True, fillcolor =’purple’)

pp.show(aspect_ratio =1, figsize =(3,3), frame= True)

Q:-x= t+sin(t) , y= 1+cos(t)

var(‘t’)

f(t) =( t+sin(t))

s(t)= 1+cos(t)

pp= parametric_plot((f(t),s(t)),(t,-2*pi, 2*pi),fill = True, fillcolor =’blue’)

pp.show()

Simple Equations

Q:- plot sine and cosine waves.

Ans:

p1=plot(sin,(-2*pi,2*pi), thickness = 2.0, rgbcolor = (0.5,1,0), legend_label=’sin(x)’)

p2=plot(cos,(-2*pi,2*pi), thickness = 3.0, color =’purple’,alpha= 0.5, legend_label=’cos(x)’)

plt = p1+p2

plt.axes_labels([‘x’,’f(x)’])

show(plt)

Q:- x^2+ y^2 -4

Ans:-

t,x,y =var(‘t,x,y’)

t= plot3d(x^2+y^2-4,(x,-2,2),(y,-2,2))

t.save(‘raj.png’)

t.show()

Q:- Plot y=x^2

Ans:-

f(x) = x^2

p=plot(f(x),(x,-pi/2,pi/2),color=’blue’)

p.show()

Advertisements

About Priyanka Kapoor

Simple, Hardworking & friendly.....
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s