+ 1
I’ve done this in JavaScript, if you look at the code you should be able to understand the logic behind it and translate it to C++: https://replit.com/@MattDESTROYER/Trigonometric-Functions-Sine-Cosine-Tangent?v=1#index.js The important part is this: ``` // subtract n^num/!num result -= Math.pow(n, num) / factorialOf(num); // increment num num += 2; // add n^num/!num result += Math.pow(n, num) / factorialOf(num); // increment num num += 2; // since we add and subtract we are effectively doubling the accuracy so instead of decrementing accuracy by 1, we decrement by 2 accuracy -= 2; ``` To be clear, you cannot simply calculate the sine of a number, you can approximate it using a series which gradually gets closer and closer to the exact value.
10th Jul 2022, 11:11 AM
Matthew James
Matthew James - avatar