Hi everyone, I'm trying to implement a general method to find the roots of a cubic equation. The conditions are: real coefficients, find all roots: real and complex. I'm using the Cardano's Formula, available here: http://www.engr.mun.ca/~adluri/courses/num_meth/General/Solution_to_cubic_equation.pdf
And using the De Moivre Formula to obtain the cubic roots for the numbers (the complex intermediate numbers). http://en.wikipedia.org/wiki/De_Moivre%27s_formula The implementation is in this spreadsheet, attached in this group (file cubic.xls). It runs in Excel or OpenOffice Calc. There's no macro. I only used cell formulas. I just can't understand when I need to calculate the cubic roots using k=0, k=1, k=2 , on the De Moivre's formula. The spreadsheet is very simple to understand. To test the formula, I enter the roots, and it calculates the coefficients and then calculates the roots from them. The result is in the table above, with the roots labeled with 1, 2 and 3. The problem is: - When the roots are 1,2,2 the roots are in k=1, and the roots for k=0 and k=2 are completely wrong; - When they are 1,1,2 the roots are in k=0; - When they are 1,1.0001,2: k=1; - When they are 1,1.0000000001,2: k=2. How can I know when to use k=0, 1 or 2? There must be some way to make a general formula. When the formula is presented anywhere, it seems to be general. Am I doing something wrong? I used Excel just because it's better to visualize. After, I want to implement it in a better language. I don't want to be dependent of any program or library, I want to program the whole method. I can't use a numerical method, because I need to optimize computation time, and I need to have guaranteed convergence. I also want to work with the complex numbers in some way that I can separate its parts (as I did in the spreadsheet), not needing to have a program or library to deal with complex numbers. I appreciate if someone can help me solving this -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.