How to find a limit without syms and limit function

10 vues (au cours des 30 derniers jours)
Florin Florin
Florin Florin le 25 Mai 2019
Let's take the limit . How can i calculate it without using syms and matlab's function limit?

Réponse acceptée

Star Strider
Star Strider le 25 Mai 2019
Modifié(e) : Star Strider le 25 Mai 2019
Crude but effective (for this function, may not be universally applicable):
fcn = @(x) (x.^3 - 1) ./ (x - 1);
x = 1;
lm = fcn(x-1E-15)
lm =
3
Experiment to get the result you want.
EDIT —
Another option is to use a simple numerical derivative:
dfdx = @(f,x) (f(x + 1E-8) - f(x)) ./ 1E-8;
fcnn = @(x) x.^3 - 1;
fcnd = @(x) x - 1;
xv = 1;
Lm = dfdx(fcnn,xv) ./ dfdx(fcnd,xv)
producing:
Lm =
3
  2 commentaires
Gustav Garpebo
Gustav Garpebo le 6 Oct 2021
Can you pleasae explain the terms? xv, fcnn, fcnd etc
Star Strider
Star Strider le 6 Oct 2021
@Gustav Garpebo — Sure! (I probably should have explained those originally, describing them in comments, although they were clear in the context 2½ years ago.)
The forward-difference derivative ‘dfdx’ function requires a function handle (first argument) and a value of ‘x’ at which the function is evaluated (second argument), and since the function is being evaluated at 1 that is what ‘xv’ is assigned to be. The two other functions, ‘fcnn’ and ‘fcnd’ are the numerator and denominator of the original function, respectively. The rest is straightforward.
.

Connectez-vous pour commenter.

Plus de réponses (1)

John D'Errico
John D'Errico le 6 Oct 2021
Modifié(e) : John D'Errico le 6 Oct 2021
You can use my limest function. It is on the file exchange.
>> fun= @(x) (x.^3 - 1)./(x-1)
fun =
function_handle with value:
@(x)(x.^3-1)./(x-1)
Now use limest. It even provides an estimate of how well it thinks that limit is known.
[L,errest] = limest(fun,1)
L =
3
errest =
2.20957326622612e-14
Is that correct? l'hopital would tell me of course. Thus, if I differentiate the numerator and the demoninator, we would have 3^x^2/1. At x==1, that is 3.
The symbolic toolbox would agree, but you don't want to see that.
syms X
F = (x^3-1)/(x-1)
limit(F,1)
ans =
3
But we can still use the symbolic TB, without use of limit, just using l'hopital...
subs(diff(X^3-1),X,1)/subs(diff(X-1),X,1)
ans =
3
As expected, it returns 3 as the desired limit.
You can find limest on the file exchange, here:
LIMEST uses an adaptive, multi-order Richardson extrapolation scheme, modified to provide also an estimate of the uncertainty at the extrapolation point, all of my invention.)

Catégories

En savoir plus sur Symbolic Math Toolbox dans Help Center 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