use taylor series result to find value?

조회 수: 11 (최근 30일)
Raphael Hatami
Raphael Hatami 2019년 9월 12일
답변: GURU PRASAD 2021년 9월 16일
Hello, I think this is relatively simple but I can't figure it out. I am computing the taylor series of a function and simply want to evaluate that taylor series result at a specific value x. How can I do this automatically (without copy/pasting the result from the command window)? Thank you
%y = taylor(f,xx,0,1)
syms x
f=@(x) 25*x.^3-6*x.^2+7*x-88;
truevalue = f(3)
T0 = f
T1 = taylor(f,x,1,'Order',1)
T2 = taylor(f,x,1,'Order',2)
T3 = taylor(f,x,1,'Order',3)
result = T3(3)
%T2result = @(x) 70*x - 132
%T2estimate = T2result(3)
%T3result = @(x) 70*x + 69*(x - 1)^2 - 132
%T3estimate = T3result(3)
The result part is what I'm trying to do...

답변 (2개)

David Hill
David Hill 2019년 9월 12일
result=subs(T3,x,3);
  댓글 수: 2
John D'Errico
John D'Errico 2019년 9월 12일
Or, you could use matlabFunction to create a function handle that will evaluate the function, converting the symbolic expression into one that will work as a simple function.
MINATI
MINATI 2020년 1월 4일
how to apply the values f(0)=0;f'(0)=1;f"(0)=a;(syms a) in
taylor(f(x),x,'order',3) to find x+a*x^2/2;
Help please @
minatipatra456@gmail.com

댓글을 달려면 로그인하십시오.


GURU PRASAD
GURU PRASAD 2021년 9월 16일
f = @(x) 25*x^3-6*x^2+7*x-88;
sample_at = 3;
trueval = f(sample_at);
syms xx;
fs = f(xx);
for n = 0:4
y = double( subs( taylor(fs, n, 1), xx, sample_at ) );
disp([n, y]);
%now calculate the relative error
end

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by