Réponses (1)

Star Strider
Star Strider le 10 Avr 2016

1 vote

No .m-file needed. You can do a reasonably robust approximation with a simple anonymous funciton:
LHospital = @(f,g,x) (f(x+1E-8) - f(x))./(g(x+1E-8) - f(x));
f = @(x) sin(x);
g = @(x) x;
sin0_by_0 = LHospital(f,g,0)
sin0_by_0 =
1
The ‘correct’ version requires the Symbolic Math Toolbox.

2 commentaires

Torsten
Torsten le 11 Avr 2016
Slight correction:
LHospital = @(f,g,x) (f(x+1E-8) - f(x))./(g(x+1E-8) - g(x));
Best wishes
Torsten.
Star Strider
Star Strider le 11 Avr 2016
Thanks, Torsten.
I need to remember to check for typos, especially when I copy-paste.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Mathematics dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by