Write a function that generates fibbonacci series
def Fibonacci(n:int)-> int:
if n==1:
fibonacci = 0
elif n==2:
fibonacci = 1
else:
fibonacci = Fibonacci(n-1) + Fibonacci(n-2)
return fibonacci
def sin(x:float) -> float:
import math
return math.sin(x)
def derivative_sin(x:float)-> float:
import math
return math.cos(x)
def tan(x:float) -> float:
import math
return math.tan(x)
def derivative_tan(x:float)-> float:
import math
return (1/math.cos(x))**2
def cos(x:float) -> float:
import math
return math.cos(x)
def derivative_cos(x:float)-> float:
import math
return -(math.sin(x))
def exp(x) -> float:
import math
return math.exp(x)
Write a function that returns Gets the derivative of exponential of x
def derivative_exp(x:float) -> float:
import math
return math.exp(x)
Write a function that returns log of a function
def log(x:float)->float:
import math
return math.log(x)
Write a function that returns derivative of log of a function
def derivative_log(x:float)->float:
return (1/x)
def relu(x:float) -> float:
x = 0 if x < 0 else x
return x
def derivative_relu(x:float) -> float:
x = 1 if x > 0 else 0
return x
Write a function that returns runs a garbage collector
def clear_memory():
import gc
gc.collect()
def time_it(fn, *args, repetitons= 1, **kwargs):
import time
total_time = []
for _ in range(repetitons):
start_time = time.perf_counter()
fn(*args,**kwargs)
end_time = time.perf_counter()
ins_time = end_time - start_time
total_time.append(ins_time)
return sum(total_time)/len(total_time)