plotting_using_sage/questions.rst
author anand
Thu, 11 Nov 2010 00:03:57 +0530
changeset 472 fcdec2d28c9a
parent 262 0038edaf660c
permissions -rw-r--r--
Checklist OK for `The other kinds of plots`
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
255
75fd106303dc Added the script to plotting_using_sage
Nishanth <nishanth@fossee.in>
parents:
diff changeset
     1
Objective Questions
75fd106303dc Added the script to plotting_using_sage
Nishanth <nishanth@fossee.in>
parents:
diff changeset
     2
-------------------
75fd106303dc Added the script to plotting_using_sage
Nishanth <nishanth@fossee.in>
parents:
diff changeset
     3
262
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
     4
 1. Plot the curve ``sin(x) - cos(x)`` in the range (0, 2pi)
255
75fd106303dc Added the script to plotting_using_sage
Nishanth <nishanth@fossee.in>
parents:
diff changeset
     5
262
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
     6
   Answer::
255
75fd106303dc Added the script to plotting_using_sage
Nishanth <nishanth@fossee.in>
parents:
diff changeset
     7
262
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
     8
       x = var('x')
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
     9
       plot(sin(x) - cos(x), (x, 0, 2*pi))
255
75fd106303dc Added the script to plotting_using_sage
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    10
262
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    11
 2. plot ``sin(3x)`` and ``cos(x/3)`` and show them in same figure
255
75fd106303dc Added the script to plotting_using_sage
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    12
262
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    13
   Answer::
255
75fd106303dc Added the script to plotting_using_sage
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    14
262
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    15
       x = var('x')
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    16
       p1 = plot(sin(3*x), (x, 0, 2*pi))
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    17
       p2 = plot(cos(x/3), (x, 0, 2*pi))
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    18
       show(p1+p2)
255
75fd106303dc Added the script to plotting_using_sage
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    19
262
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    20
 3. plot ``cos(x)`` vs ``sin(x)^15`` in the range (-2pi, 2pi)
255
75fd106303dc Added the script to plotting_using_sage
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    21
262
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    22
   Answer::
255
75fd106303dc Added the script to plotting_using_sage
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    23
262
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    24
       x = var('x')
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    25
       parametric_plot((cos(x), sin(x)^15), (x, -2*pi, 2*pi))
255
75fd106303dc Added the script to plotting_using_sage
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    26
262
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    27
 4. plot tan curve in the range (-2pi, 2pi) in red colour.
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    28
    [hint: see the documentation]
255
75fd106303dc Added the script to plotting_using_sage
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    29
75fd106303dc Added the script to plotting_using_sage
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    30
   Answer::
75fd106303dc Added the script to plotting_using_sage
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    31
262
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    32
       x = var('x')
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    33
       p1 = plot(tan(x), (x, -2*pi, 2*pi), color=(1, 0, 0))
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    34
       show(p1)
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    35
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    36
 5. plot ``e^(1/x^2)`` in the range (0.5, 2.5) and set the y-axis limits to (0,
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    37
    20)
255
75fd106303dc Added the script to plotting_using_sage
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    38
262
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    39
   Answer::
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    40
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    41
       x = var('x')
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    42
       p2 = plot(e^(1/x^2), (x, 0.5, 2.5))
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    43
       show(p2, ymin=0, ymax=20)
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    44
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    45
 6. plot the function ``y = 5x + 3`` using dotted line in the range (-2, 2)
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    46
    [hint: read the documentation of the function ``line``]
255
75fd106303dc Added the script to plotting_using_sage
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    47
75fd106303dc Added the script to plotting_using_sage
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    48
   Answer::
75fd106303dc Added the script to plotting_using_sage
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    49
262
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    50
       points = [ (i, 5*i+3) for i in srange(-2,2,0.1) ]
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    51
       l1 = line(points, linestyle=":")
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    52
       show(l1)
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    53
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    54
 7. plot the function ``z = cos(x) + sin(y)`` for x in the range (0, 2pi) and y
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    55
    in range (-2pi, 2pi)
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    56
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    57
   Answer::
255
75fd106303dc Added the script to plotting_using_sage
Nishanth <nishanth@fossee.in>
parents:
diff changeset
    58
262
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    59
       x, y = var('x y')
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    60
       plot3d(cos(x) + sin(y), (x, 0, 2*pi), (y, -2*pi, 2*pi))
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    61
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    62
 8. Read the sage documentation and find out which function plots closed surfaces
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    63
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    64
   a. parametric_plot3d
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    65
   #. plot3d
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    66
   #. implicit_plot3d
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    67
   #. contour_plot
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    68
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    69
   Answer: implicit_plot3d
0038edaf660c Added questions
Nishanth <nishanth@fossee.in
parents: 255
diff changeset
    70