i tried to solve a simple P(x) such as X^10 + X^9+X^8+X^7+X^6+X^5+X^4+X^3+X^2+X-200 = 0 , by using solver from excel 2007, but it didn't work out.
Al old friend of mine, NEO, send me the following code:
Expand|Select|Wrap|Line Numbers
- Sub polySolver(coeffs As Range, powers As Range) As Double
- Dim rowCount As Integer
- Dim i
- Dim iii
- Dim xn As Double
- Dim xnm1 As Double
- Dim fx As Double
- fx = 0
- Dim fxprime As Double
- fxprime = 0
- xnm1 = 0.1
- Do
- For Each i In coeffs
- For Each iii In powers
- fx = (fx + i) * xnm1 ^ iii
- fxprime = fxprime + (iii * i) * xnm1 ^ (iii - 1)
- xn = xnm1 - fx / fxprime
- xnm1 = xn
- Next i
- Next iii
- Loop Until (Abs(fx) < 0.00001)
- polySolver = xn
- End Function
Can someone help fix it up??
I'm looking forward to receiving good news.
many thks