Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168728
Image: ubuntu2004
  • Vector functions of a curve have 1 parameter, i.e. 1 variable (regardless of the number of components).
  • Vector functions can have 1, 2, 3 or more components = dimension. Components are separated by commas.
  • In SAGE, use DOUBLE parentheses to define a vector function!
  • Top section: define and plot vector (parametric) functions of curves.
  • Below are commands: extract components r[0], evaluate r(t=3), magnitude abs(r) norm(r), derivatives diff(r,t)

var ('t') r=vector((t,t^2)) parametric_plot(r,(t,-2,2), figsize=2)

Notice that parametric_plot is 2d or 3d depending on what it is plotting. (No separate command.)

var ('t') r=vector((sin(t),cos(t),t)) parametric_plot(r,(t,-2*pi,2*pi),color='purple',thickness=3, aspect_ratio=(3,3,1))
view(r)
\newcommand{\Bold}[1]{\mathbf{#1}}\left(\sin\left(t\right),\,\cos\left(t\right),\,t\right)

Extract component functions.

To project onto the x-y plane, define a new vector function using the first 2 components of 3d vector function (numbering starts at 0).

var ('t') r=vector((sin(t),cos(t),t)) r2=vector((r[0],r[1])) p2=parametric_plot(r2,(t,-2*pi,2*pi),rgbcolor=(1,0,0),thickness=2, aspect_ratio=1) show(p2, figsize=3)

You cannot just force a 3d plot of 2d curve with aspect_ratio. (You will get an error as 1- below.)

In order to plot the 2d curve, you need to also plot an actual 3d curve. If you don't want to see it, makes its opacity=0. (See 2-below.)

var ('t') r=vector((sin(t),cos(t),t)) r2=vector((r[0],r[1])) p2_3=parametric_plot(r2,(t,-2*pi,2*pi),color='red',thickness=5, aspect_ratio=(3,3,1)) show(p2_3)
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "_sage_input_15.py", line 10, in <module> exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("dmFyICgndCcpCnI9dmVjdG9yKChzaW4odCksY29zKHQpLHQpKQpyMj12ZWN0b3IoKHJbMF0sclsxXSkpCnAyXzM9cGFyYW1ldHJpY19wbG90KHIyLCh0LC0yKnBpLDIqcGkpLGNvbG9yPSdyZWQnLHRoaWNrbmVzcz01LCBhc3BlY3RfcmF0aW89KDMsMywxKSkKc2hvdyhwMl8zKQ=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))' + '\n', '', 'single') File "", line 1, in <module> File "/tmp/tmpJik_OI/___code___.py", line 7, in <module> exec compile(u'show(p2_3)' + '\n', '', 'single') File "", line 1, in <module> File "/home/sage/sage-4.7/local/lib/python2.6/site-packages/sage/misc/functional.py", line 1487, in show return x.show(*args, **kwds) File "/home/sage/sage-4.7/local/lib/python2.6/site-packages/sage/misc/decorators.py", line 381, in wrapper return func(*args, **kwds) File "/home/sage/sage-4.7/local/lib/python2.6/site-packages/sage/plot/plot.py", line 1726, in show self.save(**kwds) File "/home/sage/sage-4.7/local/lib/python2.6/site-packages/sage/misc/decorators.py", line 381, in wrapper return func(*args, **kwds) File "/home/sage/sage-4.7/local/lib/python2.6/site-packages/sage/plot/plot.py", line 2453, in save figure = self.matplotlib(**options) File "/home/sage/sage-4.7/local/lib/python2.6/site-packages/sage/plot/plot.py", line 1945, in matplotlib ymin=ymin, ymax=ymax) File "/home/sage/sage-4.7/local/lib/python2.6/site-packages/sage/plot/plot.py", line 3886, in adjust_figsize_for_aspect_ratio r = max(aspect_ratio * (xmax - xmin)/(ymax-ymin), 0.001) TypeError: can't multiply sequence by non-int of type 'float'
var ('t') r=vector((sin(t),cos(t),t)) r2=vector((r[0],r[1])) p3=parametric_plot(r,(t,-2*pi,2*pi),opacity=0) p2_3=parametric_plot(r2,(t,-2*pi,2*pi),color='red',thickness=5, aspect_ratio=(3,3,1)) show(p3+p2_3)

Click and drag to rotate this to see that we have projected the helix onto the circle.

var ('t') r=vector((sin(t),cos(t),t)) r2=vector((r[0],r[1])) p3 = parametric_plot(r,(t,-2*pi,2*pi),opacity=0.5,thickness=2,aspect_ratio=(3,3,1)) p2_3 = parametric_plot(r2,(t,-2*pi,2*pi),color='red',thickness=3) var ('x y z') px0y= implicit_plot3d(z==0,(x,-1,1),(y,-1,1),(z,-2*pi,2*pi), color='grey', opacity=0.3) show(p3+p2_3+px0y)
var ('t') r=vector((sin(t),cos(t),t)) r2=vector((r[0],r[1],3)) p2_b = parametric_plot(r2,(t,-2*pi,2*pi),color='red',thickness=5) show(p2_b)
var ('t') r=vector((sin(t),cos(t),t)) m=sqrt(r[0]^2+r[1]^2+r[2]^2) view(m)
\newcommand{\Bold}[1]{\mathbf{#1}}\sqrt{t^{2} + \sin\left(t\right)^{2} + \cos\left(t\right)^{2}}
m2=abs(r) view(m2)
\newcommand{\Bold}[1]{\mathbf{#1}}\sqrt{t^{2} + \sin\left(t\right)^{2} + \cos\left(t\right)^{2}}
m3=r.norm() view(m3)
\newcommand{\Bold}[1]{\mathbf{#1}}\sqrt{{\left| t \right|}^{2} + {\left| \sin\left(t\right) \right|}^{2} + {\left| \cos\left(t\right) \right|}^{2}}
m3a=norm(r) view(m3a)
\newcommand{\Bold}[1]{\mathbf{#1}}\sqrt{{\left| t \right|}^{2} + {\left| \sin\left(t\right) \right|}^{2} + {\left| \cos\left(t\right) \right|}^{2}}
rprime=diff(r,t) view(rprime)
\newcommand{\Bold}[1]{\mathbf{#1}}\left(\cos\left(t\right),\,-\sin\left(t\right),\,1\right)
rprime2=r.diff(t) view(rprime2)
\newcommand{\Bold}[1]{\mathbf{#1}}\left(\cos\left(t\right),\,-\sin\left(t\right),\,1\right)
ds=norm(rprime) view(ds)
\newcommand{\Bold}[1]{\mathbf{#1}}\sqrt{{\left| -\sin\left(t\right) \right|}^{2} + {\left| \cos\left(t\right) \right|}^{2} + 1}
ds(t=3.0)
\newcommand{\Bold}[1]{\mathbf{#1}}1.41421356237310
n(ds(t=3))
\newcommand{\Bold}[1]{\mathbf{#1}}1.41421356237310
var ('t') r=vector((sin(t),cos(t))) m=sqrt(r[0]^2+r[1]^2) view(m)
\newcommand{\Bold}[1]{\mathbf{#1}}\sqrt{\sin\left(t\right)^{2} + \cos\left(t\right)^{2}}
m(t=3)
sqrt(sin(3)^2 + cos(3)^2)
n(m(t=3))
1.00000000000000