Root Finding using Bisection
Maths and statistics discussion, revision, exam and homework help.
-
Root Finding using Bisection
I am slighlty confused by this as i cant match the lecture slides approach to the past exam papers
exam question says :
Using the bisection method search for a root for the function 3^x - x^3 - 5 in the interval [3,4]. Show the next 4 approximation levels
Now as far as i can see (and to be honest i may need glasses as its not very far atm
) i need to make
f(x) = 3^x - x^3 - 5
i am guessing here that x will be replaced for 3 and 4 and i just write the results of substituting the numbers in to a table? Is this correct, and when do i stop, when the numbers get practically the same?Last edited by jermaindefoe; 06-05-2010 at 14:18. -
Re: Root Finding using Bisectionwell, f(3) and f(4) straddle the root. you then take f(3.5), because it's in the middle of your interval (bisection). when you note the sign, you then take the new interval as f(3) to (3.5) or f(3.5) to f(4), depending on the sign on f(3.5) [bearing in mind that it will straddle the root, and so the signs must be different if there is a root between them]. just keep taking the value in the dead centre of your interval, and improving it by making new intervals and taking the centre of those. in your case, it must be done 4 times.(Original post by jermaindefoe)
can i just ask why we then go to 3.5? -
Re: Root Finding using BisectionWe are bisecting the interval.(Original post by jermaindefoe)
can i just ask why we then go to 3.5?
We know there is a root somewhere between 3 and 4, because f(3)<0 and f(4)>0
The reason for going to 3.5 is because that's what the bisection method states. As an algorithm it says to create smaller intervals that are half the size of the previous one until we have an interval as small as required. -
Re: Root Finding using Bisectionso i guess the new interval, if result for 3.5 was a minus will be 3.25? as its the middle of 3 and 3.5?(Original post by ziedj)
well, f(3) and f(4) straddle the root. you then take f(3.5), because it's in the middle of your interval (bisection). when you note the sign, you then take the new interval as f(3) to (3.5) or f(3.5) to f(4), depending on the sign on f(3.5) [bearing in mind that it will straddle the root, and so the signs must be different if there is a root between them]. just keep taking the value in the dead centre of your interval, and improving it by making new intervals and taking the centre of those. in your case, it must be done 4 times. -
Re: Root Finding using Bisection3.25 is not an interval.(Original post by jermaindefoe)
so i guess the new interval, if result for 3.5 was a minus will be 3.25? as its the middle of 3 and 3.5?
After calculating f(3.5), you've said that f(3.5)<0.
So from the information
f(3)<0, f(3.5)<0, f(4)>0
What two points does the root lie between? -
Re: Root Finding using BisectionHmm you've lost me there.(Original post by jermaindefoe)
any idea of how this is terminated (as in, when we deem to have found a figure thats good enough) when working with floating points?
The question says 4 iterations so the intervals would be [3,4] , [3.5,4] , [3.5,3.75] , [3.5,3.625], [3.5625,3.625].
So my answer to the original question would be the root is in the interval [3.5625,3.625]
I don't know what floating point means so I can't help any more than that. Hopefully someone else can.
Last edited by miml; 06-05-2010 at 15:19. -
Re: Root Finding using Bisectionthanks(Original post by miml)
Hmm you've lost me there.
The question says 4 iterations so the intervals would be [3,4] , [3.5,4] , [3.5,3.75] , [3.5,3.625], [3.5625,3.625].
So my answer to the original question would be the root is in the interval [3.5625,3.625]
I don't know what floating point means so I can't help any more than that. Hopefully someone else can.
it wasnt an exam question that last one , but i thought i would ask as its closley related to what i am doing so thought i might try and see what you thought about it
. but if you dont no then it doesnt matter at all , thans for all of the help
-
Re: Root Finding using Bisection
Hi jermaindefoe,
Well following what Miml said, in this specific case we have to perform 4 iterations of this iterative process, because thats what it asks us to do. Now lets consider you are wanting to apply this more generally, i'm assume your intention or ultimate task would be to write a program to calculate the roots of a function.
So we start of by taking a educated quess at a starting inverval, the general idea would then be to perform the iteration untill the upper and lower bounds of the interval round to the same decimal number to a predetermined number of decimal places.
So lets take the case Miml gave, we have so far
[3,4] , [3.5,4] , [3.5,3.75] , [3.5,3.625], [3.5625,3.625]
now lets say we have decided we wanted to find this root to 2 decimal places, so we keep perfoming interations. note the ones below I just made up, I did bisect the intervals but I didnt actually calculate f(x) for them, so the intervals are probably wrong, but it is there simply to illistrate the point
[3.5625 , 3.625]
[3.5625 , 3.59375]
[3.578125 , 3.59375]
[3.5859375 , 3.59375]
as you can see the upper and lower bounds of the interval both round to 3.59 to 2 decimal places, so either you can use a built in function to the langauge your using or your own algorithm to check the number the upper and lower bounds of your interval round to, in this case to 2 decimal places, but as I said, it is for you to decide the number of deciamal places you want to find the root to, so some psudo code might be
Hope that helps JermaindefoeCode:double x; CheckBounds() { x = Math.Round( UpperBound , 2.d.p) - Math.Round( Lower Bound , 2.d.p) if(x== double(0)) return Math.Round( UpperBound , 2.d.p) else perform another interation }