如何在matlab中使用newton raphson方法得到x的根

时间:2012-03-08 05:59:48

标签: matlab

a=2

b=3

c=7

d=5

w=14

在matlab中使用newton raphson方法查找x

enter code here
4.w.d^2.(1-x^2)^2=a.b.c^3.x.sqrt(pi^2.(1-x^2)^2+16.x^2)

1 个答案:

答案 0 :(得分:1)

有一个的帖子与此类似,即使在StackOverflow上,如this onethis one也是如此。更像是Matlab Central等网络,或其他教育网站,如here。所以,我认为你可以更多地准备好了。就我最喜欢的方法而言,我会把我的两分钱放在这里。

function x = newton(f,dfdx,x0,tolerance)
err = Inf;
x = x0;
while abs(err) > tolerance
   xPrev = x;
   x = xPrev - f(xPrev)./dfdx(xPrev);
   % stop criterion: (f(x) - 0) < tolerance
   err = f(x); % 
   % stop criterion: change of x < tolerance
   % err = x - xPrev;
end

f = @(x) ((x-4).^2-4);
dfdx = @(x)(2.*(x-4));
x0 = 1;
xRoot = newton(@f,@dfdx,x0,1e-10);

f(x)= 4wd 2 (1-x 2 2 - abc 3 x√ (π 2 *(1-X 2 2 + 16 * X 2

因此,只需将上述等式与 x 区分开来,然后就可以得到你的df / dx。将方程式插入文件句柄并运行例程!另外,我把它移到SE Math很好,但我也不知道怎么做。 : - )