Skip to main content
added 14 characters in body
Source Link
vnp
  • 58.7k
  • 4
  • 55
  • 144

In general, LGTM. Few notes:

  • The name f is meaningless. newtonDelta perhaps?

  • It feels right to compute a derivative's coefficients once, and reuse evalPoly for both the function and its derivative. After all, the polynomial's derivative is also polynomial. There is an usual space-time tradeoff, but in thisthe case of polynomials DRY rule casts a deciding vote.

  • Newton's algorithm does not necessarily converge. You should be prepared to handle the divergent case.

  • Hardcoding ε is dubious. I recommend to solveNewton have it as a parameter.

  • Using Horner schedule is a definite improvement.

In general, LGTM. Few notes:

  • The name f is meaningless. newtonDelta perhaps?

  • It feels right to compute a derivative's coefficients once, and reuse evalPoly for both the function and its derivative. After all, the polynomial's derivative is also polynomial. There is an usual space-time tradeoff, but in this case DRY rule casts a deciding vote.

  • Newton's algorithm does not necessarily converge. You should be prepared to handle the divergent case.

  • Hardcoding ε is dubious. I recommend to solveNewton have it as a parameter.

  • Using Horner schedule is a definite improvement.

In general, LGTM. Few notes:

  • The name f is meaningless. newtonDelta perhaps?

  • It feels right to compute a derivative's coefficients once, and reuse evalPoly for both the function and its derivative. After all, the polynomial's derivative is also polynomial. There is an usual space-time tradeoff, but in the case of polynomials DRY rule casts a deciding vote.

  • Newton's algorithm does not necessarily converge. You should be prepared to handle the divergent case.

  • Hardcoding ε is dubious. I recommend to solveNewton have it as a parameter.

  • Using Horner schedule is a definite improvement.

Source Link
vnp
  • 58.7k
  • 4
  • 55
  • 144

In general, LGTM. Few notes:

  • The name f is meaningless. newtonDelta perhaps?

  • It feels right to compute a derivative's coefficients once, and reuse evalPoly for both the function and its derivative. After all, the polynomial's derivative is also polynomial. There is an usual space-time tradeoff, but in this case DRY rule casts a deciding vote.

  • Newton's algorithm does not necessarily converge. You should be prepared to handle the divergent case.

  • Hardcoding ε is dubious. I recommend to solveNewton have it as a parameter.

  • Using Horner schedule is a definite improvement.