Write a pythonfunction that takes a parameter x (float or array of floats) and computes y=f(x)=ex (float
Question:
Write a pythonfunction that takes a parameter x (float or array of floats) and computes y=f(x)=ex (float if x is a float, array of floats if x is array of floats)
def fx(x):
'''
Input:
x : float (scalar) or np array
Ouptut:
y : float (scalar) or np array
'''
### Write your code here
return y
2. Write a python function that takes a parameter n and generates n random points in the range (1,3) → x
Using fx defined earlier, it also generates yd corresponding to these n points and returns both x and yd
def generate_points(n):
'''
Inputs:
n : int, Number of random points
Outputs:
x : array of floats, random points in the range (1, 3)
yd : array of floats, e^x for values in x
'''
### Write your code here
return x, yd
Data Structures and Algorithm Analysis in Java
ISBN: 978-0132576277
3rd edition
Authors: Mark A. Weiss