By using syntax ‘taylor’ in MATLAB, find the third order approximation of log x using base point at x = 1.

syms x
f = logx;
T = taylor(f, 'Order', 3)
Undefined function or variable 'logx'.
How can i do that above question? I have tried but i was unable to generate

11 Commenti

There is no logx function. The available logarithmetic functions are log, log2, and log10
Then how do i do the above question . I am a bit confused. Actually i have read the taylor document , but i don't understand that why i am asking here . Thank you.
>> syms x taylor(log(x),x,'order',3) Error using symengine Unable to compute a Taylor expansion.
Error in sym/taylor (line 128) tSym = mupadmex('symobj::taylor',f.s,x.s,a.s,options);
Is it like this to solve this question but why is there error?
The default expansion point is 0, but diff(log(x)) is infinite at 0. You need a nonzero expansion point.
taylor(log(x),x,1,'order',3)
ans =
x - (x - 1)^2/2 - 1
is the solution for the above question correct? i have spent 1 h to figure out. Thank you.
Usually, the order of a Taylor series means the order of the approximating polynomial for the function in question. In Matlab, 'Order' means the exponent in the O-term. Thus I suspect that you will have to choose 'Order' in the Taylor command to be 4 instead of 3:
syms x
f = log(x);
p = taylor(f,x,'ExpansionPoint',1,'Order',4)
Best wishes
Torsten.
is the expansion point means the give point of my question which x=1?
Yes.
But why don't you read the documentation:
https://de.mathworks.com/help/symbolic/taylor.html
?
Your question is almost answered in the section "Specify Expansion Point".
Best wishes
Torsten.
I have read it but i don't really understand. Thank you so much .

Accedi per commentare.

Risposte (2)

Hint: MATLAB does not know that when you type logx, in fact you wanted it to compute the function log(x). As well, you need to understand that a Taylor series of log(x) around the default expansion point of x==0 will be a serious problem. If you don't know why, then go back to calc 101.
So your code should start like this:
syms x
f = log(x);
T = taylor(f, 'Order', 3,'expansionpoint',1)
Which works nicely.
T =
x - (x - 1)^2/2 - 1

Tag

Richiesto:

il 13 Set 2018

Risposto:

il 8 Nov 2020

Community Treasure Hunt

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

Start Hunting!

Translated by