Effacer les filtres
Effacer les filtres

how can i write a code to find maximum error in Lagrange polynomial for given functions?

4 vues (au cours des 30 derniers jours)
norah
norah le 9 Mai 2023
Commenté : Torsten le 21 Juil 2023
im having defficulties in writing matlab cod to
  • Find the maximum error in using to approximate on the interval [0, 2]. can any one help?

Réponses (1)

Torsten
Torsten le 10 Mai 2023
Modifié(e) : Torsten le 10 Mai 2023
Choose a fine enough grid x on [0,2], evaluate your function(s) f(x) and the Lagrange polynomial(s) L(x) for the grid points and build abs(f(x)-L(x)). This should give you a good approximate value for the maximum error on [0,2].
  2 commentaires
Alvira Yawar
Alvira Yawar le 20 Juil 2023
Hi can you please share a sample program for the same
Torsten
Torsten le 21 Juil 2023
If L_eval is your function for evaluating the Lagrange polynomial, you can use
x = linspace(0,2,100);
max_error = max(abs(f(x)-L_eval(x)))

Connectez-vous pour commenter.

Catégories

En savoir plus sur Polynomials dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by