defining and plotting a parametric curve in 3d a(t)=(x(t...

19
Defining and Plotting a Parametric Curve in 3D a(t)=(x(t),y(t),z(t)) Clear@"Global`*"DH* clears all previous assingments so we can reuse them *L H* Define vector functions in 3D of one variable t, i.e. a curve in 3D *L H* to typeset the alpha, beta, and sigma using esc alpha esc, ditto beta, ditto sigma *L a@t_D = 8Cos@tD, Sin@tD,t< b@t_D = 8t, 2 * t, 3 * t< s@t_D = 8Cos@tD, Sin@tD,0< H* Plot the curves a,b, s with no plotting options defined *L H* Give the plot an assigned name and use this name in the GraphicsGrid command to plot *L aplot1 = ParametricPlot3D@a@tD, 8t, 0, 2 * Pi<D ; bplot1 = ParametricPlot3D@b@tD, 8t, 0, 2 * Pi<D ; splot1 = ParametricPlot3D@s@tD, 8t, 0, 2 * Pi<D ; H* Plot the curve with some plotting options *L aplot2 = ParametricPlot3D@a@tD, 8t, 0, 2 * Pi<, PlotStyle Ø Directive@Red, Thickness@0.015DD, AxesLabel Ø 8x, y, z<, LabelStyle Ø Directive@Black, 15DD; bplot2 = ParametricPlot3D@b@tD, 8t, 0, 2 * Pi<, PlotStyle Ø Directive@Red, Thickness@0.015D, DashedD, AxesLabel Ø 8x, y, z<, LabelStyle Ø Directive@Black, 15DD; splot2 = ParametricPlot3D@s@tD, 8t, 0, 2 * Pi<, PlotStyle Ø Directive@Red, Thickness@0.015D, DotDashedD, AxesLabel Ø 8x, y, z<, LabelStyle Ø Directive@Black, 15DD; H* Display the two plots side by side *L GraphicsGrid@ D

Upload: buinhi

Post on 16-Feb-2018

215 views

Category:

Documents


1 download

TRANSCRIPT

Defining and Plotting a Parametric Curve in 3D a(t)=(x(t),y(t),z(t))

Clear@"Global`*"D H* clears allprevious assingments so we can reuse them *L

H* Define vector functions in 3D of one variable t,i.e. a curve in 3D *LH* to typeset the alpha, beta,and sigma using esc alpha esc,ditto beta, ditto sigma *La@t_D = 8Cos@tD, Sin@tD, t<b@t_D = 8t, 2*t, 3*t<s@t_D = 8Cos@tD, Sin@tD, 0<

H* Plot the curves a,b,s with no plotting options defined *LH* Give the plot an assigned name and use thisname in the GraphicsGrid command to plot *L

aplot1 = ParametricPlot3D@a@tD, 8t, 0, 2*Pi<D ;bplot1 = ParametricPlot3D@b@tD, 8t, 0, 2*Pi<D ;splot1 = ParametricPlot3D@s@tD, 8t, 0, 2*Pi<D ;

H* Plot the curve with some plotting options *Laplot2 = ParametricPlot3D@a@tD, 8t, 0, 2*Pi<,

PlotStyle Ø Directive@Red, [email protected],AxesLabel Ø 8x, y, z<,LabelStyle Ø Directive@Black, 15DD;

bplot2 = ParametricPlot3D@b@tD, 8t, 0, 2*Pi<,PlotStyle Ø Directive@Red, [email protected], DashedD,AxesLabel Ø 8x, y, z<,LabelStyle Ø Directive@Black, 15DD;

splot2 = ParametricPlot3D@s@tD, 8t, 0, 2*Pi<,PlotStyle Ø Directive@Red, [email protected], DotDashedD,AxesLabel Ø 8x, y, z<,LabelStyle Ø Directive@Black, 15DD;

H* Display the two plots side by side *LGraphicsGrid@

D

88aplot1, bplot1, splot1<, 8aplot2, bplot2, splot2<< D

H* Display all the plots on one set of axes *Lplots1 = Show@8aplot1, bplot1, splot1<D;plots2 = Show@8aplot2, bplot2, splot2<D;

H* Now plot the combined plots side by side *LGraphicsGrid@88plots1, plots2< <D

8Cos@tD, Sin@tD, t<

8t, 2 t, 3 t<

8Cos@tD, Sin@tD, 0<

-1.0-0.50.00.51.0-1.0-0.50.0

0.51.0

0

2

4

6

0 2 4 6

0510

0

5

10

15

-1.0-0.50.0 0.5 1.0

-1.0-0.50.00.5

1.0

-1.0-0.50.00.51.0

-1.0-0.50.00.51.0x-1.0-0.50.00.51.0y

0246

z

0246x

0 510y

051015z

-1.0-0.50.00.51.0x

-1.0-0.50.00.51.0y

-1.0-0.50.00.51.0z

-1.0-0.50.00.51.0-1.0-0.5

0.00.51.0

0

2

4

6

-1.0-0.50.00.51.0x

-1.0-0.50.00.51.0y

0

2

4

6

z

2 BasicPlotting.nb

Defining and Plotting Explicit Functions z=f(x,y)

BasicPlotting.nb 3

Clear@"Global`*"D H* clears allprevious assingments so we can reuse them *L

H* Define some explicit functions z=fHx,yL,z=gHx,yL, z=hHx,yL, i.e. surfaces in 3D *Lf@ x_, y_ D = x^2 + y^2g@x_, y_D = Cos@xD*Sin@yDh@x_, y_D = 2*x - 3*y + 2

H* Plot surfaces with no plot options *LR = 5;plotf1 = Plot3D@f@x, yD, 8x, -R, R<, 8y, -R, R<D;plotg1 = Plot3D@g@x, yD, 8x, -R, R<, 8y, -R, R<D;ploth1 = Plot3D@h@x, yD, 8x, -R, R<, 8y, -R, R<D;

H* Plot surfaces with some basic plot options *LR = 5;plotf2 = Plot3D@f@x, yD, 8x, -R, R<, 8y, -R, R<,

PlotStyle Ø Directive@GreenDD;plotg2 = Plot3D@g@x, yD, 8x, -R, R<, 8y, -R, R<,

PlotStyle Ø Directive@RedD, Mesh Ø False D;ploth2 = Plot3D@h@x, yD, 8x, -R, R<, 8y, -R, R<,

PlotStyle Ø Directive@Blue, [email protected],Mesh -> FalseD;

H* Plot surfaces with some more plot options *LPlot3D@f@x, yD, 8x, -R, R<, 8y, -R, R<,ImageSize Ø 8400, 400<,ColorFunction Ø "SunsetColors", Background Ø Black,Boxed -> False, Mesh Ø 20,PlotStyle Ø Directive@[email protected]

H* Plot surfaces side by side *LGraphicsGrid@88plotf1, plotg1, ploth1<, 8plotf2, plotg2, ploth2<<D

H* Group plots on one set of axesthen display pairs side by side *L

plot1 = Show@ 8plotf1, plotg1, ploth1< D;plot2 = Show@ 8plotf2, plotg2, ploth2< D;GraphicsGrid@ 88plot1, plot2<< D

4 BasicPlotting.nb

x2 + y2

Cos@xD Sin@yD

2 + 2 x - 3 y

BasicPlotting.nb 5

6 BasicPlotting.nb

Defining and Plotting Implicit Functions f(x,y,z)=c where c is some constant

ü Recall Implicit Functions f(x,y)=c and their relation to z=f(x,y)

Clear@"Global`*"D H* clears allprevious assingments so we can reuse them *L

H* define an expression in the variables x and y *Lf@x_, y_D = x*Cos@yD;

H* ContourPlot is how youplot an implicit function fHx,yL=c *L

plot1 = ContourPlot@8f@x, yD ã -1, f@x, yD ã 1ê2<,8x, -2, 2<, 8y, -2, 2<, AxesLabel Ø 8x, y<,ContourStyle Ø Directive@Black, [email protected];

H* In terms of the surface z=fHx,yL,how do we geometrically interpret fHx,yL=c? *Lplot2 = Plot3D@8f@x, yD, -1, 1ê2<, 8x, -2, 2<, 8y, -2, 2<,

PlotStyle Ø 8Directive@Green, Specularity@White, 20DD,Directive@Black, [email protected],Directive@Black, [email protected]<,

Lighting Ø "Neutral", Mesh Ø False,ImageSize Ø 8500, 500<, AxesLabel Ø 8x, y, z<D;

H* Plot the ContourPlot and theSurface with z planes side by side *L

GraphicsGrid@88 plot1, plot2 << D

H* Just for fun lets make an animationfor various values of the "z-slice" *L

P1 = Manipulate@ContourPlot@f@x, yD ã c, 8x, -3, 3<,8y, -3, 3<, AxesLabel Ø 8x, y<, ContourStyle ØDirective@Black, [email protected], 8c, -2, 3, 1<D;

P2 = Manipulate@Plot3D@8f@x, yD, c<, 8x, -3, 3<,8y, -3, 3<, PlotStyle Ø 8Directive@GreenD,

Directive@Black, [email protected]<, Mesh Ø False,ImageSize Ø 8500, 500<, AxesLabel Ø 8x, y, z<,ImageSize Ø 8200, 200<D, 8c, -2, 3, 1<D;

GraphicsGrid@88P1, P2<<, ImageSize Ø 81200, 1200<D;

BasicPlotting.nb 7

8 BasicPlotting.nb

ü Implicit Functions f(x,y,z)=c and their relation to w=f(x,y,z) (ToDo When Get Faster Machine--ContourPlot3D)

H* Define two expression eachdepending on three variables *L

F@x_, y_, z_D = x^2 + y^2 + z^2G@x_, y_, z_D = Cos@xD*Sin@yD*z

H* ContourPlot3D is how to plot FHx,y,zL=c *LH* ContourPlot3D@8F@x,y,zD==1,F@x,y,zD==4<,8x,-2,2<,8y,-2,2<,8z,-2,2<,ContourStyleØ8Directive@BlueD, Directive@Green,[email protected] < D *L

x2 + y2 + z2

z Cos@xD Sin@yD

BasicPlotting.nb 9

Curve in 2D a(t)=(x(t),y(t)), Curve b(t)=f(a(t)) on Surface z=f(x,y) in 3D

10 BasicPlotting.nb

Clear@"Global`*"D H* clears allprevious assingments so we can reuse them *L

H* Define a functionêsurface z=fHx,yL on which we will "project" a curve *L

f@x_, y_D = x^2 + y^2*Sin@x*yD

H* Define a 2D curve aHtL in the Hx,yL-plane *Lx@t_D = Cos@tDy@t_D = Sin@tDa2@t_D = 8x@tD, y@tD<

H* Trick: Think of the 2D curve aHtLas a 3D curve in the Hx,y,z=0L-plane *L

a3@t_D = 8x@tD, y@tD, 0<

H* Define a 3D curve bHtL=fHaHtLL which is constrained to the surface z=fHx,yL *L

af@t_D = 8x@tD, y@tD, f@x@tD, y@tDD<

H* Plots of the above *La2plot = ParametricPlot@a2@tD, 8t, 0, 2*Pi<,

PlotStyle Ø Directive@ Black, [email protected],AxesLabel Ø 8x, y<, Frame Ø TrueD;

a3plot = ParametricPlot3D@a3@tD, 8t, 0, 2*Pi<,PlotStyle Ø Directive@ Black, [email protected],AxesLabel Ø 8x, y, z<, Boxed Ø TrueD;

afplot = ParametricPlot3D@af@tD, 8t, 0, 2*Pi<,PlotStyle Ø Directive@ Black, [email protected],AxesLabel Ø 8x, y, z<, Boxed Ø TrueD;

fplot = Plot3D@f@x, yD, 8x, -1, 1<, 8y, -1, 1<, PlotStyle ØDirective@Red, [email protected], Specularity@White, 20DD,

Mesh Ø False, AxesLabel Ø 8x, y, z<,Boxed Ø True, ImageSize Ø 8500, 500<D;

H* Bring the 2D and 3D plots together *Lplot1 = Show@8afplot, fplot, a3plot< D;GraphicsGrid@ 88a2plot, a3plot, plot1<< D

BasicPlotting.nb 11

x2 + y2 Sin@x yD

Cos@tD

Sin@tD

8Cos@tD, Sin@tD<

8Cos@tD, Sin@tD, 0<

9Cos@tD, Sin@tD, Cos@tD2 + Sin@tD2 Sin@Cos@tD Sin@tDD=

Bring All The Above Together: Curve of Intersection Problems

ü (In Class Problem) Find the curve of intersection of the two surfaces f(x, y) = x + 2 y - 2 and g(x, y) = 2 x + y + 3.

(Hint: Do the algebra work by hand)(Extra: Come up with plots to check your answer)

12 BasicPlotting.nb

ü

(In Class Problem) Find the curve of intersection of the two surfaces f(x, y) = x + 2 y - 2 and g(x, y) = 2 x + y + 3.

(Hint: Do the algebra work by hand)(Extra: Come up with plots to check your answer)

„ (An Answer) :

Remember that f(x,y)=x+2y-2 g(x,y)=2x+y+3 are explicit functions of x and y which weinterpret to mean z=x+2y-2 and z=2x+y+3. To be an intersection curve the x, y and z'smust all be equal. Our equations scream for us to focus on the zʼs first (since they arealready “solved” for z.

Clear@"Global`*"DH* clears all previous assingments so we can reuse them *L

H* We want to find when the z values equal,so set them equal OR find when their difference is 0 *LSolve@x + 2*y - 2 - H2*x + y + 3L ã 0, xD H* option 1,Solve for x in terms of y, i.e. find xHyL *LSolve@x + 2*y - 2 - H2*x + y + 3L ã 0, yD H* option 2,Solve for y in terms of x, that is find yHxL *L

H* At this point we can write at least two solutions *La@y_D = 8-5 + y, y, 2*H-5 + yL + y + 3 <;H* y is playing the role of the parameter t *Lb@x_D = 8x, 5 + x, x + 2*H5 + xL - 2< ;H* x is playing the role of the parameter t *L

PossibleAnswer1 ã Simplify@a@tDDPossibleAnswer2 ã Simplify@b@tDD

H* plot these curves *LSolutionCurve1 = ParametricPlot3D@a@yD, 8y, 0, 5<,

PlotStyle Ø Directive@Green, [email protected];SolutionCurve2 = ParametricPlot3D@b@xD, 8x, -1, 0<,

PlotStyle Ø Directive@Green, [email protected];

H* plot the two original surfaces *LSurfacesPlot =

Plot3D@8x + 2*y - 2, 2*x + y + 3<, 8x, -5, 5<, 8y, -5, 5<,PlotStyle Ø 8Directive@RedD, Directive@ Blue, [email protected]<D;

GraphicsGrid@ 88Show@SolutionCurve1, SurfacesPlot D,Show@SolutionCurve2, SurfacesPlot D<< D

88x Ø -5 + y<<

BasicPlotting.nb 13

88y Ø 5 + x<<

PossibleAnswer1 ã 8-5 + t, t, -7 + 3 t<

PossibleAnswer2 ã 8t, 5 + t, 8 + 3 t<

ü (HomeWork 1) Find the curve of intersection of the two surfaces x + 3 y + 4 z - 2 = 0 and (x - 1) + (2 y + 2) - (z - 2) = 0

(Hint : Do the algebra work by hand)(Extra : Come up with plots to check your answer)

„ (An Answer) : So this problem is like the In Class Problem but both surfaces are Implicit.

Donʼt panic when you see an implicit form of a function. As a start, you can always try toturn it into an explicit form by solving for the “easiest” variable.

14 BasicPlotting.nb

Clear@"Global`*"DH* clears all previous assingments so we can reuse them *L

H* So the surfaces are implicit fHx,y,zL=c form,so remedy this "problem" by solving for the explicit form x=fHy,zL. *L

foo = Expand@Hx - 1L + H2 * y + 2L - Hz - 2L ã 0Dfoo1 = Solve@foo, xDfoo2 = Solve@x + 3 * y + 4 * z - 2 ã 0, xDa@y_, z_D = -3 - 2 * y + z;

b@y_, z_D = 2 - 3 * y - 4 * z;

H* So now we have two explicit functions for x as afunction of y and z. Now repeat steps from Homework 1 *L

SurfacesPlot = ContourPlot3D@8x + 3 * y + 4 * z - 2 ã 0,Hx - 1L + H2 * y + 2L - Hz - 2L ã 0<, 8x, -10, 10<, 8y, -10, 10<, 8z, -10, 10<,

ContourStyle Ø 8Directive@RedD, Directive@ Blue, [email protected]<,AxesLabel Ø 8x, y, z<D;

H* Solve for y as a function of z *L

Solve@a@y, zD - b@y, zD ã 0, yD

H* Define a curve with parameter z andshow its plot along with the two surfaces *L

Solution@z_D = 8-3 - 2 * H5 - 5 * zL + z, 5 - 5 * z , z <

SolutionPlot = ParametricPlot3D@Solution@zD, 8z, 0, 2<,PlotStyle Ø Directive@Green, [email protected], AxesLabel Ø 8x, y, z<D;

foo3 = GraphicsGrid@88Show@SolutionPlot, SurfacesPlot D<< , ImageSize Ø 8500, 500< D

3 + x + 2 y - z ã 088x Ø -3 - 2 y + z<<88x Ø 2 - 3 y - 4 z<<88y Ø -5 H-1 + zL<<8-3 - 2 H5 - 5 zL + z, 5 - 5 z, z<

3 + x + 2 y - z ã 0

88x Ø -3 - 2 y + z<<

88x Ø 2 - 3 y - 4 z<<

88y Ø -5 H-1 + zL<<

8-3 - 2 H5 - 5 zL + z, 5 - 5 z, z<

BasicPlotting.nb 15

3 + x + 2 y - z ã 0

88x Ø -3 - 2 y + z<<

88x Ø 2 - 3 y - 4 z<<

88y Ø -5 H-1 + zL<<

8-3 - 2 H5 - 5 zL + z, 5 - 5 z, z<

16 BasicPlotting.nb

ü (HomeWork 2) Find the curve of intersection of the two surfaces f(x,y)=-x+2y and x+(y+2)+2(z+3)=0.

(Hint: Do the algebra work by hand)(Extra: Come up with plots to check your answer)

„ (An Answer):

Am I trying to trick you by giving you one implicit and one explicit function? No. Just followthe same steps as in previous examples.

SurfacesPlot = Plot3D@8-x + 2*y, -1ê2*Hx + y L - 4<, 8x, -5, 5<, 8y, -5, 5<,PlotStyle Ø 8Directive@RedD,

Directive@ Blue, [email protected]<D;

CurvePlot = ParametricPlot3D@8H5*y + 8L, y, -H5*y + 8L + 2*y<, 8y, -5, 5<,PlotStyle Ø Directive@Green, [email protected];

Show@SurfacesPlot, CurvePlot D

BasicPlotting.nb 17

ü (HomeWork, A Little More Challenging) Find the curve of intersection of the two surfaces x^2*y-z=5 and xy-z=4

(Hint: Do the algebra work by hand)(Extra: Come up with plots to check your answer)

„ (An Answer)

SurfacesPlot = ContourPlot3D@8x^2*y - z ã 5, x*y - z ã 4<, 8x, -5, 5<, 8y, -5, 5<, 8z, -5, 5<,ContourStyle Ø 8Directive@RedD,

Directive@ Blue, [email protected]<D;

a@x_D = 8x, 1êHx^2 - xL, 1êHx - 1L - 4<

H* Notice from the formula for aHxL the problem values x=0 and x=1 so take note when plotting *L

CurvePlot1 = ParametricPlot3D@a@xD, 8x, -5, -0.1<,PlotStyle Ø Directive@Green, [email protected];

CurvePlot2 = ParametricPlot3D@a@xD, 8x, 0.1, 0.9<,PlotStyle Ø Directive@Green, [email protected];

CurvePlot3 = ParametricPlot3D@a@xD, 8x, 1.01, 5<,PlotStyle Ø Directive@Green, [email protected];

Show@SurfacesPlot, CurvePlot1 , CurvePlot2, CurvePlot3D

:x,1

-x + x2, -4 +

1

-1 + x>

18 BasicPlotting.nb

BasicPlotting.nb 19