Taylor series approximation problem

5 次查看(过去 30 天)
we are considering a Taylor series approximation of f(x) = e^(-x)
my questions is how to compute the Taylor Series approximation of f(x).
The requirements are: the code should take as input x_i, x_i+1, and the order, n.
The code should output the normalized true error e_T, at x_i+1
I'm totally lost where to start, hope to get some hints or help!
thanks!

采纳的回答

Matt J
Matt J 2021-9-15
As an example,
syms x
T=taylor(exp(-x),x,7,'Order',4)
T = 
fn=matlabFunction(T)
fn = function_handle with value:
@(x)exp(-7.0)-exp(-7.0).*(x-7.0)+(exp(-7.0).*(x-7.0).^2)./2.0-(exp(-7.0).*(x-7.0).^3)./6.0
fn(3)
ans = 0.0216
You can of course find more examples in the documentation for taylor() and matlabuUnction()
  1 个评论
Lingbai Ren
Lingbai Ren 2021-9-24
Sorry Matt for the late reply, I think what works, but I finally wrote a whole for loop to run that! Thanks for helping!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by