MAT 331: Homework 3

Problem 3.1

The replacement operator /. (slash-dot) applies a transformation rule to an expression. If you give a list of rules, each rule will be tried once on each part of the expression. If you give a list of lists of rules, you get a list of results; each sublist is treated like an independent set of rules.

x^2+x^3+y^2+z /. {x_->2}

x^2+x^3+y^2+z /. {x->2, y->3, z->1}

x^2+x^3+y^2+z /. {{x->2},{x->2, y->3,z->1},{x->0,z->0}}

x^2+x^3+y^2+z /. {x_^n_ -> a}

Write a replacement rule that when applied to the expression f[x] + g[x] outputs Sin[x] + Cos[3].

Write a transformation rule that replaces any expression of the form Function[variable] with Cos[3].

Problem 3.2

Mathematica can solve various kinds of equations, symbolically or numerically. The result will be displayed as a list of transformation rules. We can then use the replacement operator /. (slash-dot) to apply these rules to any given expression.

Consider now the cubic polynomial (x^3)+a(x^2)+bx+c. Use Mathematica to find the roots (Subscript[x, 1]), (Subscript[x, 2]) and (Subscript[x, 3]). Then use transformation rules to compute the three symmetric expressions (Subscript[x, 1])+(Subscript[x, 2])+(Subscript[x, 3]), (Subscript[x, 1])(Subscript[x, 2])+(Subscript[x, 2])(Subscript[x, 3])+(Subscript[x, 3])(Subscript[x, 1]) and (Subscript[x, 1])(Subscript[x, 2])(Subscript[x, 3]). Use Simplify[...] to simplify the computations. What can you conclude about the relation between the three expressions and the coefficients of the polynomial?

Problem 3.3

One of the main applications of matrix algebra is to solve systems of linear equations, usually in a large number of variables. A system of m such equations in the n variables (Subscript[x, 1]), (Subscript[x, 2]), ..., (Subscript[x, n]), can be written explicitly:
(Subscript[a, 11])(Subscript[x, 1]) + (Subscript[a, 12])(Subscript[x, 2])+...+(Subscript[a, 1n])(Subscript[x, n])=(Subscript[b, 1])
(Subscript[a, 21])(Subscript[x, 1]) + (Subscript[a, 22])(Subscript[x, 2])+...+(Subscript[a, 2n])(Subscript[x, n])=(Subscript[b, 2]) 
.................................................
(Subscript[a, m1])(Subscript[x, 1]) + (Subscript[a, m2])(Subscript[x, 2])+...+(Subscript[a, mn])(Subscript[x, n])=(Subscript[b, m])

The same system can be written in the more convenient matrix notation as Ax=b, where A is the m × n coefficient matrix, x is the (column) vector of length n containing the variables, and b is the (column) vector of length m of the coefficients on the right hand sides of the equalities.
By general theory, a system of linear equations has no solution, exactly one solution or infinitely many solutions. 
In Mathematica, we can use the command Solve[expression,variables], to solve the system Ax=b for the variable x. 

In the code below we define a 2x2 matrix A and a vector b of length 2, both with random entries 0 or 1. Then we use the function Solve[A.x==b,x] to solve the system Ax=b. Mathematica knows that x should be a vector of 2 variables x[1] and x[2]. The function Solve returns an empty list if there is no solution, a list with one solution if the system has one solution, or a list which contains the dependency between the free variables and the dependent variables if the system has infinitely many solutions (like x[1]=-x[2]).

Clear[A,b, X, x]
A=Table[RandomInteger[],{i,2},{j,2}]; Print["A="MatrixForm[A]];
b=Table[RandomInteger[],{j,2}]; Print["b="MatrixForm[b]];
X=Table[x[j],{j,2}];
Solve[A.X==b,X]

Run the code several time to generate a couple of random 2x2 matrices and see how the solution set is displayed. Then modify the code above to answer the following questions:

Let A be a random 3x3 matrix with integer coefficients. Find the solutions set of the system Ax=(({{1}, {0}, {0}})). Then repeat the procedure to find the the solutions set of the system Ax=(({{0}, {1}, {0}})), and respectively of Ax=(({{0}, {0}, {1}})).

Find the inverse of a random 3x3 matrix A with integer coefficients, if it exists, without using the Mathematica function Inverse[...]. Recall that the matrix A is called invertible is there exists a (unique) 3x3 matrix B such that AB=BA=(Subscript[I, 3]), where (Subscript[I, 3]) is the identity matrix. If A is invertible, then the matrix B is called the inverse of the matrix A, and it is denoted by (A^(-1)).

Problem 3.4

Consider the differential equation y' (x) = 1 + y (x).

Use VectorPlot[ ...] and StreamPlot[ ...] to plot the vector field of the differential equation. Try several display options (i.e. change the size of the arrows, make the picture larger, change the colors, etc.) to see which one gives the most accurate picture.

Next use DSolve[...] to solve the differential equation y’(x) = 1 + y(x), with initial condition y(0)=1. The result will be a list of transformation rules. Define a function YSol[x_] that returns the solution found by DSolve[...]. Evaluate YSol numerically at x=0 and x=0.1. Then plot the function YSol.

Check that YSol is indeed a solution of the differential equation y’(x) = 1 + y(x) by using Mathematica to compute the derivative of the function YSol.

Now go back to the picture that you have obtained in part 1, using StreamPlot[..]. Color the solution of the differential equation y’(x) = 1+y(x) corresponding to the initial condition y(0)=1 on top of the stream plot picture.

Problem 3.5

Recall the definitions and notations from the lecture notes. Let c be a complex number and consider the quadratic polynomial (Subscript[p, c])(z)=(z^2)+c. Denote by (Subscript[J, c]) the Julia set of the polynomial (Subscript[p, c]) . The Mandelbrot set is the set of parameter values c for which the Julia set (Subscript[J, c]) of the polynomial (Subscript[p, c]) is connected.

Use the function Solve[..] to find the two fixed points (Subscript[z, 1])and (Subscript[z, 2]) of the polynomial (Subscript[p, c])(z).

Show that at most one fixed point of the polynomial (Subscript[p, c]) can be an attracting fixed point, that is, we cannot simultaneously have |(Subscript[p, c])'((Subscript[z, 1]))|<1 and |(Subscript[p, c])'((Subscript[z, 2]))|<1.  Moreover, show that both fixed points (Subscript[z, 1])and (Subscript[z, 2]) are attracting or indifferent (that is|(Subscript[p, c])'((Subscript[z, 1]))|⩽1 and |(Subscript[p, c])'((Subscript[z, 2]))|⩽1) if and only if (Subscript[z, 1])=(Subscript[z, 2])=(1/2) and c=(1/4).

Plot the Julia set of the polynomial (Subscript[p, c])(z)=(z^2)+c for c=(1/4). Highlight in red the unique fixed point (Subscript[z, 1]) of this polynomial. Now use the functions defined in class to show (in different colors) a couple of typical orbits of the polynomial (Subscript[p, c]) on the same plot of its Julia set. What can you conclude? If you pick any point z sufficiently close to the fixed point (Subscript[z, 1]), is it true that its orbit z, (Subscript[p, c])(z), (Subscript[p, c])((Subscript[p, c])(z)), (Subscript[p, c])((Subscript[p, c])((Subscript[p, c])(z))), ...  converges to the fixed point (Subscript[z, 1])?

Find all values of the parameter c for which the polynomial (Subscript[p, c]) has an attracting or indifferent fixed point. This region is called the main cardioid of the Mandelbrot set.

Plot the region you found in part 3 in the Re(c), Im(c) parameter plane. Next plot the same region on top of the Mandelbrot set, using the command Show[...].