3.016 Problem Set #2, 2010

I2-1

Define plane 1 and 2,

plane1 = z == 1 + 2 x + 3 y;
plane2 = y  == 2  - 2 z - 4x;

Plot the two planes using Plot3D,

planesPlot = Plot3D[{1 + 2 x + 3 y,1 - y/2 - 2 x},{x,-4,4},{y,-4,4},PlotStyle->{Blue, Cyan}]

Solve for the intersection line in terms of z,

lineSol = Solve[{plane1,plane2},{x,y}]

The parametric form of the intersection line in terms of z,

eqline = {x,y,z}/.lineSol[[1]]

ppoint0={7/10,-4/5,0}

lineVector={-7/10,4/5,1}

tt=lineVector/Norm[lineVector]

The parametric form of the line can be written as  ppoint0 + tt*z

pp={x,y,z};zero={0,0,0};

ww=pp-ppoint0

dd1=ww-(ww.tt)tt

dd is the distance^2 from point {x, y, z} to the line  ppoint0 + tt*z

dd=Simplify[SquaredEuclideanDistance[dd1,zero],x∈Reals&&y∈Reals&&z∈Reals]

(1/213) (164 (x^2)+149 (y^2)-160 y (-1+z)+113 (((-1+z))^2)+28 x (-5+4 y+5 z))=(1/4) would be the equation describing the desired cylinder.

solveCylin=Solve[dd==1/4,{z}]

Ploting the two branches of the solutions,

ss1=Plot3D[(1/226) (226-140 x+160 y-(Sqrt[213]) (Sqrt[113-256 (x^2)-448 x y-196 (y^2)])),{x,-5,5},{y,-5,5}]

ss2=Plot3D[(1/226) (226-140 x+160 y+(Sqrt[213]) (Sqrt[113-256 (x^2)-448 x y-196 (y^2)])),{x,-5,5},{y,-5,5}]

Plot ss1 and ss2 together (they become the entire cylinder),

ss=Show[ss1,ss2]

Plot the intersection line for -10 < z < 10,

linePlot = ParametricPlot3D[eqline,{z,-10,10},PlotStyle-> {Thick, Red}, AxesLabel->{x,y,z}]

Define two points on the line when z = -3 and 3,

point1={-(7/10) (-1+(-3)),(4/5) (-1+(-3)),-3}

point2={-(7/10) (-1+3),(4/5) (-1+3),3}

Plot the cylinder between point1 and point2 with the diameter of 1,

cylinderline=Graphics3D[{Yellow,Cylinder[{point1,point2},0.5]}]

I2-2

Show the intesection line together with the two planes,

Show[planesPlot,linePlot]

Demonstrate that the cylinder and the intersection line are co-axial,

Show[cylinderline,linePlot]

Demonstrate that the solution cylinder ss and the intersection line are co-axial,

Show[linePlot, ss]

Demonstrate that the solution cylinder ss and the plotted cylinderline are overlapping,

Show[cylinderline,ss]

I2-3

Assign aDate and evaluate,

aDate=DateString[]

Check to see what is aDate when it is called,

Table[Pause[5];aDate,{5}]//TableForm

Assign theDate with the actual time/date whenever it is called,

theDate := DateString[]

Table[Pause[5];theDate,{5}]//TableForm

I2-4

Consider a small example

Table[Fibonacci[i],{i,1,20}]

Cases[Table[Fibonacci[i],{i,1,20}], a_/;IntegerQ[Sqrt[a]]]

Generalize this

squaresOfFib[toSize_] := Cases[Table[Fibonacci[i],{i,1,toSize}], a_/;IntegerQ[Sqrt[a]]]

squaresOfFib[1000]

It appears that 144^2 is the only perfect square of the Fibonacci sequence in the first 1000. Computing it for larger lists is expensive with this method. We would wonder if 144 is the last one, and if there is a faster method? This is a problem for another day.

I2-5 (Note: students do not have to do the Viete's formula part, it was poorly worded on the problem set)

Wallis's product

Product[(2i/(2i-1))(2i/(2i+1)),{i,1,Infinity}]

approxOneWallis[upperlim_] := 2 Product[(2i/(2i-1))(2i/(2i+1)),{i,1,upperlim}]/Pi

convergencePlotWallis = ListLogPlot[Table[1-approxOneWallis[i],{i,0,1000}],AxesLabel->{"upper limit of product","Log[error]"}]

The above gives us a visual representation of the convergence.

Viete's formula, let's try to create a function that will give the n-th term of the product sequence of Viete's formula

Clear[vieteNum];vieteNum[i_] :=vieteNum[i]=Sqrt[(2 + vieteNum[i-1])]

vieteNum[0] =Sqrt[2]

Table[vieteNum[i],{i,1,5}]

These look like the numerators of the form of Viete's formula, let's define the product recursively

productViete[i_] := productViete[i] = productViete[i-1]( vieteNum[i]/2);
productViete[1] = vieteNum[1]/2

productViete[4]

Things will be speeded up considerably here if each of the terms doesn't need to be represented as a complicated symbolic expression, let's define a numerical version of the same function

Clear[vieteNumNumerical];vieteNumNumerical[i_] :=vieteNumNumerical[i]=Sqrt[(2.0 + vieteNumNumerical[i-1])];
vieteNumNumerical[0] =Sqrt[2.0]

productVieteNumerical[i_] := productViete[i] = productViete[i-1]( vieteNumNumerical[i]/2);
productVieteNumerical[1] = vieteNumNumerical[1]/2

productVieteNumerical[4]

This gives correct numerical values using Viete's formula. Let's explore convergence

approxOneViete[upperlim_] := Sqrt[2] Pi productVieteNumerical[upperlim]/4

approxOneViete[2]

Table[1-approxOneViete[i],{i,1,10}]

convergencePlotVietes = ListLogPlot[Table[Abs[1-approxOneViete[i]],{i,1,30}],AxesLabel->{"upper limit of product","Log[error]"}]