Objective Questions
-------------------
1. Plot the curve ``sin(x) - cos(x)`` in the range (0, 2pi)
Answer::
x = var('x')
plot(sin(x) - cos(x), (x, 0, 2*pi))
2. plot ``sin(3x)`` and ``cos(x/3)`` and show them in same figure
Answer::
x = var('x')
p1 = plot(sin(3*x), (x, 0, 2*pi))
p2 = plot(cos(x/3), (x, 0, 2*pi))
show(p1+p2)
3. plot ``cos(x)`` vs ``sin(x)^15`` in the range (-2pi, 2pi)
Answer::
x = var('x')
parametric_plot((cos(x), sin(x)^15), (x, -2*pi, 2*pi))
4. plot tan curve in the range (-2pi, 2pi) in red colour.
[hint: see the documentation]
Answer::
x = var('x')
p1 = plot(tan(x), (x, -2*pi, 2*pi), color=(1, 0, 0))
show(p1)
5. plot ``e^(1/x^2)`` in the range (0.5, 2.5) and set the y-axis limits to (0,
20)
Answer::
x = var('x')
p2 = plot(e^(1/x^2), (x, 0.5, 2.5))
show(p2, ymin=0, ymax=20)
6. plot the function ``y = 5x + 3`` using dotted line in the range (-2, 2)
[hint: read the documentation of the function ``line``]
Answer::
points = [ (i, 5*i+3) for i in srange(-2,2,0.1) ]
l1 = line(points, linestyle=":")
show(l1)
7. plot the function ``z = cos(x) + sin(y)`` for x in the range (0, 2pi) and y
in range (-2pi, 2pi)
Answer::
x, y = var('x y')
plot3d(cos(x) + sin(y), (x, 0, 2*pi), (y, -2*pi, 2*pi))
8. Read the sage documentation and find out which function plots closed surfaces
a. parametric_plot3d
#. plot3d
#. implicit_plot3d
#. contour_plot
Answer: implicit_plot3d