L'Hopital rule

Answers (1)

Star Strider
Star Strider on 10 Apr 2016
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 Comments

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 on 11 Apr 2016
Thanks, Torsten.
I need to remember to check for typos, especially when I copy-paste.

Sign in to comment.

Categories

Find more on Mathematics in Help Center and File Exchange

Tags

Asked:

on 10 Apr 2016

Commented:

on 11 Apr 2016

Community Treasure Hunt

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

Start Hunting!