View Single Post
09-27-2004, 01:31 AM   PM User | #4
Antoniohawk
Senior Coder

Join Date: Aug 2002
Location: Kansas City, Kansas
Posts: 1,518
Thanks: 0
Thanked 2 Times in 2 Posts
Quote:
 Originally Posted by Spookster lol I had a programming language course in college that required us to write a mid-side program in a different language every week and usually languages we had never seen or used before.
Now that is just crazy!

Back to the problem at hand (before we were rudely interrupted by Spooks ) I think that the problem lies in your for loop. As you have it right now, the for loop will probably run forever because there is no iterating variable that makes u any bigger. What you probably need to do is put that v = blah into inside of the loop.
Code:
```public class testeroo {

public static void main(String[] args) { //begin arguments

//introduce variable u (the "guess" or [x sub n]), variable v ("guess +" or [x sub n+1])
double v;

//for function

for(double u = -10000; u <= 10000; u++){
v = (u - (((0.3 * u * u * u) + 36) / ((0.9 * u) * (0.9 * u))));

if (Math.abs(u) - Math.abs(v) <= 0.001)
System.out.println("The root of the function is " + v);
}

//I used Newton's Method here.  In general terms, the formula is:

//(x sub n+1) = (x sub n) - [ f(x) / f'(x) ]
}
}```
Edit:
Also, you need to use Math.abs(u) and Math.abs(v). The last problem might lie in the fact that you need to ouput something. Right now your output is "The root of the function is ", but there's nothing after it.

Last edited by Antoniohawk; 09-27-2004 at 01:39 AM..