Newton-Raphson Method Error

6 vues (au cours des 30 derniers jours)
Cristian Segura Bidermann
Cristian Segura Bidermann le 22 Juil 2021
Commenté : Dyuman Joshi le 6 Juil 2025
I have an error in the following exercise, which I don't know why it happens. If you could help me I would be very grateful. The exercise is as follows:
My code corresponds to:
And the error that appears to me is the following:
I don't understand why the iteration limit is wrong.
  1 commentaire
Pauli Huusari
Pauli Huusari le 6 Juil 2025
Hi,
for me it seems that the row 15 in the function definition rfNewtonR is never reached, since the row 9 executes the command return when the for-looper i is equal to itmax. Executing the command return exits the function immediately. Therefore, the error message Iteration Limit Exceeded is not displayed/ thrown.
My suggestion is to remove the rows 8 - 10 in the function definition rfNewtonR. Then the row 15 is executed after the for-loop.
Best regards, Pauli Huusari

Connectez-vous pour commenter.

Réponses (1)

Pauli Huusari
Pauli Huusari le 6 Juil 2025
Hi,
for me it seems that the row 15 in the function definition rfNewtonR is never reached, since the row 9 executes the command return when the for-looper i is equal to itmax. Executing the command return exits the function immediately. Therefore, the error message Iteration Limit Exceeded is not displayed/ thrown.
My suggestion is to remove the rows 8 - 10 in the function definition rfNewtonR. Then the row 15 is executed after the for-loop.
Best regards, Pauli Huusari
  1 commentaire
Dyuman Joshi
Dyuman Joshi le 6 Juil 2025
"My suggestion is to remove the rows 8 - 10 in the function definition rfNewtonR."
They can not be removed as they follow the latter part of point #2 mentioned in the problem statement.
However, as per on point #3 - OP needs to modify the 1st if statment (i.e. lines 8-10) to include the error message. Then the code would be inline with the problem.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by