回覆列表
  • 1 # 使用者508873978285

    function [ A ] = cal( a,b,v )%a,b表示區間,v是精度

    i=1;

    x = (a+b)/2;

    A=[i x];

    t = x-(x^3-x-1)/(3*x^2-1);%迭代函式

    while(abs(t-x)>v)

    i=i+1;

    x = t;

    A = [A;i x];

    t = x-(x^3-x-1)/(3*x^2-1);%迭代函式

    end

    A = [A;i+1 t];

    end

    執行結果:

    >> format long;

    >> cal(1,2,0.00001)

    ans =

    1.000000000000000 1.500000000000000

    2.000000000000000 1.347826086956522

    3.000000000000000 1.325200398950907

    4.000000000000000 1.324718173999054

    5.000000000000000 1.324717957244790

  • 中秋節和大豐收的關聯?
  • 求助.求助,牛軋糖為什麼做出來特別硬?