// Function to calculate the sine value using Taylor series approximationfunctionsinTaylor(x, terms) {
let result = 0;
for (let i = 0; i < terms; i++) {
result += Math.pow(-1, i) * Math.pow(x, 2 * i + 1) / factorial(2 * i + 1);
}
return result;
}
// Function to calculate the factorialfunctionfactorial(num) {
if (num === 0 || num === 1){
return1;
} else {
return num * factorial(num - 1);
}
}
// Input valuesconst angleInRadians = Math.PI / 4; // Example angle in radiansconst numberOfTerms = 10; // Number of terms to include in the Taylor series approximation// Calculate sin value using Taylor seriesconst sinValue = sinTaylor(angleInRadians, numberOfTerms);
console.log(`sin(${angleInRadians}) using Taylor series with ${numberOfTerms} terms: ${sinValue}`);