Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Newton Raphson Iterations

  • 20-03-2008 2:24pm
    #1
    Registered Users, Registered Users 2 Posts: 4,502 ✭✭✭


    Hey guys i am doing some work on newton raphson and bisection method iterations to find the roots of some fuinctions.

    I have attached the graph into a word document. The roots of the function are shown from the graph to be about 2.9 and 3.1. I am performing the newton raphson iterative process to get an accurate solution for the roots and am using an initital guess of 2.9 and 3.1 as approximations. if i put in either of the guesses it converges to 2.99 for both guesses when it should converge to the roots of the function.

    Is there a reason why the Newton Raphson method will not solve this function that is graphed? and should the bisection method work in solving for the roots?

    Hopefully you geniuses can help me. I can put up the equation if needed, it is a bit long :(


Comments

  • Registered Users, Registered Users 2 Posts: 1,595 ✭✭✭MathsManiac


    The graph looks well-behaved enough. Are you sure you're implementing NR properly? Maybe you should give us the function, nasty and all as it may be!


  • Registered Users, Registered Users 2 Posts: 4,502 ✭✭✭chris85


    The graph looks well-behaved enough. Are you sure you're implementing NR properly? Maybe you should give us the function, nasty and all as it may be!

    Hey i have attached an Excel file. The graph shows where the two roots should be when x=0. The NR iterations are also performed for the equation shown in the Excel sheet.

    Any advice would be great.


  • Registered Users, Registered Users 2 Posts: 2,481 ✭✭✭Fremen


    My guess is you've graphed it wrong. In a function like that, you'll usually see more than just two roots.

    I played with your excel spreadsheet a little bit. From copying and pasting from your NR formula, it looks as if 3 actually is a root of this function. 2.9 and 3.1 don't seem to be close to roots, either.


  • Registered Users, Registered Users 2 Posts: 4,502 ✭✭✭chris85


    The roots are where the function is zero, i.e. where y=0 on the graph. So the graph shows them to be around 2.9 and 3.1 as they are the point where y=0.

    there are some roots in the negative region but not interested in them. After the graph crosses around 3.1 on the x-axis the function justs goes up and up

    Anyone else got an idea on getting these roots. Used this method for difference function and worked no problem. I think i may try Bisection method in Excel now and see what it says


  • Registered Users, Registered Users 2 Posts: 2,481 ✭✭✭Fremen


    What I'm saying is, I think your graph is wrong.

    Try pasting
    =(C8^7-3.98*C8^6-22.1199*C8^5+99.7992*C8^4+107.4006*C8^3-650.6892*C8^2-115.5951*C8+1308.9924)

    (your function)
    into a cell, then enter 3 into cell C8. You'll see that it evaluates as zero.

    Edit: google calculator agrees:
    http://www.google.co.uk/search?hl=en&q=%283%5E7-3.98*3%5E6-22.1199*3%5E5%2B99.7992*3%5E4%2B107.4006*3%5E3-650.6892*3%5E2-115.5951*3%2B1308.9924%29&btnG=Google+Search&meta=


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 4,502 ✭✭✭chris85


    Fremen wrote: »
    What I'm saying is, I think your graph is wrong.

    Try pasting
    =(C8^7-3.98*C8^6-22.1199*C8^5+99.7992*C8^4+107.4006*C8^3-650.6892*C8^2-115.5951*C8+1308.9924)

    (your function)
    into a cell, then enter 3 into cell C8. You'll see that it evaluates as zero.

    Edit: google calculator agrees:
    http://www.google.co.uk/search?hl=en&q=%283%5E7-3.98*3%5E6-22.1199*3%5E5%2B99.7992*3%5E4%2B107.4006*3%5E3-650.6892*3%5E2-115.5951*3%2B1308.9924%29&btnG=Google+Search&meta=

    You are correct my man. Very simple mistake was made. The equation that i done the graph with i left out the single digit at the end of a number, as shown in bold below.

    =(C8^7-3.98*C8^6-22.1199*C8^5+99.7992*C8^4+107.4006*C8^3-650.6892*C8^2-115.5951*C8+1308.9924)

    This meant that it went slightly lower down. That little number caused me that effort. Pain in the ass. The iterations were performed using the equation with that little bit of a number left in.

    Dam them long equations


  • Registered Users, Registered Users 2 Posts: 2,481 ✭✭✭Fremen


    Ugh, how irritating. Oh well, glad you got it sorted.


  • Registered Users, Registered Users 2 Posts: 1,595 ✭✭✭MathsManiac


    By the way, there were two other inconsistencies in your file:

    - the constant term is 1308 in the pasted image and 1308.9924 in the body of the work
    - the coefficient of x^4 is 99.7792 in the image and 99.7992 in the work.

    (You probably knew about the first, but mightn't have noticed the second one.)


  • Registered Users, Registered Users 2 Posts: 4,502 ✭✭✭chris85


    By the way, there were two other inconsistencies in your file:

    - the constant term is 1308 in the pasted image and 1308.9924 in the body of the work
    - the coefficient of x^4 is 99.7792 in the image and 99.7992 in the work.

    (You probably knew about the first, but mightn't have noticed the second one.)

    Cheers, noticed the first one alright but thats fine. The second one is fine also the version in the work is the correct one.

    Cheers


  • Registered Users, Registered Users 2 Posts: 4,502 ✭✭✭chris85


    Hey guys quick question about the function shown in the excel spreadsheet. I am trying to solve for the roots but is behaving very strangely. The polynomial is a seventh order polynomial so there should be seven roots, correct?

    There are only a three roots i can see and then the function goes to infinity. Can someone try help explain whats going on? Hoping to using NR methid to solve


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 1,595 ✭✭✭MathsManiac


    Seven roots, four of which happen to be equal, and two others of which happen to be equal!!!:

    -4., -2.01, -2.01, 3, 3, 3, 3.

    (i.e. First derivative as a root at -2.01, 1st, 2nd and 3rd derivatives have a root at 3)


  • Registered Users, Registered Users 2 Posts: 4,502 ✭✭✭chris85


    Seven roots, four of which happen to be equal, and two others of which happen to be equal!!!:

    -4., -2.01, -2.01, 3, 3, 3, 3.

    (i.e. First derivative as a root at -2.01, 1st, 2nd and 3rd derivatives have a root at 3)


    Thats it. perfect. by the way how did you find how many were equal and at which roots


  • Registered Users, Registered Users 2 Posts: 1,595 ✭✭✭MathsManiac


    Just pasted it into Maple and solved it.


  • Registered Users, Registered Users 2 Posts: 4,502 ✭✭✭chris85


    Just pasted it into Maple and solved it.

    Is there a way to see this from Matlab or Excel. dont have Maple :)


  • Moderators, Science, Health & Environment Moderators Posts: 1,852 Mod ✭✭✭✭Michael Collins


    chris85 wrote: »
    Is there a way to see this from Matlab or Excel. dont have Maple :)

    MATLAB: roots([1 2 1]) for example will find all the roots, displaying them according to multiplicity, of x^2 + 2 x + 1. i.e. the elements of the vector are the coefficients of the polynomial in question.

    EXCEL: It can be done in Excel using the Goal Seek but to my knowledge it's very messy, as you have to first find out where it crosses the axis, in order to find a new root.


  • Registered Users, Registered Users 2 Posts: 4,502 ✭✭✭chris85


    MATLAB: roots([1 2 1]) for example will find all the roots, displaying them according to multiplicity, of x^2 + 2 x + 1. i.e. the elements of the vector are the coefficients of the polynomial in question.

    EXCEL: It can be done in Excel using the Goal Seek but to my knowledge it's very messy, as you have to first find out where it crosses the axis, in order to find a new root.

    Ok Excel stuff im not optimistic about but I am unsure what you mean on the Matlab side of things. I really just aint got a way to show the multiple roots clearly. ive put the function into the taylor tool and not really sure why. Not very experienced towards the computational side of things.


  • Moderators, Science, Health & Environment Moderators Posts: 1,852 Mod ✭✭✭✭Michael Collins


    chris85 wrote: »
    Ok Excel stuff im not optimistic about but I am unsure what you mean on the Matlab side of things. I really just aint got a way to show the multiple roots clearly. ive put the function into the taylor tool and not really sure why. Not very experienced towards the computational side of things.

    The function roots in MATLAB works like roots([An An-1 ... A1 A0]), where the An are the coefficients of a general polynomial of degree n: An X^n + An-1 X^(n-1) + ... + A1 X + A0. Sorry if the notation is unclear, here are a few examples:

    If you want to find to roots of

    10x^3 + 9 x^2 + 7 x + 4, type in MATLAB: roots([10 9 7 4])

    or if you want to find the roots of

    x^4 + 3 x^3 + 4 x^2 + 5 x + 1, type in MATLAB: roots([1 3 4 5 1])

    or you want the roots of

    x^3 - 1, type in MATLAB: roots([1 0 0 -1])


    Hopefully this makes it clearer, let me know if you're still confused...


  • Registered Users, Registered Users 2 Posts: 4,502 ✭✭✭chris85


    The function roots in MATLAB works like roots([An An-1 ... A1 A0]), where the An are the coefficients of a general polynomial of degree n: An X^n + An-1 X^(n-1) + ... + A1 X + A0. Sorry if the notation is unclear, here are a few examples:

    If you want to find to roots of

    10x^3 + 9 x^2 + 7 x + 4, type in MATLAB: roots([10 9 7 4])

    or if you want to find the roots of

    x^4 + 3 x^3 + 4 x^2 + 5 x + 1, type in MATLAB: roots([1 3 4 5 1])

    or you want the roots of

    x^3 - 1, type in MATLAB: roots([1 0 0 -1])


    Hopefully this makes it clearer, let me know if you're still confused...


    No get it now. simple enough. cheers


Advertisement