HW-3

1914 days ago by bigdata2016

Problem 1. Engineering Math

Evaluate

 $\iint\limits_S y dS$

Where $S$ is the portion of the cylinder $x^2+y^2=k^2$ that lies between $z=a$ and $z=b$.

Solution: The parameterization of this cylinder

$\vec{r}(\theta, z)=(k\cos\theta, k\sin\theta, z)$ where $a\leq z\leq b$ and $0\leq\theta \leq 2\pi$

$\vec{r}_\theta(\theta, z)=\dfrac{d\vec{r}}{d\theta}=(-k\sin\theta, k\cos\theta, 0)$

$\vec{r}_z(\theta, z)=\dfrac{d\vec{r}}{dz}=(0, 0, 1)$

The cross product is

$\vec{r}_\theta\times \vec{r}_z=\left|{\begin{bmatrix}
\vec{i}&\vec{j}&\vec{k}\\ -k\sin\theta & k\cos\theta & 0\\ 0 & 0 & 1
\end{bmatrix}}\right|=(-k\cos\theta, -k\sin\theta, 0)$

The norm of the cross product is $\|{\vec{r}_\theta\times \vec{r}_z}\|=k$. Then

$\iint\limits_S y dS=\iint\limits_D k\sin\theta\cdot kdA=\int\limits_0^{2\pi}\int\limits_a^b k^2\sin\theta \quad dzd\theta=0.$

var('u,z,k') assume(k>0) r(u,v)=(k*cos(u),k*sin(u),z) r1=diff(r,u) r2=diff(r,z) show(r1) show(r2) 
       

c=r1.cross_product(r2) d=c.norm() e=d.simplify_full() show (e) 
       
var('a,b') A=integral(k*sin(u)*k,u,0,2*pi) B=integral(A,z,a,b) show (B) 
       

Problem 2. Calculus.

Quadratic Approximation

@interact def graph(g=input_box('sin(x)+cos(2x)', label="$f(x)=$"), initial=input_box('1', label="$a =$"), initial1=input_box('0.01', label="$a-x_{0} =$")): f(x)=g # change this to whatever function you like df(x)=diff(f,x) # Sage will compute the derivative of f ddf(x)=diff(df,x); a=float(initial) h=float(initial1) value=f(a)+df(a)*h+ddf(a)*h^2 html('         <font color="blue">$f(x)=%s$</font>;    <font color="red">$f^{(1)}(x)=%s$</font>; <font color="red">$f^{(2)}(x)=%s$</font><br><br>'%(latex(g),latex(df(x)), latex(ddf(x)))) html(' <font color="blue">$f(%s)\\approx%s$</font> <br><br>'%(latex(a-h),value)) 
       
$f(x)=$ 
$a =$ 
$a-x_{0} =$ 

Click to the left again to hide and once more to show the dynamic interactive window

Problem 3. Linear Algebra.

QR factorization using Householder matrix

A=matrix(RDF, [[1,2,3,4,4],[1,1,2,2,3],[-1,-2,2,1,-3],[0,1,0,2,0],[3,4,-2,0,1]]) B=A H1=identity_matrix(A.nrows()) A1=A for i in range(0,A.nrows()-1): print "Step", i+1 x=A1.matrix_from_columns([0]) html('$A_%s=%s$ and $x=%s$' %(i,latex(A.round(3)), latex(x.n(digits=3))) ) print x1_=(-sgn(x[0,0])+((-1)^sgn(x[0,0])+1)/2)*sqrt((x.transpose()*x)[0,0]) u=matrix(RDF,x.nrows(),1) u[0,0]=sqrt((x1_-x[0,0])/(2*x1_)) for j in range(1,x.nrows()): u[j]=x[j,0]/(-2*u[0,0]*x1_) H=matrix(RDF,x.nrows(),x.nrows(),1)-2*u*u.transpose() k=identity_matrix(RDF,i) H=k.block_sum(H) H1=H*H1 A=H*A html(' $H_%s=%s$' %(i+1,latex(H.round(3))) ) A1=A.submatrix(i+1,i+1,A.nrows()-i-1,A.ncols()-i-1) print html(' $Q=%s$ and $R=%s$' %(latex(H1.round(3)),latex(A.round(3))) ) 
       
Step 1
 and 

            

Step 2
 and 

            

Step 3
 and 

            

Step 4
 and 

            

    and 
Step 1
 and 

            

Step 2
 and 

            

Step 3
 and 

            

Step 4
 and 

            

    and 

Check the answer

html('$Q\cdot R=%s$' %( latex((H1.transpose()*A).round(3)) ) ) print html( '$Q^T\cdot Q=%s$'%( latex((H1.transpose()*H1).round(3) ) ))