Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Algorithm and Complexity, Python # Task 1a) Test the function with various angles and a's. The parameter should be positive but small. b). Find an
Algorithm and Complexity, Python
# Task 1a) Test the function with various angles and a's. The parameter should be positive but small.
b). Find an idea of how can we estimate the complexity of the above recursive routine. Can you improve its accuracy?
c). Build a similar algorithm for cosine and test its accuracy and complexity.
def cube(x):
return x*x*x
def p(x):
return 3*x - 4*cube(x)
def sine(angle, a):
if abs(angle)
return angle
else:
return p(sine(angle/3.0, a))
# Thel algorithm uses the identity sin(x) = 3*sin(x/3) - 4*sin(x/3)**3 # and the fact that for small arguments sin(x) is approximately equal to x. def cube (x): return x*x*x def p(x): return 3*x - 4* cube (x) def sine (angle, a): if abs (angle)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started