Taylor Series Summation Too Large
Afficher commentaires plus anciens
My goal is to run through the first 100 terms of the generalized taylor series for sin(x) for a user defined x value. However the code i currently have is giving an output of a huge number that is not the correct summation. Here is what i have:
x=sym('x')
x=input('Enter a scalar value for x: ')
n=0:99;
k=0;
for i=1:length(n)
y(i)=((-1).^n(i))*((x.^(2*n(i))+1)/factorial((2*n(i))+1));
k=k+n(i);
end
fprintf('Summation of first 100 Terms: %d\n',k)
I'm not really sure what is causing this to happen. Thank you to anyone that can help!
Réponse acceptée
Plus de réponses (1)
Walter Roberson
le 6 Août 2016
0 votes
Why are you bothering to calculate y(i) if you are going to ignore its value and base your output k strictly on the sum of the vector n?
1 commentaire
Madi Macias
le 6 Août 2016
Catégories
En savoir plus sur Mathematics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!