用黄金分割法求x^3-x-1=0,在x=1.5附近的根。matlab.在线等

如题所述

1、黄金分割法迭代格式:

2、自定义函数  fun(x)

function y = fun(x)

y=x^3-x-1;

end

3、主程序

a0=1.3;b0=1.6; %求在x=1.5附近的根

tol=1e-3;

x = gold_mean(a0,b0,tol)

y = fun(x) 

4、黄金分割法迭代程序

5、运行结果

在命令窗口中,执行

>>gold_main (回车)

温馨提示:答案为网友推荐,仅供参考
相似回答