Hi I am trying to write a code that finds approximations of sine and cosine using the equations below with a given value of theta in degrees basically as a novice programmer i am having trouble setting upa a while loop for the expansions. Also can you guys please quote sources(books,web pages, etc.) for a beginner programmer in python for syntax and basic concepts.

cos(x)= 1- x2/2! + x4/4! - x6/6! + ..

sin(x)= x - x3/3! + x5/5! - x7/7! + ..

Thanks in advance.

Recommended Answers

All 3 Replies

Hint, use math.pow() and math.factorial()
so
x4/4!
will be
math.pow(x, 4)/math.factorial(4)

Module math also has:
math.degrees(x) converts angle x from radians to degrees.
math.radians(x) converts angle x from degrees to radians.

You can get a good free online book here:
http://www.greenteapress.com/thinkpython/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.