song.yz@foxmail.com wechat: math-box

计算数学



Muhammad两步三阶迭代格式

对于非线性方程\({F\left( x \right) = 0}\),对方程函数在\({{x_n}}\)处泰勒展开得: \[\begin{gathered} F\left( x \right) = F\left( {{x_n}} \right) + \cdots + \frac{1}{{\left( {k - 1} \right)!}}{F^{\left( {k - 1} \right)}}\left( {{x_n}} \right){\left( {x - {x_n}} \right)^{\left( {k - 1} \right)}} + \hfill \\ \quad \quad \quad \int_0^1 {\frac{{{{\left( {1 - t} \right)}^{\left( {k - 1} \right)}}}}{{\left( {k - 1} \right)!}}{F^{\left( k \right)}}\left[ {{x_n} + t\left( {x - {x_n}} \right)} \right]} {\left( {x - {x_n}} \right)^k}dt \hfill \\ \end{gathered} \] 当\(k=1\)时,有 \[F\left( x \right) = F\left( {{x_n}} \right) + \int_0^1 {F'\left[ {{x_n} + t\left( {x - {x_n}} \right)} \right]} \left( {x - {x_n}} \right)dt\] 对上式采用不同的数值积分方法可以得到一系列迭代公式。 Muhammad Aslam Noor给出了如下两种的积分公式 \[\int_0^1 {F'\left[ {{x_n} + t\left( {x - {x_n}} \right)} \right]} \left( {x - {x_n}} \right)dt \approx \left[ {\frac{1}{4}F'\left( {{x_n}} \right) + \frac{3}{4}F'\left( {\frac{{{x_n} + 2x}}{3}} \right)} \right]\left( {x - {x_n}} \right)\] \[\int_0^1 {F'\left[ {{x_n} + t\left( {x - {x_n}} \right)} \right]} \left( {x - {x_n}} \right)dt \approx \left[ {\frac{3}{4}F'\left( {\frac{{2{x_n} + x}}{3}} \right) + \frac{1}{4}F'\left( {{x_n}} \right)} \right]\left( {x - {x_n}} \right)\] 由牛顿法作为第一步,由此可以给出如下两种解算非线性方程的两步迭代格式: \[\left\{ \begin{gathered} {y_n} = {x_n} - F'{\left( {{x_n}} \right)^{ - 1}}F\left( {{x_n}} \right) \hfill \\ {x_{n + 1}} = {x_n} - \frac{{F\left( {{x_n}} \right)}}{{\frac{1}{4}F'\left( {{x_n}} \right) + \frac{3}{4}F'\left( {\frac{{{x_n} + 2{y_n}}}{3}} \right)}} \hfill \\ \end{gathered} \right.\quad \quad n = 1,2, \cdots \] \[\left\{ \begin{gathered} {y_n} = {x_n} - F'{\left( {{x_n}} \right)^{ - 1}}F\left( {{x_n}} \right) \hfill \\ {x_{n + 1}} = {x_n} - \frac{{F\left( {{x_n}} \right)}}{{\frac{3}{4}F'\left( {\frac{{2{x_n} + {y_n}}}{3}} \right) + \frac{1}{4}F'\left( {{y_n}} \right)}}\quad \hfill \\ \end{gathered} \right.n = 1,2, \cdots \] 以上格式为三阶收敛,且同样适用于非线性方程组的计算。 计算非线性方程 \[f\left( x \right) = 3{x^5} - 2{x^3} + 6x - 8\] 的根。 容易给出 \[\frac{{df\left( x \right)}}{{dx}} = 15{x^4} - 6{x^2} + 6\] 下面给出go语言代码。

// muhammad
package main

import (
	"fmt"
	"math"
)

func main() {
	/*------------------------------------------------------
	!  Author  : Song Yezhi      
	!  verison : 2021-10-04 19:02:15
	!  -----------------------------------------------------
	!  Input  Parameters :
	!
	!  Output Parameters :
	!
	------------------------------------------------------*/
	var x0 float64 = 1.5
	fmt.Printf("muhammad 1 method: \n")
	_, _= muhammad1(x0)
	
	fmt.Printf("------------------ \n")
	fmt.Printf("muhammad 2 method: \n")
	_, _= muhammad2(x0)
}
func muhammad1(x0 float64)(x1,fx float64){
/*------------------------------------------------------
  Author  : Song Yezhi                       
  verison : 2021-10-4 18:51
  go build -gcflags "-N -l"  
     
  -----------------------------------------------------  
  Input  Parameters :
 
  Output Parameters :
 
------------------------------------------------------*/
    imax := 200
    tol := 1e-8
    x1 = x0
    
    var y1,tmp,dx,x2 float64
    for i:=0;i < imax ; i++ {
        fx = funcX(x1)
        y1 = x1 - fx/dfuncX(x1)
        tmp = 0.25*dfuncX(x1) +0.75 * dfuncX((x1+2*y1)/3.0)
        x2 = x1 - fx/tmp
        dx = math.Abs(x2-x1)
        if dx < tol {
            break
        }
        x1 = x2 
        fmt.Printf("i= %4d  x= %12.7f  f(x)=%12.7f \n", i, x2, fx)       
    }
    return x2,fx
}

func muhammad2(x0 float64)(x1,fx float64){
/*------------------------------------------------------
  Author  : Song Yezhi                       
  verison : 2021.10.04 
  go build -gcflags "-N -l"  
     
  -----------------------------------------------------  
  Input  Parameters :
 
  Output Parameters :
 
------------------------------------------------------*/
    imax := 200
    tol := 1e-8
    x1 = x0
    
    var y1,tmp,dx,x2 float64
    for i:=0;i < imax ; i++ {
        fx = funcX(x1)
        y1 = x1 - fx/dfuncX(x1)
        tmp = 0.75*dfuncX((2.0*x1+y1)/3.0) +0.25 * dfuncX(y1)
        x2 = x1 - fx/tmp
        dx = math.Abs(x2-x1)
        if dx < tol {
            break
        }
        x1 = x2 
        fmt.Printf("i= %4d  x= %12.7f  f(x)=%12.7f \n", i, x2, fx)       
    }
    return x2,fx
}
func funcX(x float64) float64 {
	/*------------------------------------------------------
	  !  Author  : Song Yezhi      
	  !  verison : 2021.10.04
	  !
	  ------------------------------------------------------*/
	fx := 3.0*math.Pow(x,5)-2.0*x*x*x + 6*x -8.0
	return fx
}
func dfuncX(x float64) float64 {
	/*------------------------------------------------------
	!  Author  : Song Yezhi      
	!  verison : 2021.10.04
	!
	------------------------------------------------------*/
	df := 15.0*math.Pow(x,4)-6.0*x*x + 6.0
	return df
}