sphm.net
当前位置:首页 >> mAtlAB 牛顿法 >>

mAtlAB 牛顿法

首先,建立原函数的自定义函数文件 function y = fun(x) y=x^4-3*x^3+5*cos(x)+8; 其次,建立导函数的自定义函数文件 fu...

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 运行结果...

这是两部分代码: function eq=exam1_5(x) eq=(x^7+2*x.^5+3*x.^3+5*x+7)/(7*x^6+10*x^4+9*x.^2+5); 这两行是函数部分,参数为x,返回值为eq。 下面的命令是在命令窗口输入的: x0=0.1; x1=x0-exam1_5(x0); while abs(x1-x0)>0.0001 x0=x1; x1=x...

定义函数 function y=nd(x) y= 0.036-((x/2090.7).^(1/0.1585))-x/182000 function y=nd0(x) y=- (1/0.1585)*(x/2090.7).^(1/0.1585-1)*(1/2090.7) - 1/182000 主程序 x=0.5; %迭代初值 i=0; %迭代次数计数 while i10^(-5); %收敛判断 x=y; else...

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 运行结果...

function x = newton_method(fun,x0,e,N)if nargin

%牛顿迭代法 解方程y=x.^3-x-1 x=1.5; format long; x1=x-func1_1(x)/func1_1_1(x); if(abs(x1)1e-6|abs(func1_1(x))>1e-6) x=x1; x1=x-func1_1(x)/func1_1_1(x); if(abs(x1)0) break; end x=(a+b)/2; fx=func2_1(x); if(abs(fx)

Newton's method is the classic algorithm for finding roots of functions. The breif introduction is written below. The analytic solution is The code is clear allx = zeros(1,2);f = zeros(1,2);tol = 1E-7;invJ = zeros(2,2);x(1) = 0...

程序如下,取4个不同的初值 x0=2; x=x0; while abs(x^4-1)>0.001 x=x-(x^4-1)/(4*x^3); end x x0=2*i; x=x0; while abs(x^4-1)>0.001 x=x-(x^4-1)/(4*x^3); end x x0=-2; x=x0; while abs(x^4-1)>0.001 x=x-(x^4-1)/(4*x^3); end x x0=-2*i; x=x...

网站首页 | 网站地图
All rights reserved Powered by www.sphm.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com