newton raphson on matlab
조회 수: 1 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (1개)
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!