L'Hopital rule

2 views (last 30 days)
Teddy Negrete
Teddy Negrete on 10 Apr 2016
Commented: Star Strider on 11 Apr 2016
Mfile for aplications this 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
Torsten
Torsten on 11 Apr 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 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 Creating and Concatenating Matrices in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!