21.04.2014 Views

Michael Corral: Vector Calculus

Michael Corral: Vector Calculus

Michael Corral: Vector Calculus

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

92 CHAPTER 2. FUNCTIONS OF SEVERAL VARIABLES<br />

To use this program, you should first save the code in Listing 2.1 in a plain text<br />

file called newton.java. You will need the Java Development Kit 9 to compile the<br />

code. In thedirectory wherenewton.java is saved, run thiscommandat acommand<br />

prompt to compile the code: javac newton.java<br />

Then run the program with the initial point (0,0) with this command:<br />

java newton 0 0<br />

Belowistheoutputoftheprogramusing(0,0)astheinitialpoint,truncatedtoshow<br />

the first 10 lines and the last 5 lines:<br />

java newton 0 0<br />

Initial point: (0.0,0.0)<br />

n = 1: (0.0,-1.0)<br />

n = 2: (1.0,-0.5)<br />

n = 3: (0.6065857885615251,-0.44194107452339687)<br />

n = 4: (0.484506572966545,-0.405341511995805)<br />

n = 5: (0.47123972682634485,-0.3966334583092305)<br />

n = 6: (0.47113558510349535,-0.39636450001936047)<br />

n = 7: (0.4711356343449705,-0.3963643379632247)<br />

n = 8: (0.4711356343449874,-0.39636433796318005)<br />

n = 9: (0.4711356343449874,-0.39636433796318005)<br />

n = 10: (0.4711356343449874,-0.39636433796318005)<br />

...<br />

n = 96: (0.4711356343449874,-0.39636433796318005)<br />

n = 97: (0.4711356343449874,-0.39636433796318005)<br />

n = 98: (0.4711356343449874,-0.39636433796318005)<br />

n = 99: (0.4711356343449874,-0.39636433796318005)<br />

n = 100: (0.4711356343449874,-0.39636433796318005)<br />

As you can see, we appear to have converged fairly quickly (after only 8 iterations)<br />

to what appears to be an actual critical point (up to Java’s level of precision), namely<br />

the point (0.4711356343449874,−0.39636433796318005). It is easy to confirm that∇f= 0<br />

atthispoint, eitherbyevaluating ∂f<br />

∂x and∂f ∂y atthepointourselvesorbymodifyingour<br />

program to also print the values of the partial derivatives at the point. It turns out<br />

that both partial derivatives are indeed close enough to zero to be considered zero:<br />

∂f<br />

∂x (0.4711356343449874,−0.39636433796318005)=4.85722573273506×10−17<br />

∂f<br />

∂y (0.4711356343449874,−0.39636433796318005)=−8.326672684688674×10−17<br />

We also have D(0.4711356343449874,−0.39636433796318005)=−8.776075636032301

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!