How to calculate sine and cosine without importing math?
Question: I started programming in python not too long ago and I am having trouble with
a part of a program. The program will ask for input from the user and he can
input: A, B, C, M, or Q. I have completed the A, M, and Q part but I can't
figure out how to do the parts for B (calculate the sine of the number you
want) and C (calculate the sine). All the information I was given was:

> The power series approximation for the sine of X can be expressed as:
> sine(X) = X – (X3/3!) + (X5/5!) – (X7/7!) + (X9/9!) .... Note that an
> individual term in that power series can be expressed as: (-1)k * X2k+1 /
> (2k+1)! where k = 0, 1, 2, 3, ….

Oooh, and (but for this a while loop should do right?): When computing the
sine of X or the cosine of X, the program will expand the power series until
the absolute value of the next term in the series is less than 1.0e-8 (the
specified epsilon). That term will not be included in the approximation.

And I can't use import math. Can anyone give me an idea of how I can do this?
I sincerely have no idea of where to even start hahaha.

Thanks in advance!

***Hey guys, I've been trying to do this for the last 3 hours. I'm really new
to programming and some of yours answers made it a bit more understandable for
me but my program is not working, I really don't know how to do this. And yes,
I went to speak with a tutor today but he didn't know either. So yeah, I guess
I'll just wait until I get the program graded by my teacher and then I can ask
him how it was supposed to be done. Thank you for all the answers though, I
appreciate them! :)


Answer: It seems that you aren't supposed to import `math` because you are supposed to
write your own function to compute sine. You are supposed to use the power
series approximation.

I suggest you start by writing a factorial function, then write a loop that
uses this factorial function to compute the power series.

If you still can't figure it out, I suggest you talk to your teacher or a
teacher's assistant.

