Differential Geometry in Sage

524 days ago by zrzhou

Differential Geomtry in Sage

Chapter 1. Curves

 

排版打印:

要输出漂亮的数学公式有几种方法:

1. 用pretty_print_default();

2. 勾选会话上面的Typeset;

3. 用show()。

注意:要输出漂亮的数学公式,首先必须安装jsmath字体。Ubuntu用户直接在仓库里安装即可,Win用户到这里下载字体,然后解压,将字体文件拷贝到WINDOWS的Fonts目录即可。建议使用火狐浏览器,因为在ie里公式有些错位。

pretty_print_default(True) var('x,y') x^3/(y*sin(x)) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}\frac{x^{3}}{y \sin\left(x\right)}
\newcommand{\Bold}[1]{\mathbf{#1}}\frac{x^{3}}{y \sin\left(x\right)}
pretty_print_default(False) x^3/(y*sin(x)) 
       
x^3/(y*sin(x))
x^3/(y*sin(x))
a=x^3/(y*sin(x)) a.show() 
       
\newcommand{\Bold}[1]{\mathbf{#1}}\frac{x^{3}}{y \sin\left(x\right)}
\newcommand{\Bold}[1]{\mathbf{#1}}\frac{x^{3}}{y \sin\left(x\right)}

定义三个向量的混合积:

(注意:带有#auto的元组,在工作表打开时自动运行)

#auto def triple_product(u,v,w): A=u.cross_product(v) B=A.dot_product(w) return B 
       

定义一个函数求相对曲率

\kappa_r(x,y)=\frac{x'y''-x''y'}{[(x')^2+(y')^2]^{3/2}}

def relka(x,y): xp=diff(x,t) xpp=diff(xp,t) yp=diff(y,t) ypp=diff(yp,t) rk=(xp*ypp-xpp*yp)/(xp^2+yp^2)^(3/2) return rk 
       

例:求曲线C:x=\cos t,y=\sin t的相对曲率。

t=var('t') A=relka(cos(t),sin(t)) A.subs(t=0) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}1
\newcommand{\Bold}[1]{\mathbf{#1}}1

例:求曲线C:x=a\cos t,y=b\sin t的相对曲率。

var('a,b') x=a*cos(t) y=b*sin(t) relka(x,y).subs(t=0).full_simplify() 
       
\newcommand{\Bold}[1]{\mathbf{#1}}\frac{a}{b {\left| b \right|}}
\newcommand{\Bold}[1]{\mathbf{#1}}\frac{a}{b {\left| b \right|}}
 
       

定义空间曲线的曲率:

\kappa=\frac{|r'\times r''|}{|r'|^3}

def kappa3(r): rp=diff(r,t) rpp=diff(rp,t) a=rp.cross_product(rpp).norm() b=rp.norm() return a/b^3 
       

例:计算曲线C:r=(a\cos t,a\sin t,bt)的曲率。

var('a,b,t') r=vector((a*cos(t),a*sin(t),b*t)) kappa3(r) kappa3(r).subs(t=0).full_simplify() 
       
\newcommand{\Bold}[1]{\mathbf{#1}}\frac{a}{a^{2} + b^{2}}
\newcommand{\Bold}[1]{\mathbf{#1}}\frac{a}{a^{2} + b^{2}}
 
       

定义空间曲线的挠率:

\tau=\frac{(r',r'',r''')}{|r'\times r''|^2}

def tau(r): rp=diff(r,t) rpp=diff(rp,t) rppp=diff(rpp,t) a=triple_product(rp,rpp,rppp) b=rp.cross_product(rpp).norm() return a/b^2 
       

例:计算曲线C:r=(a\cos t,a\sin t,bt)的挠率。

var('a b t') r=vector((a*cos(t),a*sin(t),b*t)) tau(r).full_simplify() 
       
\newcommand{\Bold}[1]{\mathbf{#1}}\frac{b}{b^{2} \sin\left(t\right)^{2} + b^{2} \cos\left(t\right)^{2} + a^{2}}
\newcommand{\Bold}[1]{\mathbf{#1}}\frac{b}{b^{2} \sin\left(t\right)^{2} + b^{2} \cos\left(t\right)^{2} + a^{2}}
var('a b t') r=vector((a*cos(t),a*sin(t),b*t)) tau(r).full_simplify().full_simplify() 
       
\newcommand{\Bold}[1]{\mathbf{#1}}\frac{b}{a^{2} + b^{2}}
\newcommand{\Bold}[1]{\mathbf{#1}}\frac{b}{a^{2} + b^{2}}

空间曲线C:r=(x(t),y(t),z(t))的三个基本向量:

\left\{ \begin{aligned} & {\alpha}=\frac{{r}'}{\vert{r}'\vert},\\

& {\beta}=\frac{({r}'\cdot{r}){r}''-({r}'\cdot{r}''){r}'}{\vert{r}'\vert\cdot\vert{r}'\times{r}''\vert},\\

& {\gamma}=\frac{{r}'\times{r}''}{\vert{r}'\times{r}''\vert}.\end{aligned}

\right.

 
       

曲线C:r=(x(t),y(t),z(t))t=t_0处的密切平面方程为:

\left|\begin{array}{ccc}

X-x(t_{0}) & Y-y(t_{0}) & Z-z(t_{0})\\

x'(t_{0}) & y'(t_{0}) & z'(t_{0})\\

x''(t_{0}) & y''(t_{0}) & z''(t_{0})\end{array}\right|=0.

def osculating_plane(r): rp=diff(r,t) rpp=diff(rp,t) var('X Y Z') A=Matrix(SR,[[X-r[0],Y-r[1],Z-r[2]],[rp[0],rp[1],rp[2]],[rpp[0],rpp[1],rpp[2]]]) return det(A)==0 
       
var('a b t') r=vector((a*cos(t),a*sin(t),b*t)) osculating_plane(r) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}-{\left(b t - Z\right)} a^{2} \sin\left(t\right)^{2} - {\left(a \cos\left(t\right) - X\right)} a b \sin\left(t\right) - {\left({\left(b t - Z\right)} a \cos\left(t\right) - {\left(a \sin\left(t\right) - Y\right)} b\right)} a \cos\left(t\right) = 0
\newcommand{\Bold}[1]{\mathbf{#1}}-{\left(b t - Z\right)} a^{2} \sin\left(t\right)^{2} - {\left(a \cos\left(t\right) - X\right)} a b \sin\left(t\right) - {\left({\left(b t - Z\right)} a \cos\left(t\right) - {\left(a \sin\left(t\right) - Y\right)} b\right)} a \cos\left(t\right) = 0
 
       

曲线C:r=(x(t),y(t),z(t))在点t=t_0的法平面方程为:

x'(t_0)(X-x(t_0))+y'(t_0)(Y-y(t_0))+z'(t_0)(Z-z(t_0))=0.

def normal_plane(r): rp=diff(r,t) var('X Y Z') neq=rp[0]*(X-r[0])+rp[1]*(Y-r[1])+rp[2]*(Z-r[2])==0 return neq 
       

例:求曲线C:r=(a\cos t,a\sin t,bt)的法平面方程。

var('a b t') r=vector((a*cos(t),a*sin(t),b*t)) eq=normal_plane(r) 
       
eq.subs(t=0) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}Y a + Z b = 0
\newcommand{\Bold}[1]{\mathbf{#1}}Y a + Z b = 0
normal_plane(r) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}{\left(a \cos\left(t\right) - X\right)} a \sin\left(t\right) - {\left(a \sin\left(t\right) - Y\right)} a \cos\left(t\right) - {\left(b t - Z\right)} b = 0
\newcommand{\Bold}[1]{\mathbf{#1}}{\left(a \cos\left(t\right) - X\right)} a \sin\left(t\right) - {\left(a \sin\left(t\right) - Y\right)} a \cos\left(t\right) - {\left(b t - Z\right)} b = 0