필터 지우기
필터 지우기

Taylor series of sin(x) needs to be modified for cos(x) in a better way, please explain how to do this

조회 수: 1 (최근 30일)
function [approx] = T_C(angle,counter)
approx=0;
radianangle= angle*pi/180;
polynum=1;
polynum=radianangle;
approx=approx+polynum;
while abs(counter/polynum)<1
n=n+1;
polynum=polynum*-1*anglerad*2/(2*n+1)/(2*n);
approx=approx+polynum;
end
end

답변 (1개)

Akshat Dalal
Akshat Dalal 2023년 9월 14일
Hi John,
I understand you want to find the value of sin(x) using Taylor series expansion. I believe your code should be modified as follows:
polynum=polynum*-1*(anglerad^2)/(2*(n+1))/(2*n);
You could modify the code accordingly for cos(x). You can find the both the Taylor series expansions here: https://en.wikipedia.org/wiki/Taylor_series

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by