Solving a cubic equation

后端 未结 5 1457
后悔当初
后悔当初 2020-12-16 03:24

As part of a program I\'m writing, I need to solve a cubic equation exactly (rather than using a numerical root finder):

a*x**3 + b*x**2 + c*x + d = 0.
         


        
5条回答
  •  孤城傲影
    2020-12-16 04:15

    I've looked at the Wikipedia article and your program.

    I also solved the equation using Wolfram Alpha and the results there don't match what you get.

    I'd just go through your program at each step, use a lot of print statements, and get each intermediate result. Then go through with a calculator and do it yourself.

    I can't find what's happening, but where your hand calculations and the program diverge is a good place to look.

提交回复
热议问题