I need help with these 2 functions for python 3.x. Will post my current code and
ID: 3606356 • Letter: I
Question
I need help with these 2 functions for python 3.x. Will post my current code and what the function is supposed to do below.
Function 1
def mycos_mod(x, tol=1e-8):
"""
compute cos(x) by summing taylor expansion at x0=j*pi, (for some integer j such that
j*pi is closest to x), if j is even, then
cos(x) = 1 + (x-x0)^4/4! + (x-x0)^8/8! + (x-x0)^12/12! + (x-x0)^16/16! + ...
- (x-x0)^2/2! + (x-x0)^6/6! + (x-x0)^10/10! + ... )
if j is odd, multiply the above by -1.
"""
#if you can, apply the more efficient 'updating' method instead of direct sum term-by-term
Function 2
def mysin_mod(x, tol=1e-8):
"""
compute sin(x) by summing taylor expansion at x0=j*pi, (for some integer j such that
j*pi is closest to x), if j is even, then
sin(x) = (x-x0) - (x-x0)^3/3! + (x-x0)^5/5! +.... + (-1)^k*(x-x0)^(2k+1)/(2k+1)! + ...
if n is odd, multiply the above by -1.
"""
If you can help me figure these out thatd be very helpful thanks.