- #1
s3a
- 818
- 8
Homework Statement
I'm just trying to do homework problems involving the Regula Falsi numerical method, and the solutions in my books seem to have a lot of mistakes, so I was hoping I could make a program to generate solutions for myself, so that I could check if I'm doing things correctly when I learn, and later on, review.
Homework Equations
Regula Falsi formula(e):
x_1 = [a f(b) - b f(a)] / [f(b) - f(a)],
and then for i >= 2,
x_i = [x_L f(x_R) - x_R f(x_L)] / [f(x_L) - f(x_R)], where x_L is the largest left endpoint of the ith sub-interval and x_R is the smallest right endpoint of the ith sub-interval.
The Attempt at a Solution
Here is the computer program I made.:
http://dpaste.com/3CEZ65P
Could someone please let me know if my code is 100% correct? (I ask because I don't know what to trust as being correct, and if someone who knows this stuff better than me could confirm that my code is 100% correct, then it would make me feel more relaxed, knowing that what I'm learning is in fact correct. (I don't want to learn something incorrect, while thinking it's correct.))
Basically, I seem to be getting the correct answers to things, but I'd like to know if I'm just getting the correct final answers because the bounds keep getting smaller, while still surrounding the value, despite doing something else incorrectly, such as computing the incorrect ith intermediate value, or if it's truly the case that I'm doing everything correctly (as the Regula Falsi method requires).
Any input would be GREATLY appreciated!