Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Solve a equation with x in the second power

This is a discussion on Solve a equation with x in the second power within the Excel Questions forums, part of the Question Forums category; Hello Need help solving x out of this kind of equation: x^2*234+x*123+2345=0 Any idea if I can use a simple ...

  1. #1
    New Member
    Join Date
    Jan 2006
    Posts
    18

    Default Solve a equation with x in the second power

    Hello

    Need help solving x out of this kind of equation:

    x^2*234+x*123+2345=0

    Any idea if I can use a simple command in excel to solve this, have looked over the normal fx statements and canīt find any solvers.

    Regards
    Atli F.

  2. #2
    Board Regular RichardMGreen's Avatar
    Join Date
    Feb 2006
    Location
    Somewhere beyond the Twilight Zone
    Posts
    2,143

    Default

    If you just want to use basic Excel functions without loops, your equation would look something like this :-
    Code:
    =(A4*A4)*234+(A4*123)+2345
    where A4 is the cell ref that contains your original number
    Goal Seek may also be useful but would need a loop in VBA. Something like
    Code:
    while range("B4")<>0
    Range("B4").GoalSeek Goal:=0, ChangingCell:=Range("A4")
    wend
    But that could take some thime as it will loop until you get an answer of zero (which could take forever!)
    RichardMGreen

    Flagellation, necrophilia and bestiality - Am I flogging a dead horse?

    Office 2003/2007 (Work) and Office 2007 (Home)

  3. #3
    New Member
    Join Date
    Jan 2006
    Posts
    18

    Default

    Thanks for the reply

    If you just want to use basic Excel functions without loops, your equation would look something like this :-
    Code:
    =(A4*A4)*234+(A4*123)+2345
    This isnīt the code Iīm looking for since Iīm looking for the value of A4 (donīt know it and want excel to calculate it for me)

    I just installed solver add on but canīt for the life of me figure it out, any help on that and the equation would be great.

    P.s. Iīm hoping I donīt have to resolve to VB

    Than

  4. #4
    Board Regular Loose Cannon's Avatar
    Join Date
    Feb 2006
    Posts
    92

    Default

    This is a simple quadratic. A4 will have two solutions, which can be calculated as:
    =(-123+SQRT((123)^2-(4*234*2345)))/(2*234)
    and:
    =(-123-SQRT((123)^2-(4*234*2345)))/(2*234)

    Any quadratic of the form ax^2+bx+c=0 has the following two solutions:
    =(-b+SQRT((b)^2-(4*a*c)))/(2*a)
    and:
    =(-b-SQRT((b)^2-(4*a*c)))/(2*a)

    This is basic maths. If Excel returns an error, it is because the roots (ie, the solutions) are imaginary. Google "quadratic equation" for more info.
    "The formulation of the problem is often more essential than its solution…. If I had one hour to save the world, I would spend the first 55 minutes defining the problem and the last five minutes solving it." - Albert Einstein

  5. #5
    Board Regular RichardMGreen's Avatar
    Join Date
    Feb 2006
    Location
    Somewhere beyond the Twilight Zone
    Posts
    2,143

    Default

    Just tried it in Solver and it isn't working for me either - looks like it will have to be VBA and a long wait unless anyone else has any other ideas.....
    RichardMGreen

    Flagellation, necrophilia and bestiality - Am I flogging a dead horse?

    Office 2003/2007 (Work) and Office 2007 (Home)

  6. #6
    Board Regular Loose Cannon's Avatar
    Join Date
    Feb 2006
    Posts
    92

    Default

    Import these two functions into your workbook:

    Code:
    Public Function QuadSolvePlus(a, b, c As Double)
    
    QuadSolvePlus = (-b + Sqr(b ^ 2 - (4 * a * c))) / (2 * a)
    
    End Function
    
    
    Public Function QuadSolveMinus(a, b, c As Double)
    
    QuadSolveMinus = (-b - Sqr(b ^ 2 - (4 * a * c))) / (2 * a)
    
    End Function

    You can now put the formula =QuadSolvePlus(A,B,C) into A4 and it will return x. Note two quirks of quadratic equations: first, many have non-real solutions (ie, contain a multiple of the square root of -1) and some have convergent roots (ie., QuadSolvePlus and QuadSolveMinus give the same solution for x.
    "The formulation of the problem is often more essential than its solution…. If I had one hour to save the world, I would spend the first 55 minutes defining the problem and the last five minutes solving it." - Albert Einstein

  7. #7
    Board Regular Loose Cannon's Avatar
    Join Date
    Feb 2006
    Posts
    92

    Default

    Sibbles, you are unable to get an answer on your equation from Excel because the solutions to your equation are non-real. Try this link:
    http://id.mind.net/~zona/mmts/miscel...ealSolver.html
    "The formulation of the problem is often more essential than its solution…. If I had one hour to save the world, I would spend the first 55 minutes defining the problem and the last five minutes solving it." - Albert Einstein

  8. #8
    MrExcel MVP
    Moderator
    Peter_SSs's Avatar
    Join Date
    May 2005
    Location
    Macksville, Australia
    Posts
    26,781

    Default

    Loose Cannon's (first post) formulas should work but, if you are trying to solve different equations with different coefficients, the the coefficients would need to be in different cells and his(?) formulas would need a, b, and c replaced by cell references. Note, too that the last formula given by Loose Cannon I think should start =(-b-SQRT...

    We can use Goal Seek, but note that only approximate solutions will be obtained and only 1 solution when there might actually be two. Let's take a simpler quadratic equation to start with. X^2 + x - 6 = 0 This has solutions of 2 and -3. To get Goal Seek to find a solution, put this formula in B1:
    =A1^2+A1-6
    Now go Tools|Goal Seek|Set Cell B1|To Value 0|By changing cell A1|Ok
    An (approximate) solution to the equation should appear in cell A1.

    Here is my result:

    ******** ******************** ************************************************************************>
    Microsoft Excel - Mr Excel.xls___Running: xl2002 XP : OS = Windows XP
    (F)ile (E)dit (V)iew (I)nsert (O)ptions (T)ools (D)ata (W)indow (H)elp (A)bout
    =

    A
    B
    C
    D
    1
    21.5911E-05
    2
    Equation

    [HtmlMaker 2.42] To see the formula in the cells just click on the cells hyperlink or click the Name box
    PLEASE DO NOT QUOTE THIS TABLE IMAGE ON SAME PAGE! OTHEWISE, ERROR OF JavaScript OCCUR.
    Hope this helps, good luck.
    Peter

    - Read: Posting Guidelines, Forum Rules & FAQs
    - Want to post a small screen shot? Try one of these Excel jeanie, MrExcel HTML Maker or Borders-Copy-Paste (To test: Test Here)
    - If posting vba code, please use Code Tags - like this [code]Paste code here[/code] - or use the VBHTML Maker

  9. #9
    Board Regular Loose Cannon's Avatar
    Join Date
    Feb 2006
    Posts
    92

    Default

    Good pick-up Peter - typing too fast for my own good! Will edit that now.
    "The formulation of the problem is often more essential than its solution…. If I had one hour to save the world, I would spend the first 55 minutes defining the problem and the last five minutes solving it." - Albert Einstein

  10. #10
    New Member
    Join Date
    Jan 2006
    Posts
    18

    Default

    Thanks Loose Canon and Peter

    I knew the abc formula for calculating out the formula, just wondering if excel has a simular functuion as my calculator (Casio fx9750 Plus) that solves the formula if you enter it in the same fashion as in my first post, guess I will have to make excel calculate the abc formula manually, as in your posts.

    Thanks alot for those formulas, this forum is really a neccessity when using excel.

    P.s. Will let you know my final formula and the result I will get from it

    Regards
    Atli F.

Page 1 of 2 12 LastLast

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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


DMCA.com