newton raphson on matlab

1 次查看(过去 30 天)
somebody on the net
i've been given this code to execute for x0=0; n=50; tol=10^-3 is the 0 the problem because cos(0)/-sin(0) is undefinable or is there another problem in the typing/defining? please help it's is due for tomorrow

回答(1 个)

DGM
DGM 2021-4-10
编辑:DGM 2021-4-10
I don't know why anyone would make you use x0=0 unless they wanted you to lose your hair. Think about where you are on the curve of cos(x). Think about where your tangent line is. Algebraically, you know that 1/0 is undefined, but geometrically, you're looking for the intersection of two parallel lines -- something you're not going to find either.
You should begin to see that the periodic nature of the sinusoids means that you'll need to pick a starting point close to a desired root, or else you'll end up overshooting and finding one way off down the line. Try x0=0.1 and then try x0=1.5.
Also, this is probably supposed to be x0 instead of p0.
fprintf('\nApproximate solution xn= %11.8f \n\n',p0);

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by