How to get Taylor polynomial for functions?

6 views (last 30 days)
I'm looking to write a program where i can input a function, like exp(x) or sin(x), and have the program return the Taylor polynomials for the function.
This is what I have so far. I am fairly new to Matlab and am still getting used to the software.
str=input('Function? ','s');
disp T

Accepted Answer

Rafael Hernandez-Walls
Rafael Hernandez-Walls on 19 Apr 2021
You can use a function that is in the MAThWORKS fileexchange (I put the link):
str=input('Function? ','s'); %tray with: cos(x)
z = str2syms(str)
T =
x^4/24 - x^2/2 + 1

More Answers (0)


Find more on Mathematics and Optimization in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!