jQuery in Action, 2nd edition
The moose likes Beginning Java and the fly likes Iteration using Newton Raphson's method Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Iteration using Newton Raphson Watch "Iteration using Newton Raphson New topic
Author

Iteration using Newton Raphson's method

John Morris
Greenhorn

Joined: Nov 25, 2011
Posts: 4


This is the assignment >>----http://www.cs.fiu.edu/~smithjo/assignments_2xxx/assign2xxx5_a.docx


*****************

Here is my code

I tried to put some kind of equation but it loops infinitely...



Help please. It's due sunday, at least a pointer. a hint...anything >.<


HOLY COW CodeBatman!!
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2407
x starts out at 5.

The while loop checks whether x is larger than 0.005 (note that "x * (n + 1) - x * n" is identical to "x").

The value of x never changes.
John Morris
Greenhorn

Joined: Nov 25, 2011
Posts: 4

But that doesn't show me how to form the equation. I'm still completely lost :/

I have to make it stop when it's equal to 0.005

and output all iterations.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2407
John Morris wrote:But that doesn't show me how to form the equation.

You asked for a hint, you got a hint. It's your homework - hints is all you'll get.

You will need two variables for x, let's say x0 and x1. x0 would be the value calculated in the previous iteration, and x1 the value calculated in the current iteration. You want the loop to stop when abs(x0-x1) < 0.005.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32830
    
    4
Welcome to the Ranch

We won’t show you how to form the equation, but will give hints or helps if you show an example with errors. You should write the algorithm on paper, then you can see what you have got to code.
Mohamed Sanaulla
Bartender

Joined: Sep 08, 2007
Posts: 2946
    
  15

... And as a tip- please UseCodeTags when you are posting some code. This time I have done it for you and see how good it looks


Mohamed Sanaulla | My Blog
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Iteration using Newton Raphson's method
 
Similar Threads
Class and Object Problem
Converting Number to Word
a hashkey for double precision numbers
Just Can't figure it out and it's due today