MATLAB Answers

0

use taylor series result to find value?

Asked by Raphael Hatami on 12 Sep 2019
Latest activity Commented on by John D'Errico
on 12 Sep 2019
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...

  0 Comments

Sign in to comment.

1 Answer

Answer by David Hill
on 12 Sep 2019

result=subs(T3,x,3);

  1 Comment

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.

Sign in to comment.