Part II
Summer Semester, 2006

(10 points)

Write a substitution rule that accepts only a 3x 2 (3 rows, 2 columns) matrix, and this matrix is replaced by the vectorial products of its column vectors. Use test function for the pattern!

(10 points)

Write a function that calculates the harmonic mean of the elements of the numbers given in a list. Use stucture operations! Verify that the elements are positive! The Harmonic mean of {(Subscript[a, 1]),(Subscript[a, 2]), ... , (Subscript[a, n])} is:

(1/((1/(Subscript[a, 1]))+(1/(Subscript[a, 2]))+...+(1/(Subscript[a, n]))))

(40 points)

Write a function StackPlot, implementing the StackGraphics of Mathematica, i.e., for any animation in the {x,y} cordinate system, create a 3D graphics in the {x,y,t} system, where the t-coordinate of a given frame is the index of it in the animation list. Give an example!
The result should look like this:

(40 points)

Consider the following difference equation (Henon's map):

{(Subscript[x, n+1]),(Subscript[y, n+1])}:={(Subscript[y, n])+1-1.4 ((Subscript[x, n])^2),0.3(Subscript[x, n])}

Iterate it from an appropriate initial point, and plot the coordinates with respect to the time, and the trajectory. Use coloring by the time.

(10 points)

Write a substitution rule that accepts only a 3 x 2 (3 rows, 2 columns) matrix, and this matrix is replaced by the vectorial products of its column vectors. Use test function for the pattern!

Definitions

A=(({{a11, a12}, {a21, a22}, {a31, a32}}))

MyCondition[x_]:= Dimensions[x]==={3,2}
MyCondition[A]

Substitution rule

A/.a_?MyCondition->Cross[Transpose[A][[1]],Transpose[A][[2]]]

(10 points)

Write a function that calculates the harmonic mean of the elements of the numbers given in a list. Use stucture operations! Verify that the elements are positive! The Harmonic mean of {(Subscript[a, 1]),(Subscript[a, 2]), ... , (Subscript[a, n])} is:

(1/((1/(Subscript[a, 1]))+(1/(Subscript[a, 2]))+...+(1/(Subscript[a, n]))))

Definition of the elements

n=10;

A=Table[i,{i,1,n}]

Function definition

harmmean[x_List]:=Length[x]/Apply[Plus,Which[Positive[x],1/x][[2]]]

harmmean[A]

(40 points)

Write a function  StackPlot, implementing the StackGraphics of Mathematica, i.e., for any animation in the {x,y} cordinate system, create a 3D graphics in the {x,y,t} system, where the t-coordinate of a given frame is the index of it in the animation list. Give an example!
The result should look like this:

Generating the list of Graphics

f[x_,a_]:=Sin[a x]

listgraphs=Table[Plot[f[x,a],{x,0,2Pi}],{a,1,10}];

InputForm[listgraphs]

The function "StackPlot"

StackPlot[x_List]:=Module[{graphs},graphs=Table[Graphics3D[listgraphs[[i,1]]/.{u_?NumericQ,v_?NumericQ}->{u,v,i}],{i,1,Length[listgraphs]}];
Show[graphs,PlotRange->{{0,2Pi},{-1,1},{1,10}},BoxRatios->{1,0.5,1},Axes->True];
]

StackPlot[listgraphs]

(40 points)

Consider the following difference equation (Henon's map):

{(Subscript[x, n+1]),(Subscript[y, n+1])}:={(Subscript[y, n])+1-1.4 ((Subscript[x, n])^2),0.3(Subscript[x, n])}

Iterate it from an appropriate initial point, and plot the coordinates with respect to the time, and the trajectory. Use coloring by the time.

Definitions

T[{x_,y_,t_}]:={y+1-1.4x^2,0.3x,t+0.1}

x0=0.5;y0=0.5;n=1000;t0=0;

Doing the nesting

sol=NestList[T,{x0,y0,t0},n];

Plotting the Points

p0=Show[Graphics3D[sol/.{u_,v_,w_}->{Hue[w/100],Point[{u,v,w}]}],BoxRatios->{1,1,1},Axes->True]

Plotting the trajectories

p1=Table[Show[Graphics3D[sol/.{u_,v_,w_}->{Hue[i/100],Point[{u,v,i}]}],BoxRatios->{1,1,1}],{i,0,100,10}]

Table[Show[p0,p1[[i]]],{i,1,Length[p1]}]