Homework #2: Problem 5

Here is sample output from the newt3 program, first an error from incorrect
input, and then the results of the suggested starting points for (x,y,z):

   einstein 7> newt3
    usage: newt3 <x0> <y0> <z0> [<tol>]
   einstein 8> newt3 1.0 -1.0 -0.25
    Iter           x                     y                       z

    1  1.4278066245790060E+00 -9.5197155296796876E-01 -1.9232255593430930E-01
    2  1.3977664333923043E+00 -9.8543399384905372E-01 -1.7416588474639941E-01
    3  1.3977994333164945E+00 -9.8469310727442372E-01 -1.7481060709965163E-01
    4  1.3977994362977424E+00 -9.8469258308486018E-01 -1.7481118217176370E-01
    5  1.3977994362977610E+00 -9.8469258308462249E-01 -1.7481118217209335E-01

       1.397799436297761     -0.9846925830846225     -0.1748111821720933    

Thus, the guess is a good one, and the method finds a convergence after 5
iterations.  I then altered each input (keeping the other two fixed at the
above guesses) to find the "basin of attraction".  The (x,y,z) inputs were
increased and decreased until a final point (within +/-0.0001) was reached
were the program could no longer converge within 50 iterations:

		Minimum		Default		Maximum
	x	-2.2291		1.0		2.4907
	y	-4.1362		-1.0		0.6747
	z	-4.8617		-0.25		0.6135

To check the newt3 results, I modified the newt2 Maple calls from class notes
to solve the 3-dimensional case:

	check3 := proc()

	      local f1,f2,f3,r1,r2,r3,ans;

	      f1 := x^2 + y^3 + z^4 - 1;
	      f2 := sin(x*y*z) - x - y - z;
	      f3 := cos(x) - y*z;
	      ans := fsolve({f1,f2,f3},{x,y,z});
	      r1 := evalf(subs(ans,f1));
	      r2 := evalf(subs(ans,f2));
	      r3 := evalf(subs(ans,f3));

	      print(f1); print(f2); print(f3); print(ans);
	      print(r1); print(r2); print(r3);
	end:

which gave the following output:

	bytes used=1003632, alloc=786288, time=0.76
	bytes used=2003796, alloc=1310480, time=1.65
	bytes used=3005824, alloc=1441528, time=2.60

                                 2    3    4
                                x  + y  + z  - 1

                             sin(x y z) - x - y - z

                                  cos(x) - y z

             {x = 1.397799436, z = -.1748111822, y = -.9846925831}

                                          -8
                                   -.11*10

                                         -9
                                    .2*10

                                         -9
                                    .2*10

Thus, Maple agrees with newt3 to the precision of the returned (r1,r2,r3).