Those functions usually give the irrational number for a result, and are probably calculated via taylor series but is there any documentation of how many times are those series repeated?
I’m thinking if this is sin:
public double sin(double x,int n){
double res = 0;
for (int i=0;i<n;i++){
res+=Math.pow(x,i)/this.factorial(x);
}
return res;
}
what should the n be?
I need this because I need to create Math functions myself so I should know how many times should I repeat these operations.
thanks
Calculating
powandfactorialthis way is very expensive and prone to rounding error. BTW I think you meanfactorial(i)not(x)prints