Hey all, I'm so confused about how to write a function about sine and cosine without using import math, can anyone help me about that?

Recommended Answers

All 2 Replies

Read this. Use a loop and translate the formulas you want in Python code.

For the cos(x), add pi/2 to x, then compute sin(x). For this use the Taylor series as ddanbe said above, but for faster convergence you can replace x with x - 2*k*pi, where k is chosen so that this new x is in the interval [-pi, pi]. Again you can use parity and symetry to compute the sine only in the interval [0, pi/2]. I think this transform is necessary, because if x is large, the x**n can be very large in the Taylor series.

Post attempts in python if you want more help.

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.