How do I write a function to find the taylor series expansion of sin(x) to the 9th term?
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Japheth Gielen
il 9 Ott 2016
Commentato: Japheth Gielen
il 9 Ott 2016
I am asked to create a function file to evaluate the value of sin(x) accurate to 9 Taylor Series terms. I know there is a way to write it all out using n and whatnot, but is there a simple way using the built in function "taylor()"? This is what I have, but I am not sure what is wrong.
function y = taylor9(x)
y = taylor(sin(x),x,'Order',9)
end
The error I get says "Undefined function 'taylor' for input arguments of type 'double'"
0 Commenti
Risposta accettata
Walter Roberson
il 9 Ott 2016
syms x
y = taylor(sin(x), x, 'Order', 9);
3 Commenti
Walter Roberson
il 9 Ott 2016
https://www.mathworks.com/help/symbolic/syms.html
taylor() is a function that is part of the Symbolic Toolbox, and only works with symbolic expressions and symbolic functions. It cannot be used with function handles or numeric arrays. It does calculus on the symbolic expression in order to create the taylor approximation -- it takes derivatives, which requires calculus.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Calculus in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!