anyone here got programming experience in c++? I'm running into issues with my dowhile loop and I have no idea why
I do, but its been a while.
The code compiles, I just get the wrong answer. Running a for loop for x number of times gets me the correct one, but when I change it to a dowhile and set the percent change between iterations to be .1%, it spits out "1.09297" every time (regardless of what I set the percent change to).
Code: do { x2 = g(x1); x1 = x2; } while (( abs((x2-x1))/x2) > 0.001); cout << "x = " << x1 << endl; return 1;g(x) is my function and it's supposed to be a fixed point iteration which brings me to a root. Like I said, it works when I run a for loop 10 times, but this do-while seems to fail terribly.
edit: which I notice is only a single iteration of the fixed point method. It's running one loop and then quitting. But x2-x1/x2 is much greater than .001. fffffff
i'm a complete idiot
disregard
Code: do { x2 = g(x1); x1 = x2; } while (( abs((x2-x1))/x2) > 0.001); cout << "x = " << x1 << endl; return 1;g(x) is my function and it's supposed to be a fixed point iteration which brings me to a root. Like I said, it works when I run a for loop 10 times, but this do-while seems to fail terribly.
edit: which I notice is only a single iteration of the fixed point method. It's running one loop and then quitting. But x2-x1/x2 is much greater than .001. fffffff
i'm a complete idiot
disregard
Last edited by Bevo (2011-02-09 12:29:56)
lol
Printing out table card numbers. Printing out program details. Printing out the church program details. Print print print print...
What a good little groom you are!
...
*purrr*tuckergustav wrote:
What a good little groom you are!
your opinion is based on a single photo?Macbeth wrote:
http://o.onionstatic.com/images/article … -large.jpg
From an onion article. How anyone couldn't find Filipino girls to be gorgeous is beyond me.
she's :3
G'nite. I'm off to sleep. And do stuff. And get married. See ya next week if I'm not on the run after escaping from the church
Good Luck! and Congrats!
...
goodnight, have fun
♥
Good luck
pics
You forgot to print my invitation.Ultrafunkula wrote:
Printing out table card numbers. Printing out program details. Printing out the church program details. Print print print print...
That's because you're easy to forget. In fact I don't even remember who you are.
yeah...noobest. more like whobest.
...
More like your brain is subconsciously blocking the memories because you're so ashamed.
there's that other person with noob in their name that i get confused with, fucking noobs
how could you ever forget noobmurderer you spacker
Blackbelts are just whitebelts who have never quit.
who knew sugar and puffs go so well together
♥
Charles Darwin?
Charge 1: RECKLESS DRIVING
This vehicle passed unmarked police car at speed in excess of 100mph and was weaving in and out of traffic.
way to go alex. lay of the sauce already
Make X-meds a full member, for the sake of 15 year old anal gangbang porn watchers everywhere!
thank god you had a spoiler to keep you on the roadalexb wrote:
Charge 1: RECKLESS DRIVING
This vehicle passed unmarked police car at speed in excess of 100mph and was weaving in and out of traffic.
♥
wot?Toilet Sex wrote:
thank god you had a spoiler to keep you on the roadalexb wrote:
Charge 1: RECKLESS DRIVING
This vehicle passed unmarked police car at speed in excess of 100mph and was weaving in and out of traffic.
I drive an MK4 Jetta, no spoiler.