三次方程解法

作者在 2008-01-10 11:18:24 发布以下内容

由于编程需要,在网上搜索一元三次方程的解法,数值解法一般都是用什么迭代法,弦截法搞的.没时间研究.下面是找到的资料

=======================================================

有个公式解法

见数学手册:  
  x^3   +px   +   q   =   0   的通解是:  
  x1   =   (-q/2+((q/2)^2+   (p/3)^3   )^(1/2)   )^(1/3)   +   (   -q/2   -   (   (q/2)^2   +   (p/3)^3   )^(1/2)   )^(1/3)   ;    
  x2   =   m   *   (   -q/2   +   (   (q/2)^2   +   (p/3)^3   )^(1/2)   )^(1/3)     +   m^2   *   (   -q/2   -   (   (q/2)^2   +   (p/3)^3   )^(1/2)   )^(1/3)   ;  
  x3   =   m^2   *   (   -q/2   +   (   (q/2)^2   +   (p/3)^3   )^(1/2)   )^(1/3)     +   m   *   (   -q/2   -   (   (q/2)^2   +   (p/3)^3   )^(1/2)   )^(1/3)   ;  
  其中:m   =   (   -1   +   i   *   3^(1/2)   )/2   ,     m^2   =   (   -1   -   i   *   3^(1/2)   )/2  
  而三次方程的一般形式:  
  ax^3   +   bx^2   +   cx   +   d   =   0  
  两边除以a,后设   x   =   y   -   b/3a,就可以化成   y^3   +   py   +   q   =   0   的形式:  
  p   =   c/a   -   b^2/(3*a^2),     q   =   (2*b^3)/(27*a^3)   -   (c*b)/(3*a^2)   +   d/a   ;  
  然后再用上面的公式就行了。其中x1肯定是实根。

=====================================================

一个解的vb程序,没经过验证,不过应该是可以用的

测试部分:

Private Sub Command1_Click()
  Dim x1r As Double, x1i As Double, x2r As Double, x2i As Double, x3r As Double, x3i As Double
  Dim ret As String

  ret = CubicEquation(5, 4, 3, -12, x1r, x1i, x2r, x2i, x3r, x3i)    '5x^3+4x^2+3x-12=0

  Debug.Print "~~~~~~~~~~~~~~~~~~~~~~~~" & ret
  Debug.Print x1r; " + "; x1i; " i"
  Debug.Print x2r; " + "; x2i; " i"
  Debug.Print x3r; " + "; x3i; " i"

End Sub

函数:

Private Function CubicEquation _
                         (ByVal a As Double, ByVal b As Double, ByVal c As Double, ByVal d As Double, _
                         x1r As Double, x1i As Double, x2r As Double, x2i As Double, x3r As Double, x3i As Double) As String
  'Cubic equation(v2.2), coded by www.dayi.net btef (please let this line remain)
  Dim e As Double, f As Double, g As Double, h As Double, delta As Double
  Dim r As Double, sita As Double, pi As Double, rr As Double, ri As Double

  If a = 0 Then
    CubicEquation = "Not a cubic equation: a = 0"
    Exit Function
  End If

  'pi = 3.14159265358979
  pi = 4 * Atn(1)
  b = b / a                         'simplify to a=1: x^3+bx^2+cx+d=0
  c = c / a
  d = d / a
  e = -b ^ 2 / 3 + c           'substitute x=y-b/3: y^3+ey+f=0
  f = (2 * b ^ 2 - 9 * c) * b / 27 + d

  If e = 0 And f = 0 Then
    x1r = -b / 3
    x2r = x1r
    x3r = x1r
    CubicEquation = "3 same real roots:"
  ElseIf e = 0 Then             'need to deal with e = 0, or it will cause z = 0 later.
    r = -f                           'y^3+f=0, y^3=-f
    r = Cur(r)
    x1r = r - b / 3              'a real root
    If r > 0 Then                'r never = 0 since g=f/2, f never = 0 there
      sita = 2 * pi / 3
      x2r = r * Cos(sita) - b / 3
      x2i = r * Sin(sita)
    Else
      sita = pi / 3
      x2r = -r * Cos(sita) - b / 3
      x2i = -r * Sin(sita)
    End If
    x3r = x2r
    x3i = -x2i
    CubicEquation = "1 real root and 2 image roots:"
  Else                                    'substitute y=z-e/3/z: (z^3)^2+fz^3-(e/3)^3=0, z^3=-g+sqr(delta)
    g = f / 2                         '-q-sqr(delta) is ignored
    h = e / 3
    delta = g ^ 2 + h ^ 3
    If delta < 0 Then
      r = Sqr(g ^ 2 - delta)
      sita = Argument(-g, Sqr(-delta))   'z^3=r(con(sita)+isin(sita))
      r = Cur(r)
      rr = r - h / r
      sita = sita / 3                               'z1=r(cos(sita)+isin(sita))
      x1r = rr * Cos(sita) - b / 3           'y1=(r-h/r)cos(sita)+i(r+h/r)sin(sita), x1=y1-b/3
      sita = sita + 2 * pi / 3                  'no image part since r+h/r = 0
      x2r = rr * Cos(sita) - b / 3
      sita = sita + 2 * pi / 3
      x3r = rr * Cos(sita) - b / 3
      CubicEquation = "3 real roots:"
    Else                                                'delta >= 0
      r = -g + Sqr(delta)
      r = Cur(r)
      rr = r - h / r
      ri = r + h / r
      If ri = 0 Then
        CubicEquation = "3 real roots:"
      Else
        CubicEquation = "1 real root and 2 image roots:"
      End If
      x1r = rr - b / 3                             'a real root
      If r > 0 Then                                'r never = 0 since g=f/2, f never = 0 there
        sita = 2 * pi / 3
        x2r = rr * Cos(sita) - b / 3
        x2i = ri * Sin(sita)
      Else                                              'r < 0
        sita = pi / 3
        x2r = -rr * Cos(sita) - b / 3
        x2i = -ri * Sin(sita)
      End If
      x3r = x2r
      x3i = -x2i
    End If
  End If

End Function

Private Function Cur(v As Double) As Double

  If v < 0 Then
    Cur = -(-v) ^ (1 / 3)
  Else
    Cur = v ^ (1 / 3)
  End If

End Function

Private Function Argument(a As Double, b As Double) As Double
  Dim sita As Double, pi As Double

  'pi = 3.14159265358979
  pi = 4 * Atn(1)
  If a = 0 Then
    If b >= 0 Then
      Argument = pi / 2
    Else
      Argument = -pi / 2
    End If
  Else

    sita = Atn(Abs(b / a))

    If a > 0 Then
      If b >= 0 Then
        Argument = sita
      Else
        Argument = -sita
      End If
    ElseIf a < 0 Then
      If b >= 0 Then
        Argument = pi - sita
      Else
        Argument = pi + sita
      End If
    End If

  End If

End Function

=====================================================

还找到一个叫"盛金公式"的,是个叫范盛金的中国人弄的,个人感觉这个人有点臭屁,不过这个方程好像还是比较有用的

摘录下来

http://club.xilu.com/s5518/msgview-49671-2.html

A new means

to solving a problem in mathematics

on the cubic equations in Shengjin’s formulas

三次方程新解法——盛金公式解题法

 

Shengjin’s Formulas

and Shengjin’s Distinguishing Means

and Shengjin’s Theorems from the Writings

to introduce to you and to solving a problem in mathematics

盛金公式与盛金判别法及盛金定理的运用从这里向您介绍

 

 三次方程应用广泛。用根号解一元三次方程,虽然有著名的卡尔丹公式,并有相应的判别法,但使用卡尔丹公式解题比较复杂,缺乏直观性。范盛金推导出一套直接用abcd表达的较简明形式的一元三次方程的一般式新求根公式,并建立了新判别法。

 

 

盛金公式

Shengjin’s Formulas

 

一元三次方程aX3bX2cXd=0,(abcdR,且a0)。

重根判别式:

A=b23ac

B=bc9ad

C=c23bd

总判别式:

Δ=B24AC

 

A=B=0时,盛金公式①WhenA=B=0Shengjin’s Formula①)

X1=X2=X3=b/(3a)=c/b=3d/c

 

当Δ=B24AC>0时,盛金公式②WhenΔ=B24AC>0Shengjin’s Formula②):

X1=(b(Y11/3Y21/3))/(3a)

X23=(2bY11/3Y21/3±31/2 (Y11/3Y21/3)i)/(6a)

其中Y12=Ab3a (B±(B24AC)1/2)/2i2=1

 

当Δ=B24AC=0时,盛金公式③WhenΔ=B24AC =0Shengjin’s Formula③):

X1=b/aKX2=X3=K/2   

其中K=B/A(A0)

 

当Δ=B24AC<0时,盛金公式④WhenΔ=B24AC<0Shengjin’s Formula④):

X1= (b2A1/2cos(θ/3) )/(3a)

X23= (bA1/2(cos(θ/3)±31/2sin(θ/3)))/(3a)

其中θ=arccosTT= (2Ab3aB)/(2A3/2)(A>0,-1<T<1)

 

 

 

盛金判别法

Shengjin’s Distinguishing Means

 

①:A=B=0时,方程有一个三重实根

②:Δ=B24AC>0方程有一个实根和一对共轭虚根

③:Δ=B24AC=0时,方程有三个实根,其中有一个两重根

④:Δ=B24AC<0方程有三个不相等的实根。

 

===================================================

哇靠,这个blog居然有字数限制,而且超出字数,直接删掉,连一点提示都没有,只能郁闷一下了

关于这个定理,参考下面几个连接

http://club.xilu.com/s5518/msgview-49671-2.html

http://club.xilu.com/s5518/msgview-49671-3.html

http://club.xilu.com/s5518/msgview-49671-4.html

 

 

数学 | 阅读 6397 次
文章评论,共2条
zuijianqiuge
2010-07-08 16:03
1
一、“惊人”的发现:<br />
1、三次方程的一般形式:<br />
ax^3+bx^2+cx+d=0 …………………………………………① <br />
2、三次方程的导数方程:<br />
将方程①取导得:<br />
3ax^2+2bx+c=0……………………………………………②<br />
3、根据代数方程的重根判定定理,可得三次方程有重根的充要条件:即 方程①和②至少有一个公共根。由此可得出方程①的重根判别式。<br />
4、重根判别式的推导:<br />
(1)由①*3-②*x得:<br />
bx^2+2cx+3d=0……………………………………………③<br />
(2)由②*b-③*3a得:<br />
2(b^2-3ac)x+bc-9ad=0……………………………………………④<br />
(3)由③*c/x-②*3d/x得:<br />
(bc-9ad)x+2(c^2-3bd)=0……………………………………………⑤<br />
(4)将④和⑤消去x得:<br />
(bc-9ad)^2-4(b^2-3ac)(c^2-3bd)=0<br />
<br />
二、骗人的花招:<br />
1、自我评价:<br />
我总认为,天只有井口那么大。我要向天下的人们宣布我的一项重大发现:<br />
我发现了最美丽的判别式,我创造了最伟大的三次方程新解法。<br />
2、骗人花招(一):<br />
令B=bc-9ad<br />
A=b^2-3ac<br />
C=c^2-3bd<br />
这样将三次方程判别式变得和二次方程一样美。<br />
3、骗人花招(二):<br />
虽然我把三次方程判别式打扮得很美丽,但没有多大用处。三次方程最有意义的内容是:求三次方程的根。我要将卡丹公式变个新花样,使其成为我的公式,成为我的定理。我要让天下的人们都知道:我才是研究三次方程最伟大的专家。不,专家职称太低啦!是最伟大的数学家。虽然有位数学大师已经研究出整系三次方程的双简求根公式,但我总觉得我的公式最美,我的定理最棒。<br />
4、骗人花招(三):<br />
我心里明白,我创造的三次方程新解法只不过是一个挂羊头卖狗肉的招牌。真正使我感到臭美的是我发现了最美丽的判别式。虽然有人说,此判别式在上个世纪50年代早就有人已经研究出来了,但我没有看到,是我发现了判别式的美。所以,我千万不能泄露我发现的三次方程判别式是怎么来的?我要给全天下的学生和教授一种神密感,我要让全天下的学生和教授崇拜在我的蛙皮裙下。
zuijianqiuge
2010-07-08 16:03
2
井底之蛙的骗术
游客请输入验证码