早教吧 育儿知识 作业答案 考试题库 百科 知识分享

计算Cos(x)级数前n项和,求问这样写哪里有错吗?因为计算答案和书上有差别,智商捉鸡又看不出哪里算错了=-=COS(x)=1-X^2/2!+X^4/4!-X^6/6...Dimx,n,i,flagAsInteger,s,k,tAsDoubles=1k=x*xt=1*2flag=-1For

题目详情
计算Cos(x)级数前n项和,求问这样写哪里有错吗?
因为计算答案和书上有差别,智商捉鸡又看不出哪里算错了=-=
COS(x)=1- X^2/2!+ X^4/4!- X^6/6...
Dim x,n,i,flag As Integer,s,k,t As Double
s = 1
k = x * x
t = 1 * 2
flag = -1
For i = 2 To n
s = s + flag * k / t
flag = -flag
k = k * x * x
t = t * (2 * n - 3) * (2 * n - 2)
Next
▼优质解答
答案和解析
t = t * (2 * n +1) * (2 * n + 2)
看了计算Cos(x)级数前n项和,...的网友还看了以下: