Results 1 to 5 of 5

Thread: Finding roots of an equation {resolved}

  1. #1

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Resolved Finding roots of an equation {resolved}

    I need to write an algorithm that can find the roots of any equation (of the form y=f(x).

    It would have to do it by testing X values at certain points and homing in on the root by finding the sign change. What is the most efficient method of doing this?
    Last edited by wossname; Dec 6th, 2004 at 10:26 AM. Reason: I achieved enlightenment
    I don't live here any more.

  2. #2
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    703

    Re: Finding roots of an equation

    Are you considering equations with complex roots too?

    e.g.

    (x^2) = -2

    "Any" equation is quite broad.
    an ending

  3. #3

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Finding roots of an equation

    Not complex ones no. Only Y=0 (for now)

    OK, not ANY curve then

    I'm not doing this by re-arranging equations or any cheating like that, just by calculating the Y at certain X values and interpolating to find roots.

    Function Get_Y_Value(x) 'can be treated as a "black box", we don't need to know the equation itself.
    I don't live here any more.

  4. #4
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    703

    Re: Finding roots of an equation

    So you'll need some sort of heuristic method to produce a reasonable guess at a root, then decrease or increase x depending on whether you're too high or low.

    You can scale the increase or decrease amount according to how far from y=0 you are, i.e. decrease the change as you approach y=0.

    As for the initial guess, hmm..I don't know really. It probably doesn't matter if your guess is a long way off anyway as long as you use the change-scaling approach..

    Also are you going to allow equations with no roots and detect that?
    an ending

  5. #5

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Finding roots of an equation

    Its OK. I have sorted it out now. Cheers.
    I don't live here any more.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width