Analytical Geometry - Computer lab
(EM111: Winter Semester 2011)
Gnuplot
Use gnuplot, a command-line driven graphing utility to
plot graphs, contours, and make surface plots.
Online help is available in, e.g.,
Matlab
Use matlab to plot graphs and find solutions for algebraic equations and
for the initial value problem of differential equations.
Online help is available in, e.g.,
Many other graphics packages are available.
Lines and curves on the plane
Exercise 1
Plot a parabola y = a x2.
Use gnuplot.
a = 1.0
set xrange[-2:2]
set yrange[0:4]
set xlabel 'x'
set ylabel 'y'
plot a*x**2
In order to save the graph in a file (in postscript format) under the name
fig.ps with use the commands:
set term post
set output 'fig.ps'
replot
In order to view again the graph on the screen:
set term x11
replot
Use matlab.
x=-10:0.1:10;
y=5*x.^2;
plot(x,y)
Exercise 2
Plot the unit circle.
Use matlab.
y=0:0.01:1;
x=(1-y.^2).^(1/2)
;
plot(x,y)
hold on
plot(-x,y)
plot(-x,-y)
plot(x,-y)
Exercise 3
Plot the hyperbola x2-y2=1, its conjugate, and the asymptotes.
Use matlab.
y=1:0.1:10;
x=(y.^2-1).^(1/2);
plot(x,y,'r')
hold on
plot(-x,y,'r')
plot(-x,-y,'r')
plot(x,-y,'r')
x=0:0.1:10;
y=(x.^2+1).^(1/2);
plot(y,x,'b')
plot(-y,x,'b')
plot(-y,-x,'b')
plot(y,-x,'b')
x=-10:0.1:10;
y=x;
plot(y,x,'g')
plot(-y,x,'g')
Exercise 4
Plot a circle using with rational functions for its parametrization
Use matlab.
t=-1000:0.1:1000;
x=(1-t.^2)./(1+t.^2);
y=2*t./(1+t.^2);
plot(x,y)
axis equal
Polar coordinates
Exercise 1
Plot the cardioid using polar coordinates
Use gnuplot
set xrange[-2:2]
set yrange[-1.5:1.5]
set xlabel 'x'
set ylabel 'y'
set polar
plot 1-cos(t)
Use matlab.
t=0:0.1:2*pi;
x=cos(2*t)+2*cos(t);
y=sin(2*t)+2*sin(t);
plot(x,y)
Exercise 2
Plot the Lemniscate of Bernoulli using polar coordinates
Use matlab
t=0:0.1:3*pi;
x=(2^(0.5))*cos(t)./(((sin(t)).^2)+1);
y=x.*sin(t);
plot(x,y)
Surfaces of revolution
Exercise 1
Plot a paraboloid z = x2+y2.
set xrange[-10:10]
set yrange[-10:10]
set isosamples 40,40
splot x**2+y**2