Math 223 Current Assignment

Comments on Problem 2.7.8 page 245

The program newton.m assumes its first two arguments are vectors (not matrices) of the same length. So iIf you wish to use the newton program in appendix B on page 669, you will need to convert 3 by 3 matrices to 9 by 1 vectors.

The first argument should be a vector of symbolic expressions in the varaibles, x1, x2, etc. These names of variables are hardcoded in the routine, so others are not likely to work.

Entry of symbolic expressions in Matlab is delicate; sometimes an extra space will break the syntax. (Symbolic expressions are often represented as strings.) You can construct a suymbolic 3 by 3 matrix with entries x1, x2, etc. by

	G = sym('[x1,x2,x3; x4, x5, x6; x7 x8 x9]')
Such a matrix could for example be symbolically cubed by G*G*G.

You can reshape a 3 by 3 matrix B into a 9 by 1 vector using the command

or reshape a 9 by 1 matrix C into a vector by

The following text of newton.m is taken from the Student Matlab folder on Ontario and does work. As described in Hubbard and Hubbard, typical usage is

	syms x1 x2
	newton([cos(x1)-x1; sin(x2)], [.1; 3.0], 3)

Text of newton.m

function [x]=newton(F,x0,iterations)
for i=1:length(F)
  vars=[vars 'x' iS ' '];
  eval(['x' iS '=sym(''x' iS ''');']);
vars=[vars ']'];
eval(['vars = 'vars ';']);
for i=1:iterations
Last Update: October 30, 1998