java sin(x)

来源:百度知道 编辑:UC知道 时间:2024/06/22 07:19:07
i need to create a method which is called double sin(double number) and use recursive function . i use Taylor series approximation and here is the code public double factorial(int number) // this is the recurision of factorial

{

if(number==0) //0!=1

{

return 1.0;

}

return (double)number*factorial(number-1);

}

public double sin(double number) // this is the method of sin(x)

{

double sinAns=0;

double sum=0;

for(int i=1;i<=9;i=i+4)

{

sum=pow(number,i)-pow(number,(i+2))/factorial(i+2);

sinAns=sum+sinAns;

}

return sinAns;

}

when i call the method, it returns back

public double factorial(int number) // this is the recurision of factorial

{

if(number==0) //0!=1

{

and i do not know why the reason is

我对这句话感兴趣,是不是出现的语法错误?!
应该是

and i do not know what the reason is吧

The upstairs is very good at English.haha
Up 一下

I am sorry, I don't know.